Changeset 15215f02 for src/ResolvExpr
- Timestamp:
- Apr 22, 2024, 11:37:36 PM (5 months ago)
- Branches:
- master
- Children:
- 13de4478
- Parents:
- 0fe07be (diff), d7c0ad5 (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:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
r0fe07be r15215f02 1412 1412 } 1413 1413 1414 1415 1416 1417 1418 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
r0fe07be r15215f02 397 397 } 398 398 } else if ( auto type2AsAttr = dynamic_cast< const ast::EnumAttrType * >( type2 ) ) { 399 400 401 402 403 404 405 406 407 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
r0fe07be r15215f02 379 379 380 380 void ConversionCost::postvisit( const ast::EnumAttrType * src ) { 381 381 auto dstAsEnumAttrType = dynamic_cast<const ast::EnumAttrType *>(dst); 382 382 assert( src->attr != ast::EnumAttribute::Label ); 383 384 385 386 387 388 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 394 395 396 397 398 399 400 401 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/PolyCost.cc
r0fe07be r15215f02 29 29 const ast::TypeEnvironment &env_; 30 30 31 PolyCost( const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ) 31 PolyCost( const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ) 32 32 : symtab( symtab ), result( 0 ), env_( env ) {} 33 33 34 34 void previsit( const ast::TypeInstType * type ) { 35 if ( const ast::EqvClass * eqv = env_.lookup( *type ) ) /* && */ if (eqv->bound ) {35 if ( const ast::EqvClass * eqv = env_.lookup( *type ) ; eqv && eqv->bound ) { 36 36 if ( const ast::TypeInstType * otherType = eqv->bound.as< ast::TypeInstType >() ) { 37 37 if ( symtab.lookupType( otherType->name ) ) { 38 38 // Bound to opaque type. 39 result += 1;39 result = 1; 40 40 } 41 41 } else { 42 42 // Bound to concrete type. 43 result += 1;43 result = 1; 44 44 } 45 45 } … … 52 52 const ast::Type * type, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env 53 53 ) { 54 ast::Pass<PolyCost> costing( symtab, env ); 55 type->accept( costing ); 56 return (costing.core.result > 0) ? 1 : 0; 54 return ast::Pass<PolyCost>::read( type, symtab, env ); 57 55 } 58 56 -
src/ResolvExpr/Unify.cc
r0fe07be r15215f02 307 307 // type unification calls expression unification (mutual recursion) 308 308 if ( ! unify(array->dimension, array2->dimension, 309 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 545 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.