Changeset 7a780ad for src/ResolvExpr/ConversionCost.cc
- Timestamp:
- Apr 18, 2024, 5:19:17 PM (7 months ago)
- Branches:
- master
- Children:
- 38093ae
- Parents:
- 60c5b6d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/ConversionCost.cc
r60c5b6d r7a780ad 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 ) ) { … … 383 383 } 384 384 return; 385 } 386 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::Basic Type::SignedInt ) };385 } 386 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 387 387 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); 388 388 if ( cost < Cost::unsafe ) { … … 396 396 if ( dstAsEnumAttrType && dstAsEnumAttrType->attr == ast::EnumAttribute::Label ) { 397 397 cost = costCalc( src->instance, dstAsEnumAttrType->instance, srcIsLvalue, symtab, env ); 398 } 398 } 399 399 // Add Conversion To String 400 400 } else if ( src->attr == ast::EnumAttribute::Value ) { … … 413 413 if ( cost < Cost::unsafe ) cost.incSafe(); 414 414 } else { 415 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::Basic Type::SignedInt ) };415 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 416 416 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); 417 417 if ( cost < Cost::unsafe ) { … … 478 478 } else if ( const ast::BasicType * dstAsBasic = 479 479 dynamic_cast< const ast::BasicType * >( dst ) ) { 480 int tableResult = costMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ];480 int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ]; 481 481 if ( -1 == tableResult ) { 482 482 cost = Cost::unsafe; … … 484 484 cost = Cost::zero; 485 485 cost.incSafe( tableResult + 1 ); 486 cost.incSign( signMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ] );486 cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] ); 487 487 } 488 488 // this has the effect of letting any expr such as x+0, x+1 to be typed … … 510 510 } else if ( const ast::BasicType * dstAsBasic = 511 511 dynamic_cast< const ast::BasicType * >( dst ) ) { 512 int tableResult = costMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ];512 int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ]; 513 513 if ( -1 == tableResult ) { 514 514 cost = Cost::unsafe; … … 516 516 cost = Cost::zero; 517 517 cost.incSafe( tableResult + 1 ); 518 cost.incSign( signMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ] );518 cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] ); 519 519 } 520 520 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
Note: See TracChangeset
for help on using the changeset viewer.