What is to be done.
symbol::Table< class Entry_T >
symbol::Table
in
src/symbol/table.hh which is a table of symbols dedicated to
storing some data which type is Entry_T *
. In short, it maps a
symbol::Symbol
to an Entry_T *
(that should ring a
bell...). You are encouraged to implement something simple, based on
stacks (see std::stack
or std::list
) and maps (see
std::map
).
symbol::Table
is a class template as it is used by virtually all
the AST visitors (e.g., escapes::EscapesVisitor
,
type::TypeVisitor
, translate::TranslateVisitor
etc.)
symbol::Table
must provide this interface:
Open a new scope.
Close the last scope, forgetting everything since the latest
scope_begin ()
.
Associate value to key in the current scope.
If key was associated to some
Entry_T
in the open scopes, return the most recent insertion. Otherwise return the empty pointer.
Send the content of this table on ostr in a readable manner, the top of the stack being displayed last.
type::String
, type::Int
, and
type::Void
are to be implemented. Using templates would be
particularly appreciated to factor the code between the four singleton
classes.
type::Named
is almost entirely given.
type::Array
is even simpler than the four Singletons.
type::Record
is somewhat incomplete.
Pay extra attention to the implementation of
type::operator== (const Type& a, const Type& b)
,
type::Type::assignable_to
and type::Type::comparable_to
.
type::TypeEnv
must be completed: it must fill
the environment with the definition of builtin types and functions. See
the Tiger Reference Manual.
The handling of types is left as an example, you still have to implement
the variables and functions support.
type::TypeVisitor
Tasks
, and make sure that your
configure.ac no longer includes foo/libfoo.hh
in src/modules.hh.