Next: , Previous: , Up: TC-5   [Contents][Index]


4.14.4 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.

temp::Identifier

Their implementations are to be finished. This task is independent of others. Passing test-temp.cc is probably the sign you completed correctly 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_));
}
tree::Fragment

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

translate/translation.*
translate::Translator

There are holes to fill.