The src/translate Directory

Namespace translate, delivered for TC-5. Translation to intermediate code representation.

File: local.am (src/translate/)

This is a Makefile configuration relative to the src/translate/ directory. It is responsible for the integration into the libtc library with everything exported from the translate module.

File: libtranslate.* (src/translate/)

The interface of the translate module. It exports a single procedure, translate.

File: tasks.* (src/translate/)

Tasks related to the translate module (see: The src/task Directory).

File: fwd.hh (src/translate/)

Forward declarations for the translate module.


File: access.* (src/translate/)

Static link aware versions of level::Access.

File: exp.* (src/translate/)

Implementation of translate::Ex (expressions), Nx (instructions), Cx (conditions), and Ix (if) shells. They wrap tree::Tree to delay their translation until the actual use is known.

File: level.* (src/translate/)

translate::Level are wrappers on frame::Frame that support the static links, so that we can find an access to the variables of the parent function.

File: translation.* (src/translate/)

Functions used by the translate::Translator to translate the AST into HIR. For instance, it contains Exp* simpleVar(const Access& access, const Level& level), Exp* callExp(const temp::Label& label, std::list<Exp*> args) etc… which are routines that produce some Tree::Exp. They handle all the unCx etc. magic.

File: translator.* (src/translate/)

Implement the class Translator which performs the IR generation thanks to translation.hh. It must not be polluted with translation details: it is only coordinating the AST traversal with the invocation of translation routines. For instance, here is the translation of an ast::SimpleVar:

virtual void operator()(const SimpleVar& e)
{
  exp_ = simpleVar(*var_access_[e.def_get()], *level_);
}