Public Member Functions |
virtual void | operator() (typename Const< Ast >::type &e) |
| The entry point: visit e.
|
virtual void | operator() (typename Const< ClassTy >::type &)=0 |
virtual void | operator() (typename Const< MethodCallExp >::type &)=0 |
virtual void | operator() (typename Const< MethodDec >::type &)=0 |
virtual void | operator() (typename Const< ObjectExp >::type &)=0 |
template<class E > |
void | operator() (E *e) |
| Helper to visit nodes manipulated via a pointer.
|
|
virtual void | operator() (typename Const< SimpleVar >::type &e) override |
virtual void | operator() (typename Const< FieldVar >::type &e) override |
virtual void | operator() (typename Const< SubscriptVar >::type &e) override |
virtual void | operator() (typename Const< CastVar >::type &e) override |
|
virtual void | operator() (typename Const< NilExp >::type &e) override |
virtual void | operator() (typename Const< IntExp >::type &e) override |
virtual void | operator() (typename Const< StringExp >::type &e) override |
virtual void | operator() (typename Const< CallExp >::type &e) override |
virtual void | operator() (typename Const< OpExp >::type &e) override |
virtual void | operator() (typename Const< RecordExp >::type &e) override |
virtual void | operator() (typename Const< SeqExp >::type &e) override |
virtual void | operator() (typename Const< AssignExp >::type &e) override |
virtual void | operator() (typename Const< IfExp >::type &e) override |
virtual void | operator() (typename Const< WhileExp >::type &e) override |
virtual void | operator() (typename Const< ForExp >::type &e) override |
virtual void | operator() (typename Const< BreakExp >::type &) override |
virtual void | operator() (typename Const< LetExp >::type &e) override |
virtual void | operator() (typename Const< ArrayExp >::type &e) override |
virtual void | operator() (typename Const< CastExp >::type &e) override |
virtual void | operator() (typename Const< FieldInit >::type &e) override |
|
Visiting declarations is simple, but there are many clauses. This is because in Tiger, the declarations are processed by chunks (a chunk of Function declarations, then Var or Type, then ...). So we have to explain
- How to visit a list of chunks;
- how to visit chunks of function, var, or type declarations;
- how to visit a single function, var, or type declaration.
|
virtual void | operator() (typename Const< DecsList >::type &e) override |
| Visit a list of function, type and/or variables declarations.
|
virtual void | operator() (typename Const< Decs >::type &e) |
| Visit a Decs chunks.
|
virtual void | operator() (typename Const< VarDecs >::type &e) override |
| Visit Var declarations.
|
virtual void | operator() (typename Const< VarDec >::type &e) override |
virtual void | operator() (typename Const< FunctionDecs >::type &e) override |
| Visit Function declarations.
|
virtual void | operator() (typename Const< FunctionDec >::type &e) override |
virtual void | operator() (typename Const< TypeDecs >::type &e) override |
| Visit Type declarations.
|
virtual void | operator() (typename Const< TypeDec >::type &e) override |
template<typename DecsType > |
void | decs_visit (typename Const< DecsType >::type &e) |
| Visit a chunk (i.e., a list of Function, Var, and Type decs).
|
|
virtual void | operator() (typename Const< NameTy >::type &e) override |
virtual void | operator() (typename Const< RecordTy >::type &e) override |
virtual void | operator() (typename Const< ArrayTy >::type &e) override |
|
virtual void | operator() (typename Const< Field >::type &e) override |
|
The methods should not be used, since this visitor is for the non-object flavor of the language.
|
virtual void | operator() (typename Const< ClassTy >::type &e) override |
virtual void | operator() (typename Const< MethodDecs >::type &e) override |
virtual void | operator() (typename Const< MethodDec >::type &e) override |
virtual void | operator() (typename Const< MethodCallExp >::type &e) override |
virtual void | operator() (typename Const< ObjectExp >::type &e) override |
Compute the escapes.
The EscapeVisitor is extremely similar to type::TypeChecker: in its course of operation it must relate uses to definitions. Therefore it will be run after the bind::Binder. It also needs auxiliary information about the definitions (their depth): a simple map suffice, since scoping issues were handled by the bind::Binder.
Note that this EscapesVisitor is mainly doing nothing: it is just interested in declaration and uses of variables/formals (and, of course, function declaration...). It would be somewhat stupid to write all the methods that `do nothing but walk'. This is why we will inherit from the non const ast::DefaultVisitor.
template<template< typename > class Const>
template<typename E >
A convenient shortcut for recurring code like this:
However, the drawback of this approach is that it doesn't take care of the constness, and any const violation will be reported within the body of this method, not at its corresponding call site.
We cannot use the misc/select_const.hh approach here, since the compiler cannot resolve a function overloaded or specialized on an associated type of a template. E.g., writing accept like this:
template <typename E>
void accept(
typename Const<E>::type* e);
won't work directly. Of course, one can help the compiler, providing it with E
accept<ast::NameTy>(e.result_get());
but this is painful.