The optimizer tries to constant fold expressions and modify the AST in place so that it should be faster to evaluate.
Because the AST does not contain all the scoping information and the compiler has to find that out, we cannot do all the optimizations we want. For example, loop unrolling doesn't work because unrolled loops would have a different scope. The solution would be a second syntax tree that stored the scoping rules.
Class | Optimizer |
Undocumented |
Function | optimize |
The context hint can be used to perform an static optimization based on the context given. |
Parameters | |
node:nodes.Node | Undocumented |
environment:Environment | Undocumented |
Returns | |
nodes.Node | Undocumented |