The src/translate
Directory
Namespace translate
. Translation to intermediate code representation. It
includes:
File: libtranslate.* (src/translate/)
The interface.
File: access.* (src/translate/)
Static link aware versions of
level::Access
.
File: level.* (src/translate/)
translate::Level
are wrappers onframe::Frame
that support the static links, so that we can find an access to the variables of the parent function.
File: exp.hh (src/translate/)
Implementation of
translate::Ex
(expressions),Nx
(instructions),Cx
(conditions), andIx
(if) shells. They wraptree::Tree
to delay their translation until the actual use is known.
File: translation.hh (src/translate/)
Functions used by the
translate::Translator
to translate the AST into HIR. For instance, it containsExp* simpleVar(const Access& access, const Level& level)
,Exp* callExp(const temp::Label& label, std::list<Exp*> args)
etc… which are routines that produce someTree::Exp
. They handle all theunCx
etc. magic.
File: translator.hh (src/translate/)
Implements the class
Translator
which performs the IR generation thanks totranslation.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 anast::SimpleVar
:virtual void operator()(const SimpleVar& e) { exp_ = simpleVar(*var_access_[e.def_get()], *level_); }