Changeset e33f321 for src/SynTree


Ignore:
Timestamp:
Dec 21, 2016, 2:55:56 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
626dbc10
Parents:
8bf784a
Message:

mutate env on each expression type to ensure type mappings are up to date

Location:
src/SynTree
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Mutator.cc

    r8bf784a re33f321  
    2323#include "Constant.h"
    2424#include "Common/utility.h"
     25#include "TypeSubstitution.h"
    2526
    2627Mutator::Mutator() {}
     
    178179
    179180Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
     181        applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) );
    180182        applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
    181183        applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
     
    185187
    186188Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
     189        untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) );
    187190        untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
    188191        mutateAll( untypedExpr->get_args(), *this );
     
    191194
    192195Expression *Mutator::mutate( NameExpr *nameExpr ) {
     196        nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) );
    193197        nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
    194198        return nameExpr;
     
    196200
    197201Expression *Mutator::mutate( AddressExpr *addressExpr ) {
     202        addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) );
    198203        addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
    199204        addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
     
    202207
    203208Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
     209        labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) );
    204210        labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
    205211        labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
     
    208214
    209215Expression *Mutator::mutate( CastExpr *castExpr ) {
     216        castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
    210217        castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
    211218        castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
     
    214221
    215222Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
     223        memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
    216224        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
    217225        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
     
    221229
    222230Expression *Mutator::mutate( MemberExpr *memberExpr ) {
     231        memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
    223232        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
    224233        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
     
    227236
    228237Expression *Mutator::mutate( VariableExpr *variableExpr ) {
     238        variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) );
    229239        variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
    230240        return variableExpr;
     
    232242
    233243Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
     244        constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) );
    234245        constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
    235246//  maybeMutate( constantExpr->get_constant(), *this )
     
    238249
    239250Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
     251        sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) );
    240252        sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
    241253        if ( sizeofExpr->get_isType() ) {
     
    248260
    249261Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
     262        alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) );
    250263        alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
    251264        if ( alignofExpr->get_isType() ) {
     
    258271
    259272Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
     273        offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
    260274        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
    261275        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
     
    264278
    265279Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
     280        offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
    266281        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
    267282        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
     
    271286
    272287Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
     288        offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) );
    273289        offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
    274290        offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
     
    277293
    278294Expression *Mutator::mutate( AttrExpr *attrExpr ) {
     295        attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) );
    279296        attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
    280297        if ( attrExpr->get_isType() ) {
     
    287304
    288305Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
     306        logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) );
    289307        logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
    290308        logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
     
    294312
    295313Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
     314        conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) );
    296315        conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
    297316        conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
     
    302321
    303322Expression *Mutator::mutate( CommaExpr *commaExpr ) {
     323        commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) );
    304324        commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
    305325        commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
     
    309329
    310330Expression *Mutator::mutate( TypeExpr *typeExpr ) {
     331        typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) );
    311332        typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
    312333        typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
     
    315336
    316337Expression *Mutator::mutate( AsmExpr *asmExpr ) {
     338        asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) );
    317339        asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) );
    318340        asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) );
     
    322344
    323345Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
     346        impCpCtorExpr->set_env( maybeMutate( impCpCtorExpr->get_env(), *this ) );
    324347        impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );
    325348        mutateAll( impCpCtorExpr->get_tempDecls(), *this );
     
    330353
    331354Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
     355        ctorExpr->set_env( maybeMutate( ctorExpr->get_env(), *this ) );
    332356        ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
    333357        ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
     
    336360
    337361Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
     362        compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
    338363        compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
    339364        compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) );
     
    343368
    344369Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
     370        valofExpr->set_env( maybeMutate( valofExpr->get_env(), *this ) );
    345371        valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
    346372        return valofExpr;
     
    348374
    349375Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
     376        rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
    350377        rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
    351378        rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
     
    354381
    355382Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
     383        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    356384        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    357385        mutateAll( tupleExpr->get_exprs(), *this );
     
    360388
    361389Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) {
     390        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    362391        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    363392        tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
     
    366395
    367396Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) {
     397        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    368398        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    369399        tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) );
     
    373403
    374404Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) {
     405        assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) );
    375406        assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
    376407        assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) );
     
    379410
    380411Expression *Mutator::mutate( StmtExpr *stmtExpr ) {
     412        stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) );
    381413        stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
    382414        stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
     
    387419
    388420Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) {
     421        uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) );
    389422        uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
    390423        uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) );
  • src/SynTree/TypeSubstitution.cc

    r8bf784a re33f321  
    231231}
    232232
     233TypeSubstitution * TypeSubstitution::acceptMutator( Mutator & mutator ) {
     234        for ( auto & p : typeEnv ) {
     235                p.second = maybeMutate( p.second, mutator );
     236        }
     237        for ( auto & p : varEnv ) {
     238                p.second = maybeMutate( p.second, mutator );
     239        }
     240        return this;
     241}
     242
    233243void TypeSubstitution::print( std::ostream &os, int indent ) const {
    234244        os << std::string( indent, ' ' ) << "Types:" << std::endl;
  • src/SynTree/TypeSubstitution.h

    r8bf784a re33f321  
    5353
    5454        void normalize();
     55
     56        TypeSubstitution * acceptMutator( Mutator & mutator );
    5557
    5658        void print( std::ostream &os, int indent = 0 ) const;
Note: See TracChangeset for help on using the changeset viewer.