New week new update! I had a conjunctivitis and my eyes felt really tiered but I've managed to implement type deduction for the expressions. Now we can turn code form :
mat4f getm() {.....}
void f() {
mat4f m;
vec4f v;
v = m * v * (getm() * v);
}
To :
void f() {
mat4f m;
vec4f v;
v = mul(m, v) * (mul(getm(), v));
}
This works by traversing the tree in 3 passes:
Pass 1 - run thought all nodes and describe all the defined functions and variables.
Pass 2 - using the Information above deduce the type of every expression (a table that contains "vec multiplied by a mat is a vec", and so on)
Pass 3 - The code generation. m * v in HLSL is mul(m, v) while on GLSL is m * v
The code is still here https://github.com/ongamex/playground/tree/master/lang , but i don't recommend you to even download it.
Next week I will try to Improve the architecture and the readability of the code.
The ultimate goal of this project is not to provide a complete solution, but rather to be a simple project that has the essential functionality in it and to be extendable by anyone.
PS:
Maybe I should start a Journal or a new thread, or maybe this isn't interesting to anyone?
Or maybe I'm over-hyped.