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/ExprDumper.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 "ExprDumper.h" 00010 #include "comma/ast/AggExpr.h" 00011 00012 #include "llvm/Support/Format.h" 00013 00014 using namespace comma; 00015 00016 using llvm::dyn_cast; 00017 using llvm::cast; 00018 using llvm::isa; 00019 00020 llvm::raw_ostream &ExprDumper::dump(Expr *expr, unsigned level) 00021 { 00022 unsigned savedLevel = indentLevel; 00023 indentLevel = level; 00024 visitExpr(expr); 00025 indentLevel = savedLevel; 00026 return S; 00027 } 00028 00029 void ExprDumper::visitDeclRefExpr(DeclRefExpr *node) 00030 { 00031 printHeader(node) << 00032 llvm::format(" '%s'>", node->getString()); 00033 } 00034 00035 void ExprDumper::visitFunctionCallExpr(FunctionCallExpr *node) 00036 { 00037 printHeader(node); 00038 FunctionDecl *decl = node->getConnective(0); 00039 S << llvm::format(" '%s'>", decl->getString()); 00040 } 00041 00042 void ExprDumper::visitIndexedArrayExpr(IndexedArrayExpr *node) 00043 { 00044 printHeader(node) << '>'; 00045 } 00046 00047 void ExprDumper::visitInjExpr(InjExpr *node) 00048 { 00049 printHeader(node) << '>'; 00050 } 00051 00052 void ExprDumper::visitPrjExpr(PrjExpr *node) 00053 { 00054 printHeader(node) << '>'; 00055 } 00056 00057 void ExprDumper::visitIntegerLiteral(IntegerLiteral *node) 00058 { 00059 printHeader(node) << " '"; 00060 node->getValue().print(S, false); 00061 S << "'>"; 00062 } 00063 00064 void ExprDumper::visitStringLiteral(StringLiteral *node) 00065 { 00066 printHeader(node) << " \"" << node->getString() << "\">"; 00067 } 00068 00069 void ExprDumper::visitAggregateExpr(AggregateExpr *node) 00070 { 00071 printHeader(node); 00072 indent(); 00073 00074 typedef AggregateExpr::pos_iterator pos_iterator; 00075 for (pos_iterator I = node->pos_begin(), E = node->pos_end(); I != E; ++I) { 00076 S << '\n'; 00077 dump(*I, indentLevel); 00078 } 00079 dedent(); 00080 S << ">"; 00081 } 00082 00083 void ExprDumper::visitConversionExpr(ConversionExpr *node) 00084 { 00085 printHeader(node) << " "; 00086 visitExpr(node->getOperand()); 00087 S << " "; 00088 dumpAST(node->getType()) << ">"; 00089 } 00090 00091 void ExprDumper::visitNullExpr(NullExpr *node) 00092 { 00093 printHeader(node) << '>'; 00094 } 00095 00096 void ExprDumper::visitQualifiedExpr(QualifiedExpr *node) 00097 { 00098 printHeader(node) << ' '; 00099 dumpAST(node->getPrefix()) << ' '; 00100 visitExpr(node->getOperand()); 00101 S << '>'; 00102 } 00103 00104 void ExprDumper::visitDereferenceExpr(DereferenceExpr *node) 00105 { 00106 printHeader(node) << ' '; 00107 visitExpr(node->getPrefix()); 00108 S << '>'; 00109 } 00110 00111 void ExprDumper::visitAllocatorExpr(AllocatorExpr *node) 00112 { 00113 printHeader(node) << ' '; 00114 if (node->isInitialized()) 00115 visitExpr(node->getInitializer()); 00116 else 00117 dumpAST(node->getAllocatedType()); 00118 S << '>'; 00119 } 00120 00121 void ExprDumper::visitSelectedExpr(SelectedExpr *node) 00122 { 00123 printHeader(node) << '\n'; 00124 indent(); 00125 printIndentation(); 00126 visitExpr(node->getPrefix()); 00127 if (node->isAmbiguous()) 00128 S << ' ' << node->getSelectorIdInfo(); 00129 else { 00130 S << '\n'; 00131 printIndentation(); 00132 dumpAST(node->getSelectorDecl()); 00133 dedent(); 00134 } 00135 S << '>'; 00136 }