Changeset fc1a3e2 for src/ResolvExpr
- Timestamp:
- Apr 19, 2024, 2:36:52 PM (20 months ago)
- Branches:
- master
- Children:
- ba97ebf
- Parents:
- b9b6efb
- Location:
- src/ResolvExpr
- Files:
-
- 4 edited
-
CandidateFinder.cpp (modified) (2 diffs)
-
CommonType.cc (modified) (2 diffs)
-
ConversionCost.cc (modified) (1 diff)
-
Unify.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
rb9b6efb rfc1a3e2 1412 1412 } 1413 1413 1414 void Finder::postvisit(const ast::VariableExpr *variableExpr) {1415 // not sufficient to just pass `variableExpr` here, type might have changed1416 1417 auto cand = new Candidate(variableExpr, tenv);1418 candidates.emplace_back(cand);1419 }1414 void Finder::postvisit(const ast::VariableExpr *variableExpr) { 1415 // not sufficient to just pass `variableExpr` here, type might have changed 1416 1417 auto cand = new Candidate(variableExpr, tenv); 1418 candidates.emplace_back(cand); 1419 } 1420 1420 1421 1421 void Finder::postvisit( const ast::ConstantExpr * constantExpr ) { … … 2133 2133 2134 2134 // get the valueE(...) ApplicationExpr that returns the enum value 2135 const ast::Expr * getValueEnumCall( 2136 const ast::Expr * expr, 2135 const ast::Expr * getValueEnumCall( 2136 const ast::Expr * expr, 2137 2137 const ResolvExpr::ResolveContext & context, const ast::TypeEnvironment & env ) { 2138 2138 auto callExpr = new ast::UntypedExpr( -
src/ResolvExpr/CommonType.cc
rb9b6efb rfc1a3e2 397 397 } 398 398 } else if ( auto type2AsAttr = dynamic_cast< const ast::EnumAttrType * >( type2 ) ) { 399 if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) {400 ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ];401 if (402 ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )403 || widen.first )404 && ( ( kind != basic->kind && basic->qualifiers <= type2->qualifiers )405 || widen.second )406 ) {407 result = new ast::BasicType{ kind, basic->qualifiers | type2->qualifiers };408 }409 }399 if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) { 400 ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ]; 401 if ( 402 ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers ) 403 || widen.first ) 404 && ( ( kind != basic->kind && basic->qualifiers <= type2->qualifiers ) 405 || widen.second ) 406 ) { 407 result = new ast::BasicType{ kind, basic->qualifiers | type2->qualifiers }; 408 } 409 } 410 410 } 411 411 } … … 519 519 // xxx - assume LHS is always the target type 520 520 521 if ( ! ((widen.second && ref2->qualifiers.is_mutex) 521 if ( ! ((widen.second && ref2->qualifiers.is_mutex) 522 522 || (ref1->qualifiers.is_mutex == ref2->qualifiers.is_mutex ))) return; 523 523 -
src/ResolvExpr/ConversionCost.cc
rb9b6efb rfc1a3e2 379 379 380 380 void ConversionCost::postvisit( const ast::EnumAttrType * src ) { 381 auto dstAsEnumAttrType = dynamic_cast<const ast::EnumAttrType *>(dst);381 auto dstAsEnumAttrType = dynamic_cast<const ast::EnumAttrType *>(dst); 382 382 assert( src->attr != ast::EnumAttribute::Label ); 383 if ( src->attr == ast::EnumAttribute::Value ) {384 if ( dstAsEnumAttrType && dstAsEnumAttrType->attr == ast::EnumAttribute::Value) {385 cost = costCalc( src->instance, dstAsEnumAttrType->instance, srcIsLvalue, symtab, env );386 } else {387 auto baseType = src->instance->base->base;388 cost = costCalc( baseType, dst, srcIsLvalue, symtab, env );383 if ( src->attr == ast::EnumAttribute::Value ) { 384 if ( dstAsEnumAttrType && dstAsEnumAttrType->attr == ast::EnumAttribute::Value) { 385 cost = costCalc( src->instance, dstAsEnumAttrType->instance, srcIsLvalue, symtab, env ); 386 } else { 387 auto baseType = src->instance->base->base; 388 cost = costCalc( baseType, dst, srcIsLvalue, symtab, env ); 389 389 if ( cost < Cost::infinity ) { 390 390 cost.incUnsafe(); 391 391 } 392 }393 } else { // ast::EnumAttribute::Posn394 if ( auto dstBase = dynamic_cast<const ast::EnumInstType *>( dst ) ) {395 cost = costCalc( src->instance, dstBase, srcIsLvalue, symtab, env );396 if ( cost < Cost::unsafe ) cost.incSafe();397 } else {398 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };399 cost = costCalc( integer, dst, srcIsLvalue, symtab, env );400 if ( cost < Cost::unsafe ) {401 cost.incSafe();402 }403 }404 }392 } 393 } else { // ast::EnumAttribute::Posn 394 if ( auto dstBase = dynamic_cast<const ast::EnumInstType *>( dst ) ) { 395 cost = costCalc( src->instance, dstBase, srcIsLvalue, symtab, env ); 396 if ( cost < Cost::unsafe ) cost.incSafe(); 397 } else { 398 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 399 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); 400 if ( cost < Cost::unsafe ) { 401 cost.incSafe(); 402 } 403 } 404 } 405 405 } 406 406 -
src/ResolvExpr/Unify.cc
rb9b6efb rfc1a3e2 307 307 // type unification calls expression unification (mutual recursion) 308 308 if ( ! unify(array->dimension, array2->dimension, 309 tenv, need, have, open, widen) ) return;309 tenv, need, have, open, widen) ) return; 310 310 } 311 311 … … 455 455 // check that the other type is compatible and named the same 456 456 auto otherInst = dynamic_cast< const XInstType * >( other ); 457 if (otherInst && inst->name == otherInst->name) 457 if (otherInst && inst->name == otherInst->name) 458 458 this->result = otherInst; 459 459 return otherInst; … … 542 542 // Lazy approach for now 543 543 if ( auto otherPos = dynamic_cast< const ast::EnumAttrType *>(type2) ) { 544 if ( enumAttr->match(otherPos) ) {545 result = otherPos;546 }547 } 544 if ( enumAttr->match(otherPos) ) { 545 result = otherPos; 546 } 547 } 548 548 } 549 549
Note:
See TracChangeset
for help on using the changeset viewer.