Changeset 704c9dd for src


Ignore:
Timestamp:
Nov 26, 2015, 2:37:41 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
43ffef1, b81096f
Parents:
bdf1954 (diff), 7e23d0a (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

Location:
src
Files:
4 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Unify.cc

    rbdf1954 r704c9dd  
    6161
    6262                template< typename RefType > void handleRefType( RefType *inst, Type *other );
     63                template< typename RefType > void handleGenericRefType( RefType *inst, Type *other );
    6364
    6465                bool result;
     
    496497
    497498        template< typename RefType >
    498         void Unify::handleRefType( RefType *inst, Type *other ) { 
     499        void Unify::handleRefType( RefType *inst, Type *other ) {
     500                // check that other type is compatible and named the same
    499501                RefType *otherStruct = dynamic_cast< RefType* >( other );
    500502                result = otherStruct && inst->get_name() == otherStruct->get_name();
    501         } 
     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 type unify, if any
     511                std::list< Expression* > params = inst->get_parameters();
     512                if ( ! params.empty() ) {
     513                        std::list< TypeDecl* > *baseParams = inst->get_baseParameters();
     514                        if ( ! baseParams ) {
     515                                result = false;
     516                                return;
     517                        }
     518                        std::list< Expression* >::const_iterator it = params.begin();
     519                        std::list< TypeDecl* >::const_iterator baseIt = baseParams->begin();
     520                        while ( it != params.end() && baseIt != baseParams->end()) {
     521                                TypeExpr *param = dynamic_cast< TypeExpr* >(*it);
     522                                assert(param && "Aggregate parameters should be type expressions");
     523                                TypeInstType baseType(Type::Qualifiers(), (*baseIt)->get_name(), *baseIt);
     524                                if ( ! unifyExact( param->get_type(), &baseType, env, needAssertions, haveAssertions, openVars, WidenMode(false, false), indexer ) ) {
     525                                        result = false;
     526                                        return;
     527                                }
     528                               
     529                                ++it;
     530                                ++baseIt;
     531                        }
     532                        if ( it != params.end() || baseIt != baseParams->end() ) {
     533                                result = false;
     534                        }
     535                }
     536        }
    502537
    503538        void Unify::visit(StructInstType *structInst) {
    504                 handleRefType( structInst, type2 );
     539                handleGenericRefType( structInst, type2 );
    505540        }
    506541
    507542        void Unify::visit(UnionInstType *unionInst) {
    508                 handleRefType( unionInst, type2 );
     543                handleGenericRefType( unionInst, type2 );
    509544        }
    510545
Note: See TracChangeset for help on using the changeset viewer.