Changeset 1cb758f2 for src/SynTree
- Timestamp:
- Aug 27, 2017, 11:26:26 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:
- 111a8af8, 26238c1, 7ee1e2f6
- Parents:
- 0c6596f (diff), eca3d10 (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. - Location:
- src/SynTree
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Mutator.cc
r0c6596f r1cb758f2 32 32 Mutator::~Mutator() {} 33 33 34 DeclarationWithType * Mutator::mutate( ObjectDecl *objectDecl ) {34 DeclarationWithType * Mutator::mutate( ObjectDecl *objectDecl ) { 35 35 objectDecl->set_type( maybeMutate( objectDecl->get_type(), *this ) ); 36 36 objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) ); … … 39 39 } 40 40 41 DeclarationWithType * Mutator::mutate( FunctionDecl *functionDecl ) {41 DeclarationWithType * Mutator::mutate( FunctionDecl *functionDecl ) { 42 42 functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) ); 43 43 functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) ); … … 45 45 } 46 46 47 Declaration * Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) {47 Declaration * Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) { 48 48 mutateAll( aggregateDecl->get_parameters(), *this ); 49 49 mutateAll( aggregateDecl->get_members(), *this ); … … 51 51 } 52 52 53 Declaration * Mutator::mutate( StructDecl *aggregateDecl ) {53 Declaration * Mutator::mutate( StructDecl *aggregateDecl ) { 54 54 handleAggregateDecl( aggregateDecl ); 55 55 return aggregateDecl; 56 56 } 57 57 58 Declaration * Mutator::mutate( UnionDecl *aggregateDecl ) {58 Declaration * Mutator::mutate( UnionDecl *aggregateDecl ) { 59 59 handleAggregateDecl( aggregateDecl ); 60 60 return aggregateDecl; 61 61 } 62 62 63 Declaration * Mutator::mutate( EnumDecl *aggregateDecl ) {63 Declaration * Mutator::mutate( EnumDecl *aggregateDecl ) { 64 64 handleAggregateDecl( aggregateDecl ); 65 65 return aggregateDecl; 66 66 } 67 67 68 Declaration * Mutator::mutate( TraitDecl *aggregateDecl ) {68 Declaration * Mutator::mutate( TraitDecl *aggregateDecl ) { 69 69 handleAggregateDecl( aggregateDecl ); 70 70 return aggregateDecl; 71 71 } 72 72 73 Declaration * Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {73 Declaration * Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) { 74 74 mutateAll( typeDecl->get_parameters(), *this ); 75 75 mutateAll( typeDecl->get_assertions(), *this ); … … 78 78 } 79 79 80 TypeDecl * Mutator::mutate( TypeDecl *typeDecl ) {80 TypeDecl * Mutator::mutate( TypeDecl *typeDecl ) { 81 81 handleNamedTypeDecl( typeDecl ); 82 82 typeDecl->set_init( maybeMutate( typeDecl->get_init(), *this ) ); … … 84 84 } 85 85 86 Declaration * Mutator::mutate( TypedefDecl *typeDecl ) {86 Declaration * Mutator::mutate( TypedefDecl *typeDecl ) { 87 87 handleNamedTypeDecl( typeDecl ); 88 88 return typeDecl; 89 89 } 90 90 91 AsmDecl * Mutator::mutate( AsmDecl *asmDecl ) {91 AsmDecl * Mutator::mutate( AsmDecl *asmDecl ) { 92 92 asmDecl->set_stmt( maybeMutate( asmDecl->get_stmt(), *this ) ); 93 93 return asmDecl; … … 95 95 96 96 97 CompoundStmt * Mutator::mutate( CompoundStmt *compoundStmt ) {97 CompoundStmt * Mutator::mutate( CompoundStmt *compoundStmt ) { 98 98 mutateAll( compoundStmt->get_kids(), *this ); 99 99 return compoundStmt; 100 100 } 101 101 102 Statement * Mutator::mutate( ExprStmt *exprStmt ) {102 Statement * Mutator::mutate( ExprStmt *exprStmt ) { 103 103 exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) ); 104 104 return exprStmt; 105 105 } 106 106 107 Statement * Mutator::mutate( AsmStmt *asmStmt ) {107 Statement * Mutator::mutate( AsmStmt *asmStmt ) { 108 108 asmStmt->set_instruction( maybeMutate( asmStmt->get_instruction(), *this ) ); 109 109 mutateAll( asmStmt->get_output(), *this ); … … 113 113 } 114 114 115 Statement * Mutator::mutate( IfStmt *ifStmt ) {115 Statement * Mutator::mutate( IfStmt *ifStmt ) { 116 116 mutateAll( ifStmt->get_initialization(), *this ); 117 117 ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) ); … … 121 121 } 122 122 123 Statement * Mutator::mutate( WhileStmt *whileStmt ) {123 Statement * Mutator::mutate( WhileStmt *whileStmt ) { 124 124 whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) ); 125 125 whileStmt->set_body( maybeMutate( whileStmt->get_body(), *this ) ); … … 127 127 } 128 128 129 Statement * Mutator::mutate( ForStmt *forStmt ) {129 Statement * Mutator::mutate( ForStmt *forStmt ) { 130 130 mutateAll( forStmt->get_initialization(), *this ); 131 131 forStmt->set_condition( maybeMutate( forStmt->get_condition(), *this ) ); … … 135 135 } 136 136 137 Statement * Mutator::mutate( SwitchStmt *switchStmt ) {137 Statement * Mutator::mutate( SwitchStmt *switchStmt ) { 138 138 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); 139 139 mutateAll( switchStmt->get_statements(), *this ); … … 141 141 } 142 142 143 Statement * Mutator::mutate( CaseStmt *caseStmt ) {143 Statement * Mutator::mutate( CaseStmt *caseStmt ) { 144 144 caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) ); 145 145 mutateAll (caseStmt->get_statements(), *this ); … … 148 148 } 149 149 150 Statement * Mutator::mutate( BranchStmt *branchStmt ) {150 Statement * Mutator::mutate( BranchStmt *branchStmt ) { 151 151 return branchStmt; 152 152 } 153 153 154 Statement * Mutator::mutate( ReturnStmt *returnStmt ) {154 Statement * Mutator::mutate( ReturnStmt *returnStmt ) { 155 155 returnStmt->set_expr( maybeMutate( returnStmt->get_expr(), *this ) ); 156 156 return returnStmt; 157 157 } 158 158 159 Statement * Mutator::mutate( ThrowStmt *throwStmt ) {159 Statement * Mutator::mutate( ThrowStmt *throwStmt ) { 160 160 throwStmt->set_expr( maybeMutate( throwStmt->get_expr(), *this ) ); 161 161 throwStmt->set_target( maybeMutate( throwStmt->get_target(), *this ) ); … … 163 163 } 164 164 165 Statement * Mutator::mutate( TryStmt *tryStmt ) {165 Statement * Mutator::mutate( TryStmt *tryStmt ) { 166 166 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) ); 167 167 mutateAll( tryStmt->get_catchers(), *this ); … … 170 170 } 171 171 172 Statement * Mutator::mutate( CatchStmt *catchStmt ) {172 Statement * Mutator::mutate( CatchStmt *catchStmt ) { 173 173 catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) ); 174 174 catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) ); … … 177 177 } 178 178 179 Statement * Mutator::mutate( FinallyStmt *finalStmt ) {179 Statement * Mutator::mutate( FinallyStmt *finalStmt ) { 180 180 finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) ); 181 181 return finalStmt; 182 182 } 183 183 184 NullStmt *Mutator::mutate( NullStmt *nullStmt ) { 184 Statement * Mutator::mutate( WaitForStmt *waitforStmt ) { 185 for( auto & clause : waitforStmt->clauses ) { 186 clause.target.function = maybeMutate( clause.target.function, *this ); 187 mutateAll( clause.target.arguments, *this ); 188 189 clause.statement = maybeMutate( clause.statement, *this ); 190 clause.condition = maybeMutate( clause.condition, *this ); 191 } 192 193 waitforStmt->timeout.time = maybeMutate( waitforStmt->timeout.time, *this ); 194 waitforStmt->timeout.statement = maybeMutate( waitforStmt->timeout.statement, *this ); 195 waitforStmt->timeout.condition = maybeMutate( waitforStmt->timeout.condition, *this ); 196 waitforStmt->orelse.statement = maybeMutate( waitforStmt->orelse.statement, *this ); 197 waitforStmt->orelse.condition = maybeMutate( waitforStmt->orelse.condition, *this ); 198 199 return waitforStmt; 200 } 201 202 NullStmt * Mutator::mutate( NullStmt *nullStmt ) { 185 203 return nullStmt; 186 204 } 187 205 188 Statement * Mutator::mutate( DeclStmt *declStmt ) {206 Statement * Mutator::mutate( DeclStmt *declStmt ) { 189 207 declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) ); 190 208 return declStmt; 191 209 } 192 210 193 Statement * Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) {211 Statement * Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) { 194 212 impCtorDtorStmt->set_callStmt( maybeMutate( impCtorDtorStmt->get_callStmt(), *this ) ); 195 213 return impCtorDtorStmt; … … 197 215 198 216 199 Expression * Mutator::mutate( ApplicationExpr *applicationExpr ) {217 Expression * Mutator::mutate( ApplicationExpr *applicationExpr ) { 200 218 applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) ); 201 219 applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) ); … … 205 223 } 206 224 207 Expression * Mutator::mutate( UntypedExpr *untypedExpr ) {225 Expression * Mutator::mutate( UntypedExpr *untypedExpr ) { 208 226 untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) ); 209 227 untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) ); … … 212 230 } 213 231 214 Expression * Mutator::mutate( NameExpr *nameExpr ) {232 Expression * Mutator::mutate( NameExpr *nameExpr ) { 215 233 nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) ); 216 234 nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) ); … … 218 236 } 219 237 220 Expression * Mutator::mutate( AddressExpr *addressExpr ) {238 Expression * Mutator::mutate( AddressExpr *addressExpr ) { 221 239 addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) ); 222 240 addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) ); … … 225 243 } 226 244 227 Expression * Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {245 Expression * Mutator::mutate( LabelAddressExpr *labelAddressExpr ) { 228 246 labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) ); 229 247 labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) ); … … 232 250 } 233 251 234 Expression * Mutator::mutate( CastExpr *castExpr ) {252 Expression * Mutator::mutate( CastExpr *castExpr ) { 235 253 castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) ); 236 254 castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) ); … … 239 257 } 240 258 241 Expression * Mutator::mutate( VirtualCastExpr *castExpr ) {259 Expression * Mutator::mutate( VirtualCastExpr *castExpr ) { 242 260 castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) ); 243 261 castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) ); … … 246 264 } 247 265 248 Expression * Mutator::mutate( UntypedMemberExpr *memberExpr ) {266 Expression * Mutator::mutate( UntypedMemberExpr *memberExpr ) { 249 267 memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) ); 250 268 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); … … 254 272 } 255 273 256 Expression * Mutator::mutate( MemberExpr *memberExpr ) {274 Expression * Mutator::mutate( MemberExpr *memberExpr ) { 257 275 memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) ); 258 276 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); … … 261 279 } 262 280 263 Expression * Mutator::mutate( VariableExpr *variableExpr ) {281 Expression * Mutator::mutate( VariableExpr *variableExpr ) { 264 282 variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) ); 265 283 variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) ); … … 267 285 } 268 286 269 Expression * Mutator::mutate( ConstantExpr *constantExpr ) {287 Expression * Mutator::mutate( ConstantExpr *constantExpr ) { 270 288 constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) ); 271 289 constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) ); … … 274 292 } 275 293 276 Expression * Mutator::mutate( SizeofExpr *sizeofExpr ) {294 Expression * Mutator::mutate( SizeofExpr *sizeofExpr ) { 277 295 sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) ); 278 296 sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) ); … … 285 303 } 286 304 287 Expression * Mutator::mutate( AlignofExpr *alignofExpr ) {305 Expression * Mutator::mutate( AlignofExpr *alignofExpr ) { 288 306 alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) ); 289 307 alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) ); … … 296 314 } 297 315 298 Expression * Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {316 Expression * Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) { 299 317 offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) ); 300 318 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); … … 303 321 } 304 322 305 Expression * Mutator::mutate( OffsetofExpr *offsetofExpr ) {323 Expression * Mutator::mutate( OffsetofExpr *offsetofExpr ) { 306 324 offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) ); 307 325 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); … … 311 329 } 312 330 313 Expression * Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {331 Expression * Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 314 332 offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) ); 315 333 offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) ); … … 318 336 } 319 337 320 Expression * Mutator::mutate( AttrExpr *attrExpr ) {338 Expression * Mutator::mutate( AttrExpr *attrExpr ) { 321 339 attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) ); 322 340 attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) ); … … 329 347 } 330 348 331 Expression * Mutator::mutate( LogicalExpr *logicalExpr ) {349 Expression * Mutator::mutate( LogicalExpr *logicalExpr ) { 332 350 logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) ); 333 351 logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) ); … … 337 355 } 338 356 339 Expression * Mutator::mutate( ConditionalExpr *conditionalExpr ) {357 Expression * Mutator::mutate( ConditionalExpr *conditionalExpr ) { 340 358 conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) ); 341 359 conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) ); … … 346 364 } 347 365 348 Expression * Mutator::mutate( CommaExpr *commaExpr ) {366 Expression * Mutator::mutate( CommaExpr *commaExpr ) { 349 367 commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) ); 350 368 commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) ); … … 354 372 } 355 373 356 Expression * Mutator::mutate( TypeExpr *typeExpr ) {374 Expression * Mutator::mutate( TypeExpr *typeExpr ) { 357 375 typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) ); 358 376 typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) ); … … 361 379 } 362 380 363 Expression * Mutator::mutate( AsmExpr *asmExpr ) {381 Expression * Mutator::mutate( AsmExpr *asmExpr ) { 364 382 asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) ); 365 383 asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) ); … … 386 404 } 387 405 388 Expression * Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {406 Expression * Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 389 407 compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) ); 390 408 compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) ); … … 393 411 } 394 412 395 Expression * Mutator::mutate( RangeExpr *rangeExpr ) {413 Expression * Mutator::mutate( RangeExpr *rangeExpr ) { 396 414 rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) ); 397 415 rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) ); … … 400 418 } 401 419 402 Expression * Mutator::mutate( UntypedTupleExpr *tupleExpr ) {420 Expression * Mutator::mutate( UntypedTupleExpr *tupleExpr ) { 403 421 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 404 422 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); … … 407 425 } 408 426 409 Expression * Mutator::mutate( TupleExpr *tupleExpr ) {427 Expression * Mutator::mutate( TupleExpr *tupleExpr ) { 410 428 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 411 429 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); … … 414 432 } 415 433 416 Expression * Mutator::mutate( TupleIndexExpr *tupleExpr ) {434 Expression * Mutator::mutate( TupleIndexExpr *tupleExpr ) { 417 435 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 418 436 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); … … 421 439 } 422 440 423 Expression * Mutator::mutate( TupleAssignExpr *assignExpr ) {441 Expression * Mutator::mutate( TupleAssignExpr *assignExpr ) { 424 442 assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) ); 425 443 assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) ); … … 428 446 } 429 447 430 Expression * Mutator::mutate( StmtExpr *stmtExpr ) {448 Expression * Mutator::mutate( StmtExpr *stmtExpr ) { 431 449 stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) ); 432 450 stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) ); … … 437 455 } 438 456 439 Expression * Mutator::mutate( UniqueExpr *uniqueExpr ) {457 Expression * Mutator::mutate( UniqueExpr *uniqueExpr ) { 440 458 uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) ); 441 459 uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) ); … … 444 462 } 445 463 446 Expression * Mutator::mutate( UntypedInitExpr * initExpr ) {464 Expression * Mutator::mutate( UntypedInitExpr * initExpr ) { 447 465 initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) ); 448 466 initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) ); … … 452 470 } 453 471 454 Expression * Mutator::mutate( InitExpr * initExpr ) {472 Expression * Mutator::mutate( InitExpr * initExpr ) { 455 473 initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) ); 456 474 initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) ); … … 461 479 462 480 463 Type * Mutator::mutate( VoidType *voidType ) {481 Type * Mutator::mutate( VoidType *voidType ) { 464 482 mutateAll( voidType->get_forall(), *this ); 465 483 return voidType; 466 484 } 467 485 468 Type * Mutator::mutate( BasicType *basicType ) {486 Type * Mutator::mutate( BasicType *basicType ) { 469 487 mutateAll( basicType->get_forall(), *this ); 470 488 return basicType; 471 489 } 472 490 473 Type * Mutator::mutate( PointerType *pointerType ) {491 Type * Mutator::mutate( PointerType *pointerType ) { 474 492 mutateAll( pointerType->get_forall(), *this ); 475 493 pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) ); … … 477 495 } 478 496 479 Type * Mutator::mutate( ArrayType *arrayType ) {497 Type * Mutator::mutate( ArrayType *arrayType ) { 480 498 mutateAll( arrayType->get_forall(), *this ); 481 499 arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) ); … … 484 502 } 485 503 486 Type * Mutator::mutate( ReferenceType *refType ) {504 Type * Mutator::mutate( ReferenceType * refType ) { 487 505 mutateAll( refType->get_forall(), *this ); 488 506 refType->set_base( maybeMutate( refType->get_base(), *this ) ); … … 490 508 } 491 509 492 Type * Mutator::mutate( FunctionType *functionType ) {510 Type * Mutator::mutate( FunctionType * functionType ) { 493 511 mutateAll( functionType->get_forall(), *this ); 494 512 mutateAll( functionType->get_returnVals(), *this ); … … 497 515 } 498 516 499 Type * Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {517 Type * Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) { 500 518 mutateAll( aggregateUseType->get_forall(), *this ); 501 519 mutateAll( aggregateUseType->get_parameters(), *this ); … … 503 521 } 504 522 505 Type * Mutator::mutate( StructInstType *aggregateUseType ) {523 Type * Mutator::mutate( StructInstType *aggregateUseType ) { 506 524 handleReferenceToType( aggregateUseType ); 507 525 return aggregateUseType; 508 526 } 509 527 510 Type * Mutator::mutate( UnionInstType *aggregateUseType ) {528 Type * Mutator::mutate( UnionInstType *aggregateUseType ) { 511 529 handleReferenceToType( aggregateUseType ); 512 530 return aggregateUseType; 513 531 } 514 532 515 Type * Mutator::mutate( EnumInstType *aggregateUseType ) {533 Type * Mutator::mutate( EnumInstType *aggregateUseType ) { 516 534 handleReferenceToType( aggregateUseType ); 517 535 return aggregateUseType; 518 536 } 519 537 520 Type * Mutator::mutate( TraitInstType *aggregateUseType ) {538 Type * Mutator::mutate( TraitInstType *aggregateUseType ) { 521 539 handleReferenceToType( aggregateUseType ); 522 540 mutateAll( aggregateUseType->get_members(), *this ); … … 524 542 } 525 543 526 Type * Mutator::mutate( TypeInstType *aggregateUseType ) {544 Type * Mutator::mutate( TypeInstType *aggregateUseType ) { 527 545 handleReferenceToType( aggregateUseType ); 528 546 return aggregateUseType; 529 547 } 530 548 531 Type * Mutator::mutate( TupleType *tupleType ) {549 Type * Mutator::mutate( TupleType *tupleType ) { 532 550 mutateAll( tupleType->get_forall(), *this ); 533 551 mutateAll( tupleType->get_types(), *this ); … … 536 554 } 537 555 538 Type * Mutator::mutate( TypeofType *typeofType ) {556 Type * Mutator::mutate( TypeofType *typeofType ) { 539 557 assert( typeofType->get_expr() ); 540 558 typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) ); … … 542 560 } 543 561 544 Type * Mutator::mutate( AttrType *attrType ) {562 Type * Mutator::mutate( AttrType *attrType ) { 545 563 if ( attrType->get_isType() ) { 546 564 assert( attrType->get_type() ); … … 553 571 } 554 572 555 Type * Mutator::mutate( VarArgsType *varArgsType ) {573 Type * Mutator::mutate( VarArgsType *varArgsType ) { 556 574 mutateAll( varArgsType->get_forall(), *this ); 557 575 return varArgsType; 558 576 } 559 577 560 Type * Mutator::mutate( ZeroType *zeroType ) {578 Type * Mutator::mutate( ZeroType *zeroType ) { 561 579 mutateAll( zeroType->get_forall(), *this ); 562 580 return zeroType; 563 581 } 564 582 565 Type * Mutator::mutate( OneType *oneType ) {583 Type * Mutator::mutate( OneType *oneType ) { 566 584 mutateAll( oneType->get_forall(), *this ); 567 585 return oneType; … … 569 587 570 588 571 Designation * Mutator::mutate( Designation * designation ) {589 Designation * Mutator::mutate( Designation * designation ) { 572 590 mutateAll( designation->get_designators(), *this ); 573 591 return designation; 574 592 } 575 593 576 Initializer * Mutator::mutate( SingleInit *singleInit ) {594 Initializer * Mutator::mutate( SingleInit *singleInit ) { 577 595 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) ); 578 596 return singleInit; 579 597 } 580 598 581 Initializer * Mutator::mutate( ListInit *listInit ) {599 Initializer * Mutator::mutate( ListInit *listInit ) { 582 600 mutateAll( listInit->get_designations(), *this ); 583 601 mutateAll( listInit->get_initializers(), *this ); … … 585 603 } 586 604 587 Initializer * Mutator::mutate( ConstructorInit *ctorInit ) {605 Initializer * Mutator::mutate( ConstructorInit *ctorInit ) { 588 606 ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) ); 589 607 ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) ); … … 593 611 594 612 595 Subrange * Mutator::mutate( Subrange *subrange ) {613 Subrange * Mutator::mutate( Subrange *subrange ) { 596 614 return subrange; 597 615 } 598 616 599 617 600 Constant * Mutator::mutate( Constant *constant ) {618 Constant * Mutator::mutate( Constant *constant ) { 601 619 return constant; 602 620 } -
src/SynTree/Mutator.h
r0c6596f r1cb758f2 49 49 virtual Statement* mutate( CatchStmt *catchStmt ); 50 50 virtual Statement* mutate( FinallyStmt *catchStmt ); 51 virtual Statement* mutate( WaitForStmt *waitforStmt ); 51 52 virtual NullStmt* mutate( NullStmt *nullStmt ); 52 53 virtual Statement* mutate( DeclStmt *declStmt ); -
src/SynTree/Statement.cc
r0c6596f r1cb758f2 419 419 } 420 420 421 WaitForStmt::WaitForStmt( std::list<Label> labels ) : Statement( labels ) { 422 timeout.time = nullptr; 423 timeout.statement = nullptr; 424 timeout.condition = nullptr; 425 orelse .statement = nullptr; 426 orelse .condition = nullptr; 427 } 428 429 WaitForStmt::WaitForStmt( const WaitForStmt & other ) : Statement( other ) { 430 clauses.reserve( other.clauses.size() ); 431 for( auto & ocl : other.clauses ) { 432 clauses.emplace_back(); 433 clauses.back().target.function = ocl.target.function->clone(); 434 cloneAll( ocl.target.arguments, clauses.back().target.arguments ); 435 clauses.back().statement = ocl.statement->clone(); 436 clauses.back().condition = ocl.condition->clone(); 437 } 438 439 timeout.time = other.timeout.time ->clone(); 440 timeout.statement = other.timeout.statement->clone(); 441 timeout.condition = other.timeout.condition->clone(); 442 orelse .statement = other.orelse .statement->clone(); 443 orelse .condition = other.orelse .condition->clone(); 444 } 445 446 WaitForStmt::~WaitForStmt() { 447 for( auto & clause : clauses ) { 448 delete clause.target.function; 449 deleteAll( clause.target.arguments ); 450 delete clause.statement; 451 delete clause.condition; 452 } 453 454 delete timeout.time; 455 delete timeout.statement; 456 delete timeout.condition; 457 458 delete orelse.statement; 459 delete orelse.condition; 460 } 461 462 void WaitForStmt::print( std::ostream &os, int indent ) const { 463 os << "Waitfor Statement" << endl; 464 os << string( indent + 2, ' ' ) << "with block:" << endl; 465 os << string( indent + 4, ' ' ); 466 // block->print( os, indent + 4 ); 467 } 468 421 469 NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {} 422 470 NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {} -
src/SynTree/Statement.h
r0c6596f r1cb758f2 19 19 #include <list> // for list 20 20 #include <memory> // for allocator 21 #include <vector> // for vector 21 22 22 23 #include "BaseSyntaxNode.h" // for BaseSyntaxNode … … 392 393 }; 393 394 395 class WaitForStmt : public Statement { 396 public: 397 398 struct Target { 399 Expression * function; 400 std::list<Expression * > arguments; 401 }; 402 403 struct Clause { 404 Target target; 405 Statement * statement; 406 Expression * condition; 407 }; 408 409 WaitForStmt( std::list<Label> labels = noLabels ); 410 WaitForStmt( const WaitForStmt & ); 411 virtual ~WaitForStmt(); 412 413 std::vector<Clause> clauses; 414 415 struct { 416 Expression * time; 417 Statement * statement; 418 Expression * condition; 419 } timeout; 420 421 struct { 422 Statement * statement; 423 Expression * condition; 424 } orelse; 425 426 virtual WaitForStmt *clone() const { return new WaitForStmt( *this ); } 427 virtual void accept( Visitor &v ) { v.visit( this ); } 428 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 429 virtual void print( std::ostream &os, int indent = 0 ) const; 430 431 }; 432 394 433 395 434 // represents a declaration that occurs as part of a compound statement -
src/SynTree/SynTree.h
r0c6596f r1cb758f2 54 54 class CatchStmt; 55 55 class FinallyStmt; 56 class WaitForStmt; 56 57 class NullStmt; 57 58 class DeclStmt; -
src/SynTree/Visitor.cc
r0c6596f r1cb758f2 155 155 } 156 156 157 void Visitor::visit( WaitForStmt *waitforStmt ) { 158 for( auto & clause : waitforStmt->clauses ) { 159 maybeAccept( clause.target.function, *this ); 160 acceptAll( clause.target.arguments, *this ); 161 162 maybeAccept( clause.statement, *this ); 163 maybeAccept( clause.condition, *this ); 164 } 165 166 maybeAccept( waitforStmt->timeout.time, *this ); 167 maybeAccept( waitforStmt->timeout.statement, *this ); 168 maybeAccept( waitforStmt->timeout.condition, *this ); 169 maybeAccept( waitforStmt->orelse.statement, *this ); 170 maybeAccept( waitforStmt->orelse.condition, *this ); 171 } 172 157 173 void Visitor::visit( __attribute__((unused)) NullStmt *nullStmt ) { 158 174 } -
src/SynTree/Visitor.h
r0c6596f r1cb758f2 51 51 virtual void visit( CatchStmt *catchStmt ); 52 52 virtual void visit( FinallyStmt *finallyStmt ); 53 virtual void visit( WaitForStmt *waitforStmt ); 53 54 virtual void visit( NullStmt *nullStmt ); 54 55 virtual void visit( DeclStmt *declStmt );
Note: See TracChangeset
for help on using the changeset viewer.