Changes in src/AST/Print.cpp [c957e7f:5902625]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Print.cpp
rc957e7f r5902625 22 22 #include "TypeSubstitution.hpp" 23 23 24 #include "Common/utility.h" // for group_iterate 24 using namespace std; 25 25 26 26 namespace ast { … … 28 28 template <typename C, typename... T> 29 29 constexpr auto make_array(T&&... values) -> 30 std::array<C,sizeof...(T)>30 array<C,sizeof...(T)> 31 31 { 32 return std::array<C,sizeof...(T)>{33 std::forward<T>(values)...32 return array<C,sizeof...(T)>{ 33 forward<T>(values)... 34 34 }; 35 35 } … … 37 37 class Printer : public Visitor { 38 38 public: 39 std::ostream & os;39 ostream & os; 40 40 Indenter indent; 41 42 Printer(std::ostream & os, Indenter indent) : os( os ), indent( indent ) {} 41 bool short_mode; 42 43 Printer(ostream & os, Indenter indent, bool short_mode) : os( os ), indent( indent ), short_mode(short_mode) {} 43 44 44 45 private: … … 51 52 // need an endl after each element because it's not 52 53 // easy to know when each individual item should end 53 os << std::endl;54 os << endl; 54 55 } // if 55 56 } // for … … 74 75 75 76 template<typename storage_t, size_t N> 76 void print(const storage_t & storage, const std::array<const char *, N> & Names ) {77 void print(const storage_t & storage, const array<const char *, N> & Names ) { 77 78 if ( storage.any() ) { 78 79 for ( size_t i = 0; i < Names.size(); i += 1 ) { … … 96 97 } 97 98 99 void print( const ast::AggregateDecl * node ) { 100 os << node->typeString() << " " << node->name << ":"; 101 if ( node->linkage != Linkage::Cforall ) { 102 os << " " << Linkage::name( node->linkage ); 103 } // if 104 os << " with body : " << (node->body ? "yes " : "no "); 105 106 if ( ! node->params.empty() ) { 107 os << endl << indent << "... with parameters" << endl; 108 ++indent; 109 printAll( node->params ); 110 --indent; 111 } // if 112 if ( ! node->members.empty() ) { 113 os << endl << indent << "... with members" << endl; 114 ++indent; 115 printAll( node->members ); 116 --indent; 117 } // if 118 if ( ! node->attributes.empty() ) { 119 os << endl << indent << "... with attributes" << endl; 120 ++indent; 121 printAll( node->attributes ); 122 --indent; 123 } // if 124 os << endl; 125 } 126 127 void print( const ast::NamedTypeDecl * node ) { 128 if ( !node->name.empty() ) os << node->name << ": "; 129 130 if ( node->linkage != Linkage::Cforall ) { 131 os << Linkage::name( node->linkage ) << " "; 132 } // if 133 print( node->storage ); 134 os << node->typeString(); 135 if ( node->base ) { 136 os << " for "; 137 ++indent; 138 node->base->accept( *this ); 139 --indent; 140 } // if 141 if ( ! node->params.empty() ) { 142 os << endl << indent << "... with parameters" << endl; 143 ++indent; 144 printAll( node->params ); 145 --indent; 146 } // if 147 if ( ! node->assertions.empty() ) { 148 os << endl << indent << "... with assertions" << endl; 149 ++indent; 150 printAll( node->assertions ); 151 --indent; 152 } // if 153 } 154 98 155 public: 99 virtual const ast::DeclWithType * visit( const ast::ObjectDecl* node ) {100 if ( node->name != "") os << node->name << ": ";156 virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) { 157 if ( !node->name.empty() ) os << node->name << ": "; 101 158 102 159 if ( node->linkage != Linkage::Cforall ) { … … 117 174 ? "maybe constructed" 118 175 : "not constructed" 119 ) << ")" << std::endl << indent+1;176 ) << ")" << endl << indent+1; 120 177 121 178 ++indent; 122 179 node->init->accept( *this ); 123 180 --indent; 124 os << std::endl;181 os << endl; 125 182 } // if 126 183 127 184 if ( ! node->attributes.empty() ) { 128 os << std::endl << indent << "... with attributes:" << std::endl;185 os << endl << indent << "... with attributes:" << endl; 129 186 ++indent; 130 187 printAll( node->attributes ); … … 139 196 } 140 197 141 virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) { 142 return node; 143 } 144 145 virtual const ast::Decl * visit( const ast::StructDecl * node ) { 146 return node; 147 } 148 149 virtual const ast::Decl * visit( const ast::UnionDecl * node ) { 150 return node; 151 } 152 153 virtual const ast::Decl * visit( const ast::EnumDecl * node ) { 154 return node; 155 } 156 157 virtual const ast::Decl * visit( const ast::TraitDecl * node ) { 158 return node; 159 } 160 161 virtual const ast::Decl * visit( const ast::TypeDecl * node ) { 162 return node; 163 } 164 165 virtual const ast::Decl * visit( const ast::TypedefDecl * node ) { 166 return node; 167 } 168 169 virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) { 170 return node; 171 } 172 173 virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) { 174 return node; 175 } 176 177 virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) { 178 return node; 179 } 180 181 virtual const ast::Stmt * visit( const ast::ExprStmt * node ) { 182 return node; 183 } 184 185 virtual const ast::Stmt * visit( const ast::AsmStmt * node ) { 186 return node; 187 } 188 189 virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) { 190 return node; 191 } 192 193 virtual const ast::Stmt * visit( const ast::IfStmt * node ) { 194 return node; 195 } 196 197 virtual const ast::Stmt * visit( const ast::WhileStmt * node ) { 198 return node; 199 } 200 201 virtual const ast::Stmt * visit( const ast::ForStmt * node ) { 202 return node; 203 } 204 205 virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) { 206 return node; 207 } 208 209 virtual const ast::Stmt * visit( const ast::CaseStmt * node ) { 210 return node; 211 } 212 213 virtual const ast::Stmt * visit( const ast::BranchStmt * node ) { 214 return node; 215 } 216 217 virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) { 218 return node; 219 } 220 221 virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) { 222 return node; 223 } 224 225 virtual const ast::Stmt * visit( const ast::TryStmt * node ) { 226 return node; 227 } 228 229 virtual const ast::Stmt * visit( const ast::CatchStmt * node ) { 230 return node; 231 } 232 233 virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) { 234 return node; 235 } 236 237 virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) { 238 return node; 239 } 240 241 virtual const ast::Stmt * visit( const ast::WithStmt * node ) { 242 return node; 243 } 244 245 virtual const ast::NullStmt * visit( const ast::NullStmt * node ) { 246 return node; 247 } 248 249 virtual const ast::Stmt * visit( const ast::DeclStmt * node ) { 250 return node; 251 } 252 253 virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) { 254 return node; 255 } 256 257 virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) { 258 return node; 259 } 260 261 virtual const ast::Expr * visit( const ast::UntypedExpr * node ) { 262 return node; 263 } 264 265 virtual const ast::Expr * visit( const ast::NameExpr * node ) { 266 return node; 267 } 268 269 virtual const ast::Expr * visit( const ast::AddressExpr * node ) { 270 return node; 271 } 272 273 virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) { 274 return node; 275 } 276 277 virtual const ast::Expr * visit( const ast::CastExpr * node ) { 278 return node; 279 } 280 281 virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) { 282 return node; 283 } 284 285 virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) { 286 return node; 287 } 288 289 virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) { 290 return node; 291 } 292 293 virtual const ast::Expr * visit( const ast::MemberExpr * node ) { 294 return node; 295 } 296 297 virtual const ast::Expr * visit( const ast::VariableExpr * node ) { 298 return node; 299 } 300 301 virtual const ast::Expr * visit( const ast::ConstantExpr * node ) { 302 return node; 303 } 304 305 virtual const ast::Expr * visit( const ast::SizeofExpr * node ) { 306 return node; 307 } 308 309 virtual const ast::Expr * visit( const ast::AlignofExpr * node ) { 310 return node; 311 } 312 313 virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) { 314 return node; 315 } 316 317 virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) { 318 return node; 319 } 320 321 virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) { 322 return node; 323 } 324 325 virtual const ast::Expr * visit( const ast::LogicalExpr * node ) { 326 return node; 327 } 328 329 virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) { 330 return node; 331 } 332 333 virtual const ast::Expr * visit( const ast::CommaExpr * node ) { 334 return node; 335 } 336 337 virtual const ast::Expr * visit( const ast::TypeExpr * node ) { 338 return node; 339 } 340 341 virtual const ast::Expr * visit( const ast::AsmExpr * node ) { 342 return node; 343 } 344 345 virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) { 346 return node; 347 } 348 349 virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) { 350 return node; 351 } 352 353 virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) { 354 return node; 355 } 356 357 virtual const ast::Expr * visit( const ast::RangeExpr * node ) { 358 return node; 359 } 360 361 virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) { 362 return node; 363 } 364 365 virtual const ast::Expr * visit( const ast::TupleExpr * node ) { 366 return node; 367 } 368 369 virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) { 370 return node; 371 } 372 373 virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) { 374 return node; 375 } 376 377 virtual const ast::Expr * visit( const ast::StmtExpr * node ) { 378 return node; 379 } 380 381 virtual const ast::Expr * visit( const ast::UniqueExpr * node ) { 382 return node; 383 } 384 385 virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) { 386 return node; 387 } 388 389 virtual const ast::Expr * visit( const ast::InitExpr * node ) { 390 return node; 391 } 392 393 virtual const ast::Expr * visit( const ast::DeletedExpr * node ) { 394 return node; 395 } 396 397 virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) { 398 return node; 399 } 400 401 virtual const ast::Expr * visit( const ast::GenericExpr * node ) { 402 return node; 403 } 404 405 virtual const ast::Type * visit( const ast::VoidType * node ) { 406 return node; 407 } 408 409 virtual const ast::Type * visit( const ast::BasicType * node ) { 410 return node; 411 } 412 413 virtual const ast::Type * visit( const ast::PointerType * node ) { 414 return node; 415 } 416 417 virtual const ast::Type * visit( const ast::ArrayType * node ) { 418 return node; 419 } 420 421 virtual const ast::Type * visit( const ast::ReferenceType * node ) { 422 return node; 423 } 424 425 virtual const ast::Type * visit( const ast::QualifiedType * node ) { 426 return node; 427 } 428 429 virtual const ast::Type * visit( const ast::FunctionType * node ) { 430 return node; 431 } 432 433 virtual const ast::Type * visit( const ast::StructInstType * node ) { 434 return node; 435 } 436 437 virtual const ast::Type * visit( const ast::UnionInstType * node ) { 438 return node; 439 } 440 441 virtual const ast::Type * visit( const ast::EnumInstType * node ) { 442 return node; 443 } 444 445 virtual const ast::Type * visit( const ast::TraitInstType * node ) { 446 return node; 447 } 448 449 virtual const ast::Type * visit( const ast::TypeInstType * node ) { 450 return node; 451 } 452 453 virtual const ast::Type * visit( const ast::TupleType * node ) { 454 return node; 455 } 456 457 virtual const ast::Type * visit( const ast::TypeofType * node ) { 458 return node; 459 } 460 461 virtual const ast::Type * visit( const ast::VarArgsType * node ) { 462 return node; 463 } 464 465 virtual const ast::Type * visit( const ast::ZeroType * node ) { 466 return node; 467 } 468 469 virtual const ast::Type * visit( const ast::OneType * node ) { 470 return node; 471 } 472 473 virtual const ast::Type * visit( const ast::GlobalScopeType * node ) { 474 return node; 475 } 476 477 virtual const ast::Designation * visit( const ast::Designation * node ) { 478 if ( node->designators.empty() ) return node; 479 os << "... designated by: " << std::endl; 198 virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) { 199 if ( !node->name.empty() ) { 200 os << node->name << ": "; 201 } // if 202 if ( node->linkage != Linkage::Cforall ) { 203 os << Linkage::name( node->linkage ) << " "; 204 } // if 205 206 printAll( node->attributes ); 207 208 print( node->storage ); 209 print( node->funcSpec ); 210 211 if ( node->type ) { 212 node->type->accept( *this ); 213 } else { 214 os << "untyped entity "; 215 } // if 216 217 if ( node->stmts ) { 218 os << indent << "... with body" << endl << indent+1; 219 ++indent; 220 node->stmts->accept( *this ); 221 --indent; 222 } // if 223 return node; 224 } 225 226 virtual const ast::Decl * visit( const ast::StructDecl * node ) { 227 print(node); 228 return node; 229 } 230 231 virtual const ast::Decl * visit( const ast::UnionDecl * node ) { 232 print(node); 233 return node; 234 } 235 236 virtual const ast::Decl * visit( const ast::EnumDecl * node ) { 237 print(node); 238 return node; 239 } 240 241 virtual const ast::Decl * visit( const ast::TraitDecl * node ) { 242 print(node); 243 return node; 244 } 245 246 virtual const ast::Decl * visit( const ast::TypeDecl * node ) { 247 print( node ); 248 if ( node->init ) { 249 os << endl << indent << "with type initializer: "; 250 ++indent; 251 node->init->accept( *this ); 252 --indent; 253 } 254 return node; 255 } 256 257 virtual const ast::Decl * visit( const ast::TypedefDecl * node ) { 258 print( node ); 259 return node; 260 } 261 262 virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) { 263 node->stmt->accept( *this ); 264 return node; 265 } 266 267 virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) { 268 os << "Static Assert with condition: "; 480 269 ++indent; 481 for ( const ast::Expr * d : node->designators ) { 270 node->cond->accept( *this ); 271 --indent; 272 os << endl << indent << "and message: "; 273 ++indent; 274 node->msg->accept( *this ); 275 --indent; 276 os << endl; 277 return node; 278 } 279 280 virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) { 281 os << "CompoundStmt" << endl; 282 ++indent; 283 printAll( node->kids ); 284 --indent; 285 return node; 286 } 287 288 virtual const ast::Stmt * visit( const ast::ExprStmt * node ) { 289 ++indent; 290 os << "Expression Statement:" << endl << indent; 291 node->expr->accept( *this ); 292 --indent; 293 return node; 294 } 295 296 virtual const ast::Stmt * visit( const ast::AsmStmt * node ) { 297 os << "Assembler Statement:" << endl; 298 ++indent; 299 os << indent << "instruction: " << endl << indent; 300 node->instruction->accept( *this ); 301 if ( ! node->output.empty() ) { 302 os << endl << indent+1 << "output: " << endl; 303 printAll( node->output ); 304 } // if 305 if ( ! node->input.empty() ) { 306 os << indent+1 << "input: " << endl; 307 printAll( node->input ); 308 } // if 309 if ( ! node->clobber.empty() ) { 310 os << indent+1 << "clobber: " << endl; 311 printAll( node->clobber ); 312 } // if 313 --indent; 314 return node; 315 } 316 317 virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) { 318 os << "GCC Directive:" << node->directive << endl; 319 return node; 320 } 321 322 virtual const ast::Stmt * visit( const ast::IfStmt * node ) { 323 os << "If on condition: " << endl; 324 os << indent+1; 325 ++indent; 326 node->cond->accept( *this ); 327 --indent; 328 329 if ( !node->inits.empty() ) { 330 os << indent << "... with initialization: \n"; 331 ++indent; 332 for ( const Stmt * stmt : node->inits ) { 333 os << indent; 334 stmt->accept( *this ); 335 } 336 --indent; 337 os << endl; 338 } 339 340 os << indent << "... then: " << endl; 341 342 ++indent; 343 os << indent; 344 node->thenPart->accept( *this ); 345 --indent; 346 347 if ( node->elsePart != 0 ) { 348 os << indent << "... else: " << endl; 349 ++indent; 482 350 os << indent; 483 d->accept( *this ); 484 os << std::endl; 485 } 486 --indent; 487 return node; 488 } 489 490 virtual const ast::Init * visit( const ast::SingleInit * node ) { 491 os << "Simple Initializer: "; 492 node->value->accept( *this ); 493 return node; 494 } 495 496 virtual const ast::Init * visit( const ast::ListInit * node ) { 497 os << "Compound initializer: " << std::endl; 498 ++indent; 499 for ( auto p : group_iterate( node->designations, node->initializers ) ) { 500 const ast::Designation * d = std::get<0>(p); 501 const ast::Init * init = std::get<1>(p); 502 os << indent; 503 init->accept( *this ); 504 os << std::endl; 505 if ( ! d->designators.empty() ) { 506 os << indent; 507 d->accept( *this ); 508 } 509 } 510 --indent; 511 return node; 512 } 513 514 virtual const ast::Init * visit( const ast::ConstructorInit * node ) { 515 os << "Constructor initializer: " << std::endl; 516 if ( node->ctor ) { 517 os << indent << "... initially constructed with "; 518 ++indent; 519 node->ctor->accept( *this ); 520 --indent; 521 } 522 523 if ( node->dtor ) { 524 os << indent << "... destructed with "; 525 ++indent; 526 node->dtor->accept( *this ); 527 --indent; 528 } 529 530 if ( node->init ) { 531 os << indent << "... with fallback C-style initializer: "; 532 ++indent; 533 node->init->accept( *this ); 534 --indent; 535 } 536 return node; 537 } 538 539 virtual const ast::Attribute * visit( const ast::Attribute * node ) { 540 if ( node->empty() ) return node; 541 os << "Attribute with name: " << node->name; 542 if ( node->params.empty() ) return node; 543 os << " with parameters: " << std::endl; 544 ++indent; 545 printAll( node->params ); 546 --indent; 547 return node; 548 } 549 550 virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) { 551 os << indent << "Types:" << std::endl; 552 for ( const auto& i : *node ) { 553 os << indent+1 << i.first << " -> "; 554 indent += 2; 555 i.second->accept( *this ); 556 indent -= 2; 557 os << std::endl; 558 } 559 os << indent << "Non-types:" << std::endl; 560 for ( auto i = node->beginVar(); i != node->endVar(); ++i ) { 561 os << indent+1 << i->first << " -> "; 562 indent += 2; 563 i->second->accept( *this ); 564 indent -= 2; 565 os << std::endl; 566 } 351 node->elsePart->accept( *this ); 352 --indent; 353 } // if 354 return node; 355 } 356 357 virtual const ast::Stmt * visit( const ast::WhileStmt * node ) { 358 return node; 359 } 360 361 virtual const ast::Stmt * visit( const ast::ForStmt * node ) { 362 return node; 363 } 364 365 virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) { 366 return node; 367 } 368 369 virtual const ast::Stmt * visit( const ast::CaseStmt * node ) { 370 return node; 371 } 372 373 virtual const ast::Stmt * visit( const ast::BranchStmt * node ) { 374 return node; 375 } 376 377 virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) { 378 return node; 379 } 380 381 virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) { 382 return node; 383 } 384 385 virtual const ast::Stmt * visit( const ast::TryStmt * node ) { 386 return node; 387 } 388 389 virtual const ast::Stmt * visit( const ast::CatchStmt * node ) { 390 return node; 391 } 392 393 virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) { 394 return node; 395 } 396 397 virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) { 398 return node; 399 } 400 401 virtual const ast::Stmt * visit( const ast::WithStmt * node ) { 402 return node; 403 } 404 405 virtual const ast::NullStmt * visit( const ast::NullStmt * node ) { 406 return node; 407 } 408 409 virtual const ast::Stmt * visit( const ast::DeclStmt * node ) { 410 return node; 411 } 412 413 virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) { 414 return node; 415 } 416 417 virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) { 418 return node; 419 } 420 421 virtual const ast::Expr * visit( const ast::UntypedExpr * node ) { 422 return node; 423 } 424 425 virtual const ast::Expr * visit( const ast::NameExpr * node ) { 426 return node; 427 } 428 429 virtual const ast::Expr * visit( const ast::AddressExpr * node ) { 430 return node; 431 } 432 433 virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) { 434 return node; 435 } 436 437 virtual const ast::Expr * visit( const ast::CastExpr * node ) { 438 return node; 439 } 440 441 virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) { 442 return node; 443 } 444 445 virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) { 446 return node; 447 } 448 449 virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) { 450 return node; 451 } 452 453 virtual const ast::Expr * visit( const ast::MemberExpr * node ) { 454 return node; 455 } 456 457 virtual const ast::Expr * visit( const ast::VariableExpr * node ) { 458 return node; 459 } 460 461 virtual const ast::Expr * visit( const ast::ConstantExpr * node ) { 462 return node; 463 } 464 465 virtual const ast::Expr * visit( const ast::SizeofExpr * node ) { 466 return node; 467 } 468 469 virtual const ast::Expr * visit( const ast::AlignofExpr * node ) { 470 return node; 471 } 472 473 virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) { 474 return node; 475 } 476 477 virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) { 478 return node; 479 } 480 481 virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) { 482 return node; 483 } 484 485 virtual const ast::Expr * visit( const ast::LogicalExpr * node ) { 486 return node; 487 } 488 489 virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) { 490 return node; 491 } 492 493 virtual const ast::Expr * visit( const ast::CommaExpr * node ) { 494 return node; 495 } 496 497 virtual const ast::Expr * visit( const ast::TypeExpr * node ) { 498 return node; 499 } 500 501 virtual const ast::Expr * visit( const ast::AsmExpr * node ) { 502 return node; 503 } 504 505 virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) { 506 return node; 507 } 508 509 virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) { 510 return node; 511 } 512 513 virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) { 514 return node; 515 } 516 517 virtual const ast::Expr * visit( const ast::RangeExpr * node ) { 518 return node; 519 } 520 521 virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) { 522 return node; 523 } 524 525 virtual const ast::Expr * visit( const ast::TupleExpr * node ) { 526 return node; 527 } 528 529 virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) { 530 return node; 531 } 532 533 virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) { 534 return node; 535 } 536 537 virtual const ast::Expr * visit( const ast::StmtExpr * node ) { 538 return node; 539 } 540 541 virtual const ast::Expr * visit( const ast::UniqueExpr * node ) { 542 return node; 543 } 544 545 virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) { 546 return node; 547 } 548 549 virtual const ast::Expr * visit( const ast::InitExpr * node ) { 550 return node; 551 } 552 553 virtual const ast::Expr * visit( const ast::DeletedExpr * node ) { 554 return node; 555 } 556 557 virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) { 558 return node; 559 } 560 561 virtual const ast::Expr * visit( const ast::GenericExpr * node ) { 562 return node; 563 } 564 565 virtual const ast::Type * visit( const ast::VoidType * node ) { 566 return node; 567 } 568 569 virtual const ast::Type * visit( const ast::BasicType * node ) { 570 return node; 571 } 572 573 virtual const ast::Type * visit( const ast::PointerType * node ) { 574 return node; 575 } 576 577 virtual const ast::Type * visit( const ast::ArrayType * node ) { 578 return node; 579 } 580 581 virtual const ast::Type * visit( const ast::ReferenceType * node ) { 582 return node; 583 } 584 585 virtual const ast::Type * visit( const ast::QualifiedType * node ) { 586 return node; 587 } 588 589 virtual const ast::Type * visit( const ast::FunctionType * node ) { 590 return node; 591 } 592 593 virtual const ast::Type * visit( const ast::StructInstType * node ) { 594 return node; 595 } 596 597 virtual const ast::Type * visit( const ast::UnionInstType * node ) { 598 return node; 599 } 600 601 virtual const ast::Type * visit( const ast::EnumInstType * node ) { 602 return node; 603 } 604 605 virtual const ast::Type * visit( const ast::TraitInstType * node ) { 606 return node; 607 } 608 609 virtual const ast::Type * visit( const ast::TypeInstType * node ) { 610 return node; 611 } 612 613 virtual const ast::Type * visit( const ast::TupleType * node ) { 614 return node; 615 } 616 617 virtual const ast::Type * visit( const ast::TypeofType * node ) { 618 return node; 619 } 620 621 virtual const ast::Type * visit( const ast::VarArgsType * node ) { 622 return node; 623 } 624 625 virtual const ast::Type * visit( const ast::ZeroType * node ) { 626 return node; 627 } 628 629 virtual const ast::Type * visit( const ast::OneType * node ) { 630 return node; 631 } 632 633 virtual const ast::Type * visit( const ast::GlobalScopeType * node ) { 634 return node; 635 } 636 637 virtual const ast::Designation * visit( const ast::Designation * node ) { 638 return node; 639 } 640 641 virtual const ast::Init * visit( const ast::SingleInit * node ) { 642 return node; 643 } 644 645 virtual const ast::Init * visit( const ast::ListInit * node ) { 646 return node; 647 } 648 649 virtual const ast::Init * visit( const ast::ConstructorInit * node ) { 650 return node; 651 } 652 653 virtual const ast::Attribute * visit( const ast::Attribute * node ) { 654 return node; 655 } 656 657 virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) { 567 658 return node; 568 659 } … … 570 661 }; 571 662 572 void print( std::ostream & os, const ast::Node * node, Indenter indent ) { 573 Printer printer { os, indent }; 663 void print( ostream & os, const ast::Node * node, Indenter indent ) { 664 Printer printer { os, indent, false }; 665 node->accept(printer); 666 } 667 668 void printShort( ostream & os, const ast::Node * node, Indenter indent ) { 669 Printer printer { os, indent, true }; 574 670 node->accept(printer); 575 671 } … … 578 674 // The size here needs to be explicit but at least the compiler will produce an error 579 675 // if the wrong size is specified 580 constexpr std::array<const char*, 3> Printer::Names::FuncSpecifiers;581 constexpr std::array<const char*, 5> Printer::Names::StorageClasses;582 constexpr std::array<const char*, 6> Printer::Names::Qualifiers;676 constexpr array<const char*, 3> Printer::Names::FuncSpecifiers; 677 constexpr array<const char*, 5> Printer::Names::StorageClasses; 678 constexpr array<const char*, 6> Printer::Names::Qualifiers; 583 679 }
Note: See TracChangeset
for help on using the changeset viewer.