Ignore:
Timestamp:
Sep 20, 2016, 4:14:13 PM (10 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, stuck-waitfor-destruct, with_gc
Children:
23b6643f
Parents:
8c49c0e
Message:

major change to instantiateFunction to match arguments against the formal parameter's structure rather than the reverse

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Alternative.h

    r8c49c0e raefcc3b  
    3232                Alternative( const Alternative &other );
    3333                Alternative &operator=( const Alternative &other );
     34                Alternative( Alternative && other );
     35                Alternative &operator=( Alternative && other );
    3436                ~Alternative();
    3537
     
    4951                Type * res = expr->get_result();
    5052                if ( TupleType * tupleType = dynamic_cast< TupleType * > ( res ) ) {
    51                         if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( alt.expr ) ) {
     53                        if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( expr ) ) {
     54                                // can open tuple expr and dump its exploded components
    5255                                for ( Expression * expr : tupleExpr->get_exprs() ) {
    5356                                        explodeUnique( expr, alt, out );
    5457                                }
    5558                        } else {
     59                                // tuple type, but not tuple expr - need to refer to single instance of the argument
     60                                // expression and index into its components
    5661                                UniqueExpr * unq = new UniqueExpr( expr->clone() );
    5762                                for ( unsigned int i = 0; i < tupleType->size(); i++ ) {
     
    6368                        }
    6469                } else {
     70                        // atomic (non-tuple) type - output a clone of the expression in a new alternative
    6571                        *out++ = Alternative( expr->clone(), alt.env, alt.cost, alt.cvtCost );
    6672                }
     
    6975        /// expands a tuple-valued alternative into multiple alternatives, each with a non-tuple-type
    7076        template< typename OutputIterator >
    71         void explode( Alternative &alt, OutputIterator out ) {
     77        void explode( const Alternative &alt, OutputIterator out ) {
    7278                explodeUnique( alt.expr, alt, out );
    7379        }
     
    7581        // explode list of alternatives
    7682        template< typename OutputIterator >
    77         void explode( AltList & alts, OutputIterator out ) {
    78                 for ( Alternative & alt : alts ) {
     83        void explode( const AltList & alts, OutputIterator out ) {
     84                for ( const Alternative & alt : alts ) {
    7985                        explode( alt, out );
    8086                }
Note: See TracChangeset for help on using the changeset viewer.