Changeset 408d460 for src/GenPoly/Box.cc
- Timestamp:
- Feb 5, 2016, 4:41:25 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 98735ef
- Parents:
- b10c9959 (diff), 4789f44 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
rb10c9959 r408d460 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Dec 18 14:53:08 201513 // Update Count : 2 1712 // Last Modified On : Fri Feb 05 12:23:10 2016 13 // Update Count : 280 14 14 // 15 15 … … 139 139 virtual Expression *mutate( OffsetofExpr *offsetofExpr ); 140 140 }; 141 141 142 142 /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable 143 143 class Pass3 : public PolyMutator { … … 178 178 seenIntrinsic = false; // break on this line when debugging for end of prelude 179 179 } 180 180 181 181 *i = dynamic_cast< Declaration* >( (*i)->acceptMutator( mutator ) ); 182 182 assert( *i ); … … 286 286 } 287 287 } 288 288 289 289 if ( functionDecl->get_statements() ) { // empty routine body ? 290 290 doBeginScope(); … … 320 320 findFunction( (*arg)->get_type(), functions, scopeTyVars, needsAdapter ); 321 321 } // for 322 322 323 323 AdapterMap & adapters = Pass1::adapters.top(); 324 324 for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) { … … 373 373 Expression *Pass1::makeOffsetArray( StructInstType *ty ) { 374 374 std::list< Declaration* > &baseMembers = ty->get_baseStruct()->get_members(); 375 375 376 376 // make a new temporary array 377 377 Type *offsetType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ); … … 397 397 return new VariableExpr( arrayTemp ); 398 398 } 399 399 400 400 void Pass1::passTypeVars( ApplicationExpr *appExpr, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) { 401 401 // pass size/align for type variables … … 493 493 } 494 494 } 495 495 496 496 Type *Pass1::replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone ) { 497 497 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { … … 531 531 std::string adapterName = makeAdapterName( mangleName ); 532 532 533 appExpr->get_args().push_front( appExpr->get_function() ); 533 // cast adaptee to void (*)(), since it may have any type inside a polymorphic function 534 Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 535 appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) ); 534 536 appExpr->set_function( new NameExpr( adapterName ) ); 535 537 … … 559 561 } 560 562 563 /// cast parameters to polymorphic functions so that types are replaced with 564 /// void * if they are type parameters in the formal type. 565 /// this gets rid of warnings from gcc. 561 566 void addCast( Expression *&actual, Type *formal, const TyVarMap &tyVars ) { 562 Type *newType = formal->clone(); 563 std::list< FunctionType *> functions; 564 // instead of functions needing adapters, this really ought to look for 565 // any function mentioning a polymorphic type 566 findAndReplaceFunction( newType, functions, tyVars, needsAdapter ); 567 if ( ! functions.empty() ) { 567 Type * newType = formal->clone(); 568 if ( getFunctionType( newType ) ) { 569 newType = ScrubTyVars::scrub( newType, tyVars ); 568 570 actual = new CastExpr( actual, newType ); 569 } else {570 delete newType;571 571 } // if 572 572 }
Note: See TracChangeset
for help on using the changeset viewer.