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