Changeset 64eae56 for src/GenPoly
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified 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;
Note: See TracChangeset
for help on using the changeset viewer.