Changes in src/Tuples/Explode.h [6b0b624:6d267ca]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/Explode.h
r6b0b624 r6d267ca 9 9 // Author : Rob Schluntz 10 10 // Created On : Wed Nov 9 13:12:24 2016 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:55:16 201713 // Update Count : 311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Nov 9 13:20:24 2016 13 // Update Count : 2 14 14 // 15 15 16 #pragma once 16 #ifndef _EXPLODE_H_ 17 #define _EXPLODE_H_ 17 18 18 19 #include "ResolvExpr/AlternativeFinder.h" … … 26 27 27 28 namespace Tuples { 28 /// helper function used by explode to properly distribute29 /// '&' across a tuple expression30 Expression * distributeAddr( Expression * expr );31 32 29 /// helper function used by explode 33 30 template< typename OutputIterator > 34 31 void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, const SymTab::Indexer & indexer, OutputIterator out, bool isTupleAssign ) { 35 if ( isTupleAssign ) { 36 // tuple assignment needs AddressExprs to be recursively exploded to easily get at all of the components 37 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( expr ) ) { 38 ResolvExpr::AltList alts; 39 explodeUnique( addrExpr->get_arg(), alt, indexer, back_inserter( alts ), isTupleAssign ); 40 for ( ResolvExpr::Alternative & alt : alts ) { 41 // distribute '&' over all components 42 alt.expr = distributeAddr( alt.expr ); 43 *out++ = alt; 44 } 45 // in tuple assignment, still need to handle the other cases, but only if not already handled here (don't want to output too many alternatives) 46 return; 47 } 48 } 49 Type * res = expr->get_result(); 32 Type * res = expr->get_result()->stripReferences(); 50 33 if ( TupleType * tupleType = dynamic_cast< TupleType * > ( res ) ) { 51 34 if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( expr ) ) { … … 55 38 } 56 39 } else { 57 // tuple type, but not tuple expr - recursively index into its components 40 // tuple type, but not tuple expr - recursively index into its components. 41 // if expr type is reference, convert to value type 58 42 Expression * arg = expr->clone(); 43 44 if ( dynamic_cast<ReferenceType *>( arg->get_result() ) ) { 45 // TODO: does this go here (inside uniqueexpr) or outside uniqueexpr? I'm guessing probably should go after... 46 arg = new CastExpr( arg, tupleType->clone() ); 47 } 59 48 if ( Tuples::maybeImpure( arg ) && ! dynamic_cast< UniqueExpr * >( arg ) ) { 60 49 // expressions which may contain side effects require a single unique instance of the expression. … … 94 83 } // namespace Tuples 95 84 85 #endif // _TUPLE_ASSIGNMENT_H_ 86 96 87 // Local Variables: // 97 88 // tab-width: 4 //
Note: See TracChangeset
for help on using the changeset viewer.