Changeset 000b914 for src/GenPoly
- Timestamp:
- Dec 7, 2015, 11:31:53 AM (10 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:
- baf7fee
- Parents:
- e58be8e (diff), 47534159 (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. - Location:
- src/GenPoly
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
re58be8e r000b914 50 50 FunctionType *makeAdapterType( FunctionType *adaptee, const TyVarMap &tyVars ); 51 51 52 /// Replaces polymorphic return types with out-parameters, replaces calls to polymorphic functions with adapter calls as needed, and adds appropriate type variables to the function call 52 53 class Pass1 : public PolyMutator { 53 54 public: … … 88 89 }; 89 90 91 /// Moves polymorphic returns in function types to pointer-type parameters, adds type size and assertion parameters to parameter lists as well 90 92 class Pass2 : public PolyMutator { 91 93 public: … … 105 107 }; 106 108 109 /// 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 107 110 class Pass3 : public PolyMutator { 108 111 public: … … 1009 1012 std::list< DeclarationWithType *> inferredParams; 1010 1013 ObjectDecl *newObj = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ); 1011 // /ObjectDecl *newFunPtr = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 );1014 // ObjectDecl *newFunPtr = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ); 1012 1015 for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) { 1013 1016 ObjectDecl *thisParm; … … 1021 1024 // move all assertions into parameter list 1022 1025 for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) { 1023 // /*assert = (*assert)->acceptMutator( *this );1026 // *assert = (*assert)->acceptMutator( *this ); 1024 1027 inferredParams.push_back( *assert ); 1025 1028 } … … 1063 1066 1064 1067 TypeDecl * Pass3::mutate( TypeDecl *typeDecl ) { 1065 // /Initializer *init = 0;1066 // /std::list< Expression *> designators;1067 // /scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();1068 // /if ( typeDecl->get_base() ) {1069 // /init = new SimpleInit( new SizeofExpr( handleDecl( typeDecl, typeDecl->get_base() ) ), designators );1070 // /}1071 // /return new ObjectDecl( typeDecl->get_name(), Declaration::Extern, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ), init );1068 // Initializer *init = 0; 1069 // std::list< Expression *> designators; 1070 // scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind(); 1071 // if ( typeDecl->get_base() ) { 1072 // init = new SimpleInit( new SizeofExpr( handleDecl( typeDecl, typeDecl->get_base() ) ), designators ); 1073 // } 1074 // return new ObjectDecl( typeDecl->get_name(), Declaration::Extern, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ), init ); 1072 1075 1073 1076 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind(); -
src/GenPoly/FindFunction.h
re58be8e r000b914 23 23 typedef bool (*FindFunctionPredicate)( FunctionType*, const TyVarMap& ); 24 24 25 /// recursively walk `type`, placing all functions that match `predicate` under `tyVars` into `functions` 25 26 void findFunction( Type *type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ); 27 /// like `findFunction`, but also replaces the function type with void ()(void) 26 28 void findAndReplaceFunction( Type *&type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ); 27 29 } // namespace GenPoly -
src/GenPoly/GenPoly.cc
re58be8e r000b914 21 21 22 22 namespace GenPoly { 23 // A function needs an adapter if it returns a polymorphic value or if any of its24 // parameters have polymorphic type23 /// A function needs an adapter if it returns a polymorphic value or if any of its 24 /// parameters have polymorphic type 25 25 bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) { 26 26 if ( ! adaptee->get_returnVals().empty() && isPolyVal( adaptee->get_returnVals().front()->get_type(), tyVars ) ) { -
src/GenPoly/Lvalue.cc
re58be8e r000b914 35 35 const std::list<Label> noLabels; 36 36 37 /// Replace uses of lvalue returns with appropriate pointers 37 38 class Pass1 : public Mutator { 38 39 public: … … 46 47 }; 47 48 49 /// Replace declarations of lvalue returns with appropriate pointers 48 50 class Pass2 : public Visitor { 49 51 public: -
src/GenPoly/ScrubTyVars.h
re58be8e r000b914 26 26 public: 27 27 ScrubTyVars( bool doAll, const TyVarMap &tyVars ): doAll( doAll ), tyVars( tyVars ) {} 28 28 29 /// Like scrub( SynTreeClass* ), but only applies to type variables in `tyVars` 29 30 template< typename SynTreeClass > 30 31 static SynTreeClass *scrub( SynTreeClass *target, const TyVarMap &tyVars ); 32 /// Replaces dtypes and ftypes with the appropriate void type, and sizeof expressions of polymorphic types with the proper variable 31 33 template< typename SynTreeClass > 32 34 static SynTreeClass *scrub( SynTreeClass *target );
Note:
See TracChangeset
for help on using the changeset viewer.