- Timestamp:
- Nov 24, 2020, 5:48:06 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 4702a2c
- Parents:
- 4a359e2
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Expr.hpp
r4a359e2 rbb87dd0 299 299 }; 300 300 301 /// Whether a cast existed in the program source or not 301 /// Inidicates whether the cast is introduced by the CFA type system. 302 /// GeneratedCast for casts that the resolver introduces to force a return type 303 /// ExplicitCast for casts from user code 304 /// ExplicitCast for casts from desugaring advanced CFA features into simpler CFA 305 /// example 306 /// int * p; // declaration 307 /// (float *) p; // use, with subject cast 308 /// subject cast being GeneratedCast means we are considering an interpretation with a type mismatch 309 /// subject cast being ExplicitCast means someone in charge wants it that way 302 310 enum GeneratedFlag { ExplicitCast, GeneratedCast }; 303 311 -
src/ResolvExpr/CandidateFinder.cpp
r4a359e2 rbb87dd0 1066 1066 // unification run for side-effects 1067 1067 unify( toType, cand->expr->result, cand->env, need, have, open, symtab ); 1068 Cost thisCost = castCost( cand->expr->result, toType, cand->expr->get_lvalue(), 1069 symtab, cand->env ); 1068 Cost thisCost = 1069 (castExpr->isGenerated == ast::GeneratedFlag::GeneratedCast) 1070 ? conversionCost( cand->expr->result, toType, cand->expr->get_lvalue(), symtab, cand->env ) 1071 : castCost( cand->expr->result, toType, cand->expr->get_lvalue(), symtab, cand->env ); 1072 1070 1073 PRINT( 1071 1074 std::cerr << "working on cast with result: " << toType << std::endl; … … 1543 1546 1544 1547 // unification run for side-effects 1545 unify( toType, cand->expr->result, env, need, have, open, symtab ); 1548 bool canUnify = unify( toType, cand->expr->result, env, need, have, open, symtab ); 1549 (void) canUnify; 1546 1550 Cost thisCost = computeConversionCost( cand->expr->result, toType, cand->expr->get_lvalue(), 1551 symtab, env ); 1552 PRINT( 1553 Cost legacyCost = castCost( cand->expr->result, toType, cand->expr->get_lvalue(), 1547 1554 symtab, env ); 1548 1555 std::cerr << "Considering initialization:"; 1556 std::cerr << std::endl << " FROM: " << cand->expr->result << std::endl; 1557 std::cerr << std::endl << " TO: " << toType << std::endl; 1558 std::cerr << std::endl << " Unification " << (canUnify ? "succeeded" : "failed"); 1559 std::cerr << std::endl << " Legacy cost " << legacyCost; 1560 std::cerr << std::endl << " New cost " << thisCost; 1561 std::cerr << std::endl; 1562 ) 1549 1563 if ( thisCost != Cost::infinity ) { 1550 1564 // count one safe conversion for each value that is thrown away
Note: See TracChangeset
for help on using the changeset viewer.