- File:
-
- 1 edited
-
src/GenPoly/InstantiateGeneric.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/InstantiateGeneric.cc
r5a3ac84 r87c3bef 16 16 #include <cassert> 17 17 #include <list> 18 #include <unordered_map>19 18 #include <utility> 20 19 #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"28 27 #include "PolyMutator.h" 29 28 … … 78 77 if ( params.size() != that.params.size() ) return false; 79 78 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 ( ! typesPolyCompatible( *it, *jt) ) return false;81 if ( ! ResolvExpr::typesCompatible( *it, *jt, dummy ) ) 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 if ( isPolyType( paramType->get_type() ) ) { 230 // substitute polymorphic parameter type in to generic 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 ) ); 239 } else { 240 // Just clone parameter type 231 241 out.push_back( paramType->clone() ); 232 gt = genericType::dynamic;233 } else {234 // normalize possibly dtype-static parameter type235 out.push_back( new TypeExpr{236 ScrubTyVars::scrubAll( paramType->get_type()->clone() ) } );237 gt |= genericType::concrete;238 242 } 243 // make the struct concrete or dynamic depending on the parameter 244 gt |= isPolyType( paramType->get_type() ) ? genericType::dynamic : genericType::concrete; 239 245 } else switch ( (*baseParam)->get_kind() ) { 240 246 case TypeDecl::Dtype: … … 366 372 concDecl = new StructDecl( typeNamer.newName( inst->get_name() ) ); 367 373 concDecl->set_body( inst->get_baseStruct()->has_body() ); 368 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );374 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 369 375 DeclMutator::addDeclaration( concDecl ); 370 376 insert( inst, typeSubs, concDecl );
Note:
See TracChangeset
for help on using the changeset viewer.