TC-5 Code to Write

You are encouraged to first try very simple examples: nil, 1 + 2, "foo" < "bar" etc. Then consider supporting variables, and finally handle the case of the functions.

You can run the HIR using HAVM.

Relevant pages:
src/temp/identifier.hxx

Their implementation is to be finished. This task is independent of others. Passing test-temp.cc is the sign you probably correctly completed the implementation.

You are invited to follow the best practices for variants, in particular, avoid “type switching” by hand, rather use variant visitors. For instance the IdentifierEqualVisitor can be used this way:

template <template <typename Tag_> class Traits_>
bool
Identifier<Traits_>::operator==(const Identifier<Traits_>& rhs) const
{
  return
    rank_get() == rhs.rank_get()
    && std::visit(IdentifierEqualToVisitor(),
                  static_cast<std::variant<unsigned, misc::symbol>>(value_),
                  static_cast<std::variant<unsigned,
                  misc::symbol>>(rhs.value_));
}
src/tree/fragment.cc

You need to implement tree::ProcFrag::dump that outputs the routine themselves plus the glue code (allocating the frame etc.).

For the The src/translate Directory folder you will find more information on this part in the book (Modern Compiler Implementation), in the chapter “7. Translation to Intermediate Code”.

src/translate/translator.cc

The visitor (the last one…) which translates the AST into HIR, using the wrappers defined in the translation.hh.

src/translate/translation.cc

A wrapper that helps to translate AST nodes.

src/translate/exp.cc

A set of wrappers around all Ex conversions, for example un_ex, un_ix and un_cx. These functions are to be implemented for Ex, Ix and Cx.

You will find more information on this part in the book, in the chapter on translation into intermediate language.

src/translate/level.cc

Implement static link management.

src/ast/function-dec.hh

Add information related to the static-link.