Changes in src/ResolvExpr/Unify.cc [af746cc:06601401]
- File:
-
- 1 edited
-
src/ResolvExpr/Unify.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Unify.cc
raf746cc r06601401 274 274 void previsit( const ast::Node * ) { visit_children = false; } 275 275 276 void postvisit( const ast::VoidType * vt) { 277 result = dynamic_cast< const ast::VoidType * >( type2 ) 278 || tryToUnifyWithEnumValue(vt, type2, tenv, need, have, open, noWiden()); 279 ; 276 void postvisit( const ast::VoidType * ) { 277 result = dynamic_cast< const ast::VoidType * >( type2 ); 280 278 } 281 279 … … 284 282 result = basic->kind == basic2->kind; 285 283 } 286 result = result || tryToUnifyWithEnumValue(basic, type2, tenv, need, have, open, noWiden());287 284 } 288 285 … … 293 290 noWiden()); 294 291 } 295 result = result || tryToUnifyWithEnumValue(pointer, type2, tenv, need, have, open, noWiden());296 292 } 297 293 … … 311 307 312 308 result = unifyExact( 313 array->base, array2->base, tenv, need, have, open, noWiden()) 314 || tryToUnifyWithEnumValue(array, type2, tenv, need, have, open, noWiden()); 309 array->base, array2->base, tenv, need, have, open, noWiden()); 315 310 } 316 311 … … 404 399 } 405 400 406 bool tryToUnifyWithEnumValue( const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env,407 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open,408 WidenMode widen) {409 if ( auto attrType2 = dynamic_cast<const ast::EnumAttrType *>(type2)) {410 if (attrType2->attr == ast::EnumAttribute::Value) {411 return unifyExact( type1, attrType2->instance->base->base, env, need, have, open,412 widen);413 } else if (attrType2->attr == ast::EnumAttribute::Posn) {414 return unifyExact( type1, attrType2->instance, env, need, have, open, widen );415 }416 }417 return false;418 }419 420 401 public: 421 402 void postvisit( const ast::FunctionType * func ) { … … 526 507 void postvisit( const ast::StructInstType * aggrType ) { 527 508 handleGenericRefType( aggrType, type2 ); 528 result = result || tryToUnifyWithEnumValue(aggrType, type2, tenv, need, have, open, noWiden());529 509 } 530 510 531 511 void postvisit( const ast::UnionInstType * aggrType ) { 532 512 handleGenericRefType( aggrType, type2 ); 533 result = result || tryToUnifyWithEnumValue(aggrType, type2, tenv, need, have, open, noWiden());534 513 } 535 514 536 515 void postvisit( const ast::EnumInstType * aggrType ) { 537 516 handleRefType( aggrType, type2 ); 538 result = result || tryToUnifyWithEnumValue(aggrType, type2, tenv, need, have, open, noWiden()); 539 } 540 541 void postvisit( const ast::EnumAttrType * enumAttr ) { 517 } 518 519 void postvisit( const ast::EnumPosType * posType ) { 542 520 // Lazy approach for now 543 if ( auto otherPos = dynamic_cast< const ast::EnumAttrType *>(type2) ) {544 if ( enumAttr->match(otherPos)) {545 result = otherPos;546 }547 } 521 auto otherPos = dynamic_cast< const ast::EnumPosType *>(type2); 522 if ( otherPos ) { 523 if ( otherPos->instance->base->name == posType->instance->base->name ) 524 result = otherPos; 525 } 548 526 } 549 527 550 528 void postvisit( const ast::TraitInstType * aggrType ) { 551 529 handleRefType( aggrType, type2 ); 552 result = result || tryToUnifyWithEnumValue(aggrType, type2, tenv, need, have, open, noWiden());553 530 } 554 531 … … 559 536 this->result = otherInst; 560 537 } 561 result = result || tryToUnifyWithEnumValue(typeInst, type2, tenv, need, have, open, noWiden());562 538 } 563 539 … … 634 610 auto types2 = flatten( flat2 ); 635 611 636 result = unifyList( types, types2, tenv, need, have, open ) 637 || tryToUnifyWithEnumValue(tuple, type2, tenv, need, have, open, noWiden()); 638 } 639 640 void postvisit( const ast::VarArgsType * vat) { 641 result = dynamic_cast< const ast::VarArgsType * >( type2 ) 642 || tryToUnifyWithEnumValue(vat, type2, tenv, need, have, open, noWiden()); 643 } 644 645 void postvisit( const ast::ZeroType * zt) { 646 result = dynamic_cast< const ast::ZeroType * >( type2 ) 647 || tryToUnifyWithEnumValue(zt, type2, tenv, need, have, open, noWiden()); 648 } 649 650 void postvisit( const ast::OneType * ot) { 651 result = dynamic_cast< const ast::OneType * >( type2 ) 652 || tryToUnifyWithEnumValue(ot, type2, tenv, need, have, open, noWiden()); 612 result = unifyList( types, types2, tenv, need, have, open ); 613 } 614 615 void postvisit( const ast::VarArgsType * ) { 616 result = dynamic_cast< const ast::VarArgsType * >( type2 ); 617 } 618 619 void postvisit( const ast::ZeroType * ) { 620 result = dynamic_cast< const ast::ZeroType * >( type2 ); 621 } 622 623 void postvisit( const ast::OneType * ) { 624 result = dynamic_cast< const ast::OneType * >( type2 ); 653 625 } 654 626 };
Note:
See TracChangeset
for help on using the changeset viewer.