Changeset 3c13c03 for src/ResolvExpr
- Timestamp:
- Sep 17, 2016, 8:27:51 AM (8 years ago)
- 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:
- 8c49c0e
- Parents:
- 12bc63a
- Location:
- src/ResolvExpr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Alternative.cc
r12bc63a r3c13c03 20 20 21 21 namespace ResolvExpr { 22 Alternative::Alternative() : expr( 0 ) {}22 Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( 0 ) {} 23 23 24 24 Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost ) -
src/ResolvExpr/Alternative.h
r12bc63a r3c13c03 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Alternative.h -- 7 // Alternative.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 12 12 // Last Modified On : Sat May 16 23:54:39 2015 13 13 // Update Count : 2 14 // 14 // 15 15 16 16 #ifndef ALTERNATIVE_H … … 33 33 Alternative &operator=( const Alternative &other ); 34 34 ~Alternative(); 35 35 36 36 void initialize( const Alternative &src, Alternative &dest ); 37 37 38 38 void print( std::ostream &os, int indent = 0 ) const; 39 39 40 40 Cost cost; 41 41 Cost cvtCost; … … 43 43 TypeEnvironment env; 44 44 }; 45 46 /// helper function used by explode 47 template< typename OutputIterator > 48 void explodeUnique( Expression * expr, const Alternative & alt, OutputIterator out ) { 49 Type * res = expr->get_result(); 50 if ( TupleType * tupleType = dynamic_cast< TupleType * > ( res ) ) { 51 if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( alt.expr ) ) { 52 for ( Expression * expr : tupleExpr->get_exprs() ) { 53 explodeUnique( expr, alt, out ); 54 } 55 } else { 56 UniqueExpr * unq = new UniqueExpr( expr->clone() ); 57 for ( unsigned int i = 0; i < tupleType->size(); i++ ) { 58 TupleIndexExpr * idx = new TupleIndexExpr( unq->clone(), i ); 59 explodeUnique( idx, alt, out ); 60 delete idx; 61 } 62 delete unq; 63 } 64 } else { 65 *out++ = Alternative( expr->clone(), alt.env, alt.cost, alt.cvtCost ); 66 } 67 } 68 69 /// expands a tuple-valued alternative into multiple alternatives, each with a non-tuple-type 70 template< typename OutputIterator > 71 void explode( Alternative &alt, OutputIterator out ) { 72 explodeUnique( alt.expr, alt, out ); 73 } 74 75 // explode list of alternatives 76 template< typename OutputIterator > 77 void explode( AltList & alts, OutputIterator out ) { 78 for ( Alternative & alt : alts ) { 79 explode( alt, out ); 80 } 81 } 45 82 } // namespace ResolvExpr 46 83 -
src/ResolvExpr/AlternativeFinder.cc
r12bc63a r3c13c03 380 380 381 381 std::list< DeclarationWithType* >::iterator formal = formals.begin(); 382 383 AltList newActuals; 384 explode( actuals, back_inserter( newActuals ) ); 382 385 383 386 std::list< Type * > formalTypes; … … 994 997 TupleExpr *newExpr = new TupleExpr; 995 998 makeExprList( *i, newExpr->get_exprs() ); 996 TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true, true) ); 997 Type::Qualifiers &qualifiers = tupleType->get_qualifiers(); 998 for ( Expression * resultExpr : newExpr->get_exprs() ) { 999 Type * type = resultExpr->get_result()->clone(); 1000 tupleType->get_types().push_back( type ); 1001 qualifiers &= type->get_qualifiers(); 1002 } // for 1003 newExpr->set_result( tupleType ); 999 newExpr->set_result( Tuples::makeTupleType( newExpr->get_exprs() ) ); 1004 1000 1005 1001 TypeEnvironment compositeEnv;
Note: See TracChangeset
for help on using the changeset viewer.