Changeset d3e4d6c for src/Tuples/Explode.h
- Timestamp:
- Aug 23, 2017, 6:22:07 PM (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:
- 87e08e24, cb811ac
- Parents:
- 9f07232 (diff), bd37119 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/Explode.h
r9f07232 rd3e4d6c 28 28 29 29 namespace Tuples { 30 /// helper function used by explode to properly distribute 31 /// '&' across a tuple expression 32 Expression * distributeAddr( Expression * expr ); 30 Expression * distributeReference( Expression * ); 33 31 34 32 /// helper function used by explode … … 36 34 void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, const SymTab::Indexer & indexer, OutputIterator out, bool isTupleAssign ) { 37 35 if ( isTupleAssign ) { 38 // tuple assignment needs AddressExprs to be recursively exploded to easily get at all of the components39 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( expr ) ) {36 // tuple assignment needs CastExprs to be recursively exploded to easily get at all of the components 37 if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) { 40 38 ResolvExpr::AltList alts; 41 explodeUnique( addrExpr->get_arg(), alt, indexer, back_inserter( alts ), isTupleAssign );39 explodeUnique( castExpr->get_arg(), alt, indexer, back_inserter( alts ), isTupleAssign ); 42 40 for ( ResolvExpr::Alternative & alt : alts ) { 43 // distribute '&'over all components44 alt.expr = distribute Addr( alt.expr );41 // distribute reference cast over all components 42 alt.expr = distributeReference( alt.expr ); 45 43 *out++ = alt; 46 44 } … … 49 47 } 50 48 } 51 Type * res = expr->get_result() ;49 Type * res = expr->get_result()->stripReferences(); 52 50 if ( TupleType * tupleType = dynamic_cast< TupleType * > ( res ) ) { 53 51 if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( expr ) ) { … … 57 55 } 58 56 } else { 59 // tuple type, but not tuple expr - recursively index into its components 57 // tuple type, but not tuple expr - recursively index into its components. 58 // if expr type is reference, convert to value type 60 59 Expression * arg = expr->clone(); 61 if ( Tuples::maybeImpure ( arg ) && ! dynamic_cast< UniqueExpr * >( arg ) ) {60 if ( Tuples::maybeImpureIgnoreUnique( arg ) ) { 62 61 // expressions which may contain side effects require a single unique instance of the expression. 63 62 arg = new UniqueExpr( arg ); 63 } 64 // cast reference to value type to facilitate further explosion 65 if ( dynamic_cast<ReferenceType *>( arg->get_result() ) ) { 66 arg = new CastExpr( arg, tupleType->clone() ); 64 67 } 65 68 for ( unsigned int i = 0; i < tupleType->size(); i++ ) {
Note:
See TracChangeset
for help on using the changeset viewer.