Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Unify.cc

    raf746cc r06601401  
    274274                void previsit( const ast::Node * ) { visit_children = false; }
    275275
    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 );
    280278                }
    281279
     
    284282                                result = basic->kind == basic2->kind;
    285283                        }
    286                         result = result || tryToUnifyWithEnumValue(basic, type2, tenv, need, have, open, noWiden());
    287284                }
    288285
     
    293290                                        noWiden());
    294291                        }
    295                         result = result || tryToUnifyWithEnumValue(pointer, type2, tenv, need, have, open, noWiden());
    296292                }
    297293
     
    311307
    312308                        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());
    315310                }
    316311
     
    404399                }
    405400
    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 
    420401        public:
    421402                void postvisit( const ast::FunctionType * func ) {
     
    526507                void postvisit( const ast::StructInstType * aggrType ) {
    527508                        handleGenericRefType( aggrType, type2 );
    528                         result = result || tryToUnifyWithEnumValue(aggrType, type2, tenv, need, have, open, noWiden());
    529509                }
    530510
    531511                void postvisit( const ast::UnionInstType * aggrType ) {
    532512                        handleGenericRefType( aggrType, type2 );
    533                         result = result || tryToUnifyWithEnumValue(aggrType, type2, tenv, need, have, open, noWiden());
    534513                }
    535514
    536515                void postvisit( const ast::EnumInstType * aggrType ) {
    537516                        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 ) {
    542520                        // 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                        }
    548526                }
    549527
    550528                void postvisit( const ast::TraitInstType * aggrType ) {
    551529                        handleRefType( aggrType, type2 );
    552                         result = result || tryToUnifyWithEnumValue(aggrType, type2, tenv, need, have, open, noWiden());
    553530                }
    554531
     
    559536                                this->result = otherInst;
    560537                        }
    561                         result = result || tryToUnifyWithEnumValue(typeInst, type2, tenv, need, have, open, noWiden());
    562538                }
    563539
     
    634610                        auto types2 = flatten( flat2 );
    635611
    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 );
    653625                }
    654626        };
Note: See TracChangeset for help on using the changeset viewer.