Changeset b4cd03b7 for src/GenPoly
- Timestamp:
- Feb 5, 2016, 12:27:21 PM (9 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:
- 4789f44
- Parents:
- 5721a6d
- Location:
- src/GenPoly
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r5721a6d rb4cd03b7 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 … … 137 137 virtual Expression *mutate( MemberExpr *memberExpr ); 138 138 }; 139 139 140 140 /// 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 141 141 class Pass3 : public PolyMutator { … … 176 176 seenIntrinsic = false; // break on this line when debugging for end of prelude 177 177 } 178 178 179 179 *i = dynamic_cast< Declaration* >( (*i)->acceptMutator( mutator ) ); 180 180 assert( *i ); … … 284 284 } 285 285 } 286 286 287 287 if ( functionDecl->get_statements() ) { // empty routine body ? 288 288 doBeginScope(); … … 318 318 findFunction( (*arg)->get_type(), functions, scopeTyVars, needsAdapter ); 319 319 } // for 320 320 321 321 AdapterMap & adapters = Pass1::adapters.top(); 322 322 for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) { … … 371 371 Expression *Pass1::makeOffsetArray( StructInstType *ty ) { 372 372 std::list< Declaration* > &baseMembers = ty->get_baseStruct()->get_members(); 373 373 374 374 // make a new temporary array 375 375 Type *offsetType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ); … … 395 395 return new VariableExpr( arrayTemp ); 396 396 } 397 397 398 398 void Pass1::passTypeVars( ApplicationExpr *appExpr, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) { 399 399 // pass size/align for type variables … … 491 491 } 492 492 } 493 493 494 494 Type *Pass1::replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone ) { 495 495 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { … … 529 529 std::string adapterName = makeAdapterName( mangleName ); 530 530 531 appExpr->get_args().push_front( appExpr->get_function() ); 531 // cast adaptee to void (*)(), since it may have any type inside a polymorphic function 532 Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 533 appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) ); 532 534 appExpr->set_function( new NameExpr( adapterName ) ); 533 535 … … 557 559 } 558 560 561 /// cast parameters to polymorphic functions so that types are replaced with 562 /// void * if they are type parameters in the formal type. 563 /// this gets rid of warnings from gcc. 559 564 void addCast( Expression *&actual, Type *formal, const TyVarMap &tyVars ) { 560 Type *newType = formal->clone(); 561 std::list< FunctionType *> functions; 562 // instead of functions needing adapters, this really ought to look for 563 // any function mentioning a polymorphic type 564 findAndReplaceFunction( newType, functions, tyVars, needsAdapter ); 565 if ( ! functions.empty() ) { 565 Type * newType = formal->clone(); 566 if ( getFunctionType( newType ) ) { 567 newType = ScrubTyVars::scrub( newType, tyVars ); 566 568 actual = new CastExpr( actual, newType ); 567 } else {568 delete newType;569 569 } // if 570 570 } -
src/GenPoly/FindFunction.cc
r5721a6d rb4cd03b7 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FindFunction.cc -- 7 // FindFunction.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue May 19 07:35:48 201513 // Update Count : 111 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Feb 05 12:22:20 2016 13 // Update Count : 6 14 14 // 15 15 … … 19 19 #include "SynTree/Visitor.h" 20 20 21 #include "ScrubTyVars.h" 22 21 23 namespace GenPoly { 22 24 class FindFunction : public Mutator { 23 25 public: 24 26 FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate ); 25 27 26 28 virtual Type *mutate( FunctionType *functionType ); 27 29 virtual Type *mutate( PointerType *pointerType ); … … 66 68 functions.push_back( functionType ); 67 69 if ( replaceMode ) { 68 ret = new FunctionType( Type::Qualifiers(), true ); 70 // replace type parameters in function type with void* 71 ret = ScrubTyVars::scrub( functionType->clone(), tyVars ); 69 72 } // if 70 73 } // if
Note: See TracChangeset
for help on using the changeset viewer.