Next: TC-E Samples, Up: TC-E [Contents][Index]
Things to learn during this stage that you should remember:
In TC-E, we consider the case of non-local variables, i.e., variables that are defined in a function, but used (at least once) in another function, nested in the first one. This possibility for an inner function to use variables declared in outer functions is called block structure. Because such variables are used outside of their host function, they are qualified as “escaping”. This information will be necessary during the translation to the intermediate representation (see TC-5) when variables (named temporaries a that stage) are assigned a location (in the stack or in a register). Escaping variables shall indeed be stored in memory, so that non-local uses of such variables can actually have a means to access them.
The escapes::EscapesVisitor
provided is almost empty. A goal of
TC-E is to write a complete visitor (though a small one).
Do not forget to use ast::DefaultVisitor
to factor as much code
as possible.