Changeset 38093ae for src/ResolvExpr
- Timestamp:
- Apr 18, 2024, 8:44:24 PM (12 months ago)
- Branches:
- master
- Children:
- 19313be5, cf191ac
- Parents:
- 748c751 (diff), 7a780ad (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 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ResolvExpr/CandidateFinder.cpp ¶
r748c751 r38093ae 1382 1382 } 1383 1383 } 1384 1384 1385 1385 CandidateRef newCand = std::make_shared<Candidate>( 1386 1386 newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, bentConversion? Cost::safe: Cost::zero, … … 1776 1776 auto commonAsEnumAttr = common.as<ast::EnumAttrType>(); 1777 1777 if ( commonAsEnumAttr && commonAsEnumAttr->attr == ast::EnumAttribute::Value ) { 1778 1779 1778 auto callExpr = new ast::UntypedExpr( 1780 1779 cand->expr->location, new ast::NameExpr( cand->expr->location, "valueE"), {cand->expr} ); … … 1805 1804 // if this somehow changes in the future (e.g. delayed by indeterminate return type) 1806 1805 // we may need to revisit the logic. 1807 inferParameters( newCand, matches ); 1806 inferParameters( newCand, matches ); 1808 1807 } 1809 } 1810 } 1808 } 1809 } 1811 1810 } 1812 1811 } … … 2161 2160 } 2162 2161 ), 2163 new ast::BasicType( ast::Basic Type::SignedInt )2162 new ast::BasicType( ast::BasicKind::SignedInt ) 2164 2163 ); 2165 2164 } -
TabularUnified src/ResolvExpr/CandidateFinder.hpp ¶
r748c751 r38093ae 30 30 struct CandidateFinder { 31 31 CandidateList candidates; ///< List of candidate resolutions 32 const ResolveContext & context; ///< Information about where the canditates are being found.32 const ResolveContext & context; ///< Information about where the canditates are being found. 33 33 const ast::TypeEnvironment & env; ///< Substitutions performed in this resolution 34 34 ast::ptr< ast::Type > targetType; ///< Target type for resolution 35 35 bool strictMode = false; ///< If set to true, requires targetType to be exact match (inside return cast) 36 36 bool allowVoid = false; ///< If set to true, allow void-returning function calls (only top level, cast to void and first in comma) 37 std::set< std::string > otypeKeys; ///different type may map to same key37 std::set< std::string > otypeKeys; ///< different type may map to same key 38 38 39 39 CandidateFinder( … … 70 70 const ast::Expr * expr, Cost & cost ); 71 71 72 const ast::Expr * getValueEnumCall(const ast::Expr * expr, 73 const ResolvExpr::ResolveContext & context, const ast::TypeEnvironment & env ); 72 /// Get the valueE application that returns the enum's value. 73 const ast::Expr * getValueEnumCall( const ast::Expr * expr, 74 const ResolveContext & context, const ast::TypeEnvironment & env ); 75 74 76 /// Wrap an expression to convert the result to a conditional result. 75 77 const ast::Expr * createCondExpr( const ast::Expr * expr ); -
TabularUnified src/ResolvExpr/CommonType.cc ¶
r748c751 r38093ae 38 38 // GENERATED START, DO NOT EDIT 39 39 // GENERATED BY BasicTypes-gen.cc 40 #define BT ast::Basic Type::41 static const BTKind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor40 #define BT ast::BasicKind:: 41 static const ast::BasicKind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor 42 42 /* B C SC UC SI SUI 43 43 I UI LI LUI LLI LLUI … … 339 339 // GENERATED END 340 340 static_assert( 341 sizeof(commonTypes)/sizeof(commonTypes[0][0]) == ast::Basic Type::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,341 sizeof(commonTypes)/sizeof(commonTypes[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES, 342 342 "Each basic type kind should have a corresponding row in the combined type matrix" 343 343 ); … … 366 366 void postvisit( const ast::BasicType * basic ) { 367 367 if ( auto basic2 = dynamic_cast< const ast::BasicType * >( type2 ) ) { 368 ast::Basic Type::Kind kind;368 ast::BasicKind kind; 369 369 if (basic->kind != basic2->kind && !widen.first && !widen.second) return; 370 370 else if (!widen.first) kind = basic->kind; // widen.second … … 386 386 const ast::EnumDecl* enumDecl = enumInst->base; 387 387 if ( !enumDecl->base ) { 388 ast::Basic Type::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];388 ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ]; 389 389 if ( 390 390 ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers ) … … 398 398 } else if ( auto type2AsAttr = dynamic_cast< const ast::EnumAttrType * >( type2 ) ) { 399 399 if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) { 400 ast::Basic Type::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];400 ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ]; 401 401 if ( 402 402 ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers ) … … 649 649 void postvisit( const ast::EnumInstType * enumInst ) { 650 650 if ( enumInst->base && !enumInst->base->base ) { 651 auto basicType = new ast::BasicType( ast::Basic Type::UnsignedInt );651 auto basicType = new ast::BasicType( ast::BasicKind::UnsignedInt ); 652 652 result = commonType( basicType, type2, tenv, need, have, open, widen); 653 653 } … … 674 674 } else if ( widen.second && dynamic_cast< const ast::OneType * >( type2 ) ) { 675 675 result = new ast::BasicType{ 676 ast::Basic Type::SignedInt, zero->qualifiers | type2->qualifiers };676 ast::BasicKind::SignedInt, zero->qualifiers | type2->qualifiers }; 677 677 } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) { 678 678 const ast::EnumDecl * enumDecl = enumInst->base; … … 695 695 } else if ( widen.second && dynamic_cast< const ast::ZeroType * >( type2 ) ) { 696 696 result = new ast::BasicType{ 697 ast::Basic Type::SignedInt, one->qualifiers | type2->qualifiers };697 ast::BasicKind::SignedInt, one->qualifiers | type2->qualifiers }; 698 698 } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) { 699 699 const ast::EnumDecl * enumDecl = enumInst->base; -
TabularUnified src/ResolvExpr/ConversionCost.cc ¶
r748c751 r38093ae 59 59 // GENERATED START, DO NOT EDIT 60 60 // GENERATED BY BasicTypes-gen.cc 61 static const int costMatrix[ast::Basic Type::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node61 static const int costMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // path length from root to node 62 62 /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */ 63 63 /* B */ { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 17, 16, 18, 17, }, … … 101 101 // GENERATED END 102 102 static_assert( 103 sizeof(costMatrix)/sizeof(costMatrix[0][0]) == ast::Basic Type::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,103 sizeof(costMatrix)/sizeof(costMatrix[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES, 104 104 "Missing row in the cost matrix" 105 105 ); … … 107 107 // GENERATED START, DO NOT EDIT 108 108 // GENERATED BY BasicTypes-gen.cc 109 static const int signMatrix[ast::Basic Type::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion109 static const int signMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion 110 110 /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */ 111 111 /* B */ { 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, … … 148 148 // GENERATED END 149 149 static_assert( 150 sizeof(signMatrix)/sizeof(signMatrix[0][0]) == ast::Basic Type::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,150 sizeof(signMatrix)/sizeof(signMatrix[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES, 151 151 "Missing row in the sign matrix" 152 152 ); … … 279 279 conversionCostFromBasicToBasic( basicType, dstAsBasic ); 280 280 } else if ( dynamic_cast< const ast::EnumAttrType *>(dst) ) { 281 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::Basic Type::SignedInt ) };281 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 282 282 cost = costCalc( basicType, integer, srcIsLvalue, symtab, env ); 283 283 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { … … 369 369 } 370 370 } 371 } 372 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) }; 371 return; 372 } 373 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 373 374 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); 374 375 if ( cost < Cost::unsafe ) { … … 395 396 if ( cost < Cost::unsafe ) cost.incSafe(); 396 397 } else { 397 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::Basic Type::SignedInt ) };398 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 398 399 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); 399 400 if ( cost < Cost::unsafe ) { … … 460 461 } else if ( const ast::BasicType * dstAsBasic = 461 462 dynamic_cast< const ast::BasicType * >( dst ) ) { 462 int tableResult = costMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ];463 int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ]; 463 464 if ( -1 == tableResult ) { 464 465 cost = Cost::unsafe; … … 466 467 cost = Cost::zero; 467 468 cost.incSafe( tableResult + 1 ); 468 cost.incSign( signMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ] );469 cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] ); 469 470 } 470 471 // this has the effect of letting any expr such as x+0, x+1 to be typed … … 492 493 } else if ( const ast::BasicType * dstAsBasic = 493 494 dynamic_cast< const ast::BasicType * >( dst ) ) { 494 int tableResult = costMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ];495 int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ]; 495 496 if ( -1 == tableResult ) { 496 497 cost = Cost::unsafe; … … 498 499 cost = Cost::zero; 499 500 cost.incSafe( tableResult + 1 ); 500 cost.incSign( signMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ] );501 cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] ); 501 502 } 502 503 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { -
TabularUnified src/ResolvExpr/PtrsCastable.cc ¶
r748c751 r38093ae 100 100 result = 1; 101 101 } else if ( auto bt = dynamic_cast< const ast::BasicType * >( dst ) ) { 102 if ( bt->kind == ast::Basic Type::SignedInt ) {102 if ( bt->kind == ast::BasicKind::SignedInt ) { 103 103 result = 0; 104 104 } else { -
TabularUnified src/ResolvExpr/ResolveTypeof.cc ¶
r748c751 r38093ae 63 63 if ( newType.as< ast::EnumInstType >() ) { 64 64 newType = new ast::BasicType( 65 ast::Basic Type::SignedInt, newType->qualifiers, copy(newType->attributes) );65 ast::BasicKind::SignedInt, newType->qualifiers, copy(newType->attributes) ); 66 66 } 67 67 reset_qualifiers( … … 91 91 auto mutType = mutate(arrayType); 92 92 auto globalSizeType = context.global.sizeType; 93 ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType( ast::BasicType::LongUnsignedInt);93 ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType( ast::BasicKind::LongUnsignedInt ); 94 94 mutType->dimension = findSingleExpression(arrayType->dimension, sizetype, context ); 95 95 -
TabularUnified src/ResolvExpr/Resolver.cc ¶
r748c751 r38093ae 351 351 bool isCharType( const ast::Type * t ) { 352 352 if ( auto bt = dynamic_cast< const ast::BasicType * >( t ) ) { 353 return bt->kind == ast::Basic Type::Char354 || bt->kind == ast::Basic Type::SignedChar355 || bt->kind == ast::Basic Type::UnsignedChar;353 return bt->kind == ast::BasicKind::Char 354 || bt->kind == ast::BasicKind::SignedChar 355 || bt->kind == ast::BasicKind::UnsignedChar; 356 356 } 357 357 return false; … … 458 458 if (attr->params.size() == 1) { 459 459 auto arg = attr->params.front(); 460 auto resolved = ResolvExpr::findSingleExpression( arg, new ast::BasicType( ast::Basic Type::LongLongSignedInt ), context );460 auto resolved = ResolvExpr::findSingleExpression( arg, new ast::BasicType( ast::BasicKind::LongLongSignedInt ), context ); 461 461 auto result = eval(arg); 462 462 … … 624 624 objectDecl = fixObjectType( objectDecl, context ); 625 625 currentObject = ast::CurrentObject{ 626 objectDecl->location, new ast::BasicType{ ast::Basic Type::SignedInt } };626 objectDecl->location, new ast::BasicType{ ast::BasicKind::SignedInt } }; 627 627 } 628 628 } else { … … 1095 1095 // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally 1096 1096 ast::ptr< ast::Type > target = 1097 new ast::BasicType{ ast::Basic Type::LongLongUnsignedInt };1097 new ast::BasicType{ ast::BasicKind::LongLongUnsignedInt }; 1098 1098 auto timeout_time = findSingleExpression( stmt->timeout_time, target, context ); 1099 1099 auto timeout_cond = findCondExpression( stmt->timeout_cond, context );
Note: See TracChangeset
for help on using the changeset viewer.