Ignore:
Timestamp:
Jul 4, 2017, 9:40:16 AM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
208e5be
Parents:
9c951e3 (diff), f7cb0bc (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' into references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Unify.cc

    r9c951e3 rb1e63ac5  
    115115        }
    116116
    117         bool isFtype( Type *type, const SymTab::Indexer &indexer ) {
     117        bool isFtype( Type *type ) {
    118118                if ( dynamic_cast< FunctionType* >( type ) ) {
    119119                        return true;
     
    124124        }
    125125
    126         bool tyVarCompatible( const TypeDecl::Data & data, Type *type, const SymTab::Indexer &indexer ) {
     126        bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) {
    127127                switch ( data.kind ) {
    128128                  case TypeDecl::Any:
     
    132132                        // type must also be complete
    133133                        // xxx - should this also check that type is not a tuple type and that it's not a ttype?
    134                         return ! isFtype( type, indexer ) && (! data.isComplete || type->isComplete() );
     134                        return ! isFtype( type ) && (! data.isComplete || type->isComplete() );
    135135                  case TypeDecl::Ftype:
    136                         return isFtype( type, indexer );
     136                        return isFtype( type );
    137137                  case TypeDecl::Ttype:
    138138                        // ttype unifies with any tuple type
     
    145145                OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() );
    146146                assert( tyvar != openVars.end() );
    147                 if ( ! tyVarCompatible( tyvar->second, other, indexer ) ) {
     147                if ( ! tyVarCompatible( tyvar->second, other ) ) {
    148148                        return false;
    149149                } // if
     
    345345                std::cerr << "unifyInexact type 1 is ";
    346346                type1->print( std::cerr );
    347                 std::cerr << "type 2 is ";
     347                std::cerr << " type 2 is ";
    348348                type2->print( std::cerr );
    349349                std::cerr << std::endl;
     
    389389        }
    390390
    391         void Unify::visit(VoidType *voidType) {
     391        void Unify::visit( __attribute__((unused)) VoidType *voidType) {
    392392                result = dynamic_cast< VoidType* >( type2 );
    393393        }
     
    615615                        } else if ( tupleParam ) {
    616616                                // bundle other parameters into tuple to match
    617                                 TupleType* binder = new TupleType{ paramTy->get_qualifiers() };
     617                                std::list< Type * > binderTypes;
    618618
    619619                                do {
    620                                         binder->get_types().push_back( otherParam->get_type()->clone() );
     620                                        binderTypes.push_back( otherParam->get_type()->clone() );
    621621                                        ++jt;
    622622
     
    627627                                } while (true);
    628628
    629                                 otherParamTy = binder;
     629                                otherParamTy = new TupleType{ paramTy->get_qualifiers(), binderTypes };
    630630                                ++it;  // skip ttype parameter for break
    631631                        } else if ( otherTupleParam ) {
    632632                                // bundle parameters into tuple to match other
    633                                 TupleType* binder = new TupleType{ otherParamTy->get_qualifiers() };
     633                                std::list< Type * > binderTypes;
    634634
    635635                                do {
    636                                         binder->get_types().push_back( param->get_type()->clone() );
     636                                        binderTypes.push_back( param->get_type()->clone() );
    637637                                        ++it;
    638638
     
    643643                                } while (true);
    644644
    645                                 paramTy = binder;
     645                                paramTy = new TupleType{ otherParamTy->get_qualifiers(), binderTypes };
    646646                                ++jt;  // skip ttype parameter for break
    647647                        }
     
    692692
    693693        template< typename Iterator1, typename Iterator2 >
    694         bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {
     694        bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
    695695                auto get_type = [](Type * t) { return t; };
    696696                for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) {
     
    742742                        flatten( flat2.get(), back_inserter( types2 ) );
    743743
    744                         result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, widenMode, indexer );
    745                 } // if
    746         }
    747 
    748         void Unify::visit(VarArgsType *varArgsType) {
     744                        result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, indexer );
     745                } // if
     746        }
     747
     748        void Unify::visit( __attribute__((unused)) VarArgsType *varArgsType ) {
    749749                result = dynamic_cast< VarArgsType* >( type2 );
    750750        }
    751751
    752         void Unify::visit(ZeroType *zeroType) {
     752        void Unify::visit( __attribute__((unused)) ZeroType *zeroType ) {
    753753                result = dynamic_cast< ZeroType* >( type2 );
    754754        }
    755755
    756         void Unify::visit(OneType *oneType) {
     756        void Unify::visit( __attribute__((unused)) OneType *oneType ) {
    757757                result = dynamic_cast< OneType* >( type2 );
    758758        }
     
    765765                        return function->get_returnVals().front()->get_type()->clone();
    766766                } else {
    767                         TupleType * tupleType = new TupleType( Type::Qualifiers() );
     767                        std::list< Type * > types;
    768768                        for ( DeclarationWithType * decl : function->get_returnVals() ) {
    769                                 tupleType->get_types().push_back( decl->get_type()->clone() );
     769                                types.push_back( decl->get_type()->clone() );
    770770                        } // for
    771                         return tupleType;
     771                        return new TupleType( Type::Qualifiers(), types );
    772772                }
    773773        }
Note: See TracChangeset for help on using the changeset viewer.