Changeset e67a82d for src/Tuples


Ignore:
Timestamp:
Aug 20, 2020, 11:48:15 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
d685cb0
Parents:
67ca73e (diff), 013b028 (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.
Message:

fix conflicts

Location:
src/Tuples
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/Explode.cc

    r67ca73e re67a82d  
    129129                        for ( const ast::Expr * expr : tupleExpr->exprs ) {
    130130                                exprs.emplace_back( applyCast( expr, false ) );
    131                                 //exprs.emplace_back( ast::ptr< ast::Expr >( applyCast( expr, false ) ) );
    132131                        }
    133132                        if ( first ) {
     
    148147        }
    149148
    150         const ast::Expr * postmutate( const ast::UniqueExpr * node ) {
     149        const ast::Expr * postvisit( const ast::UniqueExpr * node ) {
    151150                // move cast into unique expr so that the unique expr has type T& rather than
    152151                // type T. In particular, this transformation helps with generating the
     
    162161                        castAdded = false;
    163162                        const ast::Type * newType = getReferenceBase( newNode->result );
    164                         return new ast::CastExpr{ newNode->location, node, newType };
     163                        return new ast::CastExpr{ newNode->location, newNode, newType };
    165164                }
    166165                return newNode;
    167166        }
    168167
    169         const ast::Expr * postmutate( const ast::TupleIndexExpr * tupleExpr ) {
     168        const ast::Expr * postvisit( const ast::TupleIndexExpr * tupleExpr ) {
    170169                // tuple index expr needs to be rebuilt to ensure that the type of the
    171170                // field is consistent with the type of the tuple expr, since the field
     
    180179        ast::Pass<CastExploderCore> exploder;
    181180        expr = expr->accept( exploder );
    182         if ( ! exploder.pass.foundUniqueExpr ) {
     181        if ( ! exploder.core.foundUniqueExpr ) {
    183182                expr = new ast::CastExpr{ expr, new ast::ReferenceType{ expr->result } };
    184183        }
  • src/Tuples/Explode.h

    r67ca73e re67a82d  
    210210                        }
    211211                        // Cast a reference away to a value-type to allow further explosion.
    212                         if ( dynamic_cast< const ast::ReferenceType *>( local->result.get() ) ) {
     212                        if ( local->result.as< ast::ReferenceType >() ) {
    213213                                local = new ast::CastExpr{ local, tupleType };
    214214                        }
     
    220220                                // delete idx;
    221221                        }
    222                         // delete local;
    223222                }
    224223        } else {
  • src/Tuples/TupleAssignment.cc

    r67ca73e re67a82d  
    465465                                        // resolve ctor/dtor for the new object
    466466                                        ast::ptr< ast::Init > ctorInit = ResolvExpr::resolveCtorInit(
    467                                                         InitTweak::genCtorInit( location, ret ), spotter.crntFinder.symtab );
     467                                                        InitTweak::genCtorInit( location, ret ), spotter.crntFinder.localSyms );
    468468                                        // remove environments from subexpressions of stmtExpr
    469469                                        ast::Pass< EnvRemover > rm{ env };
     
    504504
    505505                        std::vector< ast::ptr< ast::Expr > > match() override {
    506                                 static UniqueName lhsNamer( "__massassign_L" );
    507                                 static UniqueName rhsNamer( "__massassign_R" );
     506                                // temporary workaround for new and old ast to coexist and avoid name collision
     507                                static UniqueName lhsNamer( "__massassign_Ln" );
     508                                static UniqueName rhsNamer( "__massassign_Rn" );
    508509                                // empty tuple case falls into this matcher
    509510                                assert( lhs.empty() ? rhs.empty() : rhs.size() <= 1 );
     
    534535
    535536                        std::vector< ast::ptr< ast::Expr > > match() override {
    536                                 static UniqueName lhsNamer( "__multassign_L" );
    537                                 static UniqueName rhsNamer( "__multassign_R" );
     537                                // temporary workaround for new and old ast to coexist and avoid name collision
     538                                static UniqueName lhsNamer( "__multassign_Ln" );
     539                                static UniqueName rhsNamer( "__multassign_Rn" );
    538540
    539541                                if ( lhs.size() != rhs.size() ) return {};
     
    560562                                        // resolve the cast expression so that rhsCand return type is bound by the cast
    561563                                        // type as needed, and transfer the resulting environment
    562                                         ResolvExpr::CandidateFinder finder{ spotter.crntFinder.symtab, env };
     564                                        ResolvExpr::CandidateFinder finder{ spotter.crntFinder.localSyms, env };
    563565                                        finder.find( rhsCand->expr, ResolvExpr::ResolvMode::withAdjustment() );
    564566                                        assert( finder.candidates.size() == 1 );
     
    609611                                        // explode the LHS so that each field of a tuple-valued expr is assigned
    610612                                        ResolvExpr::CandidateList lhs;
    611                                         explode( *lhsCand, crntFinder.symtab, back_inserter(lhs), true );
     613                                        explode( *lhsCand, crntFinder.localSyms, back_inserter(lhs), true );
    612614                                        for ( ResolvExpr::CandidateRef & cand : lhs ) {
    613615                                                // each LHS value must be a reference - some come in with a cast, if not
     
    629631                                                        if ( isTuple( rhsCand->expr ) ) {
    630632                                                                // multiple assignment
    631                                                                 explode( *rhsCand, crntFinder.symtab, back_inserter(rhs), true );
     633                                                                explode( *rhsCand, crntFinder.localSyms, back_inserter(rhs), true );
    632634                                                                matcher.reset(
    633635                                                                        new MultipleAssignMatcher{ *this, expr->location, lhs, rhs } );
     
    648650                                                        // multiple assignment
    649651                                                        ResolvExpr::CandidateList rhs;
    650                                                         explode( rhsCand, crntFinder.symtab, back_inserter(rhs), true );
     652                                                        explode( rhsCand, crntFinder.localSyms, back_inserter(rhs), true );
    651653                                                        matcher.reset(
    652654                                                                new MultipleAssignMatcher{ *this, expr->location, lhs, rhs } );
     
    678680                                )
    679681
    680                                 ResolvExpr::CandidateFinder finder{ crntFinder.symtab, matcher->env };
     682                                ResolvExpr::CandidateFinder finder{ crntFinder.localSyms, matcher->env };
    681683
    682684                                try {
  • src/Tuples/TupleExpansion.cc

    r67ca73e re67a82d  
    323323                std::vector<ast::ptr<ast::Type>> types;
    324324                ast::CV::Qualifiers quals{
    325                         ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue |
     325                        ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict |
    326326                        ast::CV::Atomic | ast::CV::Mutex };
    327327
  • src/Tuples/Tuples.cc

    r67ca73e re67a82d  
    4343        };
    4444        struct ImpurityDetectorIgnoreUnique : public ImpurityDetector {
     45                using ImpurityDetector::previsit;
    4546                void previsit( ast::UniqueExpr const * ) {
    4647                        visit_children = false;
     
    5253                ast::Pass<Detector> detector;
    5354                expr->accept( detector );
    54                 return detector.pass.maybeImpure;
     55                return detector.core.maybeImpure;
    5556        }
    5657} // namespace
Note: See TracChangeset for help on using the changeset viewer.