| [461046f] | 1 | // | 
|---|
|  | 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | 
|---|
|  | 3 | // | 
|---|
|  | 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
|  | 5 | // file "LICENCE" distributed with Cforall. | 
|---|
|  | 6 | // | 
|---|
| [0351e9f] | 7 | // Print.cpp -- Print an AST (or sub-tree) to a stream. | 
|---|
| [461046f] | 8 | // | 
|---|
|  | 9 | // Author           : Thierry Delisle | 
|---|
|  | 10 | // Created On       : Tue May 21 16:20:15 2019 | 
|---|
|  | 11 | // Last Modified By : | 
|---|
|  | 12 | // Last Modified On : | 
|---|
|  | 13 | // Update Count     : | 
|---|
|  | 14 | // | 
|---|
|  | 15 |  | 
|---|
|  | 16 | #include "Print.hpp" | 
|---|
|  | 17 |  | 
|---|
| [bccd70a] | 18 | #include "Attribute.hpp" | 
|---|
| [461046f] | 19 | #include "Decl.hpp" | 
|---|
|  | 20 | #include "Expr.hpp" | 
|---|
| [bccd70a] | 21 | #include "Init.hpp" | 
|---|
| [461046f] | 22 | #include "Stmt.hpp" | 
|---|
|  | 23 | #include "Type.hpp" | 
|---|
|  | 24 | #include "TypeSubstitution.hpp" | 
|---|
| [b26144d] | 25 | #include "CompilationState.h" | 
|---|
| [bccd70a] | 26 | #include "Common/Iterate.hpp" | 
|---|
| [a2e758e] | 27 |  | 
|---|
| [5902625] | 28 | using namespace std; | 
|---|
| [461046f] | 29 |  | 
|---|
|  | 30 | namespace ast { | 
|---|
|  | 31 |  | 
|---|
| [257a8f5] | 32 | namespace { | 
|---|
|  | 33 |  | 
|---|
|  | 34 | template<typename C, typename... T> | 
|---|
|  | 35 | constexpr array<C, sizeof...(T)> make_array( T&&... values ) { | 
|---|
|  | 36 | return array<C, sizeof...(T)>{ std::forward<T>( values )... }; | 
|---|
|  | 37 | } | 
|---|
|  | 38 |  | 
|---|
|  | 39 | namespace Names { | 
|---|
|  | 40 | static constexpr auto FuncSpecifiers = make_array<const char*>( | 
|---|
|  | 41 | "inline", "_Noreturn", "fortran" | 
|---|
|  | 42 | ); | 
|---|
|  | 43 |  | 
|---|
|  | 44 | static constexpr auto StorageClasses = make_array<const char*>( | 
|---|
|  | 45 | "extern", "static", "auto", "register", "__thread", "_Thread_local" | 
|---|
|  | 46 | ); | 
|---|
|  | 47 |  | 
|---|
|  | 48 | static constexpr auto Qualifiers = make_array<const char*>( | 
|---|
|  | 49 | "const", "restrict", "volatile", "mutex", "_Atomic" | 
|---|
|  | 50 | ); | 
|---|
|  | 51 | } | 
|---|
|  | 52 |  | 
|---|
|  | 53 | template<typename bits_t, size_t N> | 
|---|
|  | 54 | void print( ostream & os, const bits_t & bits, | 
|---|
|  | 55 | const array<const char *, N> & names ) { | 
|---|
|  | 56 | if ( !bits.any() ) return; | 
|---|
|  | 57 | for ( size_t i = 0 ; i < N ; i += 1 ) { | 
|---|
|  | 58 | if ( bits[i] ) { | 
|---|
|  | 59 | os << names[i] << ' '; | 
|---|
|  | 60 | } | 
|---|
|  | 61 | } | 
|---|
| [461046f] | 62 | } | 
|---|
|  | 63 |  | 
|---|
| [e67991f] | 64 | class Printer final : public Visitor { | 
|---|
| [461046f] | 65 | public: | 
|---|
| [5902625] | 66 | ostream & os; | 
|---|
| [461046f] | 67 | Indenter indent; | 
|---|
| [5902625] | 68 | bool short_mode; | 
|---|
| [461046f] | 69 |  | 
|---|
| [5902625] | 70 | Printer(ostream & os, Indenter indent, bool short_mode) : os( os ), indent( indent ), short_mode(short_mode) {} | 
|---|
| [461046f] | 71 |  | 
|---|
|  | 72 | private: | 
|---|
|  | 73 | template< typename C > | 
|---|
|  | 74 | void printAll( const C & c ) { | 
|---|
|  | 75 | for ( const auto & i : c ) { | 
|---|
|  | 76 | if ( i ) { | 
|---|
|  | 77 | os << indent; | 
|---|
|  | 78 | i->accept( *this ); | 
|---|
|  | 79 | // need an endl after each element because it's not | 
|---|
|  | 80 | // easy to know when each individual item should end | 
|---|
| [5902625] | 81 | os << endl; | 
|---|
| [461046f] | 82 | } // if | 
|---|
|  | 83 | } // for | 
|---|
|  | 84 | } | 
|---|
|  | 85 |  | 
|---|
| [20a5977] | 86 | /// call if mandatory field is missing | 
|---|
|  | 87 | void undefined() { | 
|---|
|  | 88 | os << "UNDEFINED"; | 
|---|
|  | 89 | } | 
|---|
|  | 90 |  | 
|---|
|  | 91 | /// call for fields that should be mandatory | 
|---|
|  | 92 | void safe_print( const ast::Node * n ) { | 
|---|
|  | 93 | if ( n ) n->accept( *this ); | 
|---|
|  | 94 | else undefined(); | 
|---|
|  | 95 | } | 
|---|
|  | 96 |  | 
|---|
|  | 97 | /// call to print short form. Incorporates features of safe_print() | 
|---|
| [6f4b7f2] | 98 | void short_print( const ast::Decl * n ) { | 
|---|
| [20a5977] | 99 | if ( ! n ) { undefined(); return; } | 
|---|
|  | 100 | bool old_short = short_mode; short_mode = true; | 
|---|
|  | 101 | n->accept( *this ); | 
|---|
|  | 102 | short_mode = old_short; | 
|---|
|  | 103 | } | 
|---|
|  | 104 |  | 
|---|
| [461046f] | 105 | static const char* Names[]; | 
|---|
|  | 106 |  | 
|---|
| [94b1f718] | 107 | void print( const std::vector<ast::Label> & labels ) { | 
|---|
|  | 108 | if ( labels.empty() ) return; | 
|---|
|  | 109 | os << indent << "... Labels: {"; | 
|---|
|  | 110 | bool isFirst = true; | 
|---|
|  | 111 | for ( const Label & l : labels ) { | 
|---|
|  | 112 | if ( isFirst ) { isFirst = false; } else { os << ","; } | 
|---|
|  | 113 | os << l; | 
|---|
|  | 114 | } | 
|---|
|  | 115 | os << "}" << endl; | 
|---|
|  | 116 | } | 
|---|
|  | 117 |  | 
|---|
| [20a5977] | 118 | void print( const ast::Expr::InferUnion & inferred, unsigned level = 0 ) { | 
|---|
| [79c907b] | 119 | if (inferred.data.resnSlots && !inferred.data.resnSlots->empty()) { | 
|---|
|  | 120 | os << indent << "with " << inferred.data.resnSlots->size() | 
|---|
| [94b1f718] | 121 | << " pending inference slots" << endl; | 
|---|
| [20a5977] | 122 | } | 
|---|
| [79c907b] | 123 | if (inferred.data.inferParams && !inferred.data.inferParams->empty()) { | 
|---|
| [94b1f718] | 124 | os << indent << "with inferred parameters " << level << ":" << endl; | 
|---|
| [20a5977] | 125 | ++indent; | 
|---|
| [79c907b] | 126 | for ( const auto & i : *inferred.data.inferParams ) { | 
|---|
| [20a5977] | 127 | os << indent; | 
|---|
| [79c907b] | 128 | short_print( i.second.declptr ); | 
|---|
| [94b1f718] | 129 | os << endl; | 
|---|
| [20a5977] | 130 | print( i.second.expr->inferred, level+1 ); | 
|---|
|  | 131 | } | 
|---|
|  | 132 | --indent; | 
|---|
|  | 133 | } | 
|---|
|  | 134 | } | 
|---|
|  | 135 |  | 
|---|
| [361bf01] | 136 | void print( const ast::FunctionType::ForallList & forall ) { | 
|---|
| [d908563] | 137 | if ( forall.empty() ) return; | 
|---|
| [94b1f718] | 138 | os << "forall" << endl; | 
|---|
| [b0ec971] | 139 | ++indent; | 
|---|
|  | 140 | printAll( forall ); | 
|---|
|  | 141 | os << indent; | 
|---|
|  | 142 | --indent; | 
|---|
|  | 143 | } | 
|---|
|  | 144 |  | 
|---|
| [3e5dd913] | 145 | void print( const ast::FunctionType::AssertionList & assts ) { | 
|---|
|  | 146 | if (assts.empty()) return; | 
|---|
|  | 147 | os << "with assertions" << endl; | 
|---|
|  | 148 | ++indent; | 
|---|
|  | 149 | printAll(assts); | 
|---|
|  | 150 | os << indent; | 
|---|
|  | 151 | --indent; | 
|---|
|  | 152 | } | 
|---|
|  | 153 |  | 
|---|
| [b0ec971] | 154 | void print( const std::vector<ptr<Attribute>> & attrs ) { | 
|---|
|  | 155 | if ( attrs.empty() ) return; | 
|---|
| [94b1f718] | 156 | os << "with attributes" << endl; | 
|---|
| [b0ec971] | 157 | ++indent; | 
|---|
|  | 158 | printAll( attrs ); | 
|---|
|  | 159 | --indent; | 
|---|
|  | 160 | } | 
|---|
|  | 161 |  | 
|---|
|  | 162 | void print( const std::vector<ptr<Expr>> & params ) { | 
|---|
|  | 163 | if ( params.empty() ) return; | 
|---|
| [94b1f718] | 164 | os << endl << indent << "... with parameters" << endl; | 
|---|
| [b0ec971] | 165 | ++indent; | 
|---|
|  | 166 | printAll( params ); | 
|---|
|  | 167 | --indent; | 
|---|
|  | 168 | } | 
|---|
|  | 169 |  | 
|---|
| [5902625] | 170 | void print( const ast::AggregateDecl * node ) { | 
|---|
| [6f4b7f2] | 171 | os << node->typeString() << " " << node->name; | 
|---|
| [a7d50b6] | 172 |  | 
|---|
| [6f4b7f2] | 173 | if ( ! short_mode && node->linkage != Linkage::Cforall ) { | 
|---|
| [5902625] | 174 | os << " " << Linkage::name( node->linkage ); | 
|---|
| [6f4b7f2] | 175 | } | 
|---|
| [a7d50b6] | 176 |  | 
|---|
| [6f4b7f2] | 177 | os << " " << (node->body ? "with" : "without") << " body"; | 
|---|
| [5902625] | 178 |  | 
|---|
|  | 179 | if ( ! node->params.empty() ) { | 
|---|
|  | 180 | os << endl << indent << "... with parameters" << endl; | 
|---|
|  | 181 | ++indent; | 
|---|
|  | 182 | printAll( node->params ); | 
|---|
|  | 183 | --indent; | 
|---|
| [6f4b7f2] | 184 | } | 
|---|
|  | 185 |  | 
|---|
|  | 186 | if ( ! short_mode && ! node->members.empty() ) { | 
|---|
| [5902625] | 187 | os << endl << indent << "... with members" << endl; | 
|---|
|  | 188 | ++indent; | 
|---|
|  | 189 | printAll( node->members ); | 
|---|
|  | 190 | --indent; | 
|---|
| [6f4b7f2] | 191 | } | 
|---|
|  | 192 |  | 
|---|
|  | 193 | if ( ! short_mode && ! node->attributes.empty() ) { | 
|---|
| [5902625] | 194 | os << endl << indent << "... with attributes" << endl; | 
|---|
|  | 195 | ++indent; | 
|---|
|  | 196 | printAll( node->attributes ); | 
|---|
|  | 197 | --indent; | 
|---|
| [6f4b7f2] | 198 | } | 
|---|
|  | 199 |  | 
|---|
| [4559b34] | 200 | auto ptrToEnum = dynamic_cast<const ast::EnumDecl *>(node); | 
|---|
|  | 201 | if ( ! short_mode && ptrToEnum && ptrToEnum->base ) { | 
|---|
|  | 202 | os << endl << indent << ".. with (enum) base" << endl; | 
|---|
|  | 203 | ++indent; | 
|---|
|  | 204 | ptrToEnum->base->accept( *this ); | 
|---|
| [ed9a1ae] | 205 | --indent; | 
|---|
| [4559b34] | 206 | } | 
|---|
|  | 207 |  | 
|---|
| [5902625] | 208 | os << endl; | 
|---|
|  | 209 | } | 
|---|
|  | 210 |  | 
|---|
| [cf3da24] | 211 | void print( const ast::WaitStmt * node ) { | 
|---|
| [c86b08d] | 212 | if ( node->timeout_time ) { | 
|---|
|  | 213 | os << indent-1 << "timeout of:" << endl; | 
|---|
|  | 214 | node->timeout_time->accept( *this ); | 
|---|
|  | 215 |  | 
|---|
|  | 216 | if ( node->timeout_stmt ) { | 
|---|
|  | 217 | os << indent-1 << "... with statment:" << endl; | 
|---|
|  | 218 | node->timeout_stmt->accept( *this ); | 
|---|
|  | 219 | } | 
|---|
|  | 220 |  | 
|---|
|  | 221 | if ( node->timeout_cond ) { | 
|---|
|  | 222 | os << indent-1 << "... with condition:" << endl; | 
|---|
|  | 223 | node->timeout_cond->accept( *this ); | 
|---|
|  | 224 | } | 
|---|
|  | 225 | } | 
|---|
|  | 226 |  | 
|---|
|  | 227 | if ( node->else_stmt ) { | 
|---|
|  | 228 | os << indent-1 << "else:" << endl; | 
|---|
|  | 229 | node->else_stmt->accept( *this ); | 
|---|
|  | 230 |  | 
|---|
|  | 231 | if ( node->else_cond ) { | 
|---|
|  | 232 | os << indent-1 << "... with condition:" << endl; | 
|---|
|  | 233 | node->else_cond->accept( *this ); | 
|---|
|  | 234 | } | 
|---|
|  | 235 | } | 
|---|
|  | 236 | } | 
|---|
|  | 237 |  | 
|---|
| [6f4b7f2] | 238 | void preprint( const ast::NamedTypeDecl * node ) { | 
|---|
| [cd6a6ff] | 239 | if ( ! node->name.empty() ) { | 
|---|
| [3e5dd913] | 240 | os << node->name << ": "; | 
|---|
| [cd6a6ff] | 241 | } | 
|---|
| [5902625] | 242 |  | 
|---|
| [6f4b7f2] | 243 | if ( ! short_mode && node->linkage != Linkage::Cforall ) { | 
|---|
| [5902625] | 244 | os << Linkage::name( node->linkage ) << " "; | 
|---|
| [6f4b7f2] | 245 | } | 
|---|
|  | 246 |  | 
|---|
| [257a8f5] | 247 | ast::print( os, node->storage ); | 
|---|
| [5902625] | 248 | os << node->typeString(); | 
|---|
| [a7d50b6] | 249 |  | 
|---|
| [5902625] | 250 | if ( node->base ) { | 
|---|
|  | 251 | os << " for "; | 
|---|
|  | 252 | ++indent; | 
|---|
|  | 253 | node->base->accept( *this ); | 
|---|
|  | 254 | --indent; | 
|---|
| [6f4b7f2] | 255 | } | 
|---|
|  | 256 |  | 
|---|
| [79c907b] | 257 | if ( ! node->assertions.empty() ) { | 
|---|
| [5902625] | 258 | os << endl << indent << "... with assertions" << endl; | 
|---|
|  | 259 | ++indent; | 
|---|
|  | 260 | printAll( node->assertions ); | 
|---|
|  | 261 | --indent; | 
|---|
| [6f4b7f2] | 262 | } | 
|---|
| [5902625] | 263 | } | 
|---|
| [b0ec971] | 264 |  | 
|---|
| [20a5977] | 265 | void postprint( const ast::Expr * node ) { | 
|---|
|  | 266 | print( node->inferred ); | 
|---|
|  | 267 |  | 
|---|
| [ef9988b] | 268 | if ( node->result ) { | 
|---|
| [cd6a6ff] | 269 | os << endl << indent << "... with resolved type:" << endl; | 
|---|
|  | 270 | ++indent; | 
|---|
|  | 271 | os << indent; | 
|---|
|  | 272 | node->result->accept( *this ); | 
|---|
|  | 273 | --indent; | 
|---|
| [ef9988b] | 274 | } | 
|---|
|  | 275 |  | 
|---|
| [20a5977] | 276 | if ( node->env ) { | 
|---|
| [94b1f718] | 277 | os << endl << indent << "... with environment:" << endl; | 
|---|
| [20a5977] | 278 | ++indent; | 
|---|
|  | 279 | node->env->accept( *this ); | 
|---|
|  | 280 | --indent; | 
|---|
|  | 281 | } | 
|---|
| [a16e246] | 282 |  | 
|---|
| [20a5977] | 283 | if ( node->extension ) { | 
|---|
| [94b1f718] | 284 | os << endl << indent << "... with extension"; | 
|---|
| [20a5977] | 285 | } | 
|---|
|  | 286 | } | 
|---|
|  | 287 |  | 
|---|
|  | 288 | void preprint( const ast::Type * node ) { | 
|---|
| [257a8f5] | 289 | ast::print( os, node->qualifiers ); | 
|---|
| [20a5977] | 290 | } | 
|---|
|  | 291 |  | 
|---|
| [361bf01] | 292 | void preprint( const ast::FunctionType * node ) { | 
|---|
| [20a5977] | 293 | print( node->forall ); | 
|---|
| [3e5dd913] | 294 | print( node->assertions ); | 
|---|
| [257a8f5] | 295 | ast::print( os, node->qualifiers ); | 
|---|
| [20a5977] | 296 | } | 
|---|
|  | 297 |  | 
|---|
| [98e8b3b] | 298 | void preprint( const ast::BaseInstType * node ) { | 
|---|
| [20a5977] | 299 | print( node->attributes ); | 
|---|
| [257a8f5] | 300 | ast::print( os, node->qualifiers ); | 
|---|
| [20a5977] | 301 | } | 
|---|
|  | 302 |  | 
|---|
| [461046f] | 303 | public: | 
|---|
| [e67991f] | 304 | virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) override final { | 
|---|
| [6f4b7f2] | 305 | if ( ! node->name.empty() ) os << node->name << ": "; | 
|---|
| [461046f] | 306 |  | 
|---|
| [6f4b7f2] | 307 | if ( ! short_mode && node->linkage != Linkage::Cforall ) { | 
|---|
| [461046f] | 308 | os << Linkage::name( node->linkage ) << " "; | 
|---|
| [6f4b7f2] | 309 | } | 
|---|
| [461046f] | 310 |  | 
|---|
| [257a8f5] | 311 | ast::print( os, node->storage ); | 
|---|
| [461046f] | 312 |  | 
|---|
|  | 313 | if ( node->type ) { | 
|---|
|  | 314 | node->type->accept( *this ); | 
|---|
|  | 315 | } else { | 
|---|
| [20a5977] | 316 | os << "untyped entity"; | 
|---|
| [6f4b7f2] | 317 | } | 
|---|
| [461046f] | 318 |  | 
|---|
| [6f4b7f2] | 319 | if ( ! short_mode && node->init ) { | 
|---|
|  | 320 | ++indent; | 
|---|
| [461046f] | 321 | os << " with initializer (" << ( | 
|---|
|  | 322 | node->init->maybeConstructed | 
|---|
|  | 323 | ? "maybe constructed" | 
|---|
|  | 324 | : "not constructed" | 
|---|
| [6f4b7f2] | 325 | ) << ")" << endl << indent; | 
|---|
| [461046f] | 326 | node->init->accept( *this ); | 
|---|
|  | 327 | --indent; | 
|---|
| [5902625] | 328 | os << endl; | 
|---|
| [6f4b7f2] | 329 | } | 
|---|
| [461046f] | 330 |  | 
|---|
| [6f4b7f2] | 331 | if ( ! short_mode && ! node->attributes.empty() ) { | 
|---|
| [5902625] | 332 | os << endl << indent << "... with attributes:" << endl; | 
|---|
| [461046f] | 333 | ++indent; | 
|---|
|  | 334 | printAll( node->attributes ); | 
|---|
|  | 335 | --indent; | 
|---|
|  | 336 | } | 
|---|
|  | 337 |  | 
|---|
|  | 338 | if ( node->bitfieldWidth ) { | 
|---|
|  | 339 | os << indent << " with bitfield width "; | 
|---|
|  | 340 | node->bitfieldWidth->accept( *this ); | 
|---|
| [6f4b7f2] | 341 | } | 
|---|
|  | 342 |  | 
|---|
| [461046f] | 343 | return node; | 
|---|
|  | 344 | } | 
|---|
|  | 345 |  | 
|---|
| [e67991f] | 346 | virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) override final { | 
|---|
| [6f4b7f2] | 347 | if ( !node->name.empty() ) os << node->name << ": "; | 
|---|
|  | 348 |  | 
|---|
|  | 349 | if ( ! short_mode && node->linkage != Linkage::Cforall ) { | 
|---|
| [5902625] | 350 | os << Linkage::name( node->linkage ) << " "; | 
|---|
| [6f4b7f2] | 351 | } | 
|---|
| [5902625] | 352 |  | 
|---|
| [6f4b7f2] | 353 | if ( ! short_mode ) printAll( node->attributes ); | 
|---|
| [5902625] | 354 |  | 
|---|
| [257a8f5] | 355 | ast::print( os, node->storage ); | 
|---|
|  | 356 | ast::print( os, node->funcSpec ); | 
|---|
| [451d958] | 357 |  | 
|---|
|  | 358 | if ( node->type && node->isTypeFixed ) { | 
|---|
| [5902625] | 359 | node->type->accept( *this ); | 
|---|
|  | 360 | } else { | 
|---|
| [451d958] | 361 | if (!node->type_params.empty()) { | 
|---|
|  | 362 | os << "forall" << endl; | 
|---|
|  | 363 | ++indent; | 
|---|
|  | 364 | printAll(node->type_params); | 
|---|
|  | 365 | os << indent; | 
|---|
|  | 366 | --indent; | 
|---|
|  | 367 |  | 
|---|
|  | 368 | if (!node->assertions.empty()) { | 
|---|
|  | 369 | os << "with assertions" << endl; | 
|---|
|  | 370 | ++indent; | 
|---|
|  | 371 | printAll(node->assertions); | 
|---|
|  | 372 | os << indent; | 
|---|
|  | 373 | --indent; | 
|---|
|  | 374 | } | 
|---|
|  | 375 | } | 
|---|
|  | 376 |  | 
|---|
|  | 377 | os << "function" << endl; | 
|---|
|  | 378 | if ( ! node->params.empty() ) { | 
|---|
|  | 379 | os << indent << "... with parameters" << endl; | 
|---|
|  | 380 | ++indent; | 
|---|
|  | 381 | printAll( node->params ); | 
|---|
|  | 382 | if ( node->type->isVarArgs ) { | 
|---|
|  | 383 | os << indent << "and a variable number of other arguments" << endl; | 
|---|
|  | 384 | } | 
|---|
|  | 385 | --indent; | 
|---|
|  | 386 | } else if ( node->type->isVarArgs ) { | 
|---|
|  | 387 | os << indent+1 << "accepting unspecified arguments" << endl; | 
|---|
|  | 388 | } | 
|---|
|  | 389 |  | 
|---|
|  | 390 | os << indent << "... returning"; | 
|---|
|  | 391 | if ( node->returns.empty() ) { | 
|---|
|  | 392 | os << " nothing" << endl; | 
|---|
|  | 393 | } else { | 
|---|
|  | 394 | os << endl; | 
|---|
|  | 395 | ++indent; | 
|---|
|  | 396 | printAll( node->returns ); | 
|---|
|  | 397 | --indent; | 
|---|
|  | 398 | } | 
|---|
| [6f4b7f2] | 399 | } | 
|---|
| [5902625] | 400 |  | 
|---|
| [056bee8] | 401 | if ( ! node->withExprs.empty() ) { | 
|---|
|  | 402 | // Not with a clause, but the 'with clause'. | 
|---|
|  | 403 | ++indent; | 
|---|
|  | 404 | os << " with clause" << endl << indent; | 
|---|
|  | 405 | printAll( node->withExprs ); | 
|---|
|  | 406 | --indent; | 
|---|
|  | 407 | } | 
|---|
|  | 408 |  | 
|---|
| [6f4b7f2] | 409 | if ( ! short_mode && node->stmts ) { | 
|---|
| [5902625] | 410 | ++indent; | 
|---|
| [6f4b7f2] | 411 | os << " with body" << endl << indent; | 
|---|
| [5902625] | 412 | node->stmts->accept( *this ); | 
|---|
|  | 413 | --indent; | 
|---|
| [6f4b7f2] | 414 | } | 
|---|
|  | 415 |  | 
|---|
| [461046f] | 416 | return node; | 
|---|
|  | 417 | } | 
|---|
|  | 418 |  | 
|---|
| [e67991f] | 419 | virtual const ast::Decl * visit( const ast::StructDecl * node ) override final { | 
|---|
| [5902625] | 420 | print(node); | 
|---|
| [461046f] | 421 | return node; | 
|---|
|  | 422 | } | 
|---|
|  | 423 |  | 
|---|
| [71806e0] | 424 | virtual const ast::DeclWithType * visit( const ast::InlineMemberDecl * node ) override final { | 
|---|
| [e874605] | 425 | os << "inline "; | 
|---|
|  | 426 | if ( ! node->name.empty() ) os << node->name; | 
|---|
|  | 427 |  | 
|---|
|  | 428 | return node; | 
|---|
|  | 429 | } | 
|---|
|  | 430 |  | 
|---|
| [e67991f] | 431 | virtual const ast::Decl * visit( const ast::UnionDecl * node ) override final { | 
|---|
| [5902625] | 432 | print(node); | 
|---|
| [461046f] | 433 | return node; | 
|---|
|  | 434 | } | 
|---|
|  | 435 |  | 
|---|
| [e67991f] | 436 | virtual const ast::Decl * visit( const ast::EnumDecl * node ) override final { | 
|---|
| [5902625] | 437 | print(node); | 
|---|
| [461046f] | 438 | return node; | 
|---|
|  | 439 | } | 
|---|
|  | 440 |  | 
|---|
| [e67991f] | 441 | virtual const ast::Decl * visit( const ast::TraitDecl * node ) override final { | 
|---|
| [5902625] | 442 | print(node); | 
|---|
| [461046f] | 443 | return node; | 
|---|
|  | 444 | } | 
|---|
|  | 445 |  | 
|---|
| [e67991f] | 446 | virtual const ast::Decl * visit( const ast::TypeDecl * node ) override final { | 
|---|
| [6f4b7f2] | 447 | preprint( node ); | 
|---|
|  | 448 | if ( ! short_mode && node->init ) { | 
|---|
| [5902625] | 449 | os << endl << indent << "with type initializer: "; | 
|---|
|  | 450 | ++indent; | 
|---|
|  | 451 | node->init->accept( *this ); | 
|---|
|  | 452 | --indent; | 
|---|
|  | 453 | } | 
|---|
| [6f4b7f2] | 454 |  | 
|---|
| [461046f] | 455 | return node; | 
|---|
|  | 456 | } | 
|---|
|  | 457 |  | 
|---|
| [e67991f] | 458 | virtual const ast::Decl * visit( const ast::TypedefDecl * node ) override final { | 
|---|
| [6f4b7f2] | 459 | preprint( node ); | 
|---|
| [461046f] | 460 | return node; | 
|---|
|  | 461 | } | 
|---|
|  | 462 |  | 
|---|
| [e67991f] | 463 | virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) override final { | 
|---|
| [6f4b7f2] | 464 | safe_print( node->stmt ); | 
|---|
| [461046f] | 465 | return node; | 
|---|
|  | 466 | } | 
|---|
|  | 467 |  | 
|---|
| [2d019af] | 468 | virtual const ast::DirectiveDecl * visit( const ast::DirectiveDecl * node ) override final { | 
|---|
|  | 469 | safe_print( node->stmt ); | 
|---|
|  | 470 | return node; | 
|---|
|  | 471 | } | 
|---|
|  | 472 |  | 
|---|
| [e67991f] | 473 | virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) override final { | 
|---|
| [5902625] | 474 | os << "Static Assert with condition: "; | 
|---|
|  | 475 | ++indent; | 
|---|
| [6f4b7f2] | 476 | safe_print( node->cond ); | 
|---|
|  | 477 | os << endl << indent-1 << "and message: "; | 
|---|
|  | 478 | safe_print( node->msg ); | 
|---|
| [5902625] | 479 | --indent; | 
|---|
|  | 480 | os << endl; | 
|---|
| [6f4b7f2] | 481 |  | 
|---|
| [461046f] | 482 | return node; | 
|---|
|  | 483 | } | 
|---|
|  | 484 |  | 
|---|
| [e67991f] | 485 | virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final { | 
|---|
| [94b1f718] | 486 | os << "Compound Statement:" << endl; | 
|---|
| [5902625] | 487 | ++indent; | 
|---|
|  | 488 | printAll( node->kids ); | 
|---|
|  | 489 | --indent; | 
|---|
| [461046f] | 490 | return node; | 
|---|
|  | 491 | } | 
|---|
|  | 492 |  | 
|---|
| [e67991f] | 493 | virtual const ast::Stmt * visit( const ast::ExprStmt * node ) override final { | 
|---|
| [5902625] | 494 | ++indent; | 
|---|
|  | 495 | os << "Expression Statement:" << endl << indent; | 
|---|
| [20a5977] | 496 | safe_print( node->expr ); | 
|---|
| [5902625] | 497 | --indent; | 
|---|
| [461046f] | 498 | return node; | 
|---|
|  | 499 | } | 
|---|
|  | 500 |  | 
|---|
| [e67991f] | 501 | virtual const ast::Stmt * visit( const ast::AsmStmt * node ) override final { | 
|---|
| [5902625] | 502 | os << "Assembler Statement:" << endl; | 
|---|
|  | 503 | ++indent; | 
|---|
| [94b1f718] | 504 | os << indent-1 << "instruction:" << endl << indent; | 
|---|
|  | 505 | safe_print( node->instruction ); | 
|---|
| [5902625] | 506 | if ( ! node->output.empty() ) { | 
|---|
| [94b1f718] | 507 | os << endl << indent << "output:" << endl; | 
|---|
| [5902625] | 508 | printAll( node->output ); | 
|---|
|  | 509 | } // if | 
|---|
|  | 510 | if ( ! node->input.empty() ) { | 
|---|
| [94b1f718] | 511 | os << indent << "input:" << endl; | 
|---|
| [5902625] | 512 | printAll( node->input ); | 
|---|
|  | 513 | } // if | 
|---|
|  | 514 | if ( ! node->clobber.empty() ) { | 
|---|
| [94b1f718] | 515 | os << indent << "clobber:" << endl; | 
|---|
| [5902625] | 516 | printAll( node->clobber ); | 
|---|
|  | 517 | } // if | 
|---|
|  | 518 | --indent; | 
|---|
| [461046f] | 519 | return node; | 
|---|
|  | 520 | } | 
|---|
|  | 521 |  | 
|---|
| [e67991f] | 522 | virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) override final { | 
|---|
| [94b1f718] | 523 | os << "GCC Directive: " << node->directive << endl; | 
|---|
| [461046f] | 524 | return node; | 
|---|
|  | 525 | } | 
|---|
|  | 526 |  | 
|---|
| [e67991f] | 527 | virtual const ast::Stmt * visit( const ast::IfStmt * node ) override final { | 
|---|
| [94b1f718] | 528 | os << "If on condition:" << endl; | 
|---|
| [5902625] | 529 | ++indent; | 
|---|
| [94b1f718] | 530 | os << indent; | 
|---|
| [20a5977] | 531 | safe_print( node->cond ); | 
|---|
| [5902625] | 532 | --indent; | 
|---|
|  | 533 |  | 
|---|
| [94b1f718] | 534 | if ( ! node->inits.empty() ) { | 
|---|
|  | 535 | os << indent << "... with initialization:" << endl; | 
|---|
| [5902625] | 536 | ++indent; | 
|---|
| [94b1f718] | 537 | for ( const ast::Stmt * stmt : node->inits ) { | 
|---|
| [5902625] | 538 | os << indent; | 
|---|
| [94b1f718] | 539 | safe_print( stmt ); | 
|---|
| [5902625] | 540 | } | 
|---|
|  | 541 | --indent; | 
|---|
|  | 542 | os << endl; | 
|---|
|  | 543 | } | 
|---|
|  | 544 |  | 
|---|
| [94b1f718] | 545 | os << indent << "... then:" << endl; | 
|---|
| [5902625] | 546 |  | 
|---|
|  | 547 | ++indent; | 
|---|
|  | 548 | os << indent; | 
|---|
| [3b0bc16] | 549 | safe_print( node->then ); | 
|---|
| [5902625] | 550 | --indent; | 
|---|
|  | 551 |  | 
|---|
| [3b0bc16] | 552 | if ( node->else_ != 0 ) { | 
|---|
| [94b1f718] | 553 | os << indent << "... else:" << endl; | 
|---|
| [5902625] | 554 | ++indent; | 
|---|
|  | 555 | os << indent; | 
|---|
| [3b0bc16] | 556 | node->else_->accept( *this ); | 
|---|
| [5902625] | 557 | --indent; | 
|---|
|  | 558 | } // if | 
|---|
| [461046f] | 559 | return node; | 
|---|
|  | 560 | } | 
|---|
|  | 561 |  | 
|---|
| [3b0bc16] | 562 | virtual const ast::Stmt * visit( const ast::WhileDoStmt * node ) override final { | 
|---|
| [94b1f718] | 563 | if ( node->isDoWhile ) { os << "Do-"; } | 
|---|
|  | 564 | os << "While on condition:" << endl; | 
|---|
|  | 565 | ++indent; | 
|---|
|  | 566 | safe_print( node->cond ); | 
|---|
|  | 567 | os << indent-1 << "... with body:" << endl; | 
|---|
|  | 568 | safe_print( node->body ); | 
|---|
|  | 569 |  | 
|---|
|  | 570 | if ( ! node->inits.empty() ) { | 
|---|
|  | 571 | os << indent-1 << "... with inits:" << endl; | 
|---|
|  | 572 | printAll( node->inits ); | 
|---|
|  | 573 | } | 
|---|
|  | 574 | --indent; | 
|---|
|  | 575 |  | 
|---|
| [461046f] | 576 | return node; | 
|---|
|  | 577 | } | 
|---|
|  | 578 |  | 
|---|
| [e67991f] | 579 | virtual const ast::Stmt * visit( const ast::ForStmt * node ) override final { | 
|---|
| [94b1f718] | 580 | os << "For Statement" << endl; | 
|---|
|  | 581 |  | 
|---|
|  | 582 | if ( ! node->inits.empty() ) { | 
|---|
|  | 583 | os << indent << "... initialization:" << endl; | 
|---|
|  | 584 | ++indent; | 
|---|
|  | 585 | for ( const ast::Stmt * stmt : node->inits ) { | 
|---|
|  | 586 | os << indent+1; | 
|---|
|  | 587 | safe_print( stmt ); | 
|---|
|  | 588 | } | 
|---|
|  | 589 | --indent; | 
|---|
|  | 590 | } | 
|---|
|  | 591 |  | 
|---|
|  | 592 | if ( node->cond ) { | 
|---|
|  | 593 | os << indent << "... condition:" << endl; | 
|---|
|  | 594 | ++indent; | 
|---|
|  | 595 | os << indent; | 
|---|
|  | 596 | node->cond->accept( *this ); | 
|---|
|  | 597 | --indent; | 
|---|
|  | 598 | } | 
|---|
|  | 599 |  | 
|---|
|  | 600 | if ( node->inc ) { | 
|---|
|  | 601 | os << indent << "... increment:" << endl; | 
|---|
|  | 602 | ++indent; | 
|---|
|  | 603 | os << indent; | 
|---|
|  | 604 | node->inc->accept( *this ); | 
|---|
|  | 605 | --indent; | 
|---|
|  | 606 | } | 
|---|
|  | 607 |  | 
|---|
|  | 608 | if ( node->body ) { | 
|---|
|  | 609 | os << indent << "... with body:" << endl; | 
|---|
|  | 610 | ++indent; | 
|---|
|  | 611 | os << indent; | 
|---|
|  | 612 | node->body->accept( *this ); | 
|---|
|  | 613 | --indent; | 
|---|
|  | 614 | } | 
|---|
|  | 615 | os << endl; | 
|---|
|  | 616 | print( node->labels ); | 
|---|
|  | 617 |  | 
|---|
| [461046f] | 618 | return node; | 
|---|
|  | 619 | } | 
|---|
|  | 620 |  | 
|---|
| [e67991f] | 621 | virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) override final { | 
|---|
| [94b1f718] | 622 | os << "Switch on condition: "; | 
|---|
|  | 623 | safe_print( node->cond ); | 
|---|
|  | 624 | os << endl; | 
|---|
|  | 625 |  | 
|---|
|  | 626 | ++indent; | 
|---|
| [400b8be] | 627 | for ( const ast::CaseClause * stmt : node->cases ) { | 
|---|
| [94b1f718] | 628 | stmt->accept( *this ); | 
|---|
|  | 629 | } | 
|---|
|  | 630 | --indent; | 
|---|
|  | 631 |  | 
|---|
| [461046f] | 632 | return node; | 
|---|
|  | 633 | } | 
|---|
|  | 634 |  | 
|---|
| [400b8be] | 635 | virtual const ast::CaseClause * visit( const ast::CaseClause * node ) override final { | 
|---|
| [94b1f718] | 636 | if ( node->isDefault() ) { | 
|---|
|  | 637 | os << indent << "Default "; | 
|---|
|  | 638 | } else { | 
|---|
|  | 639 | os << indent << "Case "; | 
|---|
|  | 640 | safe_print( node->cond ); | 
|---|
|  | 641 | } // if | 
|---|
|  | 642 | os << endl; | 
|---|
|  | 643 |  | 
|---|
|  | 644 | ++indent; | 
|---|
|  | 645 | for ( const ast::Stmt * stmt : node->stmts ) { | 
|---|
|  | 646 | os << indent; | 
|---|
|  | 647 | stmt->accept( *this ); | 
|---|
|  | 648 | } | 
|---|
|  | 649 | --indent; | 
|---|
|  | 650 |  | 
|---|
| [461046f] | 651 | return node; | 
|---|
|  | 652 | } | 
|---|
|  | 653 |  | 
|---|
| [e67991f] | 654 | virtual const ast::Stmt * visit( const ast::BranchStmt * node ) override final { | 
|---|
| [94b1f718] | 655 | os << "Branch (" << node->kindName() << ")" << endl; | 
|---|
|  | 656 | ++indent; | 
|---|
|  | 657 | if ( ! node->target.empty() ) { | 
|---|
|  | 658 | os << indent << "with target: " << node->target << endl; | 
|---|
|  | 659 | } | 
|---|
|  | 660 |  | 
|---|
|  | 661 | if ( ! node->originalTarget.empty() ) { | 
|---|
|  | 662 | os << indent << "with original target: " << node->originalTarget << endl; | 
|---|
|  | 663 | } | 
|---|
|  | 664 |  | 
|---|
|  | 665 | if ( node->computedTarget ) { | 
|---|
|  | 666 | os << indent << "with computed target: "; | 
|---|
|  | 667 | node->computedTarget->accept( *this ); | 
|---|
|  | 668 | os << endl; | 
|---|
|  | 669 | } | 
|---|
|  | 670 | --indent; | 
|---|
|  | 671 |  | 
|---|
| [461046f] | 672 | return node; | 
|---|
|  | 673 | } | 
|---|
|  | 674 |  | 
|---|
| [e67991f] | 675 | virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) override final { | 
|---|
| [94b1f718] | 676 | os << "Return Statement, returning"; | 
|---|
|  | 677 | if ( node->expr ) { | 
|---|
|  | 678 | ++indent; | 
|---|
|  | 679 | os << ":" << endl << indent; | 
|---|
|  | 680 | node->expr->accept( *this ); | 
|---|
|  | 681 | --indent; | 
|---|
|  | 682 | } else { | 
|---|
|  | 683 | os << " void"; | 
|---|
|  | 684 | } | 
|---|
|  | 685 | os << endl; | 
|---|
|  | 686 |  | 
|---|
| [461046f] | 687 | return node; | 
|---|
|  | 688 | } | 
|---|
|  | 689 |  | 
|---|
| [e67991f] | 690 | virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) override final { | 
|---|
| [6f4b7f2] | 691 | if ( node->target ) os << "Non-Local "; | 
|---|
|  | 692 |  | 
|---|
|  | 693 | switch( node->kind ) { | 
|---|
|  | 694 | case ast::ExceptionKind::Terminate: os << "Terminate "; break; | 
|---|
|  | 695 | case ast::ExceptionKind::Resume:    os << "Resume ";    break; | 
|---|
|  | 696 | } | 
|---|
|  | 697 |  | 
|---|
|  | 698 | ++indent; | 
|---|
|  | 699 | os << "Throw Statement, raising: "; | 
|---|
|  | 700 | safe_print( node->expr ); | 
|---|
|  | 701 | if ( node->target ) { | 
|---|
|  | 702 | os << "... at: "; | 
|---|
|  | 703 | node->target->accept( *this ); | 
|---|
|  | 704 | } | 
|---|
|  | 705 | --indent; | 
|---|
|  | 706 |  | 
|---|
| [461046f] | 707 | return node; | 
|---|
|  | 708 | } | 
|---|
|  | 709 |  | 
|---|
| [e67991f] | 710 | virtual const ast::Stmt * visit( const ast::TryStmt * node ) override final { | 
|---|
| [6f4b7f2] | 711 | ++indent; | 
|---|
| [a7d50b6] | 712 | os << "Try Statement" << endl << indent-1 | 
|---|
| [6f4b7f2] | 713 | << "... with block:" << endl << indent; | 
|---|
|  | 714 | safe_print( node->body ); | 
|---|
|  | 715 |  | 
|---|
|  | 716 | os << indent-1 << "... and handlers:" << endl; | 
|---|
| [400b8be] | 717 | for ( const ast::CatchClause * stmt : node->handlers ) { | 
|---|
| [6f4b7f2] | 718 | os << indent; | 
|---|
|  | 719 | stmt->accept( *this ); | 
|---|
|  | 720 | } | 
|---|
|  | 721 |  | 
|---|
|  | 722 | if ( node->finally ) { | 
|---|
|  | 723 | os << indent-1 << "... and finally:" << endl << indent; | 
|---|
|  | 724 | node->finally->accept( *this ); | 
|---|
|  | 725 | } | 
|---|
|  | 726 | --indent; | 
|---|
|  | 727 |  | 
|---|
| [461046f] | 728 | return node; | 
|---|
|  | 729 | } | 
|---|
|  | 730 |  | 
|---|
| [400b8be] | 731 | virtual const ast::CatchClause * visit( const ast::CatchClause * node ) override final { | 
|---|
| [6f4b7f2] | 732 | os << "Catch "; | 
|---|
|  | 733 | switch ( node->kind ) { | 
|---|
|  | 734 | case ast::ExceptionKind::Terminate: os << "Terminate "; break; | 
|---|
|  | 735 | case ast::ExceptionKind::Resume:    os << "Resume ";    break; | 
|---|
|  | 736 | } | 
|---|
|  | 737 | os << "Statement" << endl << indent; | 
|---|
|  | 738 |  | 
|---|
|  | 739 | ++indent; | 
|---|
|  | 740 | os << "... catching: "; | 
|---|
|  | 741 | short_print( node->decl ); | 
|---|
|  | 742 | os << endl; | 
|---|
|  | 743 |  | 
|---|
|  | 744 | if ( node->cond ) { | 
|---|
|  | 745 | os << indent-1 << "... with conditional:" << endl << indent; | 
|---|
|  | 746 | node->cond->accept( *this ); | 
|---|
|  | 747 | } | 
|---|
|  | 748 |  | 
|---|
|  | 749 | os << indent-1 << "... with block:" << endl << indent; | 
|---|
|  | 750 | safe_print( node->body ); | 
|---|
|  | 751 | --indent; | 
|---|
| [a7d50b6] | 752 |  | 
|---|
| [461046f] | 753 | return node; | 
|---|
|  | 754 | } | 
|---|
|  | 755 |  | 
|---|
| [400b8be] | 756 | virtual const ast::FinallyClause * visit( const ast::FinallyClause * node ) override final { | 
|---|
| [6f4b7f2] | 757 | os << "Finally Statement" << endl; | 
|---|
|  | 758 | os << indent << "... with block:" << endl; | 
|---|
|  | 759 | ++indent; | 
|---|
|  | 760 | os << indent; | 
|---|
|  | 761 | safe_print( node->body ); | 
|---|
|  | 762 | --indent; | 
|---|
|  | 763 |  | 
|---|
| [461046f] | 764 | return node; | 
|---|
|  | 765 | } | 
|---|
|  | 766 |  | 
|---|
| [37cdd97] | 767 | virtual const ast::Stmt * visit( const ast::SuspendStmt * node ) override final { | 
|---|
|  | 768 | os << "Suspend Statement"; | 
|---|
| [835d6e8] | 769 | switch (node->kind) { | 
|---|
|  | 770 | case ast::SuspendStmt::None     : os << " with implicit target"; break; | 
|---|
|  | 771 | case ast::SuspendStmt::Generator: os << " for generator"; break; | 
|---|
|  | 772 | case ast::SuspendStmt::Coroutine: os << " for coroutine"; break; | 
|---|
| [37cdd97] | 773 | } | 
|---|
|  | 774 | os << endl; | 
|---|
|  | 775 |  | 
|---|
|  | 776 | ++indent; | 
|---|
|  | 777 | if(node->then) { | 
|---|
|  | 778 | os << indent << " with post statement :" << endl; | 
|---|
|  | 779 | safe_print( node->then ); | 
|---|
|  | 780 | } | 
|---|
|  | 781 | ++indent; | 
|---|
|  | 782 |  | 
|---|
|  | 783 | return node; | 
|---|
|  | 784 | } | 
|---|
|  | 785 |  | 
|---|
| [c86b08d] | 786 | virtual const ast::WhenClause * visit( const ast::WhenClause * node ) override final { | 
|---|
|  | 787 | os << indent-1 << "target: "; | 
|---|
|  | 788 | safe_print( node->target ); | 
|---|
|  | 789 |  | 
|---|
|  | 790 | if ( node->stmt ) { | 
|---|
|  | 791 | os << indent-1 << "... with statment:" << endl; | 
|---|
|  | 792 | node->stmt->accept( *this ); | 
|---|
|  | 793 | } | 
|---|
|  | 794 |  | 
|---|
|  | 795 | if ( node->when_cond ) { | 
|---|
|  | 796 | os << indent-1 << "... with when condition:" << endl; | 
|---|
|  | 797 | node->when_cond->accept( *this ); | 
|---|
|  | 798 | } | 
|---|
|  | 799 |  | 
|---|
|  | 800 | return node; | 
|---|
|  | 801 | } | 
|---|
|  | 802 |  | 
|---|
| [e67991f] | 803 | virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) override final { | 
|---|
| [6f4b7f2] | 804 | os << "Waitfor Statement" << endl; | 
|---|
|  | 805 | indent += 2; | 
|---|
|  | 806 | for( const auto & clause : node->clauses ) { | 
|---|
| [f6e6a55] | 807 | clause->accept( *this ); | 
|---|
|  | 808 | } | 
|---|
| [a7d50b6] | 809 |  | 
|---|
| [f6e6a55] | 810 | if ( node->timeout_time ) { | 
|---|
|  | 811 | os << indent-1 << "timeout of:" << endl; | 
|---|
|  | 812 | node->timeout_time->accept( *this ); | 
|---|
| [6f4b7f2] | 813 |  | 
|---|
| [f6e6a55] | 814 | if ( node->timeout_stmt ) { | 
|---|
| [6f4b7f2] | 815 | os << indent-1 << "... with statment:" << endl; | 
|---|
| [f6e6a55] | 816 | node->timeout_stmt->accept( *this ); | 
|---|
| [6f4b7f2] | 817 | } | 
|---|
|  | 818 |  | 
|---|
| [f6e6a55] | 819 | if ( node->timeout_cond ) { | 
|---|
| [6f4b7f2] | 820 | os << indent-1 << "... with condition:" << endl; | 
|---|
| [f6e6a55] | 821 | node->timeout_cond->accept( *this ); | 
|---|
| [6f4b7f2] | 822 | } | 
|---|
|  | 823 | } | 
|---|
|  | 824 |  | 
|---|
| [f6e6a55] | 825 | if ( node->else_stmt ) { | 
|---|
|  | 826 | os << indent-1 << "else:" << endl; | 
|---|
|  | 827 | node->else_stmt->accept( *this ); | 
|---|
| [6f4b7f2] | 828 |  | 
|---|
| [f6e6a55] | 829 | if ( node->else_cond ) { | 
|---|
| [6f4b7f2] | 830 | os << indent-1 << "... with condition:" << endl; | 
|---|
| [f6e6a55] | 831 | node->else_cond->accept( *this ); | 
|---|
| [6f4b7f2] | 832 | } | 
|---|
|  | 833 | } | 
|---|
|  | 834 |  | 
|---|
| [f6e6a55] | 835 | return node; | 
|---|
|  | 836 | } | 
|---|
| [6f4b7f2] | 837 |  | 
|---|
| [f6e6a55] | 838 | virtual const ast::WaitForClause * visit( const ast::WaitForClause * node ) override final { | 
|---|
|  | 839 | os << indent-1 << "target function: "; | 
|---|
| [c86b08d] | 840 | safe_print( node->target ); | 
|---|
| [f6e6a55] | 841 |  | 
|---|
|  | 842 | if ( !node->target_args.empty() ) { | 
|---|
|  | 843 | os << endl << indent-1 << "... with arguments:" << endl; | 
|---|
|  | 844 | for( const ast::Expr * arg : node->target_args ) { | 
|---|
|  | 845 | arg->accept( *this ); | 
|---|
| [6f4b7f2] | 846 | } | 
|---|
|  | 847 | } | 
|---|
| [f6e6a55] | 848 |  | 
|---|
|  | 849 | if ( node->stmt ) { | 
|---|
|  | 850 | os << indent-1 << "... with statment:" << endl; | 
|---|
|  | 851 | node->stmt->accept( *this ); | 
|---|
|  | 852 | } | 
|---|
|  | 853 |  | 
|---|
| [c86b08d] | 854 | if ( node->when_cond ) { | 
|---|
| [f6e6a55] | 855 | os << indent-1 << "... with condition:" << endl; | 
|---|
| [c86b08d] | 856 | node->when_cond->accept( *this ); | 
|---|
| [f6e6a55] | 857 | } | 
|---|
| [6f4b7f2] | 858 |  | 
|---|
| [461046f] | 859 | return node; | 
|---|
|  | 860 | } | 
|---|
|  | 861 |  | 
|---|
| [cf3da24] | 862 | virtual const ast::Stmt * visit( const ast::WaitUntilStmt * node ) override final { | 
|---|
| [c86b08d] | 863 | os << "Waituntil Statement" << endl; | 
|---|
|  | 864 | indent += 2; | 
|---|
|  | 865 | for( const auto & clause : node->clauses ) { | 
|---|
|  | 866 | clause->accept( *this ); | 
|---|
|  | 867 | } | 
|---|
| [cf3da24] | 868 | // calls print( const ast::WaitStmt * node ) | 
|---|
|  | 869 | print(node); | 
|---|
| [c86b08d] | 870 | return node; | 
|---|
|  | 871 | } | 
|---|
|  | 872 |  | 
|---|
| [e67991f] | 873 | virtual const ast::Decl * visit( const ast::WithStmt * node ) override final { | 
|---|
| [6f4b7f2] | 874 | os << "With statement" << endl; | 
|---|
|  | 875 | os << indent << "... with expressions:" << endl; | 
|---|
|  | 876 | ++indent; | 
|---|
|  | 877 | printAll( node->exprs ); | 
|---|
|  | 878 | os << indent-1 << "... with statement:" << endl << indent; | 
|---|
|  | 879 | safe_print( node->stmt ); | 
|---|
|  | 880 | --indent; | 
|---|
|  | 881 |  | 
|---|
| [461046f] | 882 | return node; | 
|---|
|  | 883 | } | 
|---|
|  | 884 |  | 
|---|
| [e67991f] | 885 | virtual const ast::NullStmt * visit( const ast::NullStmt * node ) override final { | 
|---|
| [94b1f718] | 886 | os << "Null Statement" << endl; | 
|---|
|  | 887 | print( node->labels ); | 
|---|
|  | 888 |  | 
|---|
| [461046f] | 889 | return node; | 
|---|
|  | 890 | } | 
|---|
|  | 891 |  | 
|---|
| [e67991f] | 892 | virtual const ast::Stmt * visit( const ast::DeclStmt * node ) override final { | 
|---|
| [6f4b7f2] | 893 | os << "Declaration of "; | 
|---|
|  | 894 | safe_print( node->decl ); | 
|---|
|  | 895 |  | 
|---|
| [461046f] | 896 | return node; | 
|---|
|  | 897 | } | 
|---|
|  | 898 |  | 
|---|
| [e67991f] | 899 | virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) override final { | 
|---|
| [6f4b7f2] | 900 | os << "Implicit Ctor Dtor Statement" << endl; | 
|---|
|  | 901 | os << indent << "... with Ctor/Dtor: "; | 
|---|
|  | 902 | ++indent; | 
|---|
|  | 903 | safe_print( node->callStmt ); | 
|---|
|  | 904 | --indent; | 
|---|
|  | 905 | os << endl; | 
|---|
|  | 906 |  | 
|---|
| [461046f] | 907 | return node; | 
|---|
|  | 908 | } | 
|---|
|  | 909 |  | 
|---|
| [6cebfef] | 910 | virtual const ast::Stmt * visit( const ast::MutexStmt * node ) override final { | 
|---|
|  | 911 | os << "Mutex Statement" << endl; | 
|---|
|  | 912 | os << indent << "... with Mutex Parameters: "; | 
|---|
|  | 913 | ++indent; | 
|---|
|  | 914 | printAll( node->mutexObjs ); | 
|---|
|  | 915 | --indent; | 
|---|
|  | 916 | os << indent << "... with Statement: "; | 
|---|
|  | 917 | ++indent; | 
|---|
|  | 918 | safe_print( node->stmt ); | 
|---|
|  | 919 | --indent; | 
|---|
|  | 920 | os << endl; | 
|---|
|  | 921 |  | 
|---|
|  | 922 | return node; | 
|---|
|  | 923 | } | 
|---|
|  | 924 |  | 
|---|
| [cf3da24] | 925 | virtual const ast::Stmt * visit( const ast::CorunStmt * node ) override final { | 
|---|
| [eb779d5] | 926 | os << "Corun Statement" << endl; | 
|---|
|  | 927 | os << indent << "... with Statement: "; | 
|---|
|  | 928 | ++indent; | 
|---|
|  | 929 | safe_print( node->stmt ); | 
|---|
|  | 930 | --indent; | 
|---|
|  | 931 | os << endl; | 
|---|
|  | 932 |  | 
|---|
|  | 933 | return node; | 
|---|
|  | 934 | } | 
|---|
|  | 935 |  | 
|---|
| [3d9d017] | 936 | virtual const ast::Stmt * visit( const ast::CoforStmt * node ) override final { | 
|---|
|  | 937 | os << "Cofor Statement" << endl; | 
|---|
|  | 938 |  | 
|---|
|  | 939 | if ( ! node->inits.empty() ) { | 
|---|
|  | 940 | os << indent << "... initialization:" << endl; | 
|---|
|  | 941 | ++indent; | 
|---|
|  | 942 | for ( const ast::Stmt * stmt : node->inits ) { | 
|---|
|  | 943 | os << indent+1; | 
|---|
|  | 944 | safe_print( stmt ); | 
|---|
|  | 945 | } | 
|---|
|  | 946 | --indent; | 
|---|
|  | 947 | } | 
|---|
|  | 948 |  | 
|---|
|  | 949 | if ( node->cond ) { | 
|---|
|  | 950 | os << indent << "... condition:" << endl; | 
|---|
|  | 951 | ++indent; | 
|---|
|  | 952 | os << indent; | 
|---|
|  | 953 | node->cond->accept( *this ); | 
|---|
|  | 954 | --indent; | 
|---|
|  | 955 | } | 
|---|
|  | 956 |  | 
|---|
|  | 957 | if ( node->inc ) { | 
|---|
|  | 958 | os << indent << "... increment:" << endl; | 
|---|
|  | 959 | ++indent; | 
|---|
|  | 960 | os << indent; | 
|---|
|  | 961 | node->inc->accept( *this ); | 
|---|
|  | 962 | --indent; | 
|---|
|  | 963 | } | 
|---|
|  | 964 |  | 
|---|
|  | 965 | if ( node->body ) { | 
|---|
|  | 966 | os << indent << "... with body:" << endl; | 
|---|
|  | 967 | ++indent; | 
|---|
|  | 968 | os << indent; | 
|---|
|  | 969 | node->body->accept( *this ); | 
|---|
|  | 970 | --indent; | 
|---|
|  | 971 | } | 
|---|
|  | 972 | os << endl; | 
|---|
|  | 973 | print( node->labels ); | 
|---|
|  | 974 |  | 
|---|
|  | 975 | return node; | 
|---|
|  | 976 | } | 
|---|
|  | 977 |  | 
|---|
| [e67991f] | 978 | virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) override final { | 
|---|
| [20a5977] | 979 | ++indent; | 
|---|
| [94b1f718] | 980 | os << "Application of" << endl << indent; | 
|---|
| [20a5977] | 981 | safe_print( node->func ); | 
|---|
| [94b1f718] | 982 | os << endl; | 
|---|
| [20a5977] | 983 | if ( ! node->args.empty() ) { | 
|---|
| [94b1f718] | 984 | os << indent << "... to arguments" << endl; | 
|---|
| [20a5977] | 985 | printAll( node->args ); | 
|---|
|  | 986 | } | 
|---|
|  | 987 | --indent; | 
|---|
|  | 988 | postprint( node ); | 
|---|
|  | 989 |  | 
|---|
| [461046f] | 990 | return node; | 
|---|
|  | 991 | } | 
|---|
|  | 992 |  | 
|---|
| [e67991f] | 993 | virtual const ast::Expr * visit( const ast::UntypedExpr * node ) override final { | 
|---|
| [20a5977] | 994 | ++indent; | 
|---|
| [94b1f718] | 995 | os << "Applying untyped:" << endl; | 
|---|
| [20a5977] | 996 | os << indent; | 
|---|
|  | 997 | safe_print( node->func ); | 
|---|
| [94b1f718] | 998 | os << endl << indent-1 << "...to:" << endl; | 
|---|
| [20a5977] | 999 | printAll( node->args ); | 
|---|
|  | 1000 | --indent; | 
|---|
|  | 1001 | postprint( node ); | 
|---|
|  | 1002 |  | 
|---|
| [461046f] | 1003 | return node; | 
|---|
|  | 1004 | } | 
|---|
|  | 1005 |  | 
|---|
| [e67991f] | 1006 | virtual const ast::Expr * visit( const ast::NameExpr * node ) override final { | 
|---|
| [20a5977] | 1007 | os << "Name: " << node->name; | 
|---|
|  | 1008 | postprint( node ); | 
|---|
| [d908563] | 1009 |  | 
|---|
| [461046f] | 1010 | return node; | 
|---|
|  | 1011 | } | 
|---|
|  | 1012 |  | 
|---|
| [b0d9ff7] | 1013 | virtual const ast::Expr * visit( const ast::QualifiedNameExpr * node ) override final { | 
|---|
|  | 1014 | os << "QualifiedNameExpr: " << std::endl; | 
|---|
|  | 1015 | os << ++indent << "Type: "; | 
|---|
|  | 1016 | safe_print( node->type_decl ); | 
|---|
|  | 1017 | os << std::endl; | 
|---|
|  | 1018 | os <<  indent << "Name: " << node->name  << std::endl; | 
|---|
|  | 1019 | --indent; | 
|---|
|  | 1020 | postprint( node ); | 
|---|
|  | 1021 | return node; | 
|---|
|  | 1022 | } | 
|---|
|  | 1023 |  | 
|---|
| [e67991f] | 1024 | virtual const ast::Expr * visit( const ast::AddressExpr * node ) override final { | 
|---|
| [94b1f718] | 1025 | os << "Address of:" << endl; | 
|---|
| [20a5977] | 1026 | ++indent; | 
|---|
|  | 1027 | os << indent; | 
|---|
|  | 1028 | safe_print( node->arg ); | 
|---|
|  | 1029 |  | 
|---|
|  | 1030 | --indent; | 
|---|
|  | 1031 |  | 
|---|
| [461046f] | 1032 | return node; | 
|---|
|  | 1033 | } | 
|---|
|  | 1034 |  | 
|---|
| [e67991f] | 1035 | virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) override final { | 
|---|
| [20a5977] | 1036 | os << "Address of label:" << node->arg; | 
|---|
|  | 1037 |  | 
|---|
| [461046f] | 1038 | return node; | 
|---|
|  | 1039 | } | 
|---|
|  | 1040 |  | 
|---|
| [e67991f] | 1041 | virtual const ast::Expr * visit( const ast::CastExpr * node ) override final { | 
|---|
| [20a5977] | 1042 | ++indent; | 
|---|
| [a8ed717] | 1043 | os << (node->isGenerated ? "Generated" : "Explicit") << " Cast of:" << endl << indent; | 
|---|
| [20a5977] | 1044 | safe_print( node->arg ); | 
|---|
| [94b1f718] | 1045 | os << endl << indent-1 << "... to:"; | 
|---|
| [20a5977] | 1046 | if ( ! node->result ) { | 
|---|
|  | 1047 | os << " "; | 
|---|
|  | 1048 | undefined(); | 
|---|
|  | 1049 | } else if ( node->result->isVoid() ) { | 
|---|
|  | 1050 | os << " nothing"; | 
|---|
|  | 1051 | } else { | 
|---|
| [94b1f718] | 1052 | os << endl << indent; | 
|---|
| [20a5977] | 1053 | node->result->accept( *this ); | 
|---|
|  | 1054 | } // if | 
|---|
|  | 1055 | --indent; | 
|---|
|  | 1056 | postprint( node ); | 
|---|
|  | 1057 |  | 
|---|
| [461046f] | 1058 | return node; | 
|---|
|  | 1059 | } | 
|---|
|  | 1060 |  | 
|---|
| [e67991f] | 1061 | virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final { | 
|---|
| [20a5977] | 1062 | ++indent; | 
|---|
| [94b1f718] | 1063 | os << "Keyword Cast of:" << endl << indent; | 
|---|
| [20a5977] | 1064 | safe_print( node->arg ); | 
|---|
|  | 1065 | --indent; | 
|---|
| [94b1f718] | 1066 | os << endl << indent << "... to: " << node->targetString(); | 
|---|
| [20a5977] | 1067 | postprint( node ); | 
|---|
|  | 1068 |  | 
|---|
| [461046f] | 1069 | return node; | 
|---|
|  | 1070 | } | 
|---|
|  | 1071 |  | 
|---|
| [e67991f] | 1072 | virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) override final { | 
|---|
| [20a5977] | 1073 | ++indent; | 
|---|
| [94b1f718] | 1074 | os << "Virtual Cast of:" << endl << indent; | 
|---|
| [20a5977] | 1075 | safe_print( node->arg ); | 
|---|
| [94b1f718] | 1076 | os << endl << indent-1 << "... to:"; | 
|---|
| [20a5977] | 1077 | if ( ! node->result ) { | 
|---|
|  | 1078 | os << " unknown"; | 
|---|
|  | 1079 | } else { | 
|---|
| [94b1f718] | 1080 | os << endl << indent; | 
|---|
| [20a5977] | 1081 | node->result->accept( *this ); | 
|---|
|  | 1082 | } | 
|---|
|  | 1083 | --indent; | 
|---|
|  | 1084 | postprint( node ); | 
|---|
|  | 1085 |  | 
|---|
| [461046f] | 1086 | return node; | 
|---|
|  | 1087 | } | 
|---|
|  | 1088 |  | 
|---|
| [e67991f] | 1089 | virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) override final { | 
|---|
| [20a5977] | 1090 | ++indent; | 
|---|
| [94b1f718] | 1091 | os << "Untyped Member Expression, with field: " << endl << indent; | 
|---|
| [20a5977] | 1092 | safe_print( node->member ); | 
|---|
| [94b1f718] | 1093 | os << indent-1 << "... from aggregate:" << endl << indent; | 
|---|
| [20a5977] | 1094 | safe_print( node->aggregate ); | 
|---|
|  | 1095 | --indent; | 
|---|
|  | 1096 | postprint( node ); | 
|---|
|  | 1097 |  | 
|---|
| [461046f] | 1098 | return node; | 
|---|
|  | 1099 | } | 
|---|
|  | 1100 |  | 
|---|
| [e67991f] | 1101 | virtual const ast::Expr * visit( const ast::MemberExpr * node ) override final { | 
|---|
| [20a5977] | 1102 | ++indent; | 
|---|
| [94b1f718] | 1103 | os << "Member Expression, with field:" << endl << indent; | 
|---|
| [20a5977] | 1104 | safe_print( node->member ); | 
|---|
| [94b1f718] | 1105 | os << endl << indent-1 << "... from aggregate:" << endl << indent; | 
|---|
| [20a5977] | 1106 | safe_print( node->aggregate ); | 
|---|
|  | 1107 | --indent; | 
|---|
|  | 1108 | postprint( node ); | 
|---|
|  | 1109 |  | 
|---|
| [461046f] | 1110 | return node; | 
|---|
|  | 1111 | } | 
|---|
|  | 1112 |  | 
|---|
| [e67991f] | 1113 | virtual const ast::Expr * visit( const ast::VariableExpr * node ) override final { | 
|---|
| [20a5977] | 1114 | os << "Variable Expression: "; | 
|---|
|  | 1115 | short_print( node->var ); | 
|---|
|  | 1116 | postprint( node ); | 
|---|
|  | 1117 |  | 
|---|
| [461046f] | 1118 | return node; | 
|---|
|  | 1119 | } | 
|---|
|  | 1120 |  | 
|---|
| [e67991f] | 1121 | virtual const ast::Expr * visit( const ast::ConstantExpr * node ) override final { | 
|---|
| [20a5977] | 1122 | os << "Constant Expression (" << node->rep; | 
|---|
|  | 1123 | if ( node->result ) { | 
|---|
|  | 1124 | os << ": "; | 
|---|
|  | 1125 | node->result->accept( *this ); | 
|---|
|  | 1126 | } | 
|---|
|  | 1127 | os << ")"; | 
|---|
|  | 1128 | postprint( node ); | 
|---|
|  | 1129 |  | 
|---|
| [461046f] | 1130 | return node; | 
|---|
|  | 1131 | } | 
|---|
|  | 1132 |  | 
|---|
| [e67991f] | 1133 | virtual const ast::Expr * visit( const ast::SizeofExpr * node ) override final { | 
|---|
| [a16e246] | 1134 | os << "Sizeof Expression on: "; | 
|---|
|  | 1135 | ++indent; | 
|---|
|  | 1136 | if ( node->type ) node->type->accept( *this ); | 
|---|
|  | 1137 | else safe_print( node->expr ); | 
|---|
|  | 1138 | --indent; | 
|---|
|  | 1139 | postprint( node ); | 
|---|
|  | 1140 |  | 
|---|
| [461046f] | 1141 | return node; | 
|---|
|  | 1142 | } | 
|---|
|  | 1143 |  | 
|---|
| [e67991f] | 1144 | virtual const ast::Expr * visit( const ast::AlignofExpr * node ) override final { | 
|---|
| [a16e246] | 1145 | os << "Alignof Expression on: "; | 
|---|
|  | 1146 | ++indent; | 
|---|
|  | 1147 | if ( node->type ) node->type->accept( *this ); | 
|---|
|  | 1148 | else safe_print( node->expr ); | 
|---|
|  | 1149 | --indent; | 
|---|
|  | 1150 | postprint( node ); | 
|---|
| [d908563] | 1151 |  | 
|---|
| [461046f] | 1152 | return node; | 
|---|
|  | 1153 | } | 
|---|
|  | 1154 |  | 
|---|
| [e67991f] | 1155 | virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) override final { | 
|---|
| [a16e246] | 1156 | os << "Untyped Offsetof Expression on member " << node->member << " of "; | 
|---|
|  | 1157 | ++indent; | 
|---|
|  | 1158 | safe_print( node->type ); | 
|---|
|  | 1159 | --indent; | 
|---|
|  | 1160 | postprint( node ); | 
|---|
|  | 1161 |  | 
|---|
| [461046f] | 1162 | return node; | 
|---|
|  | 1163 | } | 
|---|
|  | 1164 |  | 
|---|
| [e67991f] | 1165 | virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) override final { | 
|---|
| [a16e246] | 1166 | os << "Offsetof Expression on member " << node->member->name << " of "; | 
|---|
|  | 1167 | ++indent; | 
|---|
|  | 1168 | safe_print( node->type ); | 
|---|
|  | 1169 | --indent; | 
|---|
|  | 1170 | postprint( node ); | 
|---|
|  | 1171 |  | 
|---|
| [461046f] | 1172 | return node; | 
|---|
|  | 1173 | } | 
|---|
|  | 1174 |  | 
|---|
| [e67991f] | 1175 | virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) override final { | 
|---|
| [a16e246] | 1176 | os << "Offset Pack Expression on: "; | 
|---|
|  | 1177 | ++indent; | 
|---|
|  | 1178 | safe_print( node->type ); | 
|---|
|  | 1179 | --indent; | 
|---|
|  | 1180 | postprint( node ); | 
|---|
|  | 1181 |  | 
|---|
| [461046f] | 1182 | return node; | 
|---|
|  | 1183 | } | 
|---|
|  | 1184 |  | 
|---|
| [e67991f] | 1185 | virtual const ast::Expr * visit( const ast::LogicalExpr * node ) override final { | 
|---|
| [a16e246] | 1186 | os << "Short-circuited operation (" << (node->isAnd ? "and" : "or") << ") on: "; | 
|---|
|  | 1187 | safe_print( node->arg1 ); | 
|---|
|  | 1188 | os << " and "; | 
|---|
|  | 1189 | safe_print( node->arg2 ); | 
|---|
|  | 1190 | postprint( node ); | 
|---|
|  | 1191 |  | 
|---|
| [461046f] | 1192 | return node; | 
|---|
|  | 1193 | } | 
|---|
|  | 1194 |  | 
|---|
| [e67991f] | 1195 | virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) override final { | 
|---|
| [a16e246] | 1196 | ++indent; | 
|---|
| [94b1f718] | 1197 | os << "Conditional expression on:" << endl << indent; | 
|---|
| [a16e246] | 1198 | safe_print( node->arg1 ); | 
|---|
| [94b1f718] | 1199 | os << indent-1 << "First alternative:" << endl << indent; | 
|---|
| [a16e246] | 1200 | safe_print( node->arg2 ); | 
|---|
| [94b1f718] | 1201 | os << indent-1 << "Second alternative:" << endl << indent; | 
|---|
| [a16e246] | 1202 | safe_print( node->arg3 ); | 
|---|
|  | 1203 | --indent; | 
|---|
|  | 1204 | postprint( node ); | 
|---|
|  | 1205 |  | 
|---|
| [461046f] | 1206 | return node; | 
|---|
|  | 1207 | } | 
|---|
|  | 1208 |  | 
|---|
| [e67991f] | 1209 | virtual const ast::Expr * visit( const ast::CommaExpr * node ) override final { | 
|---|
| [a16e246] | 1210 | ++indent; | 
|---|
| [94b1f718] | 1211 | os << "Comma Expression:" << endl << indent; | 
|---|
| [a16e246] | 1212 | safe_print( node->arg1 ); | 
|---|
| [94b1f718] | 1213 | os << endl << indent; | 
|---|
| [a16e246] | 1214 | safe_print( node->arg2 ); | 
|---|
|  | 1215 | --indent; | 
|---|
|  | 1216 | postprint( node ); | 
|---|
|  | 1217 |  | 
|---|
| [461046f] | 1218 | return node; | 
|---|
|  | 1219 | } | 
|---|
|  | 1220 |  | 
|---|
| [e67991f] | 1221 | virtual const ast::Expr * visit( const ast::TypeExpr * node ) override final { | 
|---|
| [a16e246] | 1222 | safe_print( node->type ); | 
|---|
|  | 1223 | postprint( node ); | 
|---|
|  | 1224 |  | 
|---|
| [461046f] | 1225 | return node; | 
|---|
|  | 1226 | } | 
|---|
|  | 1227 |  | 
|---|
| [4ec9513] | 1228 | virtual const ast::Expr * visit( const ast::DimensionExpr * node ) override final { | 
|---|
|  | 1229 | os << "Type-Sys Value: " << node->name; | 
|---|
|  | 1230 | postprint( node ); | 
|---|
|  | 1231 |  | 
|---|
|  | 1232 | return node; | 
|---|
|  | 1233 | } | 
|---|
|  | 1234 |  | 
|---|
| [e67991f] | 1235 | virtual const ast::Expr * visit( const ast::AsmExpr * node ) override final { | 
|---|
| [94b1f718] | 1236 | os << "Asm Expression:" << endl; | 
|---|
| [a16e246] | 1237 | ++indent; | 
|---|
| [665f432] | 1238 | if ( !node->inout.empty() ) os << "[" << node->inout << "] "; | 
|---|
| [a16e246] | 1239 | if ( node->constraint ) node->constraint->accept( *this ); | 
|---|
|  | 1240 | if ( node->operand ) node->operand->accept( *this ); | 
|---|
|  | 1241 | --indent; | 
|---|
| [d908563] | 1242 |  | 
|---|
| [461046f] | 1243 | return node; | 
|---|
|  | 1244 | } | 
|---|
|  | 1245 |  | 
|---|
| [e67991f] | 1246 | virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) override final { | 
|---|
| [a16e246] | 1247 | ++indent; | 
|---|
| [94b1f718] | 1248 | os << "Implicit Copy Constructor Expression:" << endl << indent; | 
|---|
| [a16e246] | 1249 | safe_print( node->callExpr ); | 
|---|
|  | 1250 | --indent; | 
|---|
|  | 1251 | postprint( node ); | 
|---|
|  | 1252 |  | 
|---|
| [461046f] | 1253 | return node; | 
|---|
|  | 1254 | } | 
|---|
|  | 1255 |  | 
|---|
| [e67991f] | 1256 | virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) override final { | 
|---|
| [94b1f718] | 1257 | os <<  "Constructor Expression:" << endl << indent+1; | 
|---|
| [a16e246] | 1258 | indent += 2; | 
|---|
|  | 1259 | safe_print( node->callExpr ); | 
|---|
|  | 1260 | indent -= 2; | 
|---|
|  | 1261 | postprint( node ); | 
|---|
|  | 1262 |  | 
|---|
| [461046f] | 1263 | return node; | 
|---|
|  | 1264 | } | 
|---|
|  | 1265 |  | 
|---|
| [e67991f] | 1266 | virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) override final { | 
|---|
| [a16e246] | 1267 | ++indent; | 
|---|
| [94b1f718] | 1268 | os << "Compound Literal Expression: " << endl << indent; | 
|---|
| [a16e246] | 1269 | safe_print( node->result ); | 
|---|
|  | 1270 | os << indent; | 
|---|
|  | 1271 | safe_print( node->init ); | 
|---|
|  | 1272 | --indent; | 
|---|
|  | 1273 | postprint( node ); | 
|---|
|  | 1274 |  | 
|---|
| [461046f] | 1275 | return node; | 
|---|
|  | 1276 | } | 
|---|
|  | 1277 |  | 
|---|
| [e67991f] | 1278 | virtual const ast::Expr * visit( const ast::RangeExpr * node ) override final { | 
|---|
| [a16e246] | 1279 | os << "Range Expression: "; | 
|---|
|  | 1280 | safe_print( node->low ); | 
|---|
|  | 1281 | os << " ... "; | 
|---|
|  | 1282 | safe_print( node->high ); | 
|---|
|  | 1283 | postprint( node ); | 
|---|
|  | 1284 |  | 
|---|
| [461046f] | 1285 | return node; | 
|---|
|  | 1286 | } | 
|---|
|  | 1287 |  | 
|---|
| [e67991f] | 1288 | virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) override final { | 
|---|
| [94b1f718] | 1289 | os << "Untyped Tuple:" << endl; | 
|---|
| [a16e246] | 1290 | ++indent; | 
|---|
|  | 1291 | printAll( node->exprs ); | 
|---|
|  | 1292 | --indent; | 
|---|
|  | 1293 | postprint( node ); | 
|---|
|  | 1294 |  | 
|---|
| [461046f] | 1295 | return node; | 
|---|
|  | 1296 | } | 
|---|
|  | 1297 |  | 
|---|
| [e67991f] | 1298 | virtual const ast::Expr * visit( const ast::TupleExpr * node ) override final { | 
|---|
| [94b1f718] | 1299 | os << "Tuple:" << endl; | 
|---|
| [a16e246] | 1300 | ++indent; | 
|---|
|  | 1301 | printAll( node->exprs ); | 
|---|
|  | 1302 | --indent; | 
|---|
|  | 1303 | postprint( node ); | 
|---|
|  | 1304 |  | 
|---|
| [461046f] | 1305 | return node; | 
|---|
|  | 1306 | } | 
|---|
|  | 1307 |  | 
|---|
| [e67991f] | 1308 | virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) override final { | 
|---|
| [94b1f718] | 1309 | os << "Tuple Index Expression, with tuple:" << endl; | 
|---|
| [a16e246] | 1310 | ++indent; | 
|---|
|  | 1311 | os << indent; | 
|---|
|  | 1312 | safe_print( node->tuple ); | 
|---|
| [94b1f718] | 1313 | os << indent << "with index: " << node->index << endl; | 
|---|
| [a16e246] | 1314 | --indent; | 
|---|
|  | 1315 | postprint( node ); | 
|---|
| [d908563] | 1316 |  | 
|---|
| [461046f] | 1317 | return node; | 
|---|
|  | 1318 | } | 
|---|
|  | 1319 |  | 
|---|
| [e67991f] | 1320 | virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) override final { | 
|---|
| [94b1f718] | 1321 | os << "Tuple Assignment Expression, with stmt expr:" << endl; | 
|---|
| [a16e246] | 1322 | ++indent; | 
|---|
|  | 1323 | os << indent; | 
|---|
|  | 1324 | safe_print( node->stmtExpr ); | 
|---|
|  | 1325 | --indent; | 
|---|
|  | 1326 | postprint( node ); | 
|---|
|  | 1327 |  | 
|---|
| [461046f] | 1328 | return node; | 
|---|
|  | 1329 | } | 
|---|
|  | 1330 |  | 
|---|
| [e67991f] | 1331 | virtual const ast::Expr * visit( const ast::StmtExpr * node ) override final { | 
|---|
| [a16e246] | 1332 | ++indent; | 
|---|
| [94b1f718] | 1333 | os << "Statement Expression:" << endl << indent; | 
|---|
| [a16e246] | 1334 | safe_print( node->stmts ); | 
|---|
|  | 1335 | if ( ! node->returnDecls.empty() ) { | 
|---|
|  | 1336 | os << indent << "... with returnDecls: "; | 
|---|
|  | 1337 | printAll( node->returnDecls ); | 
|---|
|  | 1338 | } | 
|---|
|  | 1339 | if ( ! node->dtors.empty() ) { | 
|---|
|  | 1340 | os << indent << "... with dtors: "; | 
|---|
|  | 1341 | printAll( node->dtors ); | 
|---|
|  | 1342 | } | 
|---|
|  | 1343 | --indent; | 
|---|
|  | 1344 | postprint( node ); | 
|---|
|  | 1345 |  | 
|---|
| [461046f] | 1346 | return node; | 
|---|
|  | 1347 | } | 
|---|
|  | 1348 |  | 
|---|
| [e67991f] | 1349 | virtual const ast::Expr * visit( const ast::UniqueExpr * node ) override final { | 
|---|
| [a16e246] | 1350 | ++indent; | 
|---|
| [94b1f718] | 1351 | os << "Unique Expression with id: " << node->id << endl << indent; | 
|---|
| [a16e246] | 1352 | safe_print( node->expr ); | 
|---|
|  | 1353 | if ( node->object ) { | 
|---|
|  | 1354 | os << indent-1 << "... with decl: "; | 
|---|
|  | 1355 | short_print( node->object ); | 
|---|
|  | 1356 | } | 
|---|
|  | 1357 | --indent; | 
|---|
|  | 1358 | postprint( node ); | 
|---|
|  | 1359 |  | 
|---|
| [461046f] | 1360 | return node; | 
|---|
|  | 1361 | } | 
|---|
|  | 1362 |  | 
|---|
| [e67991f] | 1363 | virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) override final { | 
|---|
| [a16e246] | 1364 | ++indent; | 
|---|
| [94b1f718] | 1365 | os << "Untyped Init Expression" << endl << indent; | 
|---|
| [a16e246] | 1366 | safe_print( node->expr ); | 
|---|
|  | 1367 | if ( ! node->initAlts.empty() ) { | 
|---|
|  | 1368 | for ( const InitAlternative & alt : node->initAlts ) { | 
|---|
|  | 1369 | os << indent <<  "InitAlternative: "; | 
|---|
|  | 1370 | safe_print( alt.type ); | 
|---|
|  | 1371 | safe_print( alt.designation ); | 
|---|
|  | 1372 | } | 
|---|
|  | 1373 | } | 
|---|
|  | 1374 | --indent; | 
|---|
|  | 1375 |  | 
|---|
| [461046f] | 1376 | return node; | 
|---|
|  | 1377 | } | 
|---|
|  | 1378 |  | 
|---|
| [e67991f] | 1379 | virtual const ast::Expr * visit( const ast::InitExpr * node ) override final { | 
|---|
| [a16e246] | 1380 | ++indent; | 
|---|
| [94b1f718] | 1381 | os << "Init Expression" << endl << indent; | 
|---|
| [a16e246] | 1382 | safe_print( node->expr ); | 
|---|
|  | 1383 | os << indent << "... with designation: "; | 
|---|
|  | 1384 | safe_print( node->designation ); | 
|---|
|  | 1385 | --indent; | 
|---|
|  | 1386 |  | 
|---|
| [461046f] | 1387 | return node; | 
|---|
|  | 1388 | } | 
|---|
|  | 1389 |  | 
|---|
| [e67991f] | 1390 | virtual const ast::Expr * visit( const ast::DeletedExpr * node ) override final { | 
|---|
| [a16e246] | 1391 | ++indent; | 
|---|
| [94b1f718] | 1392 | os << "Deleted Expression" << endl << indent; | 
|---|
| [a16e246] | 1393 | safe_print( node->expr ); | 
|---|
| [94b1f718] | 1394 | os << endl << indent << "... deleted by: "; | 
|---|
| [a16e246] | 1395 | safe_print( node->deleteStmt ); | 
|---|
|  | 1396 | --indent; | 
|---|
|  | 1397 |  | 
|---|
| [461046f] | 1398 | return node; | 
|---|
|  | 1399 | } | 
|---|
|  | 1400 |  | 
|---|
| [e67991f] | 1401 | virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) override final { | 
|---|
| [a16e246] | 1402 | ++indent; | 
|---|
| [94b1f718] | 1403 | os << "Default Argument Expression" << endl << indent; | 
|---|
| [a16e246] | 1404 | safe_print( node->expr ); | 
|---|
|  | 1405 | --indent; | 
|---|
|  | 1406 |  | 
|---|
| [461046f] | 1407 | return node; | 
|---|
|  | 1408 | } | 
|---|
|  | 1409 |  | 
|---|
| [e67991f] | 1410 | virtual const ast::Expr * visit( const ast::GenericExpr * node ) override final { | 
|---|
| [a16e246] | 1411 | ++indent; | 
|---|
| [94b1f718] | 1412 | os << "C11 _Generic Expression" << endl << indent; | 
|---|
| [a16e246] | 1413 | safe_print( node->control ); | 
|---|
| [94b1f718] | 1414 | os << endl << indent << "... with associations:" << endl; | 
|---|
| [a16e246] | 1415 | for ( const auto & assoc : node->associations ) { | 
|---|
|  | 1416 | os << indent; | 
|---|
|  | 1417 | if ( assoc.type ) { | 
|---|
|  | 1418 | os << "... type: "; | 
|---|
|  | 1419 | assoc.type->accept( *this ); | 
|---|
| [94b1f718] | 1420 | os << endl << indent << "... expression: "; | 
|---|
| [a16e246] | 1421 | safe_print( assoc.expr ); | 
|---|
|  | 1422 | } else { | 
|---|
|  | 1423 | os << "... default: "; | 
|---|
|  | 1424 | safe_print( assoc.expr ); | 
|---|
|  | 1425 | } | 
|---|
| [94b1f718] | 1426 | os << endl; | 
|---|
| [a16e246] | 1427 | } | 
|---|
|  | 1428 | --indent; | 
|---|
|  | 1429 |  | 
|---|
| [461046f] | 1430 | return node; | 
|---|
|  | 1431 | } | 
|---|
|  | 1432 |  | 
|---|
| [e67991f] | 1433 | virtual const ast::Type * visit( const ast::VoidType * node ) override final { | 
|---|
| [b0ec971] | 1434 | preprint( node ); | 
|---|
|  | 1435 | os << "void"; | 
|---|
| [461046f] | 1436 | return node; | 
|---|
|  | 1437 | } | 
|---|
|  | 1438 |  | 
|---|
| [e67991f] | 1439 | virtual const ast::Type * visit( const ast::BasicType * node ) override final { | 
|---|
| [b0ec971] | 1440 | preprint( node ); | 
|---|
|  | 1441 | os << ast::BasicType::typeNames[ node->kind ]; | 
|---|
| [461046f] | 1442 | return node; | 
|---|
|  | 1443 | } | 
|---|
|  | 1444 |  | 
|---|
| [e67991f] | 1445 | virtual const ast::Type * visit( const ast::PointerType * node ) override final { | 
|---|
| [b0ec971] | 1446 | preprint( node ); | 
|---|
|  | 1447 | if ( ! node->isArray() ) { | 
|---|
|  | 1448 | os << "pointer to "; | 
|---|
|  | 1449 | } else { | 
|---|
|  | 1450 | os << "decayed "; | 
|---|
|  | 1451 | if ( node->isStatic ) { | 
|---|
|  | 1452 | os << "static "; | 
|---|
|  | 1453 | } | 
|---|
|  | 1454 |  | 
|---|
|  | 1455 | if ( node->isVarLen ) { | 
|---|
|  | 1456 | os << "variable length array of "; | 
|---|
|  | 1457 | } else if ( node->dimension ) { | 
|---|
|  | 1458 | os << "array of "; | 
|---|
|  | 1459 | node->dimension->accept( *this ); | 
|---|
|  | 1460 | os << " "; | 
|---|
|  | 1461 | } | 
|---|
|  | 1462 | } | 
|---|
| [20a5977] | 1463 | safe_print( node->base ); | 
|---|
| [b0ec971] | 1464 |  | 
|---|
| [461046f] | 1465 | return node; | 
|---|
|  | 1466 | } | 
|---|
|  | 1467 |  | 
|---|
| [e67991f] | 1468 | virtual const ast::Type * visit( const ast::ArrayType * node ) override final { | 
|---|
| [b0ec971] | 1469 | preprint( node ); | 
|---|
|  | 1470 | if ( node->isStatic ) { | 
|---|
|  | 1471 | os << "static "; | 
|---|
|  | 1472 | } | 
|---|
|  | 1473 |  | 
|---|
|  | 1474 | if ( node->isVarLen ) { | 
|---|
|  | 1475 | os << "variable length array of "; | 
|---|
|  | 1476 | } else if ( node->dimension ) { | 
|---|
|  | 1477 | os << "array of "; | 
|---|
|  | 1478 | } else { | 
|---|
|  | 1479 | os << "open array of "; | 
|---|
|  | 1480 | } | 
|---|
|  | 1481 |  | 
|---|
| [20a5977] | 1482 | safe_print( node->base ); | 
|---|
| [b0ec971] | 1483 |  | 
|---|
|  | 1484 | if ( node->dimension ) { | 
|---|
|  | 1485 | os << " with dimension of "; | 
|---|
|  | 1486 | node->dimension->accept( *this ); | 
|---|
|  | 1487 | } | 
|---|
|  | 1488 |  | 
|---|
| [461046f] | 1489 | return node; | 
|---|
|  | 1490 | } | 
|---|
|  | 1491 |  | 
|---|
| [e67991f] | 1492 | virtual const ast::Type * visit( const ast::ReferenceType * node ) override final { | 
|---|
| [b0ec971] | 1493 | preprint( node ); | 
|---|
|  | 1494 | os << "reference to "; | 
|---|
| [20a5977] | 1495 | safe_print( node->base ); | 
|---|
| [b0ec971] | 1496 |  | 
|---|
| [461046f] | 1497 | return node; | 
|---|
|  | 1498 | } | 
|---|
|  | 1499 |  | 
|---|
| [e67991f] | 1500 | virtual const ast::Type * visit( const ast::QualifiedType * node ) override final { | 
|---|
| [b0ec971] | 1501 | preprint( node ); | 
|---|
|  | 1502 | ++indent; | 
|---|
| [94b1f718] | 1503 | os << "Qualified Type:" << endl << indent; | 
|---|
| [20a5977] | 1504 | safe_print( node->parent ); | 
|---|
| [94b1f718] | 1505 | os << endl << indent; | 
|---|
| [20a5977] | 1506 | safe_print( node->child ); | 
|---|
| [94b1f718] | 1507 | os << endl; | 
|---|
| [b0ec971] | 1508 | --indent; | 
|---|
|  | 1509 |  | 
|---|
| [461046f] | 1510 | return node; | 
|---|
|  | 1511 | } | 
|---|
|  | 1512 |  | 
|---|
| [e67991f] | 1513 | virtual const ast::Type * visit( const ast::FunctionType * node ) override final { | 
|---|
| [b0ec971] | 1514 | preprint( node ); | 
|---|
| [d908563] | 1515 |  | 
|---|
| [94b1f718] | 1516 | os << "function" << endl; | 
|---|
| [b0ec971] | 1517 | if ( ! node->params.empty() ) { | 
|---|
| [94b1f718] | 1518 | os << indent << "... with parameters" << endl; | 
|---|
| [b0ec971] | 1519 | ++indent; | 
|---|
|  | 1520 | printAll( node->params ); | 
|---|
|  | 1521 | if ( node->isVarArgs ) { | 
|---|
| [94b1f718] | 1522 | os << indent << "and a variable number of other arguments" << endl; | 
|---|
| [b0ec971] | 1523 | } | 
|---|
|  | 1524 | --indent; | 
|---|
|  | 1525 | } else if ( node->isVarArgs ) { | 
|---|
| [94b1f718] | 1526 | os << indent+1 << "accepting unspecified arguments" << endl; | 
|---|
| [b0ec971] | 1527 | } | 
|---|
|  | 1528 |  | 
|---|
|  | 1529 | os << indent << "... returning"; | 
|---|
|  | 1530 | if ( node->returns.empty() ) { | 
|---|
| [94b1f718] | 1531 | os << " nothing" << endl; | 
|---|
| [b0ec971] | 1532 | } else { | 
|---|
| [94b1f718] | 1533 | os << endl; | 
|---|
| [b0ec971] | 1534 | ++indent; | 
|---|
|  | 1535 | printAll( node->returns ); | 
|---|
|  | 1536 | --indent; | 
|---|
|  | 1537 | } | 
|---|
|  | 1538 |  | 
|---|
| [461046f] | 1539 | return node; | 
|---|
|  | 1540 | } | 
|---|
|  | 1541 |  | 
|---|
| [e67991f] | 1542 | virtual const ast::Type * visit( const ast::StructInstType * node ) override final { | 
|---|
| [b0ec971] | 1543 | preprint( node ); | 
|---|
|  | 1544 | os << "instance of struct " << node->name; | 
|---|
|  | 1545 | if ( node->base ) { | 
|---|
|  | 1546 | os << " " << ( node->base->body ? "with" : "without" ) << " body"; | 
|---|
|  | 1547 | } | 
|---|
|  | 1548 | print( node->params ); | 
|---|
|  | 1549 |  | 
|---|
| [461046f] | 1550 | return node; | 
|---|
|  | 1551 | } | 
|---|
|  | 1552 |  | 
|---|
| [e67991f] | 1553 | virtual const ast::Type * visit( const ast::UnionInstType * node ) override final { | 
|---|
| [b0ec971] | 1554 | preprint( node ); | 
|---|
|  | 1555 | os << "instance of union " << node->name; | 
|---|
|  | 1556 | if ( node->base ) { | 
|---|
|  | 1557 | os << " " << ( node->base->body ? "with" : "without" ) << " body"; | 
|---|
|  | 1558 | } | 
|---|
|  | 1559 | print( node->params ); | 
|---|
|  | 1560 |  | 
|---|
| [461046f] | 1561 | return node; | 
|---|
|  | 1562 | } | 
|---|
|  | 1563 |  | 
|---|
| [e67991f] | 1564 | virtual const ast::Type * visit( const ast::EnumInstType * node ) override final { | 
|---|
| [b0ec971] | 1565 | preprint( node ); | 
|---|
|  | 1566 | os << "instance of enum " << node->name; | 
|---|
|  | 1567 | if ( node->base ) { | 
|---|
|  | 1568 | os << " " << ( node->base->body ? "with" : "without" ) << " body"; | 
|---|
|  | 1569 | } | 
|---|
|  | 1570 | print( node->params ); | 
|---|
|  | 1571 |  | 
|---|
| [461046f] | 1572 | return node; | 
|---|
|  | 1573 | } | 
|---|
|  | 1574 |  | 
|---|
| [e67991f] | 1575 | virtual const ast::Type * visit( const ast::TraitInstType * node ) override final { | 
|---|
| [b0ec971] | 1576 | preprint( node ); | 
|---|
|  | 1577 | os << "instance of trait " << node->name; | 
|---|
|  | 1578 | print( node->params ); | 
|---|
|  | 1579 |  | 
|---|
| [461046f] | 1580 | return node; | 
|---|
|  | 1581 | } | 
|---|
|  | 1582 |  | 
|---|
| [e67991f] | 1583 | virtual const ast::Type * visit( const ast::TypeInstType * node ) override final { | 
|---|
| [b0ec971] | 1584 | preprint( node ); | 
|---|
| [3e5dd913] | 1585 | const auto & _name = deterministic_output && isUnboundType(node) ? "[unbound]" : node->typeString(); | 
|---|
| [cd6a6ff] | 1586 | os << "instance of type " << _name | 
|---|
| [07de76b] | 1587 | << " (" << (node->kind == ast::TypeDecl::Ftype ? "" : "not ") << "function type)"; | 
|---|
| [b0ec971] | 1588 | print( node->params ); | 
|---|
|  | 1589 |  | 
|---|
| [461046f] | 1590 | return node; | 
|---|
|  | 1591 | } | 
|---|
|  | 1592 |  | 
|---|
| [e67991f] | 1593 | virtual const ast::Type * visit( const ast::TupleType * node ) override final { | 
|---|
| [b0ec971] | 1594 | preprint( node ); | 
|---|
| [94b1f718] | 1595 | os << "tuple of types" << endl; | 
|---|
| [b0ec971] | 1596 | ++indent; | 
|---|
|  | 1597 | printAll( node->types ); | 
|---|
|  | 1598 | --indent; | 
|---|
|  | 1599 |  | 
|---|
| [461046f] | 1600 | return node; | 
|---|
|  | 1601 | } | 
|---|
|  | 1602 |  | 
|---|
| [e67991f] | 1603 | virtual const ast::Type * visit( const ast::TypeofType * node ) override final { | 
|---|
| [b0ec971] | 1604 | preprint( node ); | 
|---|
|  | 1605 | if ( node->kind == ast::TypeofType::Basetypeof ) { os << "base-"; } | 
|---|
|  | 1606 | os << "type-of expression "; | 
|---|
| [20a5977] | 1607 | safe_print( node->expr ); | 
|---|
| [b0ec971] | 1608 |  | 
|---|
| [461046f] | 1609 | return node; | 
|---|
|  | 1610 | } | 
|---|
|  | 1611 |  | 
|---|
| [3945abe] | 1612 | virtual const ast::Type * visit( const ast::VTableType * node ) override final { | 
|---|
|  | 1613 | preprint( node ); | 
|---|
|  | 1614 | os << "vtable for "; | 
|---|
|  | 1615 | safe_print( node->base ); | 
|---|
|  | 1616 |  | 
|---|
|  | 1617 | return node; | 
|---|
|  | 1618 | } | 
|---|
|  | 1619 |  | 
|---|
| [e67991f] | 1620 | virtual const ast::Type * visit( const ast::VarArgsType * node ) override final { | 
|---|
| [b0ec971] | 1621 | preprint( node ); | 
|---|
|  | 1622 | os << "builtin var args pack"; | 
|---|
| [461046f] | 1623 | return node; | 
|---|
|  | 1624 | } | 
|---|
|  | 1625 |  | 
|---|
| [e67991f] | 1626 | virtual const ast::Type * visit( const ast::ZeroType * node ) override final { | 
|---|
| [b0ec971] | 1627 | preprint( node ); | 
|---|
|  | 1628 | os << "zero_t"; | 
|---|
| [461046f] | 1629 | return node; | 
|---|
|  | 1630 | } | 
|---|
|  | 1631 |  | 
|---|
| [e67991f] | 1632 | virtual const ast::Type * visit( const ast::OneType * node ) override final { | 
|---|
| [b0ec971] | 1633 | preprint( node ); | 
|---|
|  | 1634 | os << "one_t"; | 
|---|
| [461046f] | 1635 | return node; | 
|---|
|  | 1636 | } | 
|---|
|  | 1637 |  | 
|---|
| [e67991f] | 1638 | virtual const ast::Type * visit( const ast::GlobalScopeType * node ) override final { | 
|---|
| [b0ec971] | 1639 | preprint( node ); | 
|---|
|  | 1640 | os << "Global Scope Type"; | 
|---|
| [461046f] | 1641 | return node; | 
|---|
|  | 1642 | } | 
|---|
|  | 1643 |  | 
|---|
| [e67991f] | 1644 | virtual const ast::Designation * visit( const ast::Designation * node ) override final { | 
|---|
| [c957e7f] | 1645 | if ( node->designators.empty() ) return node; | 
|---|
| [94b1f718] | 1646 | os << "... designated by: " << endl; | 
|---|
| [c957e7f] | 1647 | ++indent; | 
|---|
|  | 1648 | for ( const ast::Expr * d : node->designators ) { | 
|---|
|  | 1649 | os << indent; | 
|---|
|  | 1650 | d->accept( *this ); | 
|---|
| [94b1f718] | 1651 | os << endl; | 
|---|
| [c957e7f] | 1652 | } | 
|---|
|  | 1653 | --indent; | 
|---|
| [461046f] | 1654 | return node; | 
|---|
|  | 1655 | } | 
|---|
|  | 1656 |  | 
|---|
| [e67991f] | 1657 | virtual const ast::Init * visit( const ast::SingleInit * node ) override final { | 
|---|
| [c957e7f] | 1658 | os << "Simple Initializer: "; | 
|---|
| [20a5977] | 1659 | safe_print( node->value ); | 
|---|
| [461046f] | 1660 | return node; | 
|---|
|  | 1661 | } | 
|---|
|  | 1662 |  | 
|---|
| [e67991f] | 1663 | virtual const ast::Init * visit( const ast::ListInit * node ) override final { | 
|---|
| [94b1f718] | 1664 | os << "Compound initializer: " << endl; | 
|---|
| [c957e7f] | 1665 | ++indent; | 
|---|
|  | 1666 | for ( auto p : group_iterate( node->designations, node->initializers ) ) { | 
|---|
|  | 1667 | const ast::Designation * d = std::get<0>(p); | 
|---|
|  | 1668 | const ast::Init * init = std::get<1>(p); | 
|---|
|  | 1669 | os << indent; | 
|---|
|  | 1670 | init->accept( *this ); | 
|---|
| [94b1f718] | 1671 | os << endl; | 
|---|
| [c957e7f] | 1672 | if ( ! d->designators.empty() ) { | 
|---|
|  | 1673 | os << indent; | 
|---|
|  | 1674 | d->accept( *this ); | 
|---|
|  | 1675 | } | 
|---|
|  | 1676 | } | 
|---|
|  | 1677 | --indent; | 
|---|
| [461046f] | 1678 | return node; | 
|---|
|  | 1679 | } | 
|---|
|  | 1680 |  | 
|---|
| [e67991f] | 1681 | virtual const ast::Init * visit( const ast::ConstructorInit * node ) override final { | 
|---|
| [94b1f718] | 1682 | os << "Constructor initializer: " << endl; | 
|---|
| [c957e7f] | 1683 | if ( node->ctor ) { | 
|---|
|  | 1684 | os << indent << "... initially constructed with "; | 
|---|
|  | 1685 | ++indent; | 
|---|
|  | 1686 | node->ctor->accept( *this ); | 
|---|
|  | 1687 | --indent; | 
|---|
|  | 1688 | } | 
|---|
|  | 1689 |  | 
|---|
|  | 1690 | if ( node->dtor ) { | 
|---|
|  | 1691 | os << indent << "... destructed with "; | 
|---|
|  | 1692 | ++indent; | 
|---|
|  | 1693 | node->dtor->accept( *this ); | 
|---|
|  | 1694 | --indent; | 
|---|
|  | 1695 | } | 
|---|
|  | 1696 |  | 
|---|
|  | 1697 | if ( node->init ) { | 
|---|
|  | 1698 | os << indent << "... with fallback C-style initializer: "; | 
|---|
|  | 1699 | ++indent; | 
|---|
|  | 1700 | node->init->accept( *this ); | 
|---|
|  | 1701 | --indent; | 
|---|
|  | 1702 | } | 
|---|
| [461046f] | 1703 | return node; | 
|---|
|  | 1704 | } | 
|---|
|  | 1705 |  | 
|---|
| [e67991f] | 1706 | virtual const ast::Attribute * visit( const ast::Attribute * node ) override final { | 
|---|
| [489bacf] | 1707 | if ( node->empty() ) return node; | 
|---|
|  | 1708 | os << "Attribute with name: " << node->name; | 
|---|
|  | 1709 | if ( node->params.empty() ) return node; | 
|---|
| [94b1f718] | 1710 | os << " with parameters: " << endl; | 
|---|
| [489bacf] | 1711 | ++indent; | 
|---|
|  | 1712 | printAll( node->params ); | 
|---|
|  | 1713 | --indent; | 
|---|
| [461046f] | 1714 | return node; | 
|---|
|  | 1715 | } | 
|---|
|  | 1716 |  | 
|---|
| [e67991f] | 1717 | virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) override final { | 
|---|
| [94b1f718] | 1718 | os << indent << "Types:" << endl; | 
|---|
| [76ed81f] | 1719 | for ( const auto& i : *node ) { | 
|---|
| [3e5dd913] | 1720 | os << indent+1 << i.first.typeString() << " -> "; | 
|---|
| [76ed81f] | 1721 | indent += 2; | 
|---|
| [20a5977] | 1722 | safe_print( i.second ); | 
|---|
| [76ed81f] | 1723 | indent -= 2; | 
|---|
| [94b1f718] | 1724 | os << endl; | 
|---|
| [76ed81f] | 1725 | } | 
|---|
| [461046f] | 1726 | return node; | 
|---|
|  | 1727 | } | 
|---|
|  | 1728 |  | 
|---|
|  | 1729 | }; | 
|---|
|  | 1730 |  | 
|---|
| [257a8f5] | 1731 | } // namespace | 
|---|
|  | 1732 |  | 
|---|
| [5902625] | 1733 | void print( ostream & os, const ast::Node * node, Indenter indent ) { | 
|---|
|  | 1734 | Printer printer { os, indent, false }; | 
|---|
|  | 1735 | node->accept(printer); | 
|---|
|  | 1736 | } | 
|---|
|  | 1737 |  | 
|---|
| [6f4b7f2] | 1738 | void printShort( ostream & os, const ast::Decl * node, Indenter indent ) { | 
|---|
| [5902625] | 1739 | Printer printer { os, indent, true }; | 
|---|
| [461046f] | 1740 | node->accept(printer); | 
|---|
|  | 1741 | } | 
|---|
|  | 1742 |  | 
|---|
| [257a8f5] | 1743 | void print( ostream & os, Function::Specs specs ) { | 
|---|
|  | 1744 | print( os, specs, Names::FuncSpecifiers ); | 
|---|
|  | 1745 | } | 
|---|
|  | 1746 |  | 
|---|
|  | 1747 | void print( ostream & os, Storage::Classes storage ) { | 
|---|
|  | 1748 | print( os, storage, Names::StorageClasses ); | 
|---|
| [461046f] | 1749 | } | 
|---|
| [257a8f5] | 1750 |  | 
|---|
|  | 1751 | void print( ostream & os, CV::Qualifiers qualifiers ) { | 
|---|
|  | 1752 | print( os, qualifiers, Names::Qualifiers ); | 
|---|
|  | 1753 | } | 
|---|
|  | 1754 |  | 
|---|
|  | 1755 | } // namespace ast | 
|---|