Changeset b8524ca for src/Tuples


Ignore:
Timestamp:
Jun 20, 2019, 6:50:42 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
9af00d23
Parents:
234b1cb
Message:

new AST porting

  • mostly InitTweak? autogeneration
  • added some convenience methods
    • nullptr assignment for ast::ptr
    • convenience wrapper ctors for AddressExpr?, CastExpr? that draw location from first arg
Location:
src/Tuples
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/Explode.cc

    r234b1cb rb8524ca  
    133133                        if ( first ) {
    134134                                castAdded = true;
    135                                 const ast::Expr * tuple = new ast::TupleExpr(
    136                                         tupleExpr->location, std::move( exprs ) );
    137                                 return new ast::CastExpr( tuple->location,
    138                                         tuple, new ast::ReferenceType( tuple->result.get(), ast::CV::Qualifiers() ) );
     135                                const ast::Expr * tuple = new ast::TupleExpr{
     136                                        tupleExpr->location, std::move( exprs ) };
     137                                return new ast::CastExpr{ tuple, new ast::ReferenceType{ tuple->result } };
    139138                        } else {
    140139                                return new ast::TupleExpr( tupleExpr->location, std::move( exprs ) );
     
    145144                } else {
    146145                        castAdded = true;
    147                         return new ast::CastExpr( expr->location, expr,
    148                                 new ast::ReferenceType( expr->result, ast::CV::Qualifiers() ) );
     146                        return new ast::CastExpr{ expr, new ast::ReferenceType{ expr->result } };
    149147                }
    150148        }
     
    164162                        castAdded = false;
    165163                        const ast::Type * newType = getReferenceBase( newNode->result );
    166                         return new ast::CastExpr( newNode->location, node, newType );
     164                        return new ast::CastExpr{ newNode->location, node, newType };
    167165                }
    168166                return newNode;
     
    183181        expr = expr->accept( exploder );
    184182        if ( ! exploder.pass.foundUniqueExpr ) {
    185                 expr = new ast::CastExpr( expr->location, expr,
    186                         new ast::ReferenceType( expr->result, ast::CV::Qualifiers() ) );
     183                expr = new ast::CastExpr{ expr, new ast::ReferenceType{ expr->result } };
    187184        }
    188185        return expr;
  • src/Tuples/Explode.h

    r234b1cb rb8524ca  
    211211                        // Cast a reference away to a value-type to allow further explosion.
    212212                        if ( dynamic_cast< const ast::ReferenceType *>( local->result.get() ) ) {
    213                                 local = new ast::CastExpr( local->location, local, tupleType );
     213                                local = new ast::CastExpr{ local, tupleType };
    214214                        }
    215215                        // Now we have to go across the tuple via indexing.
  • src/Tuples/TupleAssignment.cc

    r234b1cb rb8524ca  
    464464                                        // resolve ctor/dtor for the new object
    465465                                        ast::ptr< ast::Init > ctorInit = ResolvExpr::resolveCtorInit(
    466                                                         InitTweak::genCtorInit( ret ), spotter.crntFinder.symtab );
     466                                                        InitTweak::genCtorInit( location, ret ), spotter.crntFinder.symtab );
    467467                                        // remove environments from subexpressions of stmtExpr
    468468                                        ast::Pass< EnvRemover > rm{ env };
     
    550550                                        // is && and RHS is lvalue
    551551                                        auto lhsType = lhsCand->expr->result.strict_as< ast::ReferenceType >();
    552                                         rhsCand->expr = new ast::CastExpr{
    553                                                 rhsCand->expr->location, rhsCand->expr, lhsType->base };
     552                                        rhsCand->expr = new ast::CastExpr{ rhsCand->expr, lhsType->base };
    554553                                        ast::ptr< ast::ObjectDecl > lobj = newObject( lhsNamer, lhsCand->expr );
    555554                                        ast::ptr< ast::ObjectDecl > robj = newObject( rhsNamer, rhsCand->expr );
     
    604603                                        if ( ! lhsCand->expr.as< ast::CastExpr >() ) {
    605604                                                lhsCand->expr = new ast::CastExpr{
    606                                                         lhsCand->expr->location, lhsCand->expr,
    607                                                         new ast::ReferenceType{ lhsCand->expr->result } };
     605                                                        lhsCand->expr, new ast::ReferenceType{ lhsCand->expr->result } };
    608606                                        }
    609607
     
    616614                                                if ( ! cand->expr->result.as< ast::ReferenceType >() ) {
    617615                                                        cand->expr = new ast::CastExpr{
    618                                                                 cand->expr->location, cand->expr,
    619                                                                 new ast::ReferenceType{ cand->expr->result } };
     616                                                                cand->expr, new ast::ReferenceType{ cand->expr->result } };
    620617                                                }
    621618                                        }
Note: See TracChangeset for help on using the changeset viewer.