Changeset cfaf9be


Ignore:
Timestamp:
Feb 27, 2018, 5:50:22 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
4b1be68
Parents:
86e84e4
Message:

Make all Visitor/Mutator? functions pure virtual, remove unused Visitor/Mutator? code

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.impl.h

    r86e84e4 rcfaf9be  
    20602060
    20612061        maybeAccept_impl( node->forall, *this );
     2062        // xxx - should PointerType visit/mutate dimension?
    20622063        maybeAccept_impl( node->base, *this );
    20632064
     
    20702071
    20712072        maybeMutate_impl( node->forall, *this );
     2073        // xxx - should PointerType visit/mutate dimension?
    20722074        maybeMutate_impl( node->base, *this );
    20732075
  • src/SynTree/Mutator.cc

    r86e84e4 rcfaf9be  
    3232
    3333Mutator::~Mutator() {}
    34 
    35 DeclarationWithType * Mutator::mutate( ObjectDecl *objectDecl ) {
    36         objectDecl->set_type( maybeMutate( objectDecl->get_type(), *this ) );
    37         objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) );
    38         objectDecl->set_bitfieldWidth( maybeMutate( objectDecl->get_bitfieldWidth(), *this ) );
    39         mutateAll( objectDecl->attributes, *this );
    40         return objectDecl;
    41 }
    42 
    43 DeclarationWithType * Mutator::mutate( FunctionDecl *functionDecl ) {
    44         functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) );
    45         functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
    46         mutateAll( functionDecl->attributes, *this );
    47         return functionDecl;
    48 }
    49 
    50 Declaration * Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
    51         mutateAll( aggregateDecl->get_parameters(), *this );
    52         mutateAll( aggregateDecl->get_members(), *this );
    53         return aggregateDecl;
    54 }
    55 
    56 Declaration * Mutator::mutate( StructDecl *aggregateDecl ) {
    57         handleAggregateDecl( aggregateDecl );
    58         return aggregateDecl;
    59 }
    60 
    61 Declaration * Mutator::mutate( UnionDecl *aggregateDecl ) {
    62         handleAggregateDecl( aggregateDecl );
    63         return aggregateDecl;
    64 }
    65 
    66 Declaration * Mutator::mutate( EnumDecl *aggregateDecl ) {
    67         handleAggregateDecl( aggregateDecl );
    68         return aggregateDecl;
    69 }
    70 
    71 Declaration * Mutator::mutate( TraitDecl *aggregateDecl ) {
    72         handleAggregateDecl( aggregateDecl );
    73         return aggregateDecl;
    74 }
    75 
    76 Declaration * Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {
    77         mutateAll( typeDecl->get_parameters(), *this );
    78         mutateAll( typeDecl->get_assertions(), *this );
    79         typeDecl->set_base( maybeMutate( typeDecl->get_base(), *this ) );
    80         return typeDecl;
    81 }
    82 
    83 Declaration * Mutator::mutate( TypeDecl *typeDecl ) {
    84         handleNamedTypeDecl( typeDecl );
    85         typeDecl->set_init( maybeMutate( typeDecl->get_init(), *this ) );
    86         return typeDecl;
    87 }
    88 
    89 Declaration * Mutator::mutate( TypedefDecl *typeDecl ) {
    90         handleNamedTypeDecl( typeDecl );
    91         return typeDecl;
    92 }
    93 
    94 AsmDecl * Mutator::mutate( AsmDecl *asmDecl ) {
    95         asmDecl->set_stmt( maybeMutate( asmDecl->get_stmt(), *this ) );
    96         return asmDecl;
    97 }
    98 
    99 
    100 CompoundStmt * Mutator::mutate( CompoundStmt *compoundStmt ) {
    101         mutateAll( compoundStmt->get_kids(), *this );
    102         return compoundStmt;
    103 }
    104 
    105 Statement * Mutator::mutate( ExprStmt *exprStmt ) {
    106         exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) );
    107         return exprStmt;
    108 }
    109 
    110 Statement * Mutator::mutate( AsmStmt *asmStmt ) {
    111         asmStmt->set_instruction( maybeMutate( asmStmt->get_instruction(), *this ) );
    112         mutateAll( asmStmt->get_output(), *this );
    113         mutateAll( asmStmt->get_input(), *this );
    114         mutateAll( asmStmt->get_clobber(), *this );
    115         return asmStmt;
    116 }
    117 
    118 Statement * Mutator::mutate( IfStmt *ifStmt ) {
    119         mutateAll( ifStmt->get_initialization(), *this );
    120         ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) );
    121         ifStmt->set_thenPart( maybeMutate( ifStmt->get_thenPart(), *this ) );
    122         ifStmt->set_elsePart( maybeMutate( ifStmt->get_elsePart(), *this ) );
    123         return ifStmt;
    124 }
    125 
    126 Statement * Mutator::mutate( WhileStmt *whileStmt ) {
    127         whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) );
    128         whileStmt->set_body( maybeMutate( whileStmt->get_body(), *this ) );
    129         return whileStmt;
    130 }
    131 
    132 Statement * Mutator::mutate( ForStmt *forStmt ) {
    133         mutateAll( forStmt->get_initialization(), *this );
    134         forStmt->set_condition( maybeMutate( forStmt->get_condition(), *this ) );
    135         forStmt->set_increment( maybeMutate( forStmt->get_increment(), *this ) );
    136         forStmt->set_body( maybeMutate( forStmt->get_body(), *this ) );
    137         return forStmt;
    138 }
    139 
    140 Statement * Mutator::mutate( SwitchStmt *switchStmt ) {
    141         switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
    142         mutateAll( switchStmt->get_statements(), *this );
    143         return switchStmt;
    144 }
    145 
    146 Statement * Mutator::mutate( CaseStmt *caseStmt ) {
    147         caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) );
    148         mutateAll (caseStmt->get_statements(), *this );
    149 
    150         return caseStmt;
    151 }
    152 
    153 Statement * Mutator::mutate( BranchStmt *branchStmt ) {
    154         return branchStmt;
    155 }
    156 
    157 Statement * Mutator::mutate( ReturnStmt *returnStmt ) {
    158         returnStmt->set_expr( maybeMutate( returnStmt->get_expr(), *this ) );
    159         return returnStmt;
    160 }
    161 
    162 Statement * Mutator::mutate( ThrowStmt *throwStmt ) {
    163         throwStmt->set_expr( maybeMutate( throwStmt->get_expr(), *this ) );
    164         throwStmt->set_target( maybeMutate( throwStmt->get_target(), *this ) );
    165         return throwStmt;
    166 }
    167 
    168 Statement * Mutator::mutate( TryStmt *tryStmt ) {
    169         tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
    170         mutateAll( tryStmt->get_catchers(), *this );
    171         tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );
    172         return tryStmt;
    173 }
    174 
    175 Statement * Mutator::mutate( CatchStmt *catchStmt ) {
    176         catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
    177         catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );
    178         catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) );
    179         return catchStmt;
    180 }
    181 
    182 Statement * Mutator::mutate( FinallyStmt *finalStmt ) {
    183         finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) );
    184         return finalStmt;
    185 }
    186 
    187 Statement * Mutator::mutate( WaitForStmt *waitforStmt ) {
    188         for( auto & clause : waitforStmt->clauses ) {
    189                 clause.target.function = maybeMutate( clause.target.function, *this );
    190                 mutateAll( clause.target.arguments, *this );
    191 
    192                 clause.statement = maybeMutate( clause.statement, *this );
    193                 clause.condition = maybeMutate( clause.condition, *this );
    194         }
    195 
    196         waitforStmt->timeout.time      = maybeMutate( waitforStmt->timeout.time, *this );
    197         waitforStmt->timeout.statement = maybeMutate( waitforStmt->timeout.statement, *this );
    198         waitforStmt->timeout.condition = maybeMutate( waitforStmt->timeout.condition, *this );
    199         waitforStmt->orelse.statement  = maybeMutate( waitforStmt->orelse.statement, *this );
    200         waitforStmt->orelse.condition  = maybeMutate( waitforStmt->orelse.condition, *this );
    201 
    202         return waitforStmt;
    203 }
    204 
    205 Statement * Mutator::mutate( WithStmt * withStmt ) {
    206         mutateAll( withStmt->exprs, *this );
    207         withStmt->stmt = maybeMutate( withStmt->stmt, *this );
    208         return withStmt;
    209 }
    210 
    211 NullStmt * Mutator::mutate( NullStmt *nullStmt ) {
    212         return nullStmt;
    213 }
    214 
    215 Statement * Mutator::mutate( DeclStmt *declStmt ) {
    216         declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) );
    217         return declStmt;
    218 }
    219 
    220 Statement * Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
    221         impCtorDtorStmt->set_callStmt( maybeMutate( impCtorDtorStmt->get_callStmt(), *this ) );
    222         return impCtorDtorStmt;
    223 }
    224 
    225 
    226 Expression * Mutator::mutate( ApplicationExpr *applicationExpr ) {
    227         applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) );
    228         applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
    229         applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
    230         mutateAll( applicationExpr->get_args(), *this );
    231         return applicationExpr;
    232 }
    233 
    234 Expression * Mutator::mutate( UntypedExpr *untypedExpr ) {
    235         untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) );
    236         untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
    237         mutateAll( untypedExpr->get_args(), *this );
    238         return untypedExpr;
    239 }
    240 
    241 Expression * Mutator::mutate( NameExpr *nameExpr ) {
    242         nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) );
    243         nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
    244         return nameExpr;
    245 }
    246 
    247 Expression * Mutator::mutate( AddressExpr *addressExpr ) {
    248         addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) );
    249         addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
    250         addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
    251         return addressExpr;
    252 }
    253 
    254 Expression * Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
    255         labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) );
    256         labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
    257         return labelAddressExpr;
    258 }
    259 
    260 Expression * Mutator::mutate( CastExpr *castExpr ) {
    261         castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
    262         castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
    263         castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
    264         return castExpr;
    265 }
    266 
    267 Expression * Mutator::mutate( VirtualCastExpr *castExpr ) {
    268         castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
    269         castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
    270         castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
    271         return castExpr;
    272 }
    273 
    274 Expression * Mutator::mutate( UntypedMemberExpr *memberExpr ) {
    275         memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
    276         memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
    277         memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    278         memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) );
    279         return memberExpr;
    280 }
    281 
    282 Expression * Mutator::mutate( MemberExpr *memberExpr ) {
    283         memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
    284         memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
    285         memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    286         return memberExpr;
    287 }
    288 
    289 Expression * Mutator::mutate( VariableExpr *variableExpr ) {
    290         variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) );
    291         variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
    292         return variableExpr;
    293 }
    294 
    295 Expression * Mutator::mutate( ConstantExpr *constantExpr ) {
    296         constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) );
    297         constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
    298 //  maybeMutate( constantExpr->get_constant(), *this )
    299         return constantExpr;
    300 }
    301 
    302 Expression * Mutator::mutate( SizeofExpr *sizeofExpr ) {
    303         sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) );
    304         sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
    305         if ( sizeofExpr->get_isType() ) {
    306                 sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
    307         } else {
    308                 sizeofExpr->set_expr( maybeMutate( sizeofExpr->get_expr(), *this ) );
    309         }
    310         return sizeofExpr;
    311 }
    312 
    313 Expression * Mutator::mutate( AlignofExpr *alignofExpr ) {
    314         alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) );
    315         alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
    316         if ( alignofExpr->get_isType() ) {
    317                 alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
    318         } else {
    319                 alignofExpr->set_expr( maybeMutate( alignofExpr->get_expr(), *this ) );
    320         }
    321         return alignofExpr;
    322 }
    323 
    324 Expression * Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
    325         offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
    326         offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
    327         offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    328         return offsetofExpr;
    329 }
    330 
    331 Expression * Mutator::mutate( OffsetofExpr *offsetofExpr ) {
    332         offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
    333         offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
    334         offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    335         offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
    336         return offsetofExpr;
    337 }
    338 
    339 Expression * Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
    340         offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) );
    341         offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
    342         offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
    343         return offsetPackExpr;
    344 }
    345 
    346 Expression * Mutator::mutate( AttrExpr *attrExpr ) {
    347         attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) );
    348         attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
    349         if ( attrExpr->get_isType() ) {
    350                 attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
    351         } else {
    352                 attrExpr->set_expr( maybeMutate( attrExpr->get_expr(), *this ) );
    353         }
    354         return attrExpr;
    355 }
    356 
    357 Expression * Mutator::mutate( LogicalExpr *logicalExpr ) {
    358         logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) );
    359         logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
    360         logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
    361         logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
    362         return logicalExpr;
    363 }
    364 
    365 Expression * Mutator::mutate( ConditionalExpr *conditionalExpr ) {
    366         conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) );
    367         conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
    368         conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
    369         conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
    370         conditionalExpr->set_arg3( maybeMutate( conditionalExpr->get_arg3(), *this ) );
    371         return conditionalExpr;
    372 }
    373 
    374 Expression * Mutator::mutate( CommaExpr *commaExpr ) {
    375         commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) );
    376         commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
    377         commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
    378         commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
    379         return commaExpr;
    380 }
    381 
    382 Expression * Mutator::mutate( TypeExpr *typeExpr ) {
    383         typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) );
    384         typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
    385         typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
    386         return typeExpr;
    387 }
    388 
    389 Expression * Mutator::mutate( AsmExpr *asmExpr ) {
    390         asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) );
    391         asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) );
    392         asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) );
    393         asmExpr->set_operand( maybeMutate( asmExpr->get_operand(), *this ) );
    394         return asmExpr;
    395 }
    396 
    397 Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
    398         impCpCtorExpr->set_env( maybeMutate( impCpCtorExpr->get_env(), *this ) );
    399         impCpCtorExpr->set_result( maybeMutate( impCpCtorExpr->get_result(), *this ) );
    400         impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );
    401         mutateAll( impCpCtorExpr->get_tempDecls(), *this );
    402         mutateAll( impCpCtorExpr->get_returnDecls(), *this );
    403         mutateAll( impCpCtorExpr->get_dtors(), *this );
    404         return impCpCtorExpr;
    405 }
    406 
    407 Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
    408         ctorExpr->set_env( maybeMutate( ctorExpr->get_env(), *this ) );
    409         ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
    410         ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
    411         return ctorExpr;
    412 }
    413 
    414 Expression * Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
    415         compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
    416         compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
    417         compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
    418         return compLitExpr;
    419 }
    420 
    421 Expression * Mutator::mutate( RangeExpr *rangeExpr ) {
    422         rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
    423         rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
    424         rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
    425         return rangeExpr;
    426 }
    427 
    428 Expression * Mutator::mutate( UntypedTupleExpr *tupleExpr ) {
    429         tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    430         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    431         mutateAll( tupleExpr->get_exprs(), *this );
    432         return tupleExpr;
    433 }
    434 
    435 Expression * Mutator::mutate( TupleExpr *tupleExpr ) {
    436         tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    437         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    438         mutateAll( tupleExpr->get_exprs(), *this );
    439         return tupleExpr;
    440 }
    441 
    442 Expression * Mutator::mutate( TupleIndexExpr *tupleExpr ) {
    443         tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    444         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    445         tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
    446         return tupleExpr;
    447 }
    448 
    449 Expression * Mutator::mutate( TupleAssignExpr *assignExpr ) {
    450         assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) );
    451         assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
    452         assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) );
    453         return assignExpr;
    454 }
    455 
    456 Expression * Mutator::mutate( StmtExpr *stmtExpr ) {
    457         stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) );
    458         stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
    459         stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
    460         mutateAll( stmtExpr->get_returnDecls(), *this );
    461         mutateAll( stmtExpr->get_dtors(), *this );
    462         return stmtExpr;
    463 }
    464 
    465 Expression * Mutator::mutate( UniqueExpr *uniqueExpr ) {
    466         uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) );
    467         uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
    468         uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) );
    469         return uniqueExpr;
    470 }
    471 
    472 Expression * Mutator::mutate( UntypedInitExpr * initExpr ) {
    473         initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
    474         initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
    475         initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
    476         // not currently mutating initAlts, but this doesn't matter since this node is only used in the resolver.
    477         return initExpr;
    478 }
    479 
    480 Expression * Mutator::mutate( InitExpr * initExpr ) {
    481         initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
    482         initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
    483         initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
    484         initExpr->set_designation( maybeMutate( initExpr->get_designation(), *this ) );
    485         return initExpr;
    486 }
    487 
    488 
    489 Type * Mutator::mutate( VoidType *voidType ) {
    490         mutateAll( voidType->get_forall(), *this );
    491         return voidType;
    492 }
    493 
    494 Type * Mutator::mutate( BasicType *basicType ) {
    495         mutateAll( basicType->get_forall(), *this );
    496         return basicType;
    497 }
    498 
    499 Type * Mutator::mutate( PointerType *pointerType ) {
    500         mutateAll( pointerType->get_forall(), *this );
    501         pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) );
    502         return pointerType;
    503 }
    504 
    505 Type * Mutator::mutate( ArrayType *arrayType ) {
    506         mutateAll( arrayType->get_forall(), *this );
    507         arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) );
    508         arrayType->set_base( maybeMutate( arrayType->get_base(), *this ) );
    509         return arrayType;
    510 }
    511 
    512 Type * Mutator::mutate( ReferenceType * refType ) {
    513         mutateAll( refType->get_forall(), *this );
    514         refType->set_base( maybeMutate( refType->get_base(), *this ) );
    515         return refType;
    516 }
    517 
    518 Type * Mutator::mutate( FunctionType * functionType ) {
    519         mutateAll( functionType->get_forall(), *this );
    520         mutateAll( functionType->get_returnVals(), *this );
    521         mutateAll( functionType->get_parameters(), *this );
    522         return functionType;
    523 }
    524 
    525 Type * Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {
    526         mutateAll( aggregateUseType->get_forall(), *this );
    527         mutateAll( aggregateUseType->get_parameters(), *this );
    528         return aggregateUseType;
    529 }
    530 
    531 Type * Mutator::mutate( StructInstType *aggregateUseType ) {
    532         handleReferenceToType( aggregateUseType );
    533         return aggregateUseType;
    534 }
    535 
    536 Type * Mutator::mutate( UnionInstType *aggregateUseType ) {
    537         handleReferenceToType( aggregateUseType );
    538         return aggregateUseType;
    539 }
    540 
    541 Type * Mutator::mutate( EnumInstType *aggregateUseType ) {
    542         handleReferenceToType( aggregateUseType );
    543         return aggregateUseType;
    544 }
    545 
    546 Type * Mutator::mutate( TraitInstType *aggregateUseType ) {
    547         handleReferenceToType( aggregateUseType );
    548         return aggregateUseType;
    549 }
    550 
    551 Type * Mutator::mutate( TypeInstType *aggregateUseType ) {
    552         handleReferenceToType( aggregateUseType );
    553         return aggregateUseType;
    554 }
    55534
    55635Type * Mutator::mutate( TupleType *tupleType ) {
  • src/SynTree/Mutator.h

    r86e84e4 rcfaf9be  
    2525        virtual ~Mutator();
    2626  public:
    27         virtual DeclarationWithType * mutate( ObjectDecl * objectDecl );
    28         virtual DeclarationWithType * mutate( FunctionDecl * functionDecl );
    29         virtual Declaration * mutate( StructDecl * aggregateDecl );
    30         virtual Declaration * mutate( UnionDecl * aggregateDecl );
    31         virtual Declaration * mutate( EnumDecl * aggregateDecl );
    32         virtual Declaration * mutate( TraitDecl * aggregateDecl );
    33         virtual Declaration * mutate( TypeDecl * typeDecl );
    34         virtual Declaration * mutate( TypedefDecl * typeDecl );
    35         virtual AsmDecl * mutate( AsmDecl * asmDecl );
     27        virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) = 0;
     28        virtual DeclarationWithType * mutate( FunctionDecl * functionDecl ) = 0;
     29        virtual Declaration * mutate( StructDecl * aggregateDecl ) = 0;
     30        virtual Declaration * mutate( UnionDecl * aggregateDecl ) = 0;
     31        virtual Declaration * mutate( EnumDecl * aggregateDecl ) = 0;
     32        virtual Declaration * mutate( TraitDecl * aggregateDecl ) = 0;
     33        virtual Declaration * mutate( TypeDecl * typeDecl ) = 0;
     34        virtual Declaration * mutate( TypedefDecl * typeDecl ) = 0;
     35        virtual AsmDecl * mutate( AsmDecl * asmDecl ) = 0;
    3636
    37         virtual CompoundStmt * mutate( CompoundStmt * compoundStmt );
    38         virtual Statement * mutate( ExprStmt * exprStmt );
    39         virtual Statement * mutate( AsmStmt * asmStmt );
    40         virtual Statement * mutate( IfStmt * ifStmt );
    41         virtual Statement * mutate( WhileStmt * whileStmt );
    42         virtual Statement * mutate( ForStmt * forStmt );
    43         virtual Statement * mutate( SwitchStmt * switchStmt );
    44         virtual Statement * mutate( CaseStmt * caseStmt );
    45         virtual Statement * mutate( BranchStmt * branchStmt );
    46         virtual Statement * mutate( ReturnStmt * returnStmt );
    47         virtual Statement * mutate( ThrowStmt * throwStmt );
    48         virtual Statement * mutate( TryStmt * tryStmt );
    49         virtual Statement * mutate( CatchStmt * catchStmt );
    50         virtual Statement * mutate( FinallyStmt * catchStmt );
    51         virtual Statement * mutate( WaitForStmt * waitforStmt );
    52         virtual Statement * mutate( WithStmt * withStmt );
    53         virtual NullStmt * mutate( NullStmt * nullStmt );
    54         virtual Statement * mutate( DeclStmt * declStmt );
    55         virtual Statement * mutate( ImplicitCtorDtorStmt * impCtorDtorStmt );
     37        virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) = 0;
     38        virtual Statement * mutate( ExprStmt * exprStmt ) = 0;
     39        virtual Statement * mutate( AsmStmt * asmStmt ) = 0;
     40        virtual Statement * mutate( IfStmt * ifStmt ) = 0;
     41        virtual Statement * mutate( WhileStmt * whileStmt ) = 0;
     42        virtual Statement * mutate( ForStmt * forStmt ) = 0;
     43        virtual Statement * mutate( SwitchStmt * switchStmt ) = 0;
     44        virtual Statement * mutate( CaseStmt * caseStmt ) = 0;
     45        virtual Statement * mutate( BranchStmt * branchStmt ) = 0;
     46        virtual Statement * mutate( ReturnStmt * returnStmt ) = 0;
     47        virtual Statement * mutate( ThrowStmt * throwStmt ) = 0;
     48        virtual Statement * mutate( TryStmt * tryStmt ) = 0;
     49        virtual Statement * mutate( CatchStmt * catchStmt ) = 0;
     50        virtual Statement * mutate( FinallyStmt * catchStmt ) = 0;
     51        virtual Statement * mutate( WaitForStmt * waitforStmt ) = 0;
     52        virtual Statement * mutate( WithStmt * withStmt ) = 0;
     53        virtual NullStmt * mutate( NullStmt * nullStmt ) = 0;
     54        virtual Statement * mutate( DeclStmt * declStmt ) = 0;
     55        virtual Statement * mutate( ImplicitCtorDtorStmt * impCtorDtorStmt ) = 0;
    5656
    57         virtual Expression * mutate( ApplicationExpr * applicationExpr );
    58         virtual Expression * mutate( UntypedExpr * untypedExpr );
    59         virtual Expression * mutate( NameExpr * nameExpr );
    60         virtual Expression * mutate( AddressExpr * castExpr );
    61         virtual Expression * mutate( LabelAddressExpr * labAddressExpr );
    62         virtual Expression * mutate( CastExpr * castExpr );
    63         virtual Expression * mutate( VirtualCastExpr * castExpr );
    64         virtual Expression * mutate( UntypedMemberExpr * memberExpr );
    65         virtual Expression * mutate( MemberExpr * memberExpr );
    66         virtual Expression * mutate( VariableExpr * variableExpr );
    67         virtual Expression * mutate( ConstantExpr * constantExpr );
    68         virtual Expression * mutate( SizeofExpr * sizeofExpr );
    69         virtual Expression * mutate( AlignofExpr * alignofExpr );
    70         virtual Expression * mutate( UntypedOffsetofExpr * offsetofExpr );
    71         virtual Expression * mutate( OffsetofExpr * offsetofExpr );
    72         virtual Expression * mutate( OffsetPackExpr * offsetPackExpr );
    73         virtual Expression * mutate( AttrExpr * attrExpr );
    74         virtual Expression * mutate( LogicalExpr * logicalExpr );
    75         virtual Expression * mutate( ConditionalExpr * conditionalExpr );
    76         virtual Expression * mutate( CommaExpr * commaExpr );
    77         virtual Expression * mutate( TypeExpr * typeExpr );
    78         virtual Expression * mutate( AsmExpr * asmExpr );
    79         virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr );
    80         virtual Expression * mutate( ConstructorExpr * ctorExpr );
    81         virtual Expression * mutate( CompoundLiteralExpr * compLitExpr );
    82         virtual Expression * mutate( RangeExpr * rangeExpr );
    83         virtual Expression * mutate( UntypedTupleExpr * tupleExpr );
    84         virtual Expression * mutate( TupleExpr * tupleExpr );
    85         virtual Expression * mutate( TupleIndexExpr * tupleExpr );
    86         virtual Expression * mutate( TupleAssignExpr * assignExpr );
    87         virtual Expression * mutate( StmtExpr  * stmtExpr );
    88         virtual Expression * mutate( UniqueExpr  * uniqueExpr );
    89         virtual Expression * mutate( UntypedInitExpr  * initExpr );
    90         virtual Expression * mutate( InitExpr  * initExpr );
     57        virtual Expression * mutate( ApplicationExpr * applicationExpr ) = 0;
     58        virtual Expression * mutate( UntypedExpr * untypedExpr ) = 0;
     59        virtual Expression * mutate( NameExpr * nameExpr ) = 0;
     60        virtual Expression * mutate( AddressExpr * castExpr ) = 0;
     61        virtual Expression * mutate( LabelAddressExpr * labAddressExpr ) = 0;
     62        virtual Expression * mutate( CastExpr * castExpr ) = 0;
     63        virtual Expression * mutate( VirtualCastExpr * castExpr ) = 0;
     64        virtual Expression * mutate( UntypedMemberExpr * memberExpr ) = 0;
     65        virtual Expression * mutate( MemberExpr * memberExpr ) = 0;
     66        virtual Expression * mutate( VariableExpr * variableExpr ) = 0;
     67        virtual Expression * mutate( ConstantExpr * constantExpr ) = 0;
     68        virtual Expression * mutate( SizeofExpr * sizeofExpr ) = 0;
     69        virtual Expression * mutate( AlignofExpr * alignofExpr ) = 0;
     70        virtual Expression * mutate( UntypedOffsetofExpr * offsetofExpr ) = 0;
     71        virtual Expression * mutate( OffsetofExpr * offsetofExpr ) = 0;
     72        virtual Expression * mutate( OffsetPackExpr * offsetPackExpr ) = 0;
     73        virtual Expression * mutate( AttrExpr * attrExpr ) = 0;
     74        virtual Expression * mutate( LogicalExpr * logicalExpr ) = 0;
     75        virtual Expression * mutate( ConditionalExpr * conditionalExpr ) = 0;
     76        virtual Expression * mutate( CommaExpr * commaExpr ) = 0;
     77        virtual Expression * mutate( TypeExpr * typeExpr ) = 0;
     78        virtual Expression * mutate( AsmExpr * asmExpr ) = 0;
     79        virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) = 0;
     80        virtual Expression * mutate( ConstructorExpr * ctorExpr ) = 0;
     81        virtual Expression * mutate( CompoundLiteralExpr * compLitExpr ) = 0;
     82        virtual Expression * mutate( RangeExpr * rangeExpr ) = 0;
     83        virtual Expression * mutate( UntypedTupleExpr * tupleExpr ) = 0;
     84        virtual Expression * mutate( TupleExpr * tupleExpr ) = 0;
     85        virtual Expression * mutate( TupleIndexExpr * tupleExpr ) = 0;
     86        virtual Expression * mutate( TupleAssignExpr * assignExpr ) = 0;
     87        virtual Expression * mutate( StmtExpr  * stmtExpr ) = 0;
     88        virtual Expression * mutate( UniqueExpr  * uniqueExpr ) = 0;
     89        virtual Expression * mutate( UntypedInitExpr  * initExpr ) = 0;
     90        virtual Expression * mutate( InitExpr  * initExpr ) = 0;
    9191        virtual Expression * mutate( DeletedExpr * delExpr ) = 0;
    9292
    93         virtual Type * mutate( VoidType * basicType );
    94         virtual Type * mutate( BasicType * basicType );
    95         virtual Type * mutate( PointerType * pointerType );
    96         virtual Type * mutate( ArrayType * arrayType );
    97         virtual Type * mutate( ReferenceType * refType );
    98         virtual Type * mutate( FunctionType * functionType );
    99         virtual Type * mutate( StructInstType * aggregateUseType );
    100         virtual Type * mutate( UnionInstType * aggregateUseType );
    101         virtual Type * mutate( EnumInstType * aggregateUseType );
    102         virtual Type * mutate( TraitInstType * aggregateUseType );
    103         virtual Type * mutate( TypeInstType * aggregateUseType );
    104         virtual Type * mutate( TupleType * tupleType );
    105         virtual Type * mutate( TypeofType * typeofType );
    106         virtual Type * mutate( AttrType * attrType );
    107         virtual Type * mutate( VarArgsType * varArgsType );
    108         virtual Type * mutate( ZeroType * zeroType );
    109         virtual Type * mutate( OneType * oneType );
     93        virtual Type * mutate( VoidType * basicType ) = 0;
     94        virtual Type * mutate( BasicType * basicType ) = 0;
     95        virtual Type * mutate( PointerType * pointerType ) = 0;
     96        virtual Type * mutate( ArrayType * arrayType ) = 0;
     97        virtual Type * mutate( ReferenceType * refType ) = 0;
     98        virtual Type * mutate( FunctionType * functionType ) = 0;
     99        virtual Type * mutate( StructInstType * aggregateUseType ) = 0;
     100        virtual Type * mutate( UnionInstType * aggregateUseType ) = 0;
     101        virtual Type * mutate( EnumInstType * aggregateUseType ) = 0;
     102        virtual Type * mutate( TraitInstType * aggregateUseType ) = 0;
     103        virtual Type * mutate( TypeInstType * aggregateUseType ) = 0;
     104        virtual Type * mutate( TupleType * tupleType ) = 0;
     105        virtual Type * mutate( TypeofType * typeofType ) = 0;
     106        virtual Type * mutate( AttrType * attrType ) = 0;
     107        virtual Type * mutate( VarArgsType * varArgsType ) = 0;
     108        virtual Type * mutate( ZeroType * zeroType ) = 0;
     109        virtual Type * mutate( OneType * oneType ) = 0;
    110110
    111         virtual Designation * mutate( Designation * designation );
    112         virtual Initializer * mutate( SingleInit * singleInit );
    113         virtual Initializer * mutate( ListInit * listInit );
    114         virtual Initializer * mutate( ConstructorInit * ctorInit );
     111        virtual Designation * mutate( Designation * designation ) = 0 ;
     112        virtual Initializer * mutate( SingleInit * singleInit ) = 0 ;
     113        virtual Initializer * mutate( ListInit * listInit ) = 0 ;
     114        virtual Initializer * mutate( ConstructorInit * ctorInit ) = 0 ;
    115115
    116         virtual Subrange * mutate( Subrange * subrange );
     116        virtual Subrange * mutate( Subrange * subrange ) = 0;
    117117
    118         virtual Constant * mutate( Constant * constant );
     118        virtual Constant * mutate( Constant * constant ) = 0;
    119119
    120         virtual Attribute * mutate( Attribute * attribute );
     120        virtual Attribute * mutate( Attribute * attribute ) = 0;
    121121
    122         virtual TypeSubstitution * mutate( TypeSubstitution * sub );
    123   private:
    124         virtual Declaration * handleAggregateDecl(AggregateDecl * aggregateDecl );
    125         virtual Declaration * handleNamedTypeDecl(NamedTypeDecl * typeDecl );
    126         virtual Type * handleReferenceToType(ReferenceToType * aggregateUseType );
     122        virtual TypeSubstitution * mutate( TypeSubstitution * sub ) = 0;
    127123};
    128124
  • src/SynTree/Visitor.cc

    r86e84e4 rcfaf9be  
    3131
    3232Visitor::~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 }
    44333
    44434void Visitor::visit( TupleType *tupleType ) {
  • src/SynTree/Visitor.h

    r86e84e4 rcfaf9be  
    2727        // of the given syntax node, but performs no other action.
    2828
    29         virtual void visit( ObjectDecl * objectDecl );
    30         virtual void visit( FunctionDecl * functionDecl );
    31         virtual void visit( StructDecl * aggregateDecl );
    32         virtual void visit( UnionDecl * aggregateDecl );
    33         virtual void visit( EnumDecl * aggregateDecl );
    34         virtual void visit( TraitDecl * aggregateDecl );
    35         virtual void visit( TypeDecl * typeDecl );
    36         virtual void visit( TypedefDecl * typeDecl );
    37         virtual void visit( AsmDecl * asmDecl );
     29        virtual void visit( ObjectDecl * objectDecl ) = 0;
     30        virtual void visit( FunctionDecl * functionDecl ) = 0;
     31        virtual void visit( StructDecl * aggregateDecl ) = 0;
     32        virtual void visit( UnionDecl * aggregateDecl ) = 0;
     33        virtual void visit( EnumDecl * aggregateDecl ) = 0;
     34        virtual void visit( TraitDecl * aggregateDecl ) = 0;
     35        virtual void visit( TypeDecl * typeDecl ) = 0;
     36        virtual void visit( TypedefDecl * typeDecl ) = 0;
     37        virtual void visit( AsmDecl * asmDecl ) = 0;
    3838
    39         virtual void visit( CompoundStmt * compoundStmt );
    40         virtual void visit( ExprStmt * exprStmt );
    41         virtual void visit( AsmStmt * asmStmt );
    42         virtual void visit( IfStmt * ifStmt );
    43         virtual void visit( WhileStmt * whileStmt );
    44         virtual void visit( ForStmt * forStmt );
    45         virtual void visit( SwitchStmt * switchStmt );
    46         virtual void visit( CaseStmt * caseStmt );
    47         virtual void visit( BranchStmt * branchStmt );
    48         virtual void visit( ReturnStmt * returnStmt );
    49         virtual void visit( ThrowStmt * throwStmt );
    50         virtual void visit( TryStmt * tryStmt );
    51         virtual void visit( CatchStmt * catchStmt );
    52         virtual void visit( FinallyStmt * finallyStmt );
    53         virtual void visit( WaitForStmt * waitforStmt );
    54         virtual void visit( WithStmt * withStmt );
    55         virtual void visit( NullStmt * nullStmt );
    56         virtual void visit( DeclStmt * declStmt );
    57         virtual void visit( ImplicitCtorDtorStmt * impCtorDtorStmt );
     39        virtual void visit( CompoundStmt * compoundStmt ) = 0;
     40        virtual void visit( ExprStmt * exprStmt ) = 0;
     41        virtual void visit( AsmStmt * asmStmt ) = 0;
     42        virtual void visit( IfStmt * ifStmt ) = 0;
     43        virtual void visit( WhileStmt * whileStmt ) = 0;
     44        virtual void visit( ForStmt * forStmt ) = 0;
     45        virtual void visit( SwitchStmt * switchStmt ) = 0;
     46        virtual void visit( CaseStmt * caseStmt ) = 0;
     47        virtual void visit( BranchStmt * branchStmt ) = 0;
     48        virtual void visit( ReturnStmt * returnStmt ) = 0;
     49        virtual void visit( ThrowStmt * throwStmt ) = 0;
     50        virtual void visit( TryStmt * tryStmt ) = 0;
     51        virtual void visit( CatchStmt * catchStmt ) = 0;
     52        virtual void visit( FinallyStmt * finallyStmt ) = 0;
     53        virtual void visit( WaitForStmt * waitforStmt ) = 0;
     54        virtual void visit( WithStmt * withStmt ) = 0;
     55        virtual void visit( NullStmt * nullStmt ) = 0;
     56        virtual void visit( DeclStmt * declStmt ) = 0;
     57        virtual void visit( ImplicitCtorDtorStmt * impCtorDtorStmt ) = 0;
    5858
    59         virtual void visit( ApplicationExpr * applicationExpr );
    60         virtual void visit( UntypedExpr * untypedExpr );
    61         virtual void visit( NameExpr * nameExpr );
    62         virtual void visit( CastExpr * castExpr );
    63         virtual void visit( VirtualCastExpr * castExpr );
    64         virtual void visit( AddressExpr * addressExpr );
    65         virtual void visit( LabelAddressExpr * labAddressExpr );
    66         virtual void visit( UntypedMemberExpr * memberExpr );
    67         virtual void visit( MemberExpr * memberExpr );
    68         virtual void visit( VariableExpr * variableExpr );
    69         virtual void visit( ConstantExpr * constantExpr );
    70         virtual void visit( SizeofExpr * sizeofExpr );
    71         virtual void visit( AlignofExpr * alignofExpr );
    72         virtual void visit( UntypedOffsetofExpr * offsetofExpr );
    73         virtual void visit( OffsetofExpr * offsetofExpr );
    74         virtual void visit( OffsetPackExpr * offsetPackExpr );
    75         virtual void visit( AttrExpr * attrExpr );
    76         virtual void visit( LogicalExpr * logicalExpr );
    77         virtual void visit( ConditionalExpr * conditionalExpr );
    78         virtual void visit( CommaExpr * commaExpr );
    79         virtual void visit( TypeExpr * typeExpr );
    80         virtual void visit( AsmExpr * asmExpr );
    81         virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
    82         virtual void visit( ConstructorExpr *  ctorExpr );
    83         virtual void visit( CompoundLiteralExpr * compLitExpr );
    84         virtual void visit( RangeExpr * rangeExpr );
    85         virtual void visit( UntypedTupleExpr * tupleExpr );
    86         virtual void visit( TupleExpr * tupleExpr );
    87         virtual void visit( TupleIndexExpr * tupleExpr );
    88         virtual void visit( TupleAssignExpr * assignExpr );
    89         virtual void visit( StmtExpr *  stmtExpr );
    90         virtual void visit( UniqueExpr *  uniqueExpr );
    91         virtual void visit( UntypedInitExpr *  initExpr );
    92         virtual void visit( InitExpr *  initExpr );
     59        virtual void visit( ApplicationExpr * applicationExpr ) = 0;
     60        virtual void visit( UntypedExpr * untypedExpr ) = 0;
     61        virtual void visit( NameExpr * nameExpr ) = 0;
     62        virtual void visit( CastExpr * castExpr ) = 0;
     63        virtual void visit( VirtualCastExpr * castExpr ) = 0;
     64        virtual void visit( AddressExpr * addressExpr ) = 0;
     65        virtual void visit( LabelAddressExpr * labAddressExpr ) = 0;
     66        virtual void visit( UntypedMemberExpr * memberExpr ) = 0;
     67        virtual void visit( MemberExpr * memberExpr ) = 0;
     68        virtual void visit( VariableExpr * variableExpr ) = 0;
     69        virtual void visit( ConstantExpr * constantExpr ) = 0;
     70        virtual void visit( SizeofExpr * sizeofExpr ) = 0;
     71        virtual void visit( AlignofExpr * alignofExpr ) = 0;
     72        virtual void visit( UntypedOffsetofExpr * offsetofExpr ) = 0;
     73        virtual void visit( OffsetofExpr * offsetofExpr ) = 0;
     74        virtual void visit( OffsetPackExpr * offsetPackExpr ) = 0;
     75        virtual void visit( AttrExpr * attrExpr ) = 0;
     76        virtual void visit( LogicalExpr * logicalExpr ) = 0;
     77        virtual void visit( ConditionalExpr * conditionalExpr ) = 0;
     78        virtual void visit( CommaExpr * commaExpr ) = 0;
     79        virtual void visit( TypeExpr * typeExpr ) = 0;
     80        virtual void visit( AsmExpr * asmExpr ) = 0;
     81        virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) = 0;
     82        virtual void visit( ConstructorExpr *  ctorExpr ) = 0;
     83        virtual void visit( CompoundLiteralExpr * compLitExpr ) = 0;
     84        virtual void visit( RangeExpr * rangeExpr ) = 0;
     85        virtual void visit( UntypedTupleExpr * tupleExpr ) = 0;
     86        virtual void visit( TupleExpr * tupleExpr ) = 0;
     87        virtual void visit( TupleIndexExpr * tupleExpr ) = 0;
     88        virtual void visit( TupleAssignExpr * assignExpr ) = 0;
     89        virtual void visit( StmtExpr *  stmtExpr ) = 0;
     90        virtual void visit( UniqueExpr *  uniqueExpr ) = 0;
     91        virtual void visit( UntypedInitExpr *  initExpr ) = 0;
     92        virtual void visit( InitExpr *  initExpr ) = 0;
    9393        virtual void visit( DeletedExpr * delExpr ) = 0;
    9494
    95         virtual void visit( VoidType * basicType );
    96         virtual void visit( BasicType * basicType );
    97         virtual void visit( PointerType * pointerType );
    98         virtual void visit( ArrayType * arrayType );
    99         virtual void visit( ReferenceType * refType );
    100         virtual void visit( FunctionType * functionType );
    101         virtual void visit( StructInstType * aggregateUseType );
    102         virtual void visit( UnionInstType * aggregateUseType );
    103         virtual void visit( EnumInstType * aggregateUseType );
    104         virtual void visit( TraitInstType * aggregateUseType );
    105         virtual void visit( TypeInstType * aggregateUseType );
    106         virtual void visit( TupleType * tupleType );
    107         virtual void visit( TypeofType * typeofType );
    108         virtual void visit( AttrType * attrType );
    109         virtual void visit( VarArgsType * varArgsType );
    110         virtual void visit( ZeroType * zeroType );
    111         virtual void visit( OneType * oneType );
     95        virtual void visit( VoidType * basicType ) = 0;
     96        virtual void visit( BasicType * basicType ) = 0;
     97        virtual void visit( PointerType * pointerType ) = 0;
     98        virtual void visit( ArrayType * arrayType ) = 0;
     99        virtual void visit( ReferenceType * refType ) = 0;
     100        virtual void visit( FunctionType * functionType ) = 0;
     101        virtual void visit( StructInstType * aggregateUseType ) = 0;
     102        virtual void visit( UnionInstType * aggregateUseType ) = 0;
     103        virtual void visit( EnumInstType * aggregateUseType ) = 0;
     104        virtual void visit( TraitInstType * aggregateUseType ) = 0;
     105        virtual void visit( TypeInstType * aggregateUseType ) = 0;
     106        virtual void visit( TupleType * tupleType ) = 0;
     107        virtual void visit( TypeofType * typeofType ) = 0;
     108        virtual void visit( AttrType * attrType ) = 0;
     109        virtual void visit( VarArgsType * varArgsType ) = 0;
     110        virtual void visit( ZeroType * zeroType ) = 0;
     111        virtual void visit( OneType * oneType ) = 0;
    112112
    113         virtual void visit( Designation * designation );
    114         virtual void visit( SingleInit * singleInit );
    115         virtual void visit( ListInit * listInit );
    116         virtual void visit( ConstructorInit * ctorInit );
     113        virtual void visit( Designation * designation ) = 0;
     114        virtual void visit( SingleInit * singleInit ) = 0;
     115        virtual void visit( ListInit * listInit ) = 0;
     116        virtual void visit( ConstructorInit * ctorInit ) = 0;
    117117
    118         virtual void visit( Subrange * subrange );
     118        virtual void visit( Subrange * subrange ) = 0;
    119119
    120         virtual void visit( Constant * constant );
     120        virtual void visit( Constant * constant ) = 0;
    121121
    122         virtual void visit( Attribute * attribute );
    123   private:
    124         virtual void handleAggregateDecl( AggregateDecl *aggregateDecl );
    125         virtual void handleNamedTypeDecl( NamedTypeDecl *typeDecl );
    126         virtual void handleReferenceToType( ReferenceToType *aggregateUseType );
     122        virtual void visit( Attribute * attribute ) = 0;
    127123};
    128124
Note: See TracChangeset for help on using the changeset viewer.