Changeset cf32116
- Timestamp:
- Oct 4, 2019, 3:07:07 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3f3bfe5a
- Parents:
- 90ce35aa
- Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Expr.cpp
r90ce35aa rcf32116 10 10 // Created On : Wed May 15 17:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Created On : Thr Jun 13 13:38:00 201913 // Update Count : 212 // Created On : Thr Jun 26 12:12:00 2019 13 // Update Count : 3 14 14 // 15 15 … … 23 23 #include "Eval.hpp" // for call 24 24 #include "GenericSubstitution.hpp" 25 #include "LinkageSpec.hpp" 25 26 #include "Stmt.hpp" 26 27 #include "Type.hpp" … … 29 30 #include "Common/SemanticError.h" 30 31 #include "GenPoly/Lvalue.h" // for referencesPermissable 31 #include "InitTweak/InitTweak.h" // for get PointerBase32 #include "InitTweak/InitTweak.h" // for getFunction, getPointerBase 32 33 #include "ResolvExpr/typeops.h" // for extractResultType 33 34 #include "Tuples/Tuples.h" // for makeTupleType 34 35 35 36 namespace ast { 37 38 namespace { 39 std::set<std::string> const lvalueFunctionNames = {"*?", "?[?]"}; 40 } 41 42 // --- Expr 43 bool Expr::get_lvalue() const { 44 return false; 45 } 36 46 37 47 // --- ApplicationExpr … … 46 56 result = ResolvExpr::extractResultType( fn ); 47 57 assert( result ); 58 } 59 60 bool ApplicationExpr::get_lvalue() const { 61 if ( const DeclWithType * func = InitTweak::getFunction( this ) ) { 62 return func->linkage == Linkage::Intrinsic && lvalueFunctionNames.count( func->name ); 63 } 64 return false; 48 65 } 49 66 … … 71 88 } 72 89 90 bool UntypedExpr::get_lvalue() const { 91 std::string fname = InitTweak::getFunctionName( this ); 92 return lvalueFunctionNames.count( fname ); 93 } 94 73 95 UntypedExpr * UntypedExpr::createAssign( const CodeLocation & loc, Expr * lhs, Expr * rhs ) { 74 96 assert( lhs && rhs ); … … 106 128 AddressExpr::AddressExpr( const CodeLocation & loc, const Expr * a ) : Expr( loc ), arg( a ) { 107 129 if ( arg->result ) { 108 if ( arg-> result->is_lvalue() ) {130 if ( arg->get_lvalue() ) { 109 131 // lvalue, retains all levels of reference, and gains a pointer inside the references 110 132 Type * res = addrType( arg->result ); … … 137 159 : Expr( loc, new VoidType{} ), arg( a ), isGenerated( g ) {} 138 160 161 bool CastExpr::get_lvalue() const { 162 // This is actually wrong by C, but it works with our current set-up. 163 return arg->get_lvalue(); 164 } 165 139 166 // --- KeywordCastExpr 140 167 … … 150 177 } 151 178 179 // --- UntypedMemberExpr 180 181 bool UntypedMemberExpr::get_lvalue() const { 182 return aggregate->get_lvalue(); 183 } 184 152 185 // --- MemberExpr 153 186 … … 210 243 } 211 244 245 bool MemberExpr::get_lvalue() const { 246 // This is actually wrong by C, but it works with our current set-up. 247 return true; 248 } 249 212 250 // --- VariableExpr 213 251 … … 222 260 r->qualifiers |= CV::Lvalue; 223 261 result = r; 262 } 263 264 bool VariableExpr::get_lvalue() const { 265 // It isn't always an lvalue, but it is never an rvalue. 266 return true; 224 267 } 225 268 … … 308 351 : Expr( loc, new BasicType{ BasicType::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {} 309 352 353 // --- CommaExpr 354 bool CommaExpr::get_lvalue() const { 355 // This is wrong by C, but the current implementation uses it. 356 // (ex: Specialize, Lvalue and Box) 357 return arg2->get_lvalue(); 358 } 359 310 360 // --- ConstructorExpr 311 361 … … 329 379 } 330 380 381 bool CompoundLiteralExpr::get_lvalue() const { 382 return true; 383 } 384 331 385 // --- TupleExpr 332 386 … … 344 398 result = type->types[ index ]; 345 399 add_qualifiers( result, CV::Lvalue ); 400 } 401 402 bool TupleIndexExpr::get_lvalue() const { 403 return tuple->get_lvalue(); 346 404 } 347 405 -
src/AST/Expr.hpp
r90ce35aa rcf32116 9 9 // Author : Aaron B. Moss 10 10 // Created On : Fri May 10 10:30:00 2019 11 // Last Modified By : A aron B. Moss12 // Created On : Fri May 10 10:30:00 201913 // Update Count : 111 // Last Modified By : Andrew Beach 12 // Created On : Thr Sep 26 12:51:00 2019 13 // Update Count : 2 14 14 // 15 15 … … 187 187 188 188 Expr * set_extension( bool ex ) { extension = ex; return this; } 189 virtual bool get_lvalue() const; 189 190 190 191 virtual const Expr * accept( Visitor & v ) const override = 0; … … 203 204 ApplicationExpr( const CodeLocation & loc, const Expr * f, std::vector<ptr<Expr>> && as = {} ); 204 205 206 bool get_lvalue() const final; 207 205 208 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 206 209 private: … … 217 220 UntypedExpr( const CodeLocation & loc, const Expr * f, std::vector<ptr<Expr>> && as = {} ) 218 221 : Expr( loc ), func( f ), args( std::move(as) ) {} 222 223 bool get_lvalue() const final; 219 224 220 225 /// Creates a new dereference expression … … 293 298 CastExpr( const Expr * a ) : CastExpr( a->location, a, GeneratedCast ) {} 294 299 300 bool get_lvalue() const final; 301 295 302 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 296 303 private: … … 340 347 : Expr( loc ), member( mem ), aggregate( agg ) { assert( aggregate ); } 341 348 349 bool get_lvalue() const final; 350 342 351 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 343 352 private: … … 353 362 354 363 MemberExpr( const CodeLocation & loc, const DeclWithType * mem, const Expr * agg ); 364 365 bool get_lvalue() const final; 355 366 356 367 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } … … 374 385 VariableExpr( const CodeLocation & loc ); 375 386 VariableExpr( const CodeLocation & loc, const DeclWithType * v ); 387 388 bool get_lvalue() const final; 376 389 377 390 /// generates a function pointer for a given function … … 545 558 } 546 559 560 bool get_lvalue() const final; 561 547 562 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 548 563 private: … … 616 631 CompoundLiteralExpr( const CodeLocation & loc, const Type * t, const Init * i ); 617 632 633 bool get_lvalue() const final; 634 618 635 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 619 636 private: … … 671 688 672 689 TupleIndexExpr( const CodeLocation & loc, const Expr * t, unsigned i ); 690 691 bool get_lvalue() const final; 673 692 674 693 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } -
src/ResolvExpr/CandidateFinder.cpp
r90ce35aa rcf32116 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed Jun 5 14:30:00 2019 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Wed Jun 5 14:30:00 201913 // Update Count : 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Oct 1 14:55:00 2019 13 // Update Count : 2 14 14 // 15 15 … … 62 62 63 63 Cost computeConversionCost( 64 const ast::Type * argType, const ast::Type * paramType, const ast::SymbolTable & symtab,65 const ast:: TypeEnvironment & env64 const ast::Type * argType, const ast::Type * paramType, bool argIsLvalue, 65 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env 66 66 ) { 67 67 PRINT( … … 74 74 std::cerr << std::endl; 75 75 ) 76 Cost convCost = conversionCost( argType, paramType, symtab, env );76 Cost convCost = conversionCost( argType, paramType, argIsLvalue, symtab, env ); 77 77 PRINT( 78 78 std::cerr << std::endl << "cost is " << convCost << std::endl; … … 110 110 const ast::Expr * arg, const ast::Type * paramType, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env, Cost & outCost 111 111 ) { 112 Cost convCost = computeConversionCost( arg->result, paramType, symtab, env ); 112 Cost convCost = computeConversionCost( 113 arg->result, paramType, arg->get_lvalue(), symtab, env ); 113 114 outCost += convCost; 114 115 … … 982 983 /// true if expression is an lvalue 983 984 static bool isLvalue( const ast::Expr * x ) { 984 return x->result && ( x-> result->is_lvalue() || x->result.as< ast::ReferenceType >() );985 return x->result && ( x->get_lvalue() || x->result.as< ast::ReferenceType >() ); 985 986 } 986 987 … … 1024 1025 // unification run for side-effects 1025 1026 unify( toType, cand->expr->result, cand->env, need, have, open, symtab ); 1026 Cost thisCost = castCost( cand->expr->result, toType, symtab, cand->env ); 1027 Cost thisCost = castCost( cand->expr->result, toType, cand->expr->get_lvalue(), 1028 symtab, cand->env ); 1027 1029 PRINT( 1028 1030 std::cerr << "working on cast with result: " << toType << std::endl; … … 1434 1436 // unification run for side-effects 1435 1437 unify( toType, cand->expr->result, env, need, have, open, symtab ); 1436 Cost thisCost = castCost( cand->expr->result, toType, symtab, env ); 1438 Cost thisCost = castCost( cand->expr->result, toType, cand->expr->get_lvalue(), 1439 symtab, env ); 1437 1440 1438 1441 if ( thisCost != Cost::infinity ) { -
src/ResolvExpr/CandidateFinder.hpp
r90ce35aa rcf32116 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed Jun 5 14:30:00 2019 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Wed Jun 5 14:30:00 201913 // Update Count : 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Oct 1 9:51:00 2019 13 // Update Count : 2 14 14 // 15 15 … … 32 32 ast::ptr< ast::Type > targetType; ///< Target type for resolution 33 33 34 CandidateFinder( 35 const ast::SymbolTable & syms, const ast::TypeEnvironment & env, 34 CandidateFinder( 35 const ast::SymbolTable & syms, const ast::TypeEnvironment & env, 36 36 const ast::Type * tt = nullptr ) 37 37 : candidates(), localSyms( syms ), env( env ), targetType( tt ) {} … … 49 49 iterator begin() { return candidates.begin(); } 50 50 const_iterator begin() const { return candidates.begin(); } 51 51 52 52 iterator end() { return candidates.end(); } 53 53 const_iterator end() const { return candidates.end(); } … … 55 55 56 56 /// Computes conversion cost between two types 57 Cost computeConversionCost( 58 const ast::Type * argType, const ast::Type * paramType, const ast::SymbolTable & symtab,59 const ast:: TypeEnvironment & env );57 Cost computeConversionCost( 58 const ast::Type * argType, const ast::Type * paramType, bool argIsLvalue, 59 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 60 60 61 61 } // namespace ResolvExpr -
src/ResolvExpr/CastCost.cc
r90ce35aa rcf32116 10 10 // Created On : Sun May 17 06:57:43 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T hu Aug 8 16:12:00 201913 // Update Count : 812 // Last Modified On : Tue Oct 4 15:00:00 2019 13 // Update Count : 9 14 14 // 15 15 … … 142 142 143 143 CastCost_new( 144 const ast::Type * dst, const ast::SymbolTable & symtab,144 const ast::Type * dst, bool srcIsLvalue, const ast::SymbolTable & symtab, 145 145 const ast::TypeEnvironment & env, CostCalculation costFunc ) 146 : ConversionCost_new( dst, s ymtab, env, costFunc ) {}146 : ConversionCost_new( dst, srcIsLvalue, symtab, env, costFunc ) {} 147 147 148 148 void postvisit( const ast::BasicType * basicType ) { … … 152 152 cost = Cost::unsafe; 153 153 } else { 154 cost = conversionCost( basicType, dst, s ymtab, env );154 cost = conversionCost( basicType, dst, srcIsLvalue, symtab, env ); 155 155 } 156 156 } … … 183 183 } 184 184 }; 185 186 #warning For overload resolution between the two versions. 187 int localPtrsCastable(const ast::Type * t1, const ast::Type * t2, 188 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ) { 189 return ptrsCastable( t1, t2, symtab, env ); 190 } 191 Cost localCastCost( 192 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 193 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env 194 ) { return castCost( src, dst, srcIsLvalue, symtab, env ); } 185 195 } // anonymous namespace 186 196 197 198 187 199 Cost castCost( 188 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,189 const ast:: TypeEnvironment & env200 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 201 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env 190 202 ) { 191 203 if ( auto typeInst = dynamic_cast< const ast::TypeInstType * >( dst ) ) { … … 193 205 // check cast cost against bound type, if present 194 206 if ( eqvClass->bound ) { 195 return castCost( src, eqvClass->bound, s ymtab, env );207 return castCost( src, eqvClass->bound, srcIsLvalue, symtab, env ); 196 208 } else { 197 209 return Cost::infinity; … … 201 213 auto type = strict_dynamic_cast< const ast::TypeDecl * >( named ); 202 214 if ( type->base ) { 203 return castCost( src, type->base, s ymtab, env ) + Cost::safe;215 return castCost( src, type->base, srcIsLvalue, symtab, env ) + Cost::safe; 204 216 } 205 217 } … … 224 236 #warning cast on ptrsCastable artifact of having two functions, remove when port done 225 237 return convertToReferenceCost( 226 src, refType, symtab, env, 227 ( int (*)( 228 const ast::Type *, const ast::Type *, const ast::SymbolTable &, 229 const ast::TypeEnvironment & ) 230 ) ptrsCastable ); 238 src, refType, srcIsLvalue, symtab, env, localPtrsCastable ); 231 239 } else { 232 240 #warning cast on castCost artifact of having two functions, remove when port done 233 ast::Pass< CastCost_new > converter{ 234 dst, symtab, env, 235 ( Cost (*)( 236 const ast::Type *, const ast::Type *, const ast::SymbolTable &, 237 const ast::TypeEnvironment & ) 238 ) castCost }; 241 ast::Pass< CastCost_new > converter( 242 dst, srcIsLvalue, symtab, env, localCastCost ); 239 243 src->accept( converter ); 240 244 return converter.pass.cost; -
src/ResolvExpr/ConversionCost.cc
r90ce35aa rcf32116 10 10 // Created On : Sun May 17 07:06:19 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Jul 4 10:56:00 201913 // Update Count : 2 712 // Last Modified On : Fri Oct 4 14:45:00 2019 13 // Update Count : 28 14 14 // 15 15 … … 497 497 } 498 498 499 static int localPtrsAssignable(const ast::Type * t1, const ast::Type * t2, 500 const ast::SymbolTable &, const ast::TypeEnvironment & env ) {501 return ptrsAssignable( t1, t2, env );502 } 503 504 // TODO: This is used for overload resolution. It might be able to be dropped once the old system 505 // is removed. 506 static Cost localConversionCost( 507 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,508 const ast::TypeEnvironment & env509 ) { return conversionCost( src, dst, symtab, env );}499 namespace { 500 # warning For overload resolution between the two versions. 501 int localPtrsAssignable(const ast::Type * t1, const ast::Type * t2, 502 const ast::SymbolTable &, const ast::TypeEnvironment & env ) { 503 return ptrsAssignable( t1, t2, env ); 504 } 505 Cost localConversionCost( 506 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 507 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env 508 ) { return conversionCost( src, dst, srcIsLvalue, symtab, env ); } 509 } 510 510 511 511 Cost conversionCost( 512 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,513 const ast:: TypeEnvironment & env512 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 513 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env 514 514 ) { 515 515 if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( dst ) ) { 516 516 if ( const ast::EqvClass * eqv = env.lookup( inst->name ) ) { 517 517 if ( eqv->bound ) { 518 return conversionCost(src, eqv->bound, s ymtab, env );518 return conversionCost(src, eqv->bound, srcIsLvalue, symtab, env ); 519 519 } else { 520 520 return Cost::infinity; … … 524 524 assertf( type, "Unexpected typedef." ); 525 525 if ( type->base ) { 526 return conversionCost( src, type->base, s ymtab, env ) + Cost::safe;526 return conversionCost( src, type->base, srcIsLvalue, symtab, env ) + Cost::safe; 527 527 } 528 528 } … … 534 534 } else if ( const ast::ReferenceType * refType = 535 535 dynamic_cast< const ast::ReferenceType * >( dst ) ) { 536 return convertToReferenceCost( src, refType, s ymtab, env, localPtrsAssignable );536 return convertToReferenceCost( src, refType, srcIsLvalue, symtab, env, localPtrsAssignable ); 537 537 } else { 538 ast::Pass<ConversionCost_new> converter( dst, s ymtab, env, localConversionCost );538 ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost ); 539 539 src->accept( converter ); 540 540 return converter.pass.cost; … … 542 542 } 543 543 544 static Cost convertToReferenceCost( const ast::Type * src, const ast::Type * dst, 544 static Cost convertToReferenceCost( const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 545 545 int diff, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env, 546 NumCostCalculation func ) {546 PtrsCalculation func ) { 547 547 if ( 0 < diff ) { 548 548 Cost cost = convertToReferenceCost( 549 strict_dynamic_cast< const ast::ReferenceType * >( src )->base, 550 dst, (diff - 1), symtab, env, func );549 strict_dynamic_cast< const ast::ReferenceType * >( src )->base, dst, 550 srcIsLvalue, (diff - 1), symtab, env, func ); 551 551 cost.incReference(); 552 552 return cost; … … 554 554 Cost cost = convertToReferenceCost( 555 555 src, strict_dynamic_cast< const ast::ReferenceType * >( dst )->base, 556 (diff + 1), symtab, env, func );556 srcIsLvalue, (diff + 1), symtab, env, func ); 557 557 cost.incReference(); 558 558 return cost; … … 579 579 } 580 580 } else { 581 ast::Pass<ConversionCost_new> converter( dst, s ymtab, env, localConversionCost );581 ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost ); 582 582 src->accept( converter ); 583 583 return converter.pass.cost; … … 588 588 assert( dstAsRef ); 589 589 if ( typesCompatibleIgnoreQualifiers( src, dstAsRef->base, symtab, env ) ) { 590 if ( src ->is_lvalue()) {590 if ( srcIsLvalue ) { 591 591 if ( src->qualifiers == dstAsRef->base->qualifiers ) { 592 592 return Cost::reference; … … 607 607 608 608 Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dst, 609 610 NumCostCalculation func ) {609 bool srcIsLvalue, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env, 610 PtrsCalculation func ) { 611 611 int sdepth = src->referenceDepth(), ddepth = dst->referenceDepth(); 612 return convertToReferenceCost( src, dst, s depth - ddepth, symtab, env, func );612 return convertToReferenceCost( src, dst, srcIsLvalue, sdepth - ddepth, symtab, env, func ); 613 613 } 614 614 … … 667 667 assert( nullptr == dynamic_cast< const ast::ReferenceType * >( dst ) ); 668 668 669 cost = costCalc( refType->base, dst, s ymtab, env );669 cost = costCalc( refType->base, dst, srcIsLvalue, symtab, env ); 670 670 if ( refType->base->qualifiers == dst->qualifiers ) { 671 671 cost.incReference(); … … 702 702 (void)enumInstType; 703 703 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) }; 704 cost = costCalc( integer, dst, s ymtab, env );704 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); 705 705 if ( cost < Cost::unsafe ) { 706 706 cost.incSafe(); … … 714 714 void ConversionCost_new::postvisit( const ast::TypeInstType * typeInstType ) { 715 715 if ( const ast::EqvClass * eqv = env.lookup( typeInstType->name ) ) { 716 cost = costCalc( eqv->bound, dst, s ymtab, env );716 cost = costCalc( eqv->bound, dst, srcIsLvalue, symtab, env ); 717 717 } else if ( const ast::TypeInstType * dstAsInst = 718 718 dynamic_cast< const ast::TypeInstType * >( dst ) ) { … … 724 724 assertf( type, "Unexpected typedef."); 725 725 if ( type->base ) { 726 cost = costCalc( type->base, dst, s ymtab, env ) + Cost::safe;726 cost = costCalc( type->base, dst, srcIsLvalue, symtab, env ) + Cost::safe; 727 727 } 728 728 } … … 737 737 auto dstEnd = dstAsTuple->types.end(); 738 738 while ( srcIt != srcEnd && dstIt != dstEnd ) { 739 Cost newCost = costCalc( * srcIt++, * dstIt++, s ymtab, env );739 Cost newCost = costCalc( * srcIt++, * dstIt++, srcIsLvalue, symtab, env ); 740 740 if ( newCost == Cost::infinity ) { 741 741 return; -
src/ResolvExpr/ConversionCost.h
r90ce35aa rcf32116 10 10 // Created On : Sun May 17 09:37:28 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T hu Aug 8 16:13:00 201913 // Update Count : 612 // Last Modified On : Tue Oct 4 14:59:00 2019 13 // Update Count : 7 14 14 // 15 15 … … 74 74 75 75 // Some function pointer types, differ in return type. 76 using CostCalculation = std::function<Cost(const ast::Type *, const ast::Type *, 76 using CostCalculation = std::function<Cost(const ast::Type *, const ast::Type *, bool, 77 77 const ast::SymbolTable &, const ast::TypeEnvironment &)>; 78 using NumCostCalculation = std::function<int(const ast::Type *, const ast::Type *,78 using PtrsCalculation = std::function<int(const ast::Type *, const ast::Type *, 79 79 const ast::SymbolTable &, const ast::TypeEnvironment &)>; 80 80 … … 83 83 protected: 84 84 const ast::Type * dst; 85 bool srcIsLvalue; 85 86 const ast::SymbolTable & symtab; 86 87 const ast::TypeEnvironment & env; … … 89 90 Cost cost; 90 91 91 ConversionCost_new( const ast::Type * dst, const ast::SymbolTable & symtab,92 ConversionCost_new( const ast::Type * dst, bool srcIsLvalue, const ast::SymbolTable & symtab, 92 93 const ast::TypeEnvironment & env, CostCalculation costCalc ) : 93 dst( dst ), symtab( symtab ), env( env ), costCalc( costCalc ), cost( Cost::infinity ) 94 dst( dst ), srcIsLvalue( srcIsLvalue ), symtab( symtab ), env( env ), 95 costCalc( costCalc ), cost( Cost::infinity ) 94 96 {} 95 97 … … 114 116 115 117 Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dest, 116 const ast::SymbolTable & indexer, const ast::TypeEnvironment & env, NumCostCalculation func ); 118 bool srcIsLvalue, const ast::SymbolTable & indexer, const ast::TypeEnvironment & env, 119 PtrsCalculation func ); 117 120 118 121 } // namespace ResolvExpr -
src/ResolvExpr/SatisfyAssertions.cpp
r90ce35aa rcf32116 9 9 // Author : Aaron B. Moss 10 10 // Created On : Mon Jun 10 17:45:00 2019 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Mon Jun 10 17:45:00 201913 // Update Count : 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Oct 1 13:56:00 2019 13 // Update Count : 2 14 14 // 15 15 … … 299 299 Cost cost; 300 300 301 OutType( 302 const ast::TypeEnvironment & e, const ast::OpenVarSet & o, 301 OutType( 302 const ast::TypeEnvironment & e, const ast::OpenVarSet & o, 303 303 const std::vector< DeferRef > & as, const ast::SymbolTable & symtab ) 304 304 : env( e ), open( o ), assns( as ), cost( Cost::zero ) { … … 306 306 for ( const DeferRef & assn : assns ) { 307 307 // compute conversion cost from satisfying decl to assertion 308 cost += computeConversionCost( 309 assn.match.adjType, assn.decl->get_type(), symtab, env );310 308 cost += computeConversionCost( 309 assn.match.adjType, assn.decl->get_type(), false, symtab, env ); 310 311 311 // mark vars+specialization on function-type assertions 312 const ast::FunctionType * func = 312 const ast::FunctionType * func = 313 313 GenPoly::getFunctionType( assn.match.cdata.id->get_type() ); 314 314 if ( ! func ) continue; … … 317 317 cost.decSpec( specCost( param->get_type() ) ); 318 318 } 319 319 320 320 cost.incVar( func->forall.size() ); 321 321 322 322 for ( const ast::TypeDecl * td : func->forall ) { 323 323 cost.decSpec( td->assertions.size() ); … … 329 329 }; 330 330 331 CandidateEnvMerger( 332 const ast::TypeEnvironment & env, const ast::OpenVarSet & open, 331 CandidateEnvMerger( 332 const ast::TypeEnvironment & env, const ast::OpenVarSet & open, 333 333 const ast::SymbolTable & syms ) 334 334 : crnt(), envs{ env }, opens{ open }, symtab( syms ) {} -
src/ResolvExpr/SatisfyAssertions.hpp
r90ce35aa rcf32116 28 28 29 29 /// Recursively satisfies all assertions provided in a candidate; returns true if succeeds 30 void satisfyAssertions( 31 CandidateRef & cand, const ast::SymbolTable & symtab, CandidateList & out, 30 void satisfyAssertions( 31 CandidateRef & cand, const ast::SymbolTable & symtab, CandidateList & out, 32 32 std::vector<std::string> & errors ); 33 33 -
src/ResolvExpr/typeops.h
r90ce35aa rcf32116 10 10 // Created On : Sun May 17 07:28:22 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T hu Aug 8 16:36:00 201913 // Update Count : 512 // Last Modified On : Tue Oct 1 09:45:00 2019 13 // Update Count : 6 14 14 // 15 15 … … 83 83 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 84 84 Cost castCost( 85 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,86 const ast:: TypeEnvironment & env );85 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 86 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 87 87 88 88 // in ConversionCost.cc … … 90 90 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 91 91 Cost conversionCost( 92 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,93 const ast:: TypeEnvironment & env );92 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 93 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 94 94 95 95 // in AlternativeFinder.cc
Note: See TracChangeset
for help on using the changeset viewer.