TC-4 Code to Write¶
What is to be done.
Because many AST nodes will be annotated with their type, the feature is factored by these two classes. See Typable, and TypeConstructor, for details.
These are typable.
These build types.
Implement the Singletons
type::Void. Using templates would be particularly appreciated to factor the code between the three singleton classes, see TC-4 Options.
The remaining classes are incomplete.
Pay extra attention to
type::operator==(const Type& a, const Type& b)and
Of course this is the most tricky part. We hope there are enough comments in there so that you understand what is to be done. Please, post your questions and help us improve it.
It is also the
type::TypeChecker’s job to set the
record_typeis holding some information about the
type::Recordtype associated to the
type::Niltype. We choose to handle the
record_typeonly when no error occured in the type-checking process.
type::Typesare visitable. You must implement the default visitor class template, which walks through the tree of types doing nothing. It’s used as a base class for the type visitors.
- In order to output nice error messages, the types need to be printed. You must implement a visitor that prints the
types, similar to
- Computing the Escaping Variables
- The implementation of TC-E, Computing the Escaping Variables, suggested at TC-3, Bindings, becomes a mandatory assignment at TC-4, Type Checking.