TC-E Goals

Things to learn during this stage that you should remember:

Understanding escaping variables

In TC-E, we consider the case of non-local variables, i.e., variables that are defined in a scope, but used (at least once) in a function, nested in the scope. This possibility for an inner function to use variables declared in outer scopes is called block structure. Because such variables are used outside of their host scope, they are qualified as “escaping”. This information will be necessary during the translation to the intermediate representation (see TC-5, Translating to the High Level Intermediate Representation) 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.

Writing a Visitor from scratch

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.