Ok. I'm done implementing the AST transformation pass. A few comments:
I implemented an additional AST pass to check if functions contain the 'eval' or 'arguments' keywords. The arguments variable currently gets resolved as global and a free variable. But technically, I think it should probably instead appear as a local variable of every function.
There is also the issue I wanted to avoid that nested functions could result in eval or arguments appearing free in a parent function, and therefore more pessimistic code than necessary being generated for the parent function...
And finally, my transformation, as it is, relies on the variable resolution pass (which finds the free variables) happening later, because I use the variable declaration statement and I need to have my arguments object alias be captured by sub-functions when they refer to the arguments of their parents.
- Maxime
On 10-08-20 11:54 AM, Maxime Chevalier-Boisvert wrote:
That's a pretty common approach, we could have some prefix for all
generated vars (e.g. tachyon#).
Good idea. I'll write a genFreeId function. Right now I'm trying to find what Marc has in place to create id objects... Hopefully I'll find something in the scanner code.
I assume that you want to transform the code prior to building the IR
That's correct. I think it's best to keep the IR generation simpler and avoid having to deal with multiple levels of function nesting during the translation.
otherwise you could just reuse the same mechanism that is generates
temporary var names in your IR construction phase.
There are no real variable names in the IR. Since it's in SSA form, temporaries are direct references to the instruction that defines the value. I added a mechanism to assign unique variable names within a given CFG to make the output more readable.
- Maxime
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list