Changeset 9ddcee1 for src/ResolvExpr
- Timestamp:
- Feb 1, 2024, 5:13:04 PM (15 months ago)
- Branches:
- master
- Children:
- 020fa10
- Parents:
- 496ffc17
- Location:
- src/ResolvExpr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ResolvExpr/CandidateFinder.cpp ¶
r496ffc17 r9ddcee1 659 659 void postvisit( const ast::OffsetofExpr * offsetofExpr ); 660 660 void postvisit( const ast::OffsetPackExpr * offsetPackExpr ); 661 void postvisit( const ast::EnumPosExpr * enumPosExpr );662 661 void postvisit( const ast::LogicalExpr * logicalExpr ); 663 662 void postvisit( const ast::ConditionalExpr * conditionalExpr ); … … 1507 1506 void Finder::postvisit( const ast::OffsetPackExpr * offsetPackExpr ) { 1508 1507 addCandidate( offsetPackExpr, tenv ); 1509 }1510 1511 void Finder::postvisit( const ast::EnumPosExpr * enumPosExpr ) {1512 CandidateFinder finder( context, tenv );1513 finder.find( enumPosExpr->expr );1514 CandidateList winners = findMinCost( finder.candidates );1515 if ( winners.size() != 1 ) SemanticError( enumPosExpr->expr.get(), "Ambiguous expression in position. ");1516 CandidateRef & choice = winners.front();1517 auto refExpr = referenceToRvalueConversion( choice->expr, choice->cost );1518 auto refResult = (refExpr->result).as<ast::EnumInstType>();1519 if ( !refResult ) {1520 SemanticError( refExpr, "Position for Non enum type is not supported" );1521 }1522 // determineEnumPosConstant( enumPosExpr, refResult );1523 1524 const ast::NameExpr * const nameExpr = enumPosExpr->expr.strict_as<ast::NameExpr>();1525 const ast::EnumDecl * base = refResult->base;1526 if ( !base ) {1527 SemanticError( enumPosExpr, "Cannot be reference to a defined enumeration type" );1528 }1529 auto it = std::find_if( std::begin( base->members ), std::end( base->members ),1530 [nameExpr]( ast::ptr<ast::Decl> decl ) { return decl->name == nameExpr->name; } );1531 unsigned position = it - base->members.begin();1532 addCandidate( ast::ConstantExpr::from_int( enumPosExpr->location, position ), tenv );1533 1508 } 1534 1509 -
TabularUnified src/ResolvExpr/ConversionCost.cc ¶
r496ffc17 r9ddcee1 361 361 } 362 362 363 void ConversionCost::postvisit( const ast::EnumInstType * enumInstType ) { 364 // const ast::EnumDecl * baseEnum = enumInstType->base; 365 // if ( const ast::Type * baseType = baseEnum->base ) { 366 // costCalc( baseType, dst, srcIsLvalue, symtab, env ); 367 // } else { 363 void ConversionCost::postvisit( const ast::EnumInstType * ) { 368 364 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) }; 369 365 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); -
TabularUnified src/ResolvExpr/Resolver.cc ¶
r496ffc17 r9ddcee1 411 411 const ast::ConstructorInit * previsit( const ast::ConstructorInit * ); 412 412 413 const ast::EnumPosExpr * previsit( const ast::EnumPosExpr * );414 415 413 void resolveWithExprs(std::vector<ast::ptr<ast::Expr>> & exprs, std::list<ast::ptr<ast::Stmt>> & stmtsToAdd); 416 414 … … 1232 1230 } 1233 1231 1234 const ast::EnumPosExpr * Resolver::previsit( const ast::EnumPosExpr * enumPos ) {1235 visitor->maybe_accept( enumPos, &ast::EnumPosExpr::expr );1236 return enumPos;1237 }1238 1239 1232 // suppress error on autogen functions and mark invalid autogen as deleted. 1240 1233 bool Resolver::on_error(ast::ptr<ast::Decl> & decl) {
Note: See TracChangeset
for help on using the changeset viewer.