Changeset 64eae56
- Timestamp:
- Dec 21, 2016, 5:15:27 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:
- 0c286cf
- Parents:
- 53e3b4a
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Specialize.cc
r53e3b4a r64eae56 194 194 } 195 195 196 /// restructures arg to match the structure of a single formal parameter. Assumes that atomic types are compatible (as the Resolver should have ensured this) 197 template< typename OutIterator > 198 void matchOneFormal( Expression * arg, unsigned & idx, Type * formal, OutIterator out ) { 199 if ( TupleType * tupleType = dynamic_cast< TupleType * >( formal ) ) { 200 std::list< Expression * > exprs; 201 for ( Type * t : *tupleType ) { 202 matchOneFormal( arg, idx, t, back_inserter( exprs ) ); 203 } 204 *out++ = new TupleExpr( exprs ); 205 } else { 206 *out++ = new TupleIndexExpr( arg->clone(), idx++ ); 207 } 208 } 209 210 /// restructures the ttype argument to match the structure of the formal parameters of the actual function. 211 // [begin, end) are the formal parameters. 212 // args is the list of arguments currently given to the actual function, the last of which needs to be restructured. 196 213 template< typename Iterator > 197 214 void fixLastArg( std::list< Expression * > & args, Iterator begin, Iterator end ) { … … 203 220 unsigned idx = 0; 204 221 for ( ; begin != end; ++begin ) { 205 //DeclarationWithType * formal = *begin;206 //Type * formalType = formal->get_type();207 args.push_back( new TupleIndexExpr( last->clone(), idx++) );222 DeclarationWithType * formal = *begin; 223 Type * formalType = formal->get_type(); 224 matchOneFormal( last, idx, formalType, back_inserter( args ) ); 208 225 } 209 226 delete last; … … 238 255 239 256 for ( DeclarationWithType* param : thunkFunc->get_functionType()->get_parameters() ) { 257 // walk the parameters to the actual function alongside the parameters to the thunk to find the location where the ttype parameter begins to satisfy parameters in the actual function. 258 assert( begin != end ); 240 259 ++begin; 241 assert( begin != end );242 260 243 261 // std::cerr << "thunk param: " << param << std::endl; -
src/ResolvExpr/Unify.cc
r53e3b4a r64eae56 491 491 std::list< Type * > types; 492 492 for ( ; begin != end; ++begin ) { 493 // might need to break apart these types too? 494 // yes, looks like we should flatten begin and push back each types individually 495 types.push_back( (*begin)->get_type()->clone() ); 493 // it's guaranteed that a ttype variable will be bound to a flat tuple, so ensure that this results in a flat tuple 494 flatten( (*begin)->get_type(), back_inserter( types ) ); 496 495 } 497 496 return new TupleType( Type::Qualifiers(), types ); -
src/tests/tupleVariadic.c
r53e3b4a r64eae56 57 57 } 58 58 59 void ?{}(array * a, int a0, int a1, int a2, int a3) { 59 // test use of a tuple argument 60 [void] ?{}(array * a, [int, int, int, int] args) { 61 int a0, a1, a2, a3; 62 [a0, a1, a2, a3] = args; 60 63 a->size = 4; 61 a->data = (int*)malloc(sizeof(int)*a->size);64 a->data = malloc(sizeof(int)*a->size); 62 65 a->data[0] = a0; 63 66 a->data[1] = a1;
Note: See TracChangeset
for help on using the changeset viewer.