Changeset b1e63ac5 for src/ResolvExpr/Unify.cc
- Timestamp:
- Jul 4, 2017, 9:40:16 AM (6 years ago)
- Branches:
- aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 208e5be
- Parents:
- 9c951e3 (diff), f7cb0bc (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
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Unify.cc
r9c951e3 rb1e63ac5 115 115 } 116 116 117 bool isFtype( Type *type , const SymTab::Indexer &indexer) {117 bool isFtype( Type *type ) { 118 118 if ( dynamic_cast< FunctionType* >( type ) ) { 119 119 return true; … … 124 124 } 125 125 126 bool tyVarCompatible( const TypeDecl::Data & data, Type *type , const SymTab::Indexer &indexer) {126 bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) { 127 127 switch ( data.kind ) { 128 128 case TypeDecl::Any: … … 132 132 // type must also be complete 133 133 // xxx - should this also check that type is not a tuple type and that it's not a ttype? 134 return ! isFtype( type , indexer) && (! data.isComplete || type->isComplete() );134 return ! isFtype( type ) && (! data.isComplete || type->isComplete() ); 135 135 case TypeDecl::Ftype: 136 return isFtype( type , indexer);136 return isFtype( type ); 137 137 case TypeDecl::Ttype: 138 138 // ttype unifies with any tuple type … … 145 145 OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() ); 146 146 assert( tyvar != openVars.end() ); 147 if ( ! tyVarCompatible( tyvar->second, other , indexer) ) {147 if ( ! tyVarCompatible( tyvar->second, other ) ) { 148 148 return false; 149 149 } // if … … 345 345 std::cerr << "unifyInexact type 1 is "; 346 346 type1->print( std::cerr ); 347 std::cerr << " type 2 is ";347 std::cerr << " type 2 is "; 348 348 type2->print( std::cerr ); 349 349 std::cerr << std::endl; … … 389 389 } 390 390 391 void Unify::visit( VoidType *voidType) {391 void Unify::visit( __attribute__((unused)) VoidType *voidType) { 392 392 result = dynamic_cast< VoidType* >( type2 ); 393 393 } … … 615 615 } else if ( tupleParam ) { 616 616 // bundle other parameters into tuple to match 617 TupleType* binder = new TupleType{ paramTy->get_qualifiers() };617 std::list< Type * > binderTypes; 618 618 619 619 do { 620 binder ->get_types().push_back( otherParam->get_type()->clone() );620 binderTypes.push_back( otherParam->get_type()->clone() ); 621 621 ++jt; 622 622 … … 627 627 } while (true); 628 628 629 otherParamTy = binder;629 otherParamTy = new TupleType{ paramTy->get_qualifiers(), binderTypes }; 630 630 ++it; // skip ttype parameter for break 631 631 } else if ( otherTupleParam ) { 632 632 // bundle parameters into tuple to match other 633 TupleType* binder = new TupleType{ otherParamTy->get_qualifiers() };633 std::list< Type * > binderTypes; 634 634 635 635 do { 636 binder ->get_types().push_back( param->get_type()->clone() );636 binderTypes.push_back( param->get_type()->clone() ); 637 637 ++it; 638 638 … … 643 643 } while (true); 644 644 645 paramTy = binder;645 paramTy = new TupleType{ otherParamTy->get_qualifiers(), binderTypes }; 646 646 ++jt; // skip ttype parameter for break 647 647 } … … 692 692 693 693 template< typename Iterator1, typename Iterator2 > 694 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode,const SymTab::Indexer &indexer ) {694 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 695 695 auto get_type = [](Type * t) { return t; }; 696 696 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { … … 742 742 flatten( flat2.get(), back_inserter( types2 ) ); 743 743 744 result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, widenMode,indexer );745 } // if 746 } 747 748 void Unify::visit( VarArgsType *varArgsType) {744 result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, indexer ); 745 } // if 746 } 747 748 void Unify::visit( __attribute__((unused)) VarArgsType *varArgsType ) { 749 749 result = dynamic_cast< VarArgsType* >( type2 ); 750 750 } 751 751 752 void Unify::visit( ZeroType *zeroType) {752 void Unify::visit( __attribute__((unused)) ZeroType *zeroType ) { 753 753 result = dynamic_cast< ZeroType* >( type2 ); 754 754 } 755 755 756 void Unify::visit( OneType *oneType) {756 void Unify::visit( __attribute__((unused)) OneType *oneType ) { 757 757 result = dynamic_cast< OneType* >( type2 ); 758 758 } … … 765 765 return function->get_returnVals().front()->get_type()->clone(); 766 766 } else { 767 TupleType * tupleType = new TupleType( Type::Qualifiers() );767 std::list< Type * > types; 768 768 for ( DeclarationWithType * decl : function->get_returnVals() ) { 769 t upleType->get_types().push_back( decl->get_type()->clone() );769 types.push_back( decl->get_type()->clone() ); 770 770 } // for 771 return tupleType;771 return new TupleType( Type::Qualifiers(), types ); 772 772 } 773 773 }
Note: See TracChangeset
for help on using the changeset viewer.