Changes in src/Tuples/Explode.h [6d267ca:6b0b624]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/Explode.h
r6d267ca r6b0b624 9 9 // Author : Rob Schluntz 10 10 // Created On : Wed Nov 9 13:12:24 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Nov 9 13:20:24 201613 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:55:16 2017 13 // Update Count : 3 14 14 // 15 15 16 #ifndef _EXPLODE_H_ 17 #define _EXPLODE_H_ 16 #pragma once 18 17 19 18 #include "ResolvExpr/AlternativeFinder.h" … … 27 26 28 27 namespace Tuples { 28 /// helper function used by explode to properly distribute 29 /// '&' across a tuple expression 30 Expression * distributeAddr( Expression * expr ); 31 29 32 /// helper function used by explode 30 33 template< typename OutputIterator > 31 34 void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, const SymTab::Indexer & indexer, OutputIterator out, bool isTupleAssign ) { 32 Type * res = expr->get_result()->stripReferences(); 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(); 33 50 if ( TupleType * tupleType = dynamic_cast< TupleType * > ( res ) ) { 34 51 if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( expr ) ) { … … 38 55 } 39 56 } else { 40 // tuple type, but not tuple expr - recursively index into its components. 41 // if expr type is reference, convert to value type 57 // tuple type, but not tuple expr - recursively index into its components 42 58 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 }48 59 if ( Tuples::maybeImpure( arg ) && ! dynamic_cast< UniqueExpr * >( arg ) ) { 49 60 // expressions which may contain side effects require a single unique instance of the expression. … … 83 94 } // namespace Tuples 84 95 85 #endif // _TUPLE_ASSIGNMENT_H_86 87 96 // Local Variables: // 88 97 // tab-width: 4 //
Note: See TracChangeset
for help on using the changeset viewer.