Changeset 24d6572 for src/ResolvExpr
- Timestamp:
- Jun 12, 2023, 2:45:32 PM (2 years ago)
- Branches:
- ast-experimental, master
- Children:
- 62d62db
- Parents:
- 34b4268 (diff), 251ce80 (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. - Location:
- src/ResolvExpr
- Files:
-
- 7 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r34b4268 r24d6572 14 14 // 15 15 16 #include "AlternativeFinder.h" 17 16 18 #include <algorithm> // for copy 17 19 #include <cassert> // for strict_dynamic_cast, assert, assertf … … 26 28 27 29 #include "CompilationState.h" // for resolvep 30 #include "AdjustExprType.hpp" // for adjustExprType 28 31 #include "Alternative.h" // for AltList, Alternative 29 #include "AlternativeFinder.h"30 32 #include "AST/Expr.hpp" 31 33 #include "AST/SymbolTable.hpp" 32 34 #include "AST/Type.hpp" 35 #include "CastCost.hpp" // for castCost 33 36 #include "Common/SemanticError.h" // for SemanticError 34 37 #include "Common/utility.h" // for deleteAll, printAll, CodeLocation 38 #include "ConversionCost.h" // for conversionCost 35 39 #include "Cost.h" // for Cost, Cost::zero, operator<<, Cost... 36 40 #include "ExplodedActual.h" // for ExplodedActual 37 41 #include "InitTweak/InitTweak.h" // for getFunctionName 42 #include "PolyCost.hpp" // for polyCost 38 43 #include "RenameVars.h" // for RenameVars, global_renamer 39 44 #include "ResolveAssertions.h" // for resolveAssertions 40 45 #include "ResolveTypeof.h" // for resolveTypeof 41 46 #include "Resolver.h" // for resolveStmtExpr 47 #include "SpecCost.hpp" // for specCost 42 48 #include "SymTab/Indexer.h" // for Indexer 43 49 #include "SymTab/Mangler.h" // for Mangler … … 51 57 #include "Tuples/Explode.h" // for explode 52 58 #include "Tuples/Tuples.h" // for isTtype, handleTupleAssignment 59 #include "typeops.h" // for combos 53 60 #include "Unify.h" // for unify 54 #include "typeops.h" // for adjustExprType, polyCost, castCost55 61 56 62 #define PRINT( text ) if ( resolvep ) { text } -
src/ResolvExpr/AlternativeFinder.h
r34b4268 r24d6572 34 34 namespace ResolvExpr { 35 35 struct ArgPack; 36 37 Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue, 38 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 39 40 void referenceToRvalueConversion( Expression *& expr, Cost & cost ); 36 41 37 42 /// First index is which argument, second index is which alternative for that argument, -
src/ResolvExpr/Candidate.cpp
r34b4268 r24d6572 17 17 18 18 #include <iostream> 19 #include <sstream> 19 20 20 21 #include "AST/Print.hpp" … … 44 45 sorted.reserve(cands.size()); 45 46 for(const auto & c : cands) { 46 std:: stringstream ss;47 std::ostringstream ss; 47 48 print( ss, *c, indent ); 48 49 sorted.push_back(ss.str()); -
src/ResolvExpr/CandidateFinder.cpp
r34b4268 r24d6572 23 23 #include <vector> 24 24 25 #include "AdjustExprType.hpp" 25 26 #include "Candidate.hpp" 26 27 #include "CompilationState.h" 27 28 #include "Cost.h" 29 #include "CastCost.hpp" 30 #include "PolyCost.hpp" 31 #include "SpecCost.hpp" 32 #include "ConversionCost.h" 28 33 #include "ExplodedArg.hpp" 29 34 #include "RenameVars.h" // for renameTyVars … … 403 408 unify( 404 409 ttype, argType, newResult.env, newResult.need, newResult.have, 405 newResult.open , symtab)410 newResult.open ) 406 411 ) { 407 412 finalResults.emplace_back( std::move( newResult ) ); … … 474 479 ) 475 480 476 if ( unify( paramType, argType, env, need, have, open , symtab) ) {481 if ( unify( paramType, argType, env, need, have, open ) ) { 477 482 unsigned nextExpl = results[i].nextExpl + 1; 478 483 if ( nextExpl == expl.exprs.size() ) { nextExpl = 0; } … … 493 498 ast::OpenVarSet open = results[i].open; 494 499 495 if ( unify( paramType, cnst->result, env, need, have, open , symtab) ) {500 if ( unify( paramType, cnst->result, env, need, have, open ) ) { 496 501 results.emplace_back( 497 502 i, new ast::DefaultArgExpr{ cnst->location, cnst }, std::move( env ), … … 536 541 537 542 // attempt to unify types 538 if ( unify( paramType, argType, env, need, have, open , symtab) ) {543 if ( unify( paramType, argType, env, need, have, open ) ) { 539 544 // add new result 540 545 results.emplace_back( … … 703 708 if ( selfFinder.strictMode ) { 704 709 if ( ! unifyExact( 705 returnType, targetType, funcEnv, funcNeed, funcHave, funcOpen, noWiden() , symtab) // xxx - is no widening correct?710 returnType, targetType, funcEnv, funcNeed, funcHave, funcOpen, noWiden() ) // xxx - is no widening correct? 706 711 ) { 707 712 // unification failed, do not pursue this candidate … … 711 716 else { 712 717 if ( ! unify( 713 returnType, targetType, funcEnv, funcNeed, funcHave, funcOpen , symtab)718 returnType, targetType, funcEnv, funcNeed, funcHave, funcOpen ) 714 719 ) { 715 720 // unification failed, do not pursue this candidate … … 1156 1161 1157 1162 // unification run for side-effects 1158 unify( toType, cand->expr->result, cand->env, need, have, open , symtab);1163 unify( toType, cand->expr->result, cand->env, need, have, open ); 1159 1164 Cost thisCost = 1160 1165 (castExpr->isGenerated == ast::GeneratedFlag::GeneratedCast) … … 1497 1502 if ( 1498 1503 unify( 1499 r2->expr->result, r3->expr->result, env, need, have, open, symtab,1504 r2->expr->result, r3->expr->result, env, need, have, open, 1500 1505 common ) 1501 1506 ) { … … 1571 1576 if ( 1572 1577 unify( 1573 r1->expr->result, r2->expr->result, env, need, have, open, symtab,1578 r1->expr->result, r2->expr->result, env, need, have, open, 1574 1579 common ) 1575 1580 ) { … … 1677 1682 1678 1683 // unification run for side-effects 1679 bool canUnify = unify( toType, cand->expr->result, env, need, have, open , symtab);1684 bool canUnify = unify( toType, cand->expr->result, env, need, have, open ); 1680 1685 (void) canUnify; 1681 1686 Cost thisCost = computeConversionCost( cand->expr->result, toType, cand->expr->get_lvalue(), -
src/ResolvExpr/CandidateFinder.hpp
r34b4268 r24d6572 65 65 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 66 66 67 /// Create an expression that preforms reference to rvalue conversion on 68 /// the given expression and update the cost of the expression. 69 const ast::Expr * referenceToRvalueConversion( 70 const ast::Expr * expr, Cost & cost ); 71 67 72 } // namespace ResolvExpr 68 73 -
src/ResolvExpr/CastCost.cc
r34b4268 r24d6572 13 13 // Update Count : 9 14 14 // 15 16 #include "CastCost.hpp" 15 17 16 18 #include <cassert> // for assert … … 22 24 #include "ConversionCost.h" // for ConversionCost 23 25 #include "Cost.h" // for Cost, Cost::infinity 26 #include "ResolvExpr/ConversionCost.h" // for conversionCost 27 #include "ResolvExpr/PtrsCastable.hpp" // for ptrsCastable 24 28 #include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment, EqvClass 29 #include "ResolvExpr/typeops.h" // for ptrsCastable 30 #include "ResolvExpr/Unify.h" // for typesCompatibleIgnoreQualifiers 25 31 #include "SymTab/Indexer.h" // for Indexer 26 32 #include "SynTree/Declaration.h" // for TypeDecl, NamedTypeDecl 27 33 #include "SynTree/Type.h" // for PointerType, Type, TypeInstType 28 #include "typeops.h" // for typesCompatibleIgnoreQualifiers29 34 30 35 #if 0 … … 160 165 if ( 161 166 pointerType->qualifiers <= ptr->qualifiers 162 && typesCompatibleIgnoreQualifiers( pointerType->base, ptr->base, symtab,env )167 && typesCompatibleIgnoreQualifiers( pointerType->base, ptr->base, env ) 163 168 ) { 164 169 cost = Cost::safe; … … 227 232 ) 228 233 229 if ( typesCompatibleIgnoreQualifiers( src, dst, symtab,env ) ) {234 if ( typesCompatibleIgnoreQualifiers( src, dst, env ) ) { 230 235 PRINT( std::cerr << "compatible!" << std::endl; ) 231 236 if (dynamic_cast<const ast::ZeroType *>(dst) || dynamic_cast<const ast::OneType *>(dst)) { -
src/ResolvExpr/CommonType.cc
r34b4268 r24d6572 14 14 // 15 15 16 #include "CommonType.hpp" 17 16 18 #include <cassert> // for strict_dynamic_cast 17 19 #include <map> // for _Rb_tree_const_iterator … … 19 21 20 22 #include "AST/Decl.hpp" 23 #include "AST/Pass.hpp" 21 24 #include "AST/Type.hpp" 22 25 #include "Common/PassVisitor.h" … … 673 676 const ast::Type * type2; 674 677 WidenMode widen; 675 const ast::SymbolTable & symtab;676 678 ast::TypeEnvironment & tenv; 677 679 const ast::OpenVarSet & open; … … 683 685 684 686 CommonType_new( 685 const ast::Type * t2, WidenMode w, const ast::SymbolTable & st,687 const ast::Type * t2, WidenMode w, 686 688 ast::TypeEnvironment & env, const ast::OpenVarSet & o, 687 689 ast::AssertionSet & need, ast::AssertionSet & have ) 688 : type2( t2 ), widen( w ), symtab( st ),tenv( env ), open( o ), need (need), have (have) ,result() {}690 : type2( t2 ), widen( w ), tenv( env ), open( o ), need (need), have (have) ,result() {} 689 691 690 692 void previsit( const ast::Node * ) { visit_children = false; } … … 764 766 ast::AssertionSet need, have; 765 767 if ( ! tenv.bindVar( 766 var, voidPtr->base, entry->second, need, have, open, widen , symtab)768 var, voidPtr->base, entry->second, need, have, open, widen ) 767 769 ) return; 768 770 } … … 777 779 ast::OpenVarSet newOpen{ open }; 778 780 if (enumInst->base->base 779 && unifyExact(type1, enumInst->base->base, tenv, need, have, newOpen, widen , symtab)) {781 && unifyExact(type1, enumInst->base->base, tenv, need, have, newOpen, widen)) { 780 782 result = type1; 781 783 return true; … … 814 816 815 817 ast::OpenVarSet newOpen{ open }; 816 if ( unifyExact( t1, t2, tenv, have, need, newOpen, noWiden() , symtab) ) {818 if ( unifyExact( t1, t2, tenv, have, need, newOpen, noWiden() ) ) { 817 819 result = pointer; 818 820 if ( q1.val != q2.val ) { … … 857 859 if (unifyExact( 858 860 arg1, tupleFromTypes( crnt2, end2 ), tenv, need, have, open, 859 noWiden() , symtab)) {861 noWiden() )) { 860 862 break; 861 863 … … 866 868 if (unifyExact( 867 869 tupleFromTypes( crnt1, end1 ), arg2, tenv, need, have, open, 868 noWiden() , symtab)) {870 noWiden() )) { 869 871 break; 870 872 … … 890 892 891 893 if ( ! unifyExact( 892 base1, base2, tenv, need, have, open, noWiden() , symtab)894 base1, base2, tenv, need, have, open, noWiden() ) 893 895 ) return; 894 896 } … … 910 912 911 913 if ( ! unifyExact( 912 base1, base2, tenv, need, have, open, noWiden() , symtab)914 base1, base2, tenv, need, have, open, noWiden() ) 913 915 ) return; 914 916 } … … 918 920 } 919 921 else if (! unifyExact( 920 arg1, arg2, tenv, need, have, open, noWiden() , symtab)) return;922 arg1, arg2, tenv, need, have, open, noWiden() )) return; 921 923 922 924 ++crnt1; ++crnt2; … … 928 930 if (! unifyExact( 929 931 t1, tupleFromTypes( crnt2, end2 ), tenv, need, have, open, 930 noWiden() , symtab)) return;932 noWiden() )) return; 931 933 } else if ( crnt2 != end2 ) { 932 934 // try unifying empty tuple with ttype … … 935 937 if (! unifyExact( 936 938 tupleFromTypes( crnt1, end1 ), t2, tenv, need, have, open, 937 noWiden() , symtab)) return;939 noWiden() )) return; 938 940 } 939 941 if ((f1->returns.size() == 0 && f2->returns.size() == 0) 940 || (f1->returns.size() == 1 && f2->returns.size() == 1 && unifyExact(f1->returns[0], f2->returns[0], tenv, need, have, open, noWiden() , symtab))) {942 || (f1->returns.size() == 1 && f2->returns.size() == 1 && unifyExact(f1->returns[0], f2->returns[0], tenv, need, have, open, noWiden()))) { 941 943 result = pointer; 942 944 … … 995 997 996 998 ast::OpenVarSet newOpen{ open }; 997 if ( unifyExact( t1, t2, tenv, have, need, newOpen, noWiden() , symtab) ) {999 if ( unifyExact( t1, t2, tenv, have, need, newOpen, noWiden() ) ) { 998 1000 result = ref; 999 1001 if ( q1.val != q2.val ) { … … 1010 1012 } else { 1011 1013 if (!dynamic_cast<const ast::EnumInstType *>(type2)) 1012 result = commonType( type2, ref, tenv, need, have, open, widen , symtab);1014 result = commonType( type2, ref, tenv, need, have, open, widen ); 1013 1015 } 1014 1016 } … … 1028 1030 void postvisit( const ast::EnumInstType * enumInst ) { 1029 1031 if (!dynamic_cast<const ast::EnumInstType *>(type2)) 1030 result = commonType( type2, enumInst, tenv, need, have, open, widen , symtab);1032 result = commonType( type2, enumInst, tenv, need, have, open, widen); 1031 1033 } 1032 1034 1033 1035 void postvisit( const ast::TraitInstType * ) {} 1034 1036 1035 void postvisit( const ast::TypeInstType * inst ) { 1036 if ( ! widen.first ) return; 1037 if ( const ast::NamedTypeDecl * nt = symtab.lookupType( inst->name ) ) { 1038 if ( const ast::Type * base = 1039 strict_dynamic_cast< const ast::TypeDecl * >( nt )->base 1040 ) { 1041 ast::CV::Qualifiers q1 = inst->qualifiers, q2 = type2->qualifiers; 1042 1043 // force t{1,2} to be cloned if their qualifiers must be mutated 1044 ast::ptr< ast::Type > t1{ base }, t2{ type2 }; 1045 reset_qualifiers( t1, q1 ); 1046 reset_qualifiers( t2 ); 1047 1048 ast::OpenVarSet newOpen{ open }; 1049 if ( unifyExact( t1, t2, tenv, have, need, newOpen, noWiden(), symtab ) ) { 1050 result = type2; 1051 reset_qualifiers( result, q1 | q2 ); 1052 } else { 1053 tryResolveWithTypedEnum( t1 ); 1054 } 1055 } 1056 } 1057 } 1037 void postvisit( const ast::TypeInstType * inst ) {} 1058 1038 1059 1039 void postvisit( const ast::TupleType * tuple) { … … 1118 1098 ast::ptr< ast::Type > handleReference( 1119 1099 const ast::ptr< ast::Type > & t1, const ast::ptr< ast::Type > & t2, WidenMode widen, 1120 const ast::SymbolTable & symtab,ast::TypeEnvironment & env,1100 ast::TypeEnvironment & env, 1121 1101 const ast::OpenVarSet & open 1122 1102 ) { … … 1126 1106 1127 1107 // need unify to bind type variables 1128 if ( unify( t1, t2, env, have, need, newOpen, symtab,common ) ) {1108 if ( unify( t1, t2, env, have, need, newOpen, common ) ) { 1129 1109 ast::CV::Qualifiers q1 = t1->qualifiers, q2 = t2->qualifiers; 1130 1110 PRINT( … … 1150 1130 const ast::ptr< ast::Type > & type1, const ast::ptr< ast::Type > & type2, 1151 1131 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 1152 const ast::OpenVarSet & open, WidenMode widen , const ast::SymbolTable & symtab1132 const ast::OpenVarSet & open, WidenMode widen 1153 1133 ) { 1154 1134 unsigned depth1 = type1->referenceDepth(); … … 1165 1145 if ( depth1 > depth2 ) { 1166 1146 assert( ref1 ); 1167 result = handleReference( ref1->base, type2, widen, symtab,env, open );1147 result = handleReference( ref1->base, type2, widen, env, open ); 1168 1148 } else { // implies depth1 < depth2 1169 1149 assert( ref2 ); 1170 result = handleReference( type1, ref2->base, widen, symtab,env, open );1150 result = handleReference( type1, ref2->base, widen, env, open ); 1171 1151 } 1172 1152 … … 1186 1166 } 1187 1167 // otherwise both are reference types of the same depth and this is handled by the visitor 1188 ast::Pass<CommonType_new> visitor{ type2, widen, symtab,env, open, need, have };1168 ast::Pass<CommonType_new> visitor{ type2, widen, env, open, need, have }; 1189 1169 type1->accept( visitor ); 1190 ast::ptr< ast::Type > result = visitor.core.result; 1191 1192 // handling for opaque type declarations (?) 1193 if ( ! result && widen.second ) { 1194 if ( const ast::TypeInstType * inst = type2.as< ast::TypeInstType >() ) { 1195 if ( const ast::NamedTypeDecl * nt = symtab.lookupType( inst->name ) ) { 1196 auto type = strict_dynamic_cast< const ast::TypeDecl * >( nt ); 1197 if ( type->base ) { 1198 ast::CV::Qualifiers q1 = type1->qualifiers, q2 = type2->qualifiers; 1199 ast::OpenVarSet newOpen{ open }; 1200 1201 // force t{1,2} to be cloned if its qualifiers must be stripped, so that 1202 // type1 and type->base are left unchanged; calling convention forces 1203 // {type1,type->base}->strong_ref >= 1 1204 ast::ptr<ast::Type> t1{ type1 }, t2{ type->base }; 1205 reset_qualifiers( t1 ); 1206 reset_qualifiers( t2, q1 ); 1207 1208 if ( unifyExact( t1, t2, env, have, need, newOpen, noWiden(), symtab ) ) { 1209 result = t1; 1210 reset_qualifiers( result, q1 | q2 ); 1211 } 1212 } 1213 } 1214 } 1215 } 1216 1217 return result; 1170 // ast::ptr< ast::Type > result = visitor.core.result; 1171 1172 return visitor.core.result; 1218 1173 } 1219 1174 -
src/ResolvExpr/ConversionCost.cc
r34b4268 r24d6572 22 22 #include "ResolvExpr/Cost.h" // for Cost 23 23 #include "ResolvExpr/TypeEnvironment.h" // for EqvClass, TypeEnvironment 24 #include "ResolvExpr/Unify.h" 24 #include "ResolvExpr/Unify.h" // for typesCompatibleIgnoreQualifiers 25 #include "ResolvExpr/PtrsAssignable.hpp" // for ptrsAssignable 25 26 #include "SymTab/Indexer.h" // for Indexer 26 27 #include "SynTree/Declaration.h" // for TypeDecl, NamedTypeDecl 27 28 #include "SynTree/Type.h" // for Type, BasicType, TypeInstType 28 #include "typeops.h" // for typesCompatibleIgnoreQualifiers29 29 30 30 … … 532 532 } 533 533 } 534 if ( typesCompatibleIgnoreQualifiers( src, dst, symtab,env ) ) {534 if ( typesCompatibleIgnoreQualifiers( src, dst, env ) ) { 535 535 return Cost::zero; 536 536 } else if ( dynamic_cast< const ast::VoidType * >( dst ) ) { … … 566 566 ast::CV::Qualifiers tq2 = dstAsRef->base->qualifiers; 567 567 if ( tq1 <= tq2 && typesCompatibleIgnoreQualifiers( 568 srcAsRef->base, dstAsRef->base, symtab,env ) ) {568 srcAsRef->base, dstAsRef->base, env ) ) { 569 569 if ( tq1 == tq2 ) { 570 570 return Cost::zero; … … 587 587 const ast::ReferenceType * dstAsRef = dynamic_cast< const ast::ReferenceType * >( dst ); 588 588 assert( dstAsRef ); 589 if ( typesCompatibleIgnoreQualifiers( src, dstAsRef->base, symtab,env ) ) {589 if ( typesCompatibleIgnoreQualifiers( src, dstAsRef->base, env ) ) { 590 590 if ( srcIsLvalue ) { 591 591 if ( src->qualifiers == dstAsRef->base->qualifiers ) { … … 653 653 ast::CV::Qualifiers tq2 = dstAsPtr->base->qualifiers; 654 654 if ( tq1 <= tq2 && typesCompatibleIgnoreQualifiers( 655 pointerType->base, dstAsPtr->base, symtab,env ) ) {655 pointerType->base, dstAsPtr->base, env ) ) { 656 656 if ( tq1 == tq2 ) { 657 657 cost = Cost::zero; -
src/ResolvExpr/ConversionCost.h
r34b4268 r24d6572 32 32 namespace ResolvExpr { 33 33 class TypeEnvironment; 34 35 Cost conversionCost( 36 const Type * src, const Type * dest, bool srcIsLvalue, 37 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 34 38 35 39 typedef std::function<Cost(const Type *, const Type *, bool, … … 80 84 const ast::SymbolTable &, const ast::TypeEnvironment &)>; 81 85 86 Cost conversionCost( 87 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 88 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 89 90 Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dest, 91 bool srcIsLvalue, const ast::SymbolTable & indexer, const ast::TypeEnvironment & env, 92 PtrsCalculation func ); 93 82 94 #warning when the old ConversionCost is removed, get ride of the _new suffix. 83 95 class ConversionCost_new : public ast::WithShortCircuiting { … … 119 131 }; 120 132 121 Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dest,122 bool srcIsLvalue, const ast::SymbolTable & indexer, const ast::TypeEnvironment & env,123 PtrsCalculation func );124 125 133 } // namespace ResolvExpr 126 134 -
src/ResolvExpr/CurrentObject.cc
r34b4268 r24d6572 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Jun 13 15:28:32 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 1 09:16:01 202213 // Update Count : 1 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Apr 10 9:40:00 2023 13 // Update Count : 18 14 14 // 15 15 … … 26 26 #include "AST/Init.hpp" // for Designation 27 27 #include "AST/Node.hpp" // for readonly 28 #include "AST/Print.hpp" 28 #include "AST/Print.hpp" // for readonly 29 29 #include "AST/Type.hpp" 30 #include "Common/Eval.h" // for eval 30 31 #include "Common/Indenter.h" // for Indenter, operator<< 31 32 #include "Common/SemanticError.h" // for SemanticError … … 592 593 593 594 namespace ast { 595 /// Iterates members of a type by initializer. 596 class MemberIterator { 597 public: 598 virtual ~MemberIterator() {} 599 600 /// Internal set position based on iterator ranges. 601 virtual void setPosition( 602 std::deque< ptr< Expr > >::const_iterator it, 603 std::deque< ptr< Expr > >::const_iterator end ) = 0; 604 605 /// Walks the current object using the given designators as a guide. 606 void setPosition( const std::deque< ptr< Expr > > & designators ) { 607 setPosition( designators.begin(), designators.end() ); 608 } 609 610 /// Retrieve the list of possible (Type,Designation) pairs for the 611 /// current position in the current object. 612 virtual std::deque< InitAlternative > operator* () const = 0; 613 614 /// True if the iterator is not currently at the end. 615 virtual operator bool() const = 0; 616 617 /// Moves the iterator by one member in the current object. 618 virtual MemberIterator & bigStep() = 0; 619 620 /// Moves the iterator by one member in the current subobject. 621 virtual MemberIterator & smallStep() = 0; 622 623 /// The type of the current object. 624 virtual const Type * getType() = 0; 625 626 /// The type of the current subobject. 627 virtual const Type * getNext() = 0; 628 629 /// Helper for operator*; aggregates must add designator to each init 630 /// alternative, but adding designators in operator* creates duplicates. 631 virtual std::deque< InitAlternative > first() const = 0; 632 }; 633 594 634 /// create a new MemberIterator that traverses a type correctly 595 635 MemberIterator * createMemberIterator( const CodeLocation & loc, const Type * type ); … … 631 671 }; 632 672 633 /// Iterates array types 634 class ArrayIterator final : public MemberIterator { 673 /// Iterates over an indexed type: 674 class IndexIterator : public MemberIterator { 675 protected: 635 676 CodeLocation location; 636 const ArrayType * array = nullptr;637 const Type * base = nullptr;638 677 size_t index = 0; 639 678 size_t size = 0; 640 std::unique_ptr< MemberIterator > memberIter; 641 642 void setSize( const Expr * expr ) { 643 auto res = eval( expr ); 644 if ( ! res.second ) { 645 SemanticError( location, toString( "Array designator must be a constant expression: ", expr ) ); 646 } 647 size = res.first; 648 } 649 650 public: 651 ArrayIterator( const CodeLocation & loc, const ArrayType * at ) : location( loc ), array( at ), base( at->base ) { 652 PRINT( std::cerr << "Creating array iterator: " << at << std::endl; ) 653 memberIter.reset( createMemberIterator( loc, base ) ); 654 if ( at->isVarLen ) { 655 SemanticError( location, at, "VLA initialization does not support @=: " ); 656 } 657 setSize( at->dimension ); 658 } 679 std::unique_ptr<MemberIterator> memberIter; 680 public: 681 IndexIterator( const CodeLocation & loc, size_t size ) : 682 location( loc ), size( size ) 683 {} 659 684 660 685 void setPosition( const Expr * expr ) { … … 665 690 auto arg = eval( expr ); 666 691 index = arg.first; 667 return;668 692 669 693 // if ( auto constExpr = dynamic_cast< const ConstantExpr * >( expr ) ) { … … 683 707 684 708 void setPosition( 685 std::deque< ptr< Expr >>::const_iterator begin,686 std::deque< ptr< Expr >>::const_iterator end709 std::deque<ast::ptr<ast::Expr>>::const_iterator begin, 710 std::deque<ast::ptr<ast::Expr>>::const_iterator end 687 711 ) override { 688 712 if ( begin == end ) return; … … 695 719 696 720 operator bool() const override { return index < size; } 721 }; 722 723 /// Iterates over the members of array types: 724 class ArrayIterator final : public IndexIterator { 725 const ArrayType * array = nullptr; 726 const Type * base = nullptr; 727 728 size_t getSize( const Expr * expr ) { 729 auto res = eval( expr ); 730 if ( !res.second ) { 731 SemanticError( location, toString( "Array designator must be a constant expression: ", expr ) ); 732 } 733 return res.first; 734 } 735 736 public: 737 ArrayIterator( const CodeLocation & loc, const ArrayType * at ) : 738 IndexIterator( loc, getSize( at->dimension) ), 739 array( at ), base( at->base ) { 740 PRINT( std::cerr << "Creating array iterator: " << at << std::endl; ) 741 memberIter.reset( createMemberIterator( loc, base ) ); 742 if ( at->isVarLen ) { 743 SemanticError( location, at, "VLA initialization does not support @=: " ); 744 } 745 } 697 746 698 747 ArrayIterator & bigStep() override { … … 833 882 834 883 const Type * getNext() final { 835 return ( memberIter && *memberIter ) ? memberIter->getType() : nullptr; 884 bool hasMember = memberIter && *memberIter; 885 return hasMember ? memberIter->getType() : nullptr; 836 886 } 837 887 … … 897 947 }; 898 948 899 class TupleIterator final : public AggregateIterator { 900 public: 901 TupleIterator( const CodeLocation & loc, const TupleType * inst ) 902 : AggregateIterator( 903 loc, "TupleIterator", toString("Tuple", inst->size()), inst, inst->members 904 ) {} 905 906 operator bool() const override { 907 return curMember != members.end() || (memberIter && *memberIter); 949 /// Iterates across the positions in a tuple: 950 class TupleIterator final : public IndexIterator { 951 ast::TupleType const * const tuple; 952 953 const ast::Type * typeAtIndex() const { 954 assert( index < size ); 955 return tuple->types[ index ].get(); 956 } 957 958 public: 959 TupleIterator( const CodeLocation & loc, const TupleType * type ) 960 : IndexIterator( loc, type->size() ), tuple( type ) { 961 PRINT( std::cerr << "Creating tuple iterator: " << type << std::endl; ) 962 memberIter.reset( createMemberIterator( loc, typeAtIndex() ) ); 908 963 } 909 964 910 965 TupleIterator & bigStep() override { 911 PRINT( std::cerr << "bigStep in " << kind << std::endl; ) 912 atbegin = false; 913 memberIter = nullptr; 914 curType = nullptr; 915 while ( curMember != members.end() ) { 916 ++curMember; 917 if ( init() ) return *this; 918 } 966 ++index; 967 memberIter.reset( index < size ? 968 createMemberIterator( location, typeAtIndex() ) : nullptr ); 919 969 return *this; 970 } 971 972 TupleIterator & smallStep() override { 973 if ( memberIter ) { 974 PRINT( std::cerr << "has member iter: " << *memberIter << std::endl; ) 975 memberIter->smallStep(); 976 if ( !memberIter ) { 977 PRINT( std::cerr << "has valid member iter" << std::endl; ) 978 return *this; 979 } 980 } 981 return bigStep(); 982 } 983 984 const ast::Type * getType() override { 985 return tuple; 986 } 987 988 const ast::Type * getNext() override { 989 bool hasMember = memberIter && *memberIter; 990 return hasMember ? memberIter->getType() : nullptr; 991 } 992 993 std::deque< InitAlternative > first() const override { 994 PRINT( std::cerr << "first in TupleIterator (" << index << "/" << size << ")" << std::endl; ) 995 if ( memberIter && *memberIter ) { 996 std::deque< InitAlternative > ret = memberIter->first(); 997 for ( InitAlternative & alt : ret ) { 998 alt.designation.get_and_mutate()->designators.emplace_front( 999 ConstantExpr::from_ulong( location, index ) ); 1000 } 1001 return ret; 1002 } 1003 return {}; 920 1004 } 921 1005 }; -
src/ResolvExpr/CurrentObject.h
r34b4268 r24d6572 9 9 // Author : Rob Schluntz 10 10 // Created On : Thu Jun 8 11:07:25 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:36:48 201713 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Apr 6 16:14:00 2023 13 // Update Count : 4 14 14 // 15 15 … … 65 65 66 66 /// Iterates members of a type by initializer 67 class MemberIterator { 68 public: 69 virtual ~MemberIterator() {} 70 71 /// Internal set position based on iterator ranges 72 virtual void setPosition( 73 std::deque< ptr< Expr > >::const_iterator it, 74 std::deque< ptr< Expr > >::const_iterator end ) = 0; 75 76 /// walks the current object using the given designators as a guide 77 void setPosition( const std::deque< ptr< Expr > > & designators ) { 78 setPosition( designators.begin(), designators.end() ); 79 } 80 81 /// retrieve the list of possible (Type,Designation) pairs for the current position in the 82 /// current object 83 virtual std::deque< InitAlternative > operator* () const = 0; 84 85 /// true if the iterator is not currently at the end 86 virtual operator bool() const = 0; 87 88 /// moves the iterator by one member in the current object 89 virtual MemberIterator & bigStep() = 0; 90 91 /// moves the iterator by one member in the current subobject 92 virtual MemberIterator & smallStep() = 0; 93 94 /// the type of the current object 95 virtual const Type * getType() = 0; 96 97 /// the type of the current subobject 98 virtual const Type * getNext() = 0; 99 100 /// helper for operator*; aggregates must add designator to each init alternative, but 101 /// adding designators in operator* creates duplicates 102 virtual std::deque< InitAlternative > first() const = 0; 103 }; 67 class MemberIterator; 104 68 105 69 /// Builds initializer lists in resolution -
src/ResolvExpr/ExplodedArg.hpp
r34b4268 r24d6572 35 35 ExplodedArg() : env(), cost( Cost::zero ), exprs() {} 36 36 ExplodedArg( const Candidate & arg, const ast::SymbolTable & symtab ); 37 37 38 38 ExplodedArg( ExplodedArg && ) = default; 39 39 ExplodedArg & operator= ( ExplodedArg && ) = default; -
src/ResolvExpr/PolyCost.cc
r34b4268 r24d6572 15 15 16 16 #include "AST/SymbolTable.hpp" 17 #include "AST/Pass.hpp" 17 18 #include "AST/Type.hpp" 18 19 #include "AST/TypeEnvironment.hpp" -
src/ResolvExpr/PtrsAssignable.cc
r34b4268 r24d6572 14 14 // 15 15 16 #include " typeops.h"16 #include "PtrsAssignable.hpp" 17 17 18 18 #include "AST/Pass.hpp" -
src/ResolvExpr/PtrsCastable.cc
r34b4268 r24d6572 14 14 // 15 15 16 #include "PtrsCastable.hpp" 17 16 18 #include "AST/Decl.hpp" 17 19 #include "AST/Pass.hpp" … … 19 21 #include "AST/TypeEnvironment.hpp" 20 22 #include "Common/PassVisitor.h" 23 #include "ResolvExpr/PtrsAssignable.hpp" // for ptrsAssignable 21 24 #include "ResolvExpr/TypeEnvironment.h" // for EqvClass, TypeEnvironment 22 25 #include "SymTab/Indexer.h" // for Indexer … … 24 27 #include "SynTree/Type.h" // for TypeInstType, Type, BasicType 25 28 #include "SynTree/Visitor.h" // for Visitor 26 #include "typeops.h" // for ptrsAssignable27 29 28 30 namespace ResolvExpr { … … 291 293 return objectCast( src, env, symtab ); 292 294 } else { 293 ast::Pass< PtrsCastable_new > ptrs{ dst, env, symtab }; 294 src->accept( ptrs ); 295 return ptrs.core.result; 295 return ast::Pass<PtrsCastable_new>::read( src, dst, env, symtab ); 296 296 } 297 297 } -
src/ResolvExpr/RenameVars.cc
r34b4268 r24d6572 83 83 84 84 const ast::TypeInstType * rename( const ast::TypeInstType * type ) { 85 // rename86 85 auto it = idMap.find( type->name ); 87 if ( it != idMap.end() ) { 88 // unconditionally mutate because map will *always* have different name 89 ast::TypeInstType * mut = ast::shallowCopy( type ); 90 // reconcile base node since some copies might have been made 91 mut->base = it->second.base; 92 mut->formal_usage = it->second.formal_usage; 93 mut->expr_id = it->second.expr_id; 94 type = mut; 95 } 96 97 return type; 86 if ( it == idMap.end() ) return type; 87 88 // Unconditionally mutate because map will *always* have different name. 89 ast::TypeInstType * mut = ast::shallowCopy( type ); 90 // Reconcile base node since some copies might have been made. 91 mut->base = it->second.base; 92 mut->formal_usage = it->second.formal_usage; 93 mut->expr_id = it->second.expr_id; 94 return mut; 98 95 } 99 96 … … 187 184 188 185 const ast::Type * renameTyVars( const ast::Type * t, RenameMode mode, bool reset ) { 189 // ast::Type *tc = ast::deepCopy(t);190 186 ast::Pass<RenameVars_new> renamer; 191 187 renamer.core.mode = mode; -
src/ResolvExpr/ResolveAssertions.cc
r34b4268 r24d6572 26 26 #include <vector> // for vector 27 27 28 #include "AdjustExprType.hpp" // for adjustExprType 28 29 #include "Alternative.h" // for Alternative, AssertionItem, AssertionList 29 30 #include "Common/FilterCombos.h" // for filterCombos 30 31 #include "Common/Indenter.h" // for Indenter 31 #include "Common/utility.h" // for sort_mins32 32 #include "GenPoly/GenPoly.h" // for getFunctionType 33 #include "ResolvExpr/AlternativeFinder.h" // for computeConversionCost 33 34 #include "ResolvExpr/RenameVars.h" // for renameTyVars 35 #include "SpecCost.hpp" // for specCost 34 36 #include "SymTab/Indexer.h" // for Indexer 35 37 #include "SymTab/Mangler.h" // for Mangler 36 38 #include "SynTree/Expression.h" // for InferredParams 37 39 #include "TypeEnvironment.h" // for TypeEnvironment, etc. 38 #include "typeops.h" // for adjustExprType, specCost39 40 #include "Unify.h" // for unify 40 41 -
src/ResolvExpr/Resolver.cc
r34b4268 r24d6572 38 38 #include "AST/SymbolTable.hpp" 39 39 #include "AST/Type.hpp" 40 #include "Common/Eval.h" // for eval 41 #include "Common/Iterate.hpp" // for group_iterate 40 42 #include "Common/PassVisitor.h" // for PassVisitor 41 43 #include "Common/SemanticError.h" // for SemanticError 42 44 #include "Common/Stats/ResolveTime.h" // for ResolveTime::start(), ResolveTime::stop() 43 #include "Common/ utility.h" // for ValueGuard, group_iterate45 #include "Common/ToString.hpp" // for toCString 44 46 #include "InitTweak/GenInit.h" 45 47 #include "InitTweak/InitTweak.h" // for isIntrinsicSingleArgCallStmt … … 1107 1109 void removeExtraneousCast( ast::ptr<ast::Expr> & expr, const ast::SymbolTable & symtab ) { 1108 1110 if ( const ast::CastExpr * castExpr = expr.as< ast::CastExpr >() ) { 1109 if ( typesCompatible( castExpr->arg->result, castExpr->result , symtab) ) {1111 if ( typesCompatible( castExpr->arg->result, castExpr->result ) ) { 1110 1112 // cast is to the same type as its argument, remove it 1111 1113 swap_and_save_env( expr, castExpr->arg ); … … 1729 1731 1730 1732 // Find all candidates for a function in canonical form 1731 funcFinder.find( clause.target _func, ResolvMode::withAdjustment() );1733 funcFinder.find( clause.target, ResolvMode::withAdjustment() ); 1732 1734 1733 1735 if ( funcFinder.candidates.empty() ) { 1734 1736 stringstream ss; 1735 1737 ss << "Use of undeclared indentifier '"; 1736 ss << clause.target _func.strict_as< ast::NameExpr >()->name;1738 ss << clause.target.strict_as< ast::NameExpr >()->name; 1737 1739 ss << "' in call to waitfor"; 1738 1740 SemanticError( stmt->location, ss.str() ); … … 1833 1835 if ( 1834 1836 ! unify( 1835 arg->expr->result, *param, resultEnv, need, have, open, 1836 symtab ) 1837 arg->expr->result, *param, resultEnv, need, have, open ) 1837 1838 ) { 1838 1839 // Type doesn't match … … 1921 1922 auto clause2 = new ast::WaitForClause( clause.location ); 1922 1923 1923 clause2->target _func= funcCandidates.front()->expr;1924 clause2->target = funcCandidates.front()->expr; 1924 1925 1925 1926 clause2->target_args.reserve( clause.target_args.size() ); … … 1944 1945 1945 1946 // Resolve the conditions as if it were an IfStmt, statements normally 1946 clause2-> cond = findSingleExpression( clause.cond, context );1947 clause2->when_cond = findSingleExpression( clause.when_cond, context ); 1947 1948 clause2->stmt = clause.stmt->accept( *visitor ); 1948 1949 -
src/ResolvExpr/Resolver.h
r34b4268 r24d6572 34 34 class Decl; 35 35 class DeletedExpr; 36 class Expr; 36 37 class Init; 37 38 class StmtExpr; -
src/ResolvExpr/SatisfyAssertions.cpp
r34b4268 r24d6572 24 24 #include <vector> 25 25 26 #include "AdjustExprType.hpp" 26 27 #include "Candidate.hpp" 27 28 #include "CandidateFinder.hpp" 29 #include "CommonType.hpp" 28 30 #include "Cost.h" 29 31 #include "RenameVars.h" 32 #include "SpecCost.hpp" 30 33 #include "typeops.h" 31 34 #include "Unify.h" … … 181 184 .strict_as<ast::FunctionType>()->params[0] 182 185 .strict_as<ast::ReferenceType>()->base; 183 sat.cand->env.apply(thisArgType); 186 // sat.cand->env.apply(thisArgType); 187 188 if (auto inst = thisArgType.as<ast::TypeInstType>()) { 189 auto cls = sat.cand->env.lookup(*inst); 190 if (cls && cls->bound) thisArgType = cls->bound; 191 } 184 192 185 193 std::string otypeKey = ""; … … 218 226 ast::TypeEnvironment tempNewEnv {newEnv}; 219 227 220 if ( unifyExact( toType, adjType, tempNewEnv, newNeed, have, newOpen, WidenMode {true, true} , sat.symtab) ) {228 if ( unifyExact( toType, adjType, tempNewEnv, newNeed, have, newOpen, WidenMode {true, true} ) ) { 221 229 // set up binding slot for recursive assertions 222 230 ast::UniqueId crntResnSlot = 0; … … 234 242 // newEnv = sat.cand->env; 235 243 // newNeed.clear(); 236 if ( auto c = commonType( toType, adjType, newEnv, newNeed, have, newOpen, WidenMode {true, true} , sat.symtab) ) {244 if ( auto c = commonType( toType, adjType, newEnv, newNeed, have, newOpen, WidenMode {true, true} ) ) { 237 245 // set up binding slot for recursive assertions 238 246 ast::UniqueId crntResnSlot = 0; … … 398 406 mergeOpenVars( open, i.match.open ); 399 407 400 if ( ! env.combine( i.match.env, open , symtab) ) return false;408 if ( ! env.combine( i.match.env, open ) ) return false; 401 409 402 410 crnt.emplace_back( i ); -
src/ResolvExpr/Unify.cc
r34b4268 r24d6572 33 33 #include "AST/TypeEnvironment.hpp" 34 34 #include "Common/PassVisitor.h" // for PassVisitor 35 #include "CommonType.hpp" // for commonType 35 36 #include "FindOpenVars.h" // for findOpenVars 37 #include "SpecCost.hpp" // for SpecCost 36 38 #include "SynTree/LinkageSpec.h" // for C 37 39 #include "SynTree/Constant.h" // for Constant … … 43 45 #include "Tuples/Tuples.h" // for isTtype 44 46 #include "TypeEnvironment.h" // for EqvClass, AssertionSet, OpenVarSet 45 #include "typeops.h" // for flatten, occurs , commonType47 #include "typeops.h" // for flatten, occurs 46 48 47 49 namespace ast { … … 50 52 51 53 namespace SymTab { 52 class Indexer;54 class Indexer; 53 55 } // namespace SymTab 54 56 … … 56 58 57 59 namespace ResolvExpr { 60 61 // Template Helpers: 62 template< typename Iterator1, typename Iterator2 > 63 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, std::list< Type* > &commonTypes ) { 64 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { 65 Type *commonType = 0; 66 if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 67 return false; 68 } // if 69 commonTypes.push_back( commonType ); 70 } // for 71 return ( list1Begin == list1End && list2Begin == list2End ); 72 } 73 74 template< typename Iterator1, typename Iterator2 > 75 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 76 std::list< Type* > commonTypes; 77 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) { 78 deleteAll( commonTypes ); 79 return true; 80 } else { 81 return false; 82 } // if 83 } 58 84 59 85 struct Unify_old : public WithShortCircuiting { … … 102 128 const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env, 103 129 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, 104 WidenMode widen , const ast::SymbolTable & symtab);130 WidenMode widen ); 105 131 106 132 bool typesCompatible( const Type * first, const Type * second, const SymTab::Indexer & indexer, const TypeEnvironment & env ) { … … 124 150 125 151 bool typesCompatible( 126 const ast::Type * first, const ast::Type * second, const ast::SymbolTable & symtab,152 const ast::Type * first, const ast::Type * second, 127 153 const ast::TypeEnvironment & env ) { 128 154 ast::TypeEnvironment newEnv; … … 137 163 findOpenVars( newSecond, open, closed, need, have, newEnv, FirstOpen ); 138 164 139 return unifyExact(newFirst, newSecond, newEnv, need, have, open, noWiden() , symtab);165 return unifyExact(newFirst, newSecond, newEnv, need, have, open, noWiden() ); 140 166 } 141 167 … … 157 183 158 184 bool typesCompatibleIgnoreQualifiers( 159 const ast::Type * first, const ast::Type * second, const ast::SymbolTable & symtab,185 const ast::Type * first, const ast::Type * second, 160 186 const ast::TypeEnvironment & env ) { 161 187 ast::TypeEnvironment newEnv; … … 190 216 subFirst, 191 217 subSecond, 192 newEnv, need, have, open, noWiden() , symtab);218 newEnv, need, have, open, noWiden() ); 193 219 } 194 220 … … 760 786 const ast::OpenVarSet & open; 761 787 WidenMode widen; 762 const ast::SymbolTable & symtab;763 788 public: 764 789 static size_t traceId; … … 767 792 Unify_new( 768 793 const ast::Type * type2, ast::TypeEnvironment & env, ast::AssertionSet & need, 769 ast::AssertionSet & have, const ast::OpenVarSet & open, WidenMode widen, 770 const ast::SymbolTable & symtab ) 794 ast::AssertionSet & have, const ast::OpenVarSet & open, WidenMode widen ) 771 795 : type2(type2), tenv(env), need(need), have(have), open(open), widen(widen), 772 symtab(symtab),result(false) {}796 result(false) {} 773 797 774 798 void previsit( const ast::Node * ) { visit_children = false; } … … 788 812 result = unifyExact( 789 813 pointer->base, pointer2->base, tenv, need, have, open, 790 noWiden() , symtab);814 noWiden()); 791 815 } 792 816 } … … 811 835 812 836 result = unifyExact( 813 array->base, array2->base, tenv, need, have, open, noWiden(), 814 symtab ); 837 array->base, array2->base, tenv, need, have, open, noWiden()); 815 838 } 816 839 … … 818 841 if ( auto ref2 = dynamic_cast< const ast::ReferenceType * >( type2 ) ) { 819 842 result = unifyExact( 820 ref->base, ref2->base, tenv, need, have, open, noWiden(), 821 symtab ); 843 ref->base, ref2->base, tenv, need, have, open, noWiden()); 822 844 } 823 845 } … … 828 850 static bool unifyTypeList( 829 851 Iter crnt1, Iter end1, Iter crnt2, Iter end2, ast::TypeEnvironment & env, 830 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, 831 const ast::SymbolTable & symtab 852 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open 832 853 ) { 833 854 while ( crnt1 != end1 && crnt2 != end2 ) { … … 842 863 return unifyExact( 843 864 t1, tupleFromTypes( crnt2, end2 ), env, need, have, open, 844 noWiden() , symtab);865 noWiden() ); 845 866 } else if ( ! isTuple1 && isTuple2 ) { 846 867 // combine remainder of list1, then unify 847 868 return unifyExact( 848 869 tupleFromTypes( crnt1, end1 ), t2, env, need, have, open, 849 noWiden() , symtab);870 noWiden() ); 850 871 } 851 872 852 873 if ( ! unifyExact( 853 t1, t2, env, need, have, open, noWiden() , symtab)874 t1, t2, env, need, have, open, noWiden() ) 854 875 ) return false; 855 876 … … 865 886 return unifyExact( 866 887 t1, tupleFromTypes( crnt2, end2 ), env, need, have, open, 867 noWiden() , symtab);888 noWiden() ); 868 889 } else if ( crnt2 != end2 ) { 869 890 // try unifying empty tuple with ttype … … 872 893 return unifyExact( 873 894 tupleFromTypes( crnt1, end1 ), t2, env, need, have, open, 874 noWiden() , symtab);895 noWiden() ); 875 896 } 876 897 … … 882 903 const std::vector< ast::ptr< ast::Type > > & list2, 883 904 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 884 const ast::OpenVarSet & open , const ast::SymbolTable & symtab905 const ast::OpenVarSet & open 885 906 ) { 886 907 return unifyTypeList( 887 list1.begin(), list1.end(), list2.begin(), list2.end(), env, need, have, open, 888 symtab ); 908 list1.begin(), list1.end(), list2.begin(), list2.end(), env, need, have, open); 889 909 } 890 910 … … 927 947 ) return; 928 948 929 if ( ! unifyTypeList( params, params2, tenv, need, have, open , symtab) ) return;949 if ( ! unifyTypeList( params, params2, tenv, need, have, open ) ) return; 930 950 if ( ! unifyTypeList( 931 func->returns, func2->returns, tenv, need, have, open , symtab) ) return;951 func->returns, func2->returns, tenv, need, have, open ) ) return; 932 952 933 953 markAssertions( have, need, func ); … … 944 964 // check that the other type is compatible and named the same 945 965 auto otherInst = dynamic_cast< const XInstType * >( other ); 946 if (otherInst && inst->name == otherInst->name) this->result = otherInst; 966 if (otherInst && inst->name == otherInst->name) 967 this->result = otherInst; 947 968 return otherInst; 948 969 } … … 1000 1021 1001 1022 if ( ! unifyExact( 1002 pty, pty2, tenv, need, have, open, noWiden() , symtab) ) {1023 pty, pty2, tenv, need, have, open, noWiden() ) ) { 1003 1024 result = false; 1004 1025 return; … … 1030 1051 void postvisit( const ast::TypeInstType * typeInst ) { 1031 1052 // assert( open.find( *typeInst ) == open.end() ); 1032 handleRefType( typeInst, type2 ); 1053 auto otherInst = dynamic_cast< const ast::TypeInstType * >( type2 ); 1054 if (otherInst && typeInst->name == otherInst->name) 1055 this->result = otherInst; 1056 // return otherInst; 1033 1057 } 1034 1058 … … 1039 1063 const std::vector< ast::ptr< ast::Type > > & list1, 1040 1064 const std::vector< ast::ptr< ast::Type > > & list2, ast::TypeEnvironment & env, 1041 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, 1042 const ast::SymbolTable & symtab 1065 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open 1043 1066 ) { 1044 1067 auto crnt1 = list1.begin(); … … 1055 1078 return unifyExact( 1056 1079 t1, tupleFromTypes( list2 ), env, need, have, open, 1057 noWiden() , symtab);1080 noWiden() ); 1058 1081 } else if ( ! isTuple1 && isTuple2 ) { 1059 1082 // combine entirety of list1, then unify 1060 1083 return unifyExact( 1061 1084 tupleFromTypes( list1 ), t2, env, need, have, open, 1062 noWiden() , symtab);1085 noWiden() ); 1063 1086 } 1064 1087 1065 1088 if ( ! unifyExact( 1066 t1, t2, env, need, have, open, noWiden() , symtab)1089 t1, t2, env, need, have, open, noWiden() ) 1067 1090 ) return false; 1068 1091 … … 1078 1101 return unifyExact( 1079 1102 t1, tupleFromTypes( list2 ), env, need, have, open, 1080 noWiden() , symtab);1103 noWiden() ); 1081 1104 } else if ( crnt2 != list2.end() ) { 1082 1105 // try unifying empty tuple with ttype … … 1087 1110 return unifyExact( 1088 1111 tupleFromTypes( list1 ), t2, env, need, have, open, 1089 noWiden() , symtab);1112 noWiden() ); 1090 1113 } 1091 1114 … … 1106 1129 auto types2 = flatten( flat2 ); 1107 1130 1108 result = unifyList( types, types2, tenv, need, have, open , symtab);1131 result = unifyList( types, types2, tenv, need, have, open ); 1109 1132 } 1110 1133 … … 1130 1153 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 1131 1154 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 1132 ast::OpenVarSet & open , const ast::SymbolTable & symtab1155 ast::OpenVarSet & open 1133 1156 ) { 1134 1157 ast::ptr<ast::Type> common; 1135 return unify( type1, type2, env, need, have, open, symtab,common );1158 return unify( type1, type2, env, need, have, open, common ); 1136 1159 } 1137 1160 … … 1139 1162 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 1140 1163 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 1141 ast::OpenVarSet & open, const ast::SymbolTable & symtab,ast::ptr<ast::Type> & common1164 ast::OpenVarSet & open, ast::ptr<ast::Type> & common 1142 1165 ) { 1143 1166 ast::OpenVarSet closed; … … 1145 1168 findOpenVars( type2, open, closed, need, have, env, FirstOpen ); 1146 1169 return unifyInexact( 1147 type1, type2, env, need, have, open, WidenMode{ true, true }, symtab,common );1170 type1, type2, env, need, have, open, WidenMode{ true, true }, common ); 1148 1171 } 1149 1172 … … 1151 1174 const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env, 1152 1175 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, 1153 WidenMode widen , const ast::SymbolTable & symtab1176 WidenMode widen 1154 1177 ) { 1155 1178 if ( type1->qualifiers != type2->qualifiers ) return false; … … 1170 1193 return env.bindVarToVar( 1171 1194 var1, var2, ast::TypeData{ entry1->second, entry2->second }, need, have, 1172 open, widen , symtab);1195 open, widen ); 1173 1196 } else if ( isopen1 ) { 1174 return env.bindVar( var1, type2, entry1->second, need, have, open, widen , symtab);1197 return env.bindVar( var1, type2, entry1->second, need, have, open, widen ); 1175 1198 } else if ( isopen2 ) { 1176 1199 return env.bindVar( var2, type1, entry2->second, need, have, open, widen, symtab ); … … 1180 1203 return env.bindVarToVar( 1181 1204 var1, var2, ast::TypeData{ var1->base->kind, var1->base->sized||var2->base->sized }, need, have, 1182 open, widen , symtab);1205 open, widen ); 1183 1206 } else if ( isopen1 ) { 1184 return env.bindVar( var1, type2, ast::TypeData{var1->base}, need, have, open, widen , symtab);1207 return env.bindVar( var1, type2, ast::TypeData{var1->base}, need, have, open, widen ); 1185 1208 } else if ( isopen2 ) { 1186 return env.bindVar( var2, type1, ast::TypeData{var2->base}, need, have, open, widen , symtab);1209 return env.bindVar( var2, type1, ast::TypeData{var2->base}, need, have, open, widen ); 1187 1210 }else { 1188 1211 return ast::Pass<Unify_new>::read( 1189 type1, type2, env, need, have, open, widen , symtab);1212 type1, type2, env, need, have, open, widen ); 1190 1213 } 1191 1214 … … 1195 1218 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 1196 1219 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 1197 const ast::OpenVarSet & open, WidenMode widen, const ast::SymbolTable & symtab,1220 const ast::OpenVarSet & open, WidenMode widen, 1198 1221 ast::ptr<ast::Type> & common 1199 1222 ) { … … 1209 1232 ast::ptr< ast::Type > t2_(t2); 1210 1233 1211 if ( unifyExact( t1, t2, env, need, have, open, widen , symtab) ) {1234 if ( unifyExact( t1, t2, env, need, have, open, widen ) ) { 1212 1235 // if exact unification on unqualified types, try to merge qualifiers 1213 1236 if ( q1 == q2 || ( ( q1 > q2 || widen.first ) && ( q2 > q1 || widen.second ) ) ) { … … 1219 1242 } 1220 1243 1221 } else if (( common = commonType( t1, t2, env, need, have, open, widen , symtab))) {1244 } else if (( common = commonType( t1, t2, env, need, have, open, widen ))) { 1222 1245 // no exact unification, but common type 1223 1246 auto c = shallowCopy(common.get()); -
src/ResolvExpr/Unify.h
r34b4268 r24d6572 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 13:09:04 2015 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Mon Jun 18 11:58:00 201813 // Update Count : 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jan 17 11:12:00 2023 13 // Update Count : 5 14 14 // 15 15 … … 37 37 38 38 namespace ResolvExpr { 39 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );40 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType );41 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );42 bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer, Type *&common );43 39 44 template< typename Iterator1, typename Iterator2 > 45 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, std::list< Type* > &commonTypes ) { 46 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { 47 Type *commonType = 0; 48 if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 49 return false; 50 } // if 51 commonTypes.push_back( commonType ); 52 } // for 53 if ( list1Begin != list1End || list2Begin != list2End ) { 54 return false; 55 } else { 56 return true; 57 } // if 58 } 40 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 41 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); 42 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 43 bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer, Type *&common ); 59 44 60 template< typename Iterator1, typename Iterator2 > 61 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 62 std::list< Type* > commonTypes; 63 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) { 64 deleteAll( commonTypes ); 65 return true; 66 } else { 67 return false; 68 } // if 69 } 45 bool typesCompatible( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 46 bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 70 47 71 bool unify( 72 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2,73 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have,74 ast::OpenVarSet & open, const ast::SymbolTable & symtab ); 48 inline bool typesCompatible( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 49 TypeEnvironment env; 50 return typesCompatible( t1, t2, indexer, env ); 51 } 75 52 76 bool unify( 77 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2,78 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have,79 ast::OpenVarSet & open, const ast::SymbolTable & symtab, ast::ptr<ast::Type> & common ); 53 inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 54 TypeEnvironment env; 55 return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env ); 56 } 80 57 81 bool unifyExact( 82 const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env,83 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open,84 WidenMode widen, const ast::SymbolTable & symtab);58 bool unify( 59 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 60 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 61 ast::OpenVarSet & open ); 85 62 86 bool unifyInexact( 87 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 88 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 89 const ast::OpenVarSet & open, WidenMode widen, const ast::SymbolTable & symtab, 90 ast::ptr<ast::Type> & common ); 63 bool unify( 64 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 65 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 66 ast::OpenVarSet & open, ast::ptr<ast::Type> & common ); 67 68 bool unifyExact( 69 const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env, 70 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, 71 WidenMode widen ); 72 73 bool unifyInexact( 74 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 75 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 76 const ast::OpenVarSet & open, WidenMode widen, 77 ast::ptr<ast::Type> & common ); 78 79 bool typesCompatible( 80 const ast::Type *, const ast::Type *, 81 const ast::TypeEnvironment & env = {} ); 82 83 bool typesCompatibleIgnoreQualifiers( 84 const ast::Type *, const ast::Type *, 85 const ast::TypeEnvironment & env = {} ); 86 87 /// Creates the type represented by the list of returnVals in a FunctionType. 88 /// The caller owns the return value. 89 Type * extractResultType( FunctionType * functionType ); 90 /// Creates or extracts the type represented by returns in a `FunctionType`. 91 ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func ); 92 93 std::vector<ast::ptr<ast::Type>> flattenList( 94 const std::vector<ast::ptr<ast::Type>> & src, ast::TypeEnvironment & env 95 ); 91 96 92 97 } // namespace ResolvExpr -
src/ResolvExpr/WidenMode.h
r34b4268 r24d6572 19 19 struct WidenMode { 20 20 WidenMode( bool first, bool second ): first( first ), second( second ) {} 21 21 22 22 WidenMode &operator|=( const WidenMode &other ) { 23 23 first |= other.first; second |= other.second; return *this; … … 35 35 WidenMode newWM( *this ); newWM &= other; return newWM; 36 36 } 37 37 38 38 operator bool() { return first && second; } 39 39 -
src/ResolvExpr/module.mk
r34b4268 r24d6572 17 17 SRC_RESOLVEXPR = \ 18 18 ResolvExpr/AdjustExprType.cc \ 19 ResolvExpr/AdjustExprType.hpp \ 19 20 ResolvExpr/Alternative.cc \ 20 21 ResolvExpr/AlternativeFinder.cc \ … … 26 27 ResolvExpr/Candidate.hpp \ 27 28 ResolvExpr/CastCost.cc \ 29 ResolvExpr/CastCost.hpp \ 28 30 ResolvExpr/CommonType.cc \ 31 ResolvExpr/CommonType.hpp \ 29 32 ResolvExpr/ConversionCost.cc \ 30 33 ResolvExpr/ConversionCost.h \ … … 40 43 ResolvExpr/Occurs.cc \ 41 44 ResolvExpr/PolyCost.cc \ 45 ResolvExpr/PolyCost.hpp \ 42 46 ResolvExpr/PtrsAssignable.cc \ 47 ResolvExpr/PtrsAssignable.hpp \ 43 48 ResolvExpr/PtrsCastable.cc \ 49 ResolvExpr/PtrsCastable.hpp \ 44 50 ResolvExpr/RenameVars.cc \ 45 51 ResolvExpr/RenameVars.h \ … … 54 60 ResolvExpr/SatisfyAssertions.hpp \ 55 61 ResolvExpr/SpecCost.cc \ 62 ResolvExpr/SpecCost.hpp \ 56 63 ResolvExpr/TypeEnvironment.cc \ 57 64 ResolvExpr/TypeEnvironment.h \ -
src/ResolvExpr/typeops.h
r34b4268 r24d6572 10 10 // Created On : Sun May 17 07:28:22 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Oct 1 09:45:00 201913 // Update Count : 612 // Last Modified On : Wed Jan 18 11:54:00 2023 13 // Update Count : 7 14 14 // 15 15 … … 18 18 #include <vector> 19 19 20 #include "Cost.h"21 #include "TypeEnvironment.h"22 #include "WidenMode.h"23 #include "AST/Fwd.hpp"24 #include "AST/Node.hpp"25 #include "AST/SymbolTable.hpp"26 20 #include "AST/Type.hpp" 27 #include "AST/TypeEnvironment.hpp"28 #include "SynTree/SynTree.h"29 21 #include "SynTree/Type.h" 30 22 … … 34 26 35 27 namespace ResolvExpr { 28 class TypeEnvironment; 29 36 30 // combos: takes a list of sets and returns a set of lists representing every possible way of forming a list by 37 31 // picking one element out of each set … … 61 55 } 62 56 63 // in AdjustExprType.cc64 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function65 void adjustExprType( Type *& type, const TypeEnvironment & env, const SymTab::Indexer & indexer );66 67 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function using empty TypeEnvironment and Indexer68 void adjustExprType( Type *& type );69 70 template< typename ForwardIterator >71 void adjustExprTypeList( ForwardIterator begin, ForwardIterator end, const TypeEnvironment & env, const SymTab::Indexer & indexer ) {72 while ( begin != end ) {73 adjustExprType( *begin++, env, indexer );74 } // while75 }76 77 /// Replaces array types with equivalent pointer, and function types with a pointer-to-function78 const ast::Type * adjustExprType(79 const ast::Type * type, const ast::TypeEnvironment & env, const ast::SymbolTable & symtab );80 81 // in CastCost.cc82 Cost castCost( const Type * src, const Type * dest, bool srcIsLvalue,83 const SymTab::Indexer & indexer, const TypeEnvironment & env );84 Cost castCost(85 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,86 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );87 88 // in ConversionCost.cc89 Cost conversionCost( const Type * src, const Type * dest, bool srcIsLvalue,90 const SymTab::Indexer & indexer, const TypeEnvironment & env );91 Cost conversionCost(92 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,93 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );94 95 // in AlternativeFinder.cc96 Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue,97 const SymTab::Indexer & indexer, const TypeEnvironment & env );98 99 // in PtrsAssignable.cc100 int ptrsAssignable( const Type * src, const Type * dest, const TypeEnvironment & env );101 int ptrsAssignable( const ast::Type * src, const ast::Type * dst,102 const ast::TypeEnvironment & env );103 104 // in PtrsCastable.cc105 int ptrsCastable( const Type * src, const Type * dest, const TypeEnvironment & env, const SymTab::Indexer & indexer );106 int ptrsCastable(107 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,108 const ast::TypeEnvironment & env );109 110 // in Unify.cc111 bool typesCompatible( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env );112 bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env );113 114 inline bool typesCompatible( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) {115 TypeEnvironment env;116 return typesCompatible( t1, t2, indexer, env );117 }118 119 inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) {120 TypeEnvironment env;121 return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env );122 }123 124 bool typesCompatible(125 const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {},126 const ast::TypeEnvironment & env = {} );127 128 bool typesCompatibleIgnoreQualifiers(129 const ast::Type *, const ast::Type *, const ast::SymbolTable &,130 const ast::TypeEnvironment & env = {} );131 132 /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value.133 Type * extractResultType( FunctionType * functionType );134 /// Creates or extracts the type represented by the list of returns in a `FunctionType`.135 ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func );136 137 // in CommonType.cc138 Type * commonType( Type * type1, Type * type2, bool widenFirst, bool widenSecond, const SymTab::Indexer & indexer, TypeEnvironment & env, const OpenVarSet & openVars );139 ast::ptr< ast::Type > commonType(140 const ast::ptr< ast::Type > & type1, const ast::ptr< ast::Type > & type2,141 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have,142 const ast::OpenVarSet & open, WidenMode widen, const ast::SymbolTable & symtab143 );144 // in Unify.cc145 std::vector< ast::ptr< ast::Type > > flattenList(146 const std::vector< ast::ptr< ast::Type > > & src, ast::TypeEnvironment & env147 );148 149 // in PolyCost.cc150 int polyCost( Type * type, const TypeEnvironment & env, const SymTab::Indexer & indexer );151 int polyCost(152 const ast::Type * type, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );153 154 // in SpecCost.cc155 int specCost( Type * type );156 int specCost( const ast::Type * type );157 158 57 // in Occurs.cc 159 58 bool occurs( const Type * type, const std::string & varName, const TypeEnvironment & env ); … … 168 67 return false; 169 68 } 170 171 // in AlternativeFinder.cc172 void referenceToRvalueConversion( Expression *& expr, Cost & cost );173 // in CandidateFinder.cpp174 const ast::Expr * referenceToRvalueConversion( const ast::Expr * expr, Cost & cost );175 69 176 70 /// flatten tuple type into list of types … … 218 112 } 219 113 220 221 114 return new ast::TupleType{ std::move(types) }; 222 115 } … … 227 120 return tupleFromTypes( tys.begin(), tys.end() ); 228 121 } 229 230 231 122 232 123 // in TypeEnvironment.cc
Note:
See TracChangeset
for help on using the changeset viewer.