Changeset 3f06c05
- Timestamp:
- Jul 16, 2020, 12:35:19 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 463cb33
- Parents:
- cadec25
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/InstantiateGeneric.cc
rcadec25 r3f06c05 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu Aug 04 18:33:00 2016 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Thu Aug 04 18:33:00 201613 // Update Count : 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jul 16 10:17:00 2020 13 // Update Count : 2 14 14 // 15 15 #include "InstantiateGeneric.h" … … 297 297 } 298 298 299 template< typename AggrInst > 300 static AggrInst * asForward( AggrInst * decl ) { 301 if ( !decl->body ) { 302 return nullptr; 303 } 304 decl = decl->clone(); 305 decl->body = false; 306 deleteAll( decl->members ); 307 decl->members.clear(); 308 return decl; 309 } 310 299 311 void GenericInstantiator::stripDtypeParams( AggregateDecl *base, std::list< TypeDecl* >& baseParams, const std::list< TypeExpr* >& typeSubs ) { 300 312 substituteMembers( base->get_members(), baseParams, typeSubs ); … … 373 385 concDecl->set_body( inst->get_baseStruct()->has_body() ); 374 386 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 375 insert( inst, typeSubs, concDecl ); // must insert before recursion 387 // Forward declare before recursion. (TODO: Only when needed, #199.) 388 insert( inst, typeSubs, concDecl ); 389 if ( StructDecl *forwardDecl = asForward( concDecl ) ) { 390 declsToAddBefore.push_back( forwardDecl ); 391 } 376 392 concDecl->acceptMutator( *visitor ); // recursively instantiate members 377 393 declsToAddBefore.push_back( concDecl ); // must occur before declaration is added so that member instantiations appear first … … 423 439 concDecl->set_body( inst->get_baseUnion()->has_body() ); 424 440 substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 425 insert( inst, typeSubs, concDecl ); // must insert before recursion 441 // Forward declare before recursion. (TODO: Only when needed, #199.) 442 insert( inst, typeSubs, concDecl ); 443 if ( UnionDecl *forwardDecl = asForward( concDecl ) ) { 444 declsToAddBefore.push_back( forwardDecl ); 445 } 426 446 concDecl->acceptMutator( *visitor ); // recursively instantiate members 427 447 declsToAddBefore.push_back( concDecl ); // must occur before declaration is added so that member instantiations appear first -
tests/.expect/functions.x64.txt
rcadec25 r3f06c05 121 121 122 122 } 123 struct _conc__tuple2_0; 123 124 struct _conc__tuple2_0 { 124 125 signed int field_0; … … 157 158 158 159 } 160 struct _conc__tuple3_1; 159 161 struct _conc__tuple3_1 { 160 162 signed int field_0; … … 170 172 __attribute__ ((unused)) struct _conc__tuple3_1 _X9_retval_fT3iii_1 = { }; 171 173 } 174 struct _conc__tuple3_2; 172 175 struct _conc__tuple3_2 { 173 176 signed int field_0; … … 260 263 __attribute__ ((unused)) signed int *const _X10_retval_f3KPi_1; 261 264 } 265 struct _conc__tuple2_3; 262 266 struct _conc__tuple2_3 { 263 267 signed int *field_0; -
tests/.expect/functions.x86.txt
rcadec25 r3f06c05 121 121 122 122 } 123 struct _conc__tuple2_0; 123 124 struct _conc__tuple2_0 { 124 125 signed int field_0; … … 157 158 158 159 } 160 struct _conc__tuple3_1; 159 161 struct _conc__tuple3_1 { 160 162 signed int field_0; … … 170 172 __attribute__ ((unused)) struct _conc__tuple3_1 _X9_retval_fT3iii_1 = { }; 171 173 } 174 struct _conc__tuple3_2; 172 175 struct _conc__tuple3_2 { 173 176 signed int field_0; … … 260 263 __attribute__ ((unused)) signed int *const _X10_retval_f3KPi_1; 261 264 } 265 struct _conc__tuple2_3; 262 266 struct _conc__tuple2_3 { 263 267 signed int *field_0;
Note: See TracChangeset
for help on using the changeset viewer.