Changeset 37a3b8f9
- Timestamp:
- Nov 10, 2015, 4:15:48 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:
- d8847b7
- Parents:
- d2ded3e7
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypeData.cc
rd2ded3e7 r37a3b8f9 799 799 case DeclarationNode::Struct: 800 800 at = new StructDecl( aggregate->name ); 801 buildForall( aggregate->params, at->get_parameters() ); 801 802 break; 802 803 case DeclarationNode::Union: 803 804 at = new UnionDecl( aggregate->name ); 805 buildForall( aggregate->params, at->get_parameters() ); 804 806 break; 805 807 case DeclarationNode::Context: 806 808 at = new ContextDecl( aggregate->name ); 809 buildList( aggregate->params, at->get_parameters() ); 807 810 break; 808 811 default: 809 812 assert( false ); 810 813 } // switch 811 buildList( aggregate->params, at->get_parameters() );814 // buildList( aggregate->params, at->get_parameters() ); 812 815 buildList( aggregate->fields, at->get_members() ); 813 816 -
src/SymTab/Validate.cc
rd2ded3e7 r37a3b8f9 629 629 Declaration *makeStructAssignment( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting ) { 630 630 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 631 632 // Make function polymorphic in same parameters as generic struct, if applicable 633 std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters(); 634 for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) { 635 assignType->get_forall().push_back( (*param)->clone() ); 636 } 631 637 632 638 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 ); -
src/SynTree/ReferenceToType.cc
rd2ded3e7 r37a3b8f9 59 59 std::string StructInstType::typeString() const { return "struct"; } 60 60 61 std::list<TypeDecl*>& StructInstType::get_baseParameters() { return baseStruct->get_parameters(); } 62 61 63 void StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 62 64 assert( baseStruct ); … … 65 67 66 68 std::string UnionInstType::typeString() const { return "union"; } 69 70 std::list<TypeDecl*>& UnionInstType::get_baseParameters() { return baseUnion->get_parameters(); } 67 71 68 72 void UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { -
src/SynTree/Type.h
rd2ded3e7 r37a3b8f9 237 237 StructDecl *get_baseStruct() const { return baseStruct; } 238 238 void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; } 239 240 // a utility function 239 240 /// Accesses generic parameters of base struct 241 std::list<TypeDecl*>& get_baseParameters(); 242 243 /// Looks up the members of this struct named "name" and places them into "foundDecls". 244 /// Clones declarations into "foundDecls", caller responsible for freeing 241 245 void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const; 242 246 … … 260 264 UnionDecl *get_baseUnion() const { return baseUnion; } 261 265 void set_baseUnion( UnionDecl *newValue ) { baseUnion = newValue; } 262 263 // a utility function 266 267 /// Accesses generic parameters of base union 268 std::list<TypeDecl*>& get_baseParameters(); 269 270 /// looks up the members of this union named "name" and places them into "foundDecls" 271 /// Clones declarations into "foundDecls", caller responsible for freeing 264 272 void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const; 265 273 -
src/SynTree/TypeSubstitution.cc
rd2ded3e7 r37a3b8f9 126 126 Type *TypeSubstitution::handleType( TypeClass *type ) { 127 127 BoundVarsType oldBoundVars( boundVars ); 128 // bind type variables from forall-qualifiers 128 129 if ( freeOnly ) { 129 130 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { … … 136 137 } 137 138 139 template< typename TypeClass > 140 Type *TypeSubstitution::handleAggregateType( TypeClass *type ) { 141 BoundVarsType oldBoundVars( boundVars ); 142 // bind type variables from forall-qualifiers 143 if ( freeOnly ) { 144 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { 145 boundVars.insert( (*tyvar )->get_name() ); 146 } // for 147 } // if 148 // bind type variables from generic type instantiations 149 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_baseParameters().begin(); tyvar != type->get_baseParameters().end(); ++tyvar ) { 150 boundVars.insert( (*tyvar)->get_name() ); 151 } // for 152 Type *ret = Mutator::mutate( type ); 153 boundVars = oldBoundVars; 154 return ret; 155 } 156 138 157 Type * TypeSubstitution::mutate( VoidType *basicType ) { 139 158 return handleType( basicType ); … … 157 176 158 177 Type * TypeSubstitution::mutate( StructInstType *aggregateUseType ) { 159 return handle Type( aggregateUseType );178 return handleAggregateType( aggregateUseType ); 160 179 } 161 180 162 181 Type * TypeSubstitution::mutate( UnionInstType *aggregateUseType ) { 163 return handle Type( aggregateUseType );182 return handleAggregateType( aggregateUseType ); 164 183 } 165 184 -
src/SynTree/TypeSubstitution.h
rd2ded3e7 r37a3b8f9 58 58 virtual Type* mutate(TypeInstType *aggregateUseType); 59 59 virtual Expression* mutate(NameExpr *nameExpr); 60 60 61 /// Records type variable bindings from forall-statements 61 62 template< typename TypeClass > Type *handleType( TypeClass *type ); 63 /// Records type variable bindings from forall-statements and instantiations of generic types 64 template< typename TypeClass > Type *handleAggregateType( TypeClass *type ); 62 65 63 66 virtual Type* mutate(VoidType *basicType);
Note: See TracChangeset
for help on using the changeset viewer.