Changeset dcbb03b for src/SynTree/Visitor.cc
- Timestamp:
- Mar 1, 2018, 9:29:03 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 1f37ed02
- Parents:
- b002261 (diff), 446ffa3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Visitor.cc
rb002261 rdcbb03b 31 31 32 32 Visitor::~Visitor() {} 33 34 void Visitor::visit( ObjectDecl *objectDecl ) {35 maybeAccept( objectDecl->get_type(), *this );36 maybeAccept( objectDecl->get_init(), *this );37 maybeAccept( objectDecl->get_bitfieldWidth(), *this );38 acceptAll( objectDecl->attributes, *this );39 }40 41 void Visitor::visit( FunctionDecl *functionDecl ) {42 maybeAccept( functionDecl->get_functionType(), *this );43 maybeAccept( functionDecl->get_statements(), *this );44 acceptAll( functionDecl->attributes, *this );45 }46 47 void Visitor::handleAggregateDecl( AggregateDecl *aggregateDecl ) {48 acceptAll( aggregateDecl->get_parameters(), *this );49 acceptAll( aggregateDecl->get_members(), *this );50 }51 52 void Visitor::visit( StructDecl *aggregateDecl ) {53 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );54 }55 56 void Visitor::visit( UnionDecl *aggregateDecl ) {57 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );58 }59 60 void Visitor::visit( EnumDecl *aggregateDecl ) {61 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );62 }63 64 void Visitor::visit( TraitDecl *aggregateDecl ) {65 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );66 }67 68 void Visitor::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {69 acceptAll( typeDecl->get_parameters(), *this );70 acceptAll( typeDecl->get_assertions(), *this );71 maybeAccept( typeDecl->get_base(), *this );72 }73 74 void Visitor::visit( TypeDecl *typeDecl ) {75 handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) );76 maybeAccept( typeDecl->get_init(), *this );77 }78 79 void Visitor::visit( TypedefDecl *typeDecl ) {80 handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) );81 }82 83 void Visitor::visit( AsmDecl *asmDecl ) {84 maybeAccept( asmDecl->get_stmt(), *this );85 }86 87 88 void Visitor::visit( CompoundStmt *compoundStmt ) {89 acceptAll( compoundStmt->get_kids(), *this );90 }91 92 void Visitor::visit( ExprStmt *exprStmt ) {93 maybeAccept( exprStmt->get_expr(), *this );94 }95 96 void Visitor::visit( AsmStmt *asmStmt ) {97 maybeAccept( asmStmt->get_instruction(), *this );98 acceptAll( asmStmt->get_output(), *this );99 acceptAll( asmStmt->get_input(), *this );100 acceptAll( asmStmt->get_clobber(), *this );101 }102 103 void Visitor::visit( IfStmt *ifStmt ) {104 acceptAll( ifStmt->get_initialization(), *this );105 maybeAccept( ifStmt->get_condition(), *this );106 maybeAccept( ifStmt->get_thenPart(), *this );107 maybeAccept( ifStmt->get_elsePart(), *this );108 }109 110 void Visitor::visit( WhileStmt *whileStmt ) {111 maybeAccept( whileStmt->get_condition(), *this );112 maybeAccept( whileStmt->get_body(), *this );113 }114 115 void Visitor::visit( ForStmt *forStmt ) {116 acceptAll( forStmt->get_initialization(), *this );117 maybeAccept( forStmt->get_condition(), *this );118 maybeAccept( forStmt->get_increment(), *this );119 maybeAccept( forStmt->get_body(), *this );120 }121 122 void Visitor::visit( SwitchStmt *switchStmt ) {123 maybeAccept( switchStmt->get_condition(), *this );124 acceptAll( switchStmt->get_statements(), *this );125 }126 127 void Visitor::visit( CaseStmt *caseStmt ) {128 maybeAccept( caseStmt->get_condition(), *this );129 acceptAll( caseStmt->get_statements(), *this );130 }131 132 void Visitor::visit( __attribute__((unused)) BranchStmt *branchStmt ) {133 }134 135 void Visitor::visit( ReturnStmt *returnStmt ) {136 maybeAccept( returnStmt->get_expr(), *this );137 }138 139 void Visitor::visit( ThrowStmt * throwStmt ) {140 maybeAccept( throwStmt->get_expr(), *this );141 maybeAccept( throwStmt->get_target(), *this );142 }143 144 void Visitor::visit( TryStmt *tryStmt ) {145 maybeAccept( tryStmt->get_block(), *this );146 acceptAll( tryStmt->get_catchers(), *this );147 maybeAccept( tryStmt->get_finally(), *this );148 }149 150 void Visitor::visit( CatchStmt *catchStmt ) {151 maybeAccept( catchStmt->get_decl(), *this );152 maybeAccept( catchStmt->get_cond(), *this );153 maybeAccept( catchStmt->get_body(), *this );154 }155 156 void Visitor::visit( FinallyStmt *finalStmt ) {157 maybeAccept( finalStmt->get_block(), *this );158 }159 160 void Visitor::visit( WaitForStmt *waitforStmt ) {161 for( auto & clause : waitforStmt->clauses ) {162 maybeAccept( clause.target.function, *this );163 acceptAll( clause.target.arguments, *this );164 165 maybeAccept( clause.statement, *this );166 maybeAccept( clause.condition, *this );167 }168 169 maybeAccept( waitforStmt->timeout.time, *this );170 maybeAccept( waitforStmt->timeout.statement, *this );171 maybeAccept( waitforStmt->timeout.condition, *this );172 maybeAccept( waitforStmt->orelse.statement, *this );173 maybeAccept( waitforStmt->orelse.condition, *this );174 }175 176 void Visitor::visit( WithStmt * withStmt ) {177 acceptAll( withStmt->exprs, *this );178 maybeAccept( withStmt->stmt, *this );179 }180 181 void Visitor::visit( NullStmt * ) {182 }183 184 void Visitor::visit( DeclStmt *declStmt ) {185 maybeAccept( declStmt->get_decl(), *this );186 }187 188 void Visitor::visit( ImplicitCtorDtorStmt *impCtorDtorStmt ) {189 maybeAccept( impCtorDtorStmt->get_callStmt(), *this );190 }191 192 193 void Visitor::visit( ApplicationExpr *applicationExpr ) {194 maybeAccept( applicationExpr->get_result(), *this );195 maybeAccept( applicationExpr->get_function(), *this );196 acceptAll( applicationExpr->get_args(), *this );197 }198 199 void Visitor::visit( UntypedExpr *untypedExpr ) {200 maybeAccept( untypedExpr->get_result(), *this );201 acceptAll( untypedExpr->get_args(), *this );202 }203 204 void Visitor::visit( NameExpr *nameExpr ) {205 maybeAccept( nameExpr->get_result(), *this );206 }207 208 void Visitor::visit( AddressExpr *addressExpr ) {209 maybeAccept( addressExpr->get_result(), *this );210 maybeAccept( addressExpr->get_arg(), *this );211 }212 213 void Visitor::visit( LabelAddressExpr *labAddressExpr ) {214 maybeAccept( labAddressExpr->get_result(), *this );215 }216 217 void Visitor::visit( CastExpr *castExpr ) {218 maybeAccept( castExpr->get_result(), *this );219 maybeAccept( castExpr->get_arg(), *this );220 }221 222 void Visitor::visit( VirtualCastExpr *castExpr ) {223 maybeAccept( castExpr->get_result(), *this );224 maybeAccept( castExpr->get_arg(), *this );225 }226 227 void Visitor::visit( UntypedMemberExpr *memberExpr ) {228 maybeAccept( memberExpr->get_result(), *this );229 maybeAccept( memberExpr->get_aggregate(), *this );230 maybeAccept( memberExpr->get_member(), *this );231 }232 233 void Visitor::visit( MemberExpr *memberExpr ) {234 maybeAccept( memberExpr->get_result(), *this );235 maybeAccept( memberExpr->get_aggregate(), *this );236 }237 238 void Visitor::visit( VariableExpr *variableExpr ) {239 maybeAccept( variableExpr->get_result(), *this );240 }241 242 void Visitor::visit( ConstantExpr *constantExpr ) {243 maybeAccept( constantExpr->get_result(), *this );244 maybeAccept( constantExpr->get_constant(), *this );245 }246 247 void Visitor::visit( SizeofExpr *sizeofExpr ) {248 maybeAccept( sizeofExpr->get_result(), *this );249 if ( sizeofExpr->get_isType() ) {250 maybeAccept( sizeofExpr->get_type(), *this );251 } else {252 maybeAccept( sizeofExpr->get_expr(), *this );253 }254 }255 256 void Visitor::visit( AlignofExpr *alignofExpr ) {257 maybeAccept( alignofExpr->get_result(), *this );258 if ( alignofExpr->get_isType() ) {259 maybeAccept( alignofExpr->get_type(), *this );260 } else {261 maybeAccept( alignofExpr->get_expr(), *this );262 }263 }264 265 void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {266 maybeAccept( offsetofExpr->get_result(), *this );267 maybeAccept( offsetofExpr->get_type(), *this );268 }269 270 void Visitor::visit( OffsetofExpr *offsetofExpr ) {271 maybeAccept( offsetofExpr->get_result(), *this );272 maybeAccept( offsetofExpr->get_type(), *this );273 maybeAccept( offsetofExpr->get_member(), *this );274 }275 276 void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {277 maybeAccept( offsetPackExpr->get_result(), *this );278 maybeAccept( offsetPackExpr->get_type(), *this );279 }280 281 void Visitor::visit( AttrExpr *attrExpr ) {282 maybeAccept( attrExpr->get_result(), *this );283 if ( attrExpr->get_isType() ) {284 maybeAccept( attrExpr->get_type(), *this );285 } else {286 maybeAccept( attrExpr->get_expr(), *this );287 }288 }289 290 void Visitor::visit( LogicalExpr *logicalExpr ) {291 maybeAccept( logicalExpr->get_result(), *this );292 maybeAccept( logicalExpr->get_arg1(), *this );293 maybeAccept( logicalExpr->get_arg2(), *this );294 }295 296 void Visitor::visit( ConditionalExpr *conditionalExpr ) {297 maybeAccept( conditionalExpr->get_result(), *this );298 maybeAccept( conditionalExpr->get_arg1(), *this );299 maybeAccept( conditionalExpr->get_arg2(), *this );300 maybeAccept( conditionalExpr->get_arg3(), *this );301 }302 303 void Visitor::visit( CommaExpr *commaExpr ) {304 maybeAccept( commaExpr->get_result(), *this );305 maybeAccept( commaExpr->get_arg1(), *this );306 maybeAccept( commaExpr->get_arg2(), *this );307 }308 309 void Visitor::visit( TypeExpr *typeExpr ) {310 maybeAccept( typeExpr->get_result(), *this );311 maybeAccept( typeExpr->get_type(), *this );312 }313 314 void Visitor::visit( AsmExpr *asmExpr ) {315 maybeAccept( asmExpr->get_inout(), *this );316 maybeAccept( asmExpr->get_constraint(), *this );317 maybeAccept( asmExpr->get_operand(), *this );318 }319 320 void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {321 maybeAccept( impCpCtorExpr->get_result(), *this );322 maybeAccept( impCpCtorExpr->get_callExpr(), *this );323 acceptAll( impCpCtorExpr->get_tempDecls(), *this );324 acceptAll( impCpCtorExpr->get_returnDecls(), *this );325 acceptAll( impCpCtorExpr->get_dtors(), *this );326 }327 328 void Visitor::visit( ConstructorExpr * ctorExpr ) {329 maybeAccept( ctorExpr->get_result(), *this );330 maybeAccept( ctorExpr->get_callExpr(), *this );331 }332 333 void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {334 maybeAccept( compLitExpr->get_result(), *this );335 maybeAccept( compLitExpr->get_initializer(), *this );336 }337 338 void Visitor::visit( RangeExpr *rangeExpr ) {339 maybeAccept( rangeExpr->get_low(), *this );340 maybeAccept( rangeExpr->get_high(), *this );341 }342 343 void Visitor::visit( UntypedTupleExpr *tupleExpr ) {344 maybeAccept( tupleExpr->get_result(), *this );345 acceptAll( tupleExpr->get_exprs(), *this );346 }347 348 void Visitor::visit( TupleExpr *tupleExpr ) {349 maybeAccept( tupleExpr->get_result(), *this );350 acceptAll( tupleExpr->get_exprs(), *this );351 }352 353 void Visitor::visit( TupleIndexExpr *tupleExpr ) {354 maybeAccept( tupleExpr->get_result(), *this );355 maybeAccept( tupleExpr->get_tuple(), *this );356 }357 358 void Visitor::visit( TupleAssignExpr *assignExpr ) {359 maybeAccept( assignExpr->get_result(), *this );360 maybeAccept( assignExpr->get_stmtExpr(), *this );361 }362 363 void Visitor::visit( StmtExpr *stmtExpr ) {364 maybeAccept( stmtExpr->get_result(), *this );365 maybeAccept( stmtExpr->get_statements(), *this );366 acceptAll( stmtExpr->get_returnDecls(), *this );367 acceptAll( stmtExpr->get_dtors(), *this );368 }369 370 void Visitor::visit( UniqueExpr *uniqueExpr ) {371 maybeAccept( uniqueExpr->get_result(), *this );372 maybeAccept( uniqueExpr->get_expr(), *this );373 }374 375 void Visitor::visit( UntypedInitExpr * initExpr ) {376 maybeAccept( initExpr->get_result(), *this );377 maybeAccept( initExpr->get_expr(), *this );378 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.379 }380 381 void Visitor::visit( InitExpr * initExpr ) {382 maybeAccept( initExpr->get_result(), *this );383 maybeAccept( initExpr->get_expr(), *this );384 maybeAccept( initExpr->get_designation(), *this );385 }386 387 388 void Visitor::visit( VoidType *voidType ) {389 acceptAll( voidType->get_forall(), *this );390 }391 392 void Visitor::visit( BasicType *basicType ) {393 acceptAll( basicType->get_forall(), *this );394 }395 396 void Visitor::visit( PointerType *pointerType ) {397 acceptAll( pointerType->get_forall(), *this );398 // xxx - should PointerType visit/mutate dimension?399 maybeAccept( pointerType->get_base(), *this );400 }401 402 void Visitor::visit( ArrayType *arrayType ) {403 acceptAll( arrayType->get_forall(), *this );404 maybeAccept( arrayType->get_dimension(), *this );405 maybeAccept( arrayType->get_base(), *this );406 }407 408 void Visitor::visit( ReferenceType *refType ) {409 acceptAll( refType->get_forall(), *this );410 maybeAccept( refType->get_base(), *this );411 }412 413 void Visitor::visit( FunctionType *functionType ) {414 acceptAll( functionType->get_forall(), *this );415 acceptAll( functionType->get_returnVals(), *this );416 acceptAll( functionType->get_parameters(), *this );417 }418 419 void Visitor::handleReferenceToType( ReferenceToType *aggregateUseType ) {420 acceptAll( aggregateUseType->get_forall(), *this );421 acceptAll( aggregateUseType->get_parameters(), *this );422 }423 424 void Visitor::visit( StructInstType *aggregateUseType ) {425 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );426 }427 428 void Visitor::visit( UnionInstType *aggregateUseType ) {429 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );430 }431 432 void Visitor::visit( EnumInstType *aggregateUseType ) {433 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );434 }435 436 void Visitor::visit( TraitInstType *aggregateUseType ) {437 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );438 }439 440 void Visitor::visit( TypeInstType *aggregateUseType ) {441 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );442 }443 33 444 34 void Visitor::visit( TupleType *tupleType ) {
Note: See TracChangeset
for help on using the changeset viewer.