Changeset 0ddb713 for src/ResolvExpr/Unify.cc
- Timestamp:
- Dec 2, 2015, 11:58:59 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, with_gc
- Children:
- 9cb8e88d
- Parents:
- 9ed3237 (diff), f2b2029 (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. - File:
-
- 1 edited
-
src/ResolvExpr/Unify.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Unify.cc
r9ed3237 r0ddb713 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; … … 496 497 497 498 template< typename RefType > 498 void Unify::handleRefType( RefType *inst, Type *other ) { 499 void Unify::handleRefType( RefType *inst, Type *other ) { 500 // check that other type is compatible and named the same 499 501 RefType *otherStruct = dynamic_cast< RefType* >( other ); 500 502 result = otherStruct && inst->get_name() == otherStruct->get_name(); 501 } 503 } 504 505 template< typename RefType > 506 void Unify::handleGenericRefType( RefType *inst, Type *other ) { 507 // Check that other type is compatible and named the same 508 handleRefType( inst, other ); 509 if ( ! result ) return; 510 // Check that parameters of types unify, if any 511 std::list< Expression* > params = inst->get_parameters(); 512 std::list< Expression* > otherParams = ((RefType*)other)->get_parameters(); 513 514 std::list< Expression* >::const_iterator it = params.begin(), jt = otherParams.begin(); 515 for ( ; it != params.end() && jt != otherParams.end(); ++it, ++jt ) { 516 TypeExpr *param = dynamic_cast< TypeExpr* >(*it); 517 assert(param && "Aggregate parameters should be type expressions"); 518 TypeExpr *otherParam = dynamic_cast< TypeExpr* >(*jt); 519 assert(otherParam && "Aggregate parameters should be type expressions"); 520 521 if ( ! unifyExact( param->get_type(), otherParam->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode(false, false), indexer ) ) { 522 result = false; 523 return; 524 } 525 } 526 result = ( it == params.end() && jt == otherParams.end() ); 527 } 502 528 503 529 void Unify::visit(StructInstType *structInst) { 504 handle RefType( structInst, type2 );530 handleGenericRefType( structInst, type2 ); 505 531 } 506 532 507 533 void Unify::visit(UnionInstType *unionInst) { 508 handle RefType( unionInst, type2 );534 handleGenericRefType( unionInst, type2 ); 509 535 } 510 536
Note:
See TracChangeset
for help on using the changeset viewer.