00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "comma/ast/StmtVisitor.h"
00010 #include "comma/ast/Stmt.h"
00011
00012 using namespace comma;
00013
00014 using llvm::dyn_cast;
00015 using llvm::cast;
00016 using llvm::isa;
00017
00018 void StmtVisitor::visitAst(Ast *node)
00019 {
00020 if (Stmt *stmt = dyn_cast<Stmt>(node))
00021 visitStmt(stmt);
00022 }
00023
00026 #define DISPATCH(TYPE, NODE) \
00027 Ast::AST_ ## TYPE: \
00028 visit ## TYPE(cast<TYPE>(NODE)); \
00029 break
00030
00031 void StmtVisitor::visitStmt(Stmt *node)
00032 {
00033 switch (node->getKind()) {
00034 default:
00035 assert(false && "Cannot visit this kind of node!");
00036 break;
00037
00038 case DISPATCH(StmtSequence, node);
00039 case DISPATCH(BlockStmt, node);
00040 case DISPATCH(ProcedureCallStmt, node);
00041 case DISPATCH(ReturnStmt, node);
00042 case DISPATCH(AssignmentStmt, node);
00043 case DISPATCH(IfStmt, node);
00044 case DISPATCH(WhileStmt, node);
00045 case DISPATCH(ForStmt, node);
00046 case DISPATCH(LoopStmt, node);
00047 case DISPATCH(RaiseStmt, node);
00048 case DISPATCH(PragmaStmt, node);
00049 case DISPATCH(NullStmt, node);
00050 }
00051 }
00052
00053 void StmtVisitor::visitStmtSequence(StmtSequence *node)
00054 {
00055 if (BlockStmt *block = dyn_cast<BlockStmt>(node))
00056 visitBlockStmt(block);
00057 }
00058
00059 void StmtVisitor::visitBlockStmt(BlockStmt *node) { }
00060 void StmtVisitor::visitProcedureCallStmt(ProcedureCallStmt *node) { }
00061 void StmtVisitor::visitReturnStmt(ReturnStmt *node) { }
00062 void StmtVisitor::visitAssignmentStmt(AssignmentStmt *node) { }
00063 void StmtVisitor::visitIfStmt(IfStmt *node) { }
00064 void StmtVisitor::visitWhileStmt(WhileStmt *node) { }
00065 void StmtVisitor::visitForStmt(ForStmt *node) { }
00066 void StmtVisitor::visitLoopStmt(LoopStmt *node) { }
00067 void StmtVisitor::visitRaiseStmt(RaiseStmt *node) { }
00068 void StmtVisitor::visitPragmaStmt(PragmaStmt *node) { }
00069 void StmtVisitor::visitNullStmt(NullStmt *node) { }
00070