This machine mirrors various open-source projects.
20 Gbit/s uplink.
If there are any issues or you want another project mirrored, please contact
mirror-service -=AT=- netcologne DOT de !
00001 //===-- ast/ExprVisitor.cpp ----------------------------------- -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2009-2010, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 #include "comma/ast/AttribExpr.h" 00010 #include "comma/ast/AggExpr.h" 00011 #include "comma/ast/ExprVisitor.h" 00012 00013 using namespace comma; 00014 00015 using llvm::dyn_cast; 00016 using llvm::cast; 00017 using llvm::isa; 00018 00021 #define DISPATCH(TYPE, NODE) \ 00022 Ast::AST_ ## TYPE: \ 00023 visit ## TYPE(cast<TYPE>(NODE)); \ 00024 break 00025 00026 void ExprVisitor::visitAst(Ast *node) 00027 { 00028 if (Expr *expr = dyn_cast<Expr>(node)) 00029 visitExpr(expr); 00030 } 00031 00032 void ExprVisitor::visitExpr(Expr *node) 00033 { 00034 if (isa<AttribExpr>(node)) 00035 visitAttribExpr(cast<AttribExpr>(node)); 00036 else { 00037 switch (node->getKind()) { 00038 default: 00039 assert(false && "Cannot visit this kind of node!"); 00040 break; 00041 case DISPATCH(DeclRefExpr, node); 00042 case DISPATCH(FunctionCallExpr, node); 00043 case DISPATCH(IndexedArrayExpr, node); 00044 case DISPATCH(SelectedExpr, node); 00045 case DISPATCH(InjExpr, node); 00046 case DISPATCH(PrjExpr, node); 00047 case DISPATCH(IntegerLiteral, node); 00048 case DISPATCH(StringLiteral, node); 00049 case DISPATCH(AggregateExpr, node); 00050 case DISPATCH(ConversionExpr, node); 00051 case DISPATCH(NullExpr, node); 00052 case DISPATCH(QualifiedExpr, node); 00053 case DISPATCH(DereferenceExpr, node); 00054 case DISPATCH(AllocatorExpr, node); 00055 case DISPATCH(DiamondExpr, node); 00056 }; 00057 } 00058 } 00059 00060 void ExprVisitor::visitAttribExpr(AttribExpr *node) 00061 { 00062 switch (node->getKind()) { 00063 default: 00064 assert(false && "Cannot visit this kind of attribute!"); 00065 break; 00066 case DISPATCH(FirstAE, node); 00067 case DISPATCH(FirstArrayAE, node); 00068 case DISPATCH(LastArrayAE, node); 00069 case DISPATCH(LastAE, node); 00070 }; 00071 } 00072 00073 //===----------------------------------------------------------------------===// 00074 // Leaf nodes. Default implementations do nothing. 00075 00076 void ExprVisitor::visitDeclRefExpr(DeclRefExpr *node) { } 00077 void ExprVisitor::visitFunctionCallExpr(FunctionCallExpr *node) { } 00078 void ExprVisitor::visitIndexedArrayExpr(IndexedArrayExpr *node) { } 00079 void ExprVisitor::visitSelectedExpr(SelectedExpr *node) { } 00080 void ExprVisitor::visitInjExpr(InjExpr *node) { } 00081 void ExprVisitor::visitPrjExpr(PrjExpr *node) { } 00082 void ExprVisitor::visitIntegerLiteral(IntegerLiteral *node) { } 00083 void ExprVisitor::visitStringLiteral(StringLiteral *node) { } 00084 void ExprVisitor::visitAggregateExpr(AggregateExpr *node) { } 00085 void ExprVisitor::visitConversionExpr(ConversionExpr *node) { } 00086 void ExprVisitor::visitNullExpr(NullExpr *node) { } 00087 void ExprVisitor::visitQualifiedExpr(QualifiedExpr *node) { } 00088 void ExprVisitor::visitDereferenceExpr(DereferenceExpr *node) { } 00089 void ExprVisitor::visitAllocatorExpr(AllocatorExpr *node) { } 00090 void ExprVisitor::visitDiamondExpr(DiamondExpr *node) { } 00091 00092 void ExprVisitor::visitFirstAE(FirstAE *node) { } 00093 void ExprVisitor::visitFirstArrayAE(FirstArrayAE *node) { } 00094 void ExprVisitor::visitLastArrayAE(LastArrayAE *node) { } 00095 void ExprVisitor::visitLastAE(LastAE *node) { }