Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Unify.cc

    rf5234f3 r1cbca6e  
    6161
    6262                template< typename RefType > void handleRefType( RefType *inst, Type *other );
    63                 template< typename RefType > void handleGenericRefType( RefType *inst, Type *other );
    6463
    6564                bool result;
     
    497496
    498497        template< typename RefType >
    499         void Unify::handleRefType( RefType *inst, Type *other ) {
    500                 // check that other type is compatible and named the same
     498        void Unify::handleRefType( RefType *inst, Type *other ) { 
    501499                RefType *otherStruct = dynamic_cast< RefType* >( other );
    502500                result = otherStruct && inst->get_name() == otherStruct->get_name();
    503         }
    504 
    505         template< typename RefType >
    506         void Unify::handleGenericRefType( RefType *inst, Type *other ) {
    507                 // Check that other type is compatible and named the same
    508                 handleRefType( inst, other );
    509                 if ( ! result ) return;
    510                 // Check that parameters of types unify, if any
    511                 std::list< Expression* > params = inst->get_parameters();
    512                 std::list< Expression* > otherParams = ((RefType*)other)->get_parameters();
    513 
    514                 std::list< Expression* >::const_iterator it = params.begin(), jt = otherParams.begin();
    515                 for ( ; it != params.end() && jt != otherParams.end(); ++it, ++jt ) {
    516                         TypeExpr *param = dynamic_cast< TypeExpr* >(*it);
    517                         assert(param && "Aggregate parameters should be type expressions");
    518                         TypeExpr *otherParam = dynamic_cast< TypeExpr* >(*jt);
    519                         assert(otherParam && "Aggregate parameters should be type expressions");
    520 
    521                         if ( ! unifyExact( param->get_type(), otherParam->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode(false, false), indexer ) ) {
    522                                 result = false;
    523                                 return;
    524                         }
    525                 }
    526                 result = ( it == params.end() && jt == otherParams.end() );
    527         }
     501        } 
    528502
    529503        void Unify::visit(StructInstType *structInst) {
    530                 handleGenericRefType( structInst, type2 );
     504                handleRefType( structInst, type2 );
    531505        }
    532506
    533507        void Unify::visit(UnionInstType *unionInst) {
    534                 handleGenericRefType( unionInst, type2 );
     508                handleRefType( unionInst, type2 );
    535509        }
    536510
Note: See TracChangeset for help on using the changeset viewer.