Changeset 02ec390
- Timestamp:
- Nov 25, 2015, 2:53:22 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:
- 7e23d0a
- Parents:
- 70d4b4f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Unify.cc
r70d4b4f r02ec390 61 61 62 62 template< typename RefType > void handleRefType( RefType *inst, Type *other ); 63 template< typename RefType > void handleGenericRefType( RefType *inst, Type *other ); 63 64 64 65 bool result; … … 464 465 465 466 template< typename RefType > 466 void Unify::handleRefType( RefType *inst, Type *other ) { 467 void Unify::handleRefType( RefType *inst, Type *other ) { 468 // check that other type is compatible and named the same 467 469 RefType *otherStruct = dynamic_cast< RefType* >( other ); 468 470 result = otherStruct && inst->get_name() == otherStruct->get_name(); 469 } 471 } 472 473 template< typename RefType > 474 void Unify::handleGenericRefType( RefType *inst, Type *other ) { 475 // Check that other type is compatible and named the same 476 handleRefType( inst, other ); 477 if ( ! result ) return; 478 // Check that parameters of type unify, if any 479 std::list< Expression* > params = inst->get_parameters(); 480 if ( ! params.empty() ) { 481 std::list< TypeDecl* > *baseParams = inst->get_baseParameters(); 482 if ( ! baseParams ) { 483 result = false; 484 return; 485 } 486 std::list< Expression* >::const_iterator it = params.begin(); 487 std::list< TypeDecl* >::const_iterator baseIt = baseParams->begin(); 488 while ( it != params.end() && baseIt != baseParams->end()) { 489 TypeExpr *param = dynamic_cast< TypeExpr* >(*it); 490 assert(param && "Aggregate parameters should be type expressions"); 491 TypeInstType baseType(Type::Qualifiers(), (*baseIt)->get_name(), *baseIt); 492 if ( ! unifyExact( param->get_type(), &baseType, env, needAssertions, haveAssertions, openVars, WidenMode(false, false), indexer ) ) { 493 result = false; 494 return; 495 } 496 497 ++it; 498 ++baseIt; 499 } 500 if ( it != params.end() || baseIt != baseParams->end() ) { 501 result = false; 502 } 503 } 504 } 470 505 471 506 void Unify::visit(StructInstType *structInst) { 472 handle RefType( structInst, type2 );507 handleGenericRefType( structInst, type2 ); 473 508 } 474 509 475 510 void Unify::visit(UnionInstType *unionInst) { 476 handle RefType( unionInst, type2 );511 handleGenericRefType( unionInst, type2 ); 477 512 } 478 513
Note: See TracChangeset
for help on using the changeset viewer.