Changeset 65660bd for src/ResolvExpr


Ignore:
Timestamp:
Sep 22, 2016, 8:14:56 AM (9 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:
ac9ca96
Parents:
1132b62
git-author:
Rob Schluntz <rschlunt@…> (09/21/16 23:43:37)
git-committer:
Rob Schluntz <rschlunt@…> (09/22/16 08:14:56)
Message:

replace multiple-returning functions with tuple-returning functions, implement tuple ctor/dtor, allow N-arg tuple assignment

Location:
src/ResolvExpr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/ResolvExpr/Alternative.h

    r1132b62 r65660bd  
    4545                TypeEnvironment env;
    4646        };
    47 
    48         /// helper function used by explode
    49         template< typename OutputIterator >
    50         void explodeUnique( Expression * expr, const Alternative & alt, OutputIterator out ) {
    51                 Type * res = expr->get_result();
    52                 if ( TupleType * tupleType = dynamic_cast< TupleType * > ( res ) ) {
    53                         if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( expr ) ) {
    54                                 // can open tuple expr and dump its exploded components
    55                                 for ( Expression * expr : tupleExpr->get_exprs() ) {
    56                                         explodeUnique( expr, alt, out );
    57                                 }
    58                         } else {
    59                                 // tuple type, but not tuple expr - need to refer to single instance of the argument
    60                                 // expression and index into its components
    61                                 UniqueExpr * unq = new UniqueExpr( expr->clone() );
    62                                 for ( unsigned int i = 0; i < tupleType->size(); i++ ) {
    63                                         TupleIndexExpr * idx = new TupleIndexExpr( unq->clone(), i );
    64                                         explodeUnique( idx, alt, out );
    65                                         delete idx;
    66                                 }
    67                                 delete unq;
    68                         }
    69                 } else {
    70                         // atomic (non-tuple) type - output a clone of the expression in a new alternative
    71                         *out++ = Alternative( expr->clone(), alt.env, alt.cost, alt.cvtCost );
    72                 }
    73         }
    74 
    75         /// expands a tuple-valued alternative into multiple alternatives, each with a non-tuple-type
    76         template< typename OutputIterator >
    77         void explode( const Alternative &alt, OutputIterator out ) {
    78                 explodeUnique( alt.expr, alt, out );
    79         }
    80 
    81         // explode list of alternatives
    82         template< typename OutputIterator >
    83         void explode( const AltList & alts, OutputIterator out ) {
    84                 for ( const Alternative & alt : alts ) {
    85                         explode( alt, out );
    86                 }
    87         }
    8847} // namespace ResolvExpr
    8948
  • TabularUnified src/ResolvExpr/AlternativeFinder.cc

    r1132b62 r65660bd  
    435435                // flatten actuals so that each actual has an atomic (non-tuple) type
    436436                AltList exploded;
    437                 explode( actuals, back_inserter( exploded ) );
     437                Tuples::explode( actuals, back_inserter( exploded ) );
    438438
    439439                AltList::iterator actualExpr = exploded.begin();
  • TabularUnified src/ResolvExpr/Resolver.cc

    r1132b62 r65660bd  
    3838
    3939                virtual void visit( FunctionDecl *functionDecl );
    40                 virtual void visit( ObjectDecl *functionDecl );
     40                virtual void visit( ObjectDecl *objectDecl );
    4141                virtual void visit( TypeDecl *typeDecl );
    4242                virtual void visit( EnumDecl * enumDecl );
     
    442442                                (*iter)->accept( *this );
    443443                        } // for
     444                } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) {
     445                        for ( Type * t : *tt ) {
     446                                if ( iter == end ) break;
     447                                initContext = t;
     448                                (*iter++)->accept( *this );
     449                        }
    444450                } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) {
    445451                        resolveAggrInit( st->get_baseStruct(), iter, end );
Note: See TracChangeset for help on using the changeset viewer.