#ifndef _IV_AST_VISITOR_H_ #define _IV_AST_VISITOR_H_ #include #include "noncopyable.h" #include "ast-fwd.h" namespace iv { namespace core { namespace ast { namespace detail { template struct AstVisitorTraits { }; template struct AstVisitorTraits { typedef typename std::tr1::add_pointer< typename std::tr1::add_const::type>::type type; }; template struct AstVisitorTraits { typedef typename std::tr1::add_pointer< typename std::tr1::add_const::type>::type type; }; } // namespace iv::core::ast::detail template class BasicAstVisitor : private Noncopyable >::type { private: template struct add { typedef typename detail::AstVisitorTraits::type type; }; public: virtual ~BasicAstVisitor() = 0; virtual void Visit(typename add >::type block) = 0; //NOLINT virtual void Visit(typename add >::type func) = 0; //NOLINT virtual void Visit(typename add >::type var) = 0; //NOLINT virtual void Visit(typename add >::type empty) = 0; //NOLINT virtual void Visit(typename add >::type ifstmt) = 0; //NOLINT virtual void Visit(typename add >::type dowhile) = 0; //NOLINT virtual void Visit(typename add >::type whilestmt) = 0; //NOLINT virtual void Visit(typename add >::type forstmt) = 0; //NOLINT virtual void Visit(typename add >::type forstmt) = 0; //NOLINT virtual void Visit(typename add >::type continuestmt) = 0; //NOLINT virtual void Visit(typename add >::type breakstmt) = 0; //NOLINT virtual void Visit(typename add >::type returnstmt) = 0; //NOLINT virtual void Visit(typename add >::type withstmt) = 0; //NOLINT virtual void Visit(typename add >::type labelledstmt) = 0; //NOLINT virtual void Visit(typename add >::type switchstmt) = 0; //NOLINT virtual void Visit(typename add >::type throwstmt) = 0; //NOLINT virtual void Visit(typename add >::type trystmt) = 0; //NOLINT virtual void Visit(typename add >::type debuggerstmt) = 0; //NOLINT virtual void Visit(typename add >::type exprstmt) = 0; //NOLINT virtual void Visit(typename add >::type assign) = 0; //NOLINT virtual void Visit(typename add >::type binary) = 0; //NOLINT virtual void Visit(typename add >::type cond) = 0; //NOLINT virtual void Visit(typename add >::type unary) = 0; //NOLINT virtual void Visit(typename add >::type postfix) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type literal) = 0; //NOLINT virtual void Visit(typename add >::type prop) = 0; //NOLINT virtual void Visit(typename add >::type prop) = 0; //NOLINT virtual void Visit(typename add >::type call) = 0; //NOLINT virtual void Visit(typename add >::type call) = 0; //NOLINT protected: template class Acceptor { public: explicit Acceptor(T* visitor) : visitor_(visitor) { } template void operator()(U* p) const { p->Accept(visitor_); } private: T* const visitor_; }; template class Visitor { public: explicit Visitor(T* visitor) : visitor_(visitor) { } template void operator()(U* p) const { visitor_->Visit(p); } private: T* const visitor_; }; }; template inline BasicAstVisitor::~BasicAstVisitor() { } template struct AstVisitor { typedef BasicAstVisitor type; typedef BasicAstVisitor const_type; }; } } } // namespace iv::core::ast #endif // _IV_AST_VISITOR_H_