Changeset eb7586e for src/ResolvExpr
- Timestamp:
- Apr 28, 2024, 7:50:11 PM (8 months ago)
- Branches:
- master
- Children:
- c5c123f
- Parents:
- 7042c60
- Location:
- src/ResolvExpr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
r7042c60 reb7586e 906 906 } 907 907 CandidateRef & choice = winners.front(); 908 choice->cost.inc Var();908 choice->cost.incSafe(); 909 909 candidates.emplace_back( std::move(choice) ); 910 910 } … … 1376 1376 ast::Expr * newExpr = data.combine( nameExpr->location, cost ); 1377 1377 1378 bool bentConversion = false; 1379 if ( auto inst = newExpr->result.as<ast::EnumInstType>() ) { 1380 if ( inst->base && inst->base->base ) { 1381 bentConversion = true; 1382 } 1383 } 1384 1378 // bool bentConversion = false; 1379 // if ( auto inst = newExpr->result.as<ast::EnumInstType>() ) { 1380 // if ( inst->base && inst->base->base ) { 1381 // bentConversion = true; 1382 // } 1383 // } 1384 1385 // CandidateRef newCand = std::make_shared<Candidate>( 1386 // newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, bentConversion? Cost::safe: Cost::zero, 1387 // cost ); 1385 1388 CandidateRef newCand = std::make_shared<Candidate>( 1386 newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, bentConversion? Cost::safe:Cost::zero,1389 newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, Cost::zero, 1387 1390 cost ); 1388 1389 1391 if (newCand->expr->env) { 1390 1392 newCand->env.add(*newCand->expr->env); … … 1829 1831 Cost cost = Cost::zero; 1830 1832 ast::Expr * newExpr = data.combine( expr->location, cost ); 1833 // CandidateRef newCand = 1834 // std::make_shared<Candidate>( 1835 // newExpr, copy( tenv ), ast::OpenVarSet{}, 1836 // ast::AssertionSet{}, Cost::safe, cost 1837 // ); 1831 1838 CandidateRef newCand = 1832 1839 std::make_shared<Candidate>( 1833 1840 newExpr, copy( tenv ), ast::OpenVarSet{}, 1834 ast::AssertionSet{}, Cost:: safe, cost1841 ast::AssertionSet{}, Cost::zero, cost 1835 1842 ); 1836 1837 1843 if (newCand->expr->env) { 1838 1844 newCand->env.add(*newCand->expr->env); -
src/ResolvExpr/CastCost.cc
r7042c60 reb7586e 53 53 } else { 54 54 cost = conversionCost( basicType, dst, srcIsLvalue, symtab, env ); 55 if ( Cost::unsafe < cost ) { 56 if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) { 57 assert(enumInst->base->base); 58 cost = Cost::unsafe; 59 } 60 } 55 61 } 62 } 63 64 void postvisit( const ast::ZeroType * zero ) { 65 // auto ptr = dynamic_cast< const ast::PointerType * >( dst ); 66 // if ( ptr && basicType->isInteger() ) { 67 // // needed for, e.g. unsigned long => void * 68 // cost = Cost::unsafe; 69 // } else { 70 cost = conversionCost( zero, dst, srcIsLvalue, symtab, env ); 71 if ( Cost::unsafe < cost ) { 72 if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) { 73 assert(enumInst->base->base); 74 cost = Cost::unsafe; 75 } 76 } 77 // } 78 } 79 80 void postvisit( const ast::OneType * one ) { 81 // auto ptr = dynamic_cast< const ast::PointerType * >( dst ); 82 // if ( ptr && basicType->isInteger() ) { 83 // // needed for, e.g. unsigned long => void * 84 // cost = Cost::unsafe; 85 // } else { 86 cost = conversionCost( one, dst, srcIsLvalue, symtab, env ); 87 if ( Cost::unsafe < cost ) { 88 if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) { 89 assert(enumInst->base->base); 90 cost = Cost::unsafe; 91 } 92 } 93 // } 56 94 } 57 95 … … 80 118 cost = Cost::unsafe; 81 119 } 120 } 121 } 122 123 void postvist( const ast::EnumInstType * ) { 124 if ( auto basic = dynamic_cast< const ast::BasicType * >(dst) ) { 125 if ( basic->isInteger() ) cost = Cost::unsafe; 82 126 } 83 127 } -
src/ResolvExpr/ConversionCost.cc
r7042c60 reb7586e 284 284 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { 285 285 if ( dstAsEnumInst->base && !dstAsEnumInst->base->base ) { 286 cost = Cost::zero; 287 cost.incUnsafe(); 286 cost = Cost::unsafe; 288 287 } 289 288 } … … 482 481 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { 483 482 if ( dstAsEnumInst->base && !dstAsEnumInst->base->base ) { 484 cost = Cost::zero; 485 cost.incUnsafe(); 483 cost = Cost::unsafe; 486 484 } 487 485 } … … 504 502 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { 505 503 if ( dstAsEnumInst->base && !dstAsEnumInst->base->base ) { 506 cost = Cost::zero; 507 cost.incUnsafe(); 504 cost = Cost::unsafe; 508 505 } 509 506 }
Note: See TracChangeset
for help on using the changeset viewer.