- File:
-
- 1 edited
-
src/GenPoly/InstantiateGeneric.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/InstantiateGeneric.cc
r87c3bef r5a3ac84 16 16 #include <cassert> 17 17 #include <list> 18 #include <unordered_map> 18 19 #include <utility> 19 20 #include <vector> 20 #include <unordered_map>21 21 22 22 #include "InstantiateGeneric.h" … … 25 25 #include "GenPoly.h" 26 26 #include "ScopedSet.h" 27 #include "ScrubTyVars.h" 27 28 #include "PolyMutator.h" 28 29 … … 77 78 if ( params.size() != that.params.size() ) return false; 78 79 79 SymTab::Indexer dummy;80 80 for ( std::list< Type* >::const_iterator it = params.begin(), jt = that.params.begin(); it != params.end(); ++it, ++jt ) { 81 if ( ! ResolvExpr::typesCompatible( *it, *jt, dummy) ) return false;81 if ( ! typesPolyCompatible( *it, *jt ) ) return false; 82 82 } 83 83 return true; … … 227 227 if ( (*baseParam)->isComplete() ) { 228 228 // substitute parameter for complete (otype or sized dtype) type 229 int pointerLevels = 0; 230 if ( hasPolyBase( paramType->get_type(), &pointerLevels ) && pointerLevels > 0 ) { 231 // Make a void* with equivalent nesting 232 Type* voidPtr = new VoidType( Type::Qualifiers() ); 233 while ( pointerLevels > 0 ) { 234 // Just about data layout, so qualifiers *shouldn't* matter 235 voidPtr = new PointerType( Type::Qualifiers(), voidPtr ); 236 --pointerLevels; 237 } 238 out.push_back( new TypeExpr( voidPtr ) ); 229 if ( isPolyType( paramType->get_type() ) ) { 230 // substitute polymorphic parameter type in to generic type 231 out.push_back( paramType->clone() ); 232 gt = genericType::dynamic; 239 233 } else { 240 // Just clone parameter type 241 out.push_back( paramType->clone() ); 234 // normalize possibly dtype-static parameter type 235 out.push_back( new TypeExpr{ 236 ScrubTyVars::scrubAll( paramType->get_type()->clone() ) } ); 237 gt |= genericType::concrete; 242 238 } 243 // make the struct concrete or dynamic depending on the parameter244 gt |= isPolyType( paramType->get_type() ) ? genericType::dynamic : genericType::concrete;245 239 } else switch ( (*baseParam)->get_kind() ) { 246 240 case TypeDecl::Dtype: … … 372 366 concDecl = new StructDecl( typeNamer.newName( inst->get_name() ) ); 373 367 concDecl->set_body( inst->get_baseStruct()->has_body() ); 374 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );368 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 375 369 DeclMutator::addDeclaration( concDecl ); 376 370 insert( inst, typeSubs, concDecl );
Note:
See TracChangeset
for help on using the changeset viewer.