Changeset 7e23d0a for src/ResolvExpr


Ignore:
Timestamp:
Nov 25, 2015, 2:53:26 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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:
32d281d, 704c9dd
Parents:
02ec390 (diff), 5189888 (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:software/cfa/cfa-cc

Location:
src/ResolvExpr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CastCost.cc

    r02ec390 r7e23d0a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 06:57:43 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 06:59:10 2015
    13 // Update Count     : 2
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon Oct 05 14:48:45 2015
     13// Update Count     : 5
    1414//
    1515
     
    5656                                return Cost::infinity;
    5757                        } else {
     58                                // xxx - why are we adding cost 0 here?
    5859                                return converter.get_cost() + Cost( 0, 0, 0 );
    5960                        } // if
     
    8283                                newEnv.add( pointerType->get_forall() );
    8384                                newEnv.add( pointerType->get_base()->get_forall() );
    84                                 int assignResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
    85                                 if ( assignResult > 0 ) {
     85                                int castResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
     86                                if ( castResult > 0 ) {
    8687                                        cost = Cost( 0, 0, 1 );
    87                                 } else if ( assignResult < 0 ) {
     88                                } else if ( castResult < 0 ) {
    8889                                        cost = Cost( 1, 0, 0 );
    8990                                } // if
  • src/ResolvExpr/PtrsAssignable.cc

    r02ec390 r7e23d0a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 11:44:11 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 11:47:36 2015
    13 // Update Count     : 2
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon Sep 21 14:34:58 2015
     13// Update Count     : 7
    1414//
    1515
     
    106106        void PtrsAssignable::visit( TypeInstType *inst ) {
    107107                EqvClass eqvClass;
    108                 if ( env.lookup( inst->get_name(), eqvClass ) ) {
     108                if ( env.lookup( inst->get_name(), eqvClass ) && eqvClass.type ) {
    109109                        result = ptrsAssignable( eqvClass.type, dest, env );
    110110                } else {
  • src/ResolvExpr/PtrsCastable.cc

    r02ec390 r7e23d0a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 11:48:00 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 11:51:17 2015
    13 // Update Count     : 2
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon Oct 05 14:49:12 2015
     13// Update Count     : 7
    1414//
    1515
     
    133133
    134134        void PtrsCastable::visit(TypeInstType *inst) {
    135                 result = objectCast( inst, env, indexer ) && objectCast( dest, env, indexer ) ? 1 : -1;
     135                result = objectCast( inst, env, indexer ) > 0 && objectCast( dest, env, indexer ) > 0 ? 1 : -1;
    136136        }
    137137
  • src/ResolvExpr/Unify.cc

    r02ec390 r7e23d0a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:27:10 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 26 14:57:05 2015
    13 // Update Count     : 7
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Sep 02 14:43:22 2015
     13// Update Count     : 36
    1414//
    1515
     
    2828
    2929
    30 //#define DEBUG
     30// #define DEBUG
    3131
    3232namespace ResolvExpr {
     
    8181        bool typesCompatible( Type *first, Type *second, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
    8282                TypeEnvironment newEnv;
    83                 OpenVarSet openVars;
     83                OpenVarSet openVars, closedVars; // added closedVars
    8484                AssertionSet needAssertions, haveAssertions;
    8585                Type *newFirst = first->clone(), *newSecond = second->clone();
    8686                env.apply( newFirst );
    8787                env.apply( newSecond );
     88
     89                // do we need to do this? Seems like we do, types should be able to be compatible if they
     90                // have free variables that can unify
     91                findOpenVars( newFirst, openVars, closedVars, needAssertions, haveAssertions, false );
     92                findOpenVars( newSecond, openVars, closedVars, needAssertions, haveAssertions, true );
     93
    8894                bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    8995                delete newFirst;
     
    426432
    427433        void Unify::visit(ArrayType *arrayType) {
    428                 // XXX -- compare array dimension
    429434                ArrayType *otherArray = dynamic_cast< ArrayType* >( type2 );
    430                 if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) {
     435                // to unify, array types must both be VLA or both not VLA
     436                // and must both have a dimension expression or not have a dimension
     437                if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen()
     438                                && ((arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0)
     439                                        || (arrayType->get_dimension() == 0 && otherArray->get_dimension() == 0))) {
     440
     441                        // not positive this is correct in all cases, but it's needed for typedefs
     442                        if ( arrayType->get_isVarLen() || otherArray->get_isVarLen() ) {
     443                                return;
     444                        }
     445
     446                        if ( ! arrayType->get_isVarLen() && ! otherArray->get_isVarLen() &&
     447                                arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0 ) {
     448                                ConstantExpr * ce1 = dynamic_cast< ConstantExpr * >( arrayType->get_dimension() );
     449                                ConstantExpr * ce2 = dynamic_cast< ConstantExpr * >( otherArray->get_dimension() );
     450                                assert(ce1 && ce2);
     451
     452                                Constant * c1 = ce1->get_constant();
     453                                Constant * c2 = ce2->get_constant();
     454
     455                                if ( c1->get_value() != c2->get_value() ) {
     456                                        // does not unify if the dimension is different
     457                                        return;
     458                                }
     459                        }
     460
    431461                        result = unifyExact( arrayType->get_base(), otherArray->get_base(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    432462                } // if
     
    436466        bool unifyDeclList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
    437467                for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) {
     468                        // Type * commonType;
     469                        // if ( ! unifyInexact( (*list1Begin)->get_type(), (*list2Begin)->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode( true, true ), indexer, commonType ) ) {
    438470                        if ( ! unifyExact( (*list1Begin)->get_type(), (*list2Begin)->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ) ) {
    439471                                return false;
     
    450482                FunctionType *otherFunction = dynamic_cast< FunctionType* >( type2 );
    451483                if ( otherFunction && functionType->get_isVarArgs() == otherFunction->get_isVarArgs() ) {
    452  
     484
    453485                        if ( unifyDeclList( functionType->get_parameters().begin(), functionType->get_parameters().end(), otherFunction->get_parameters().begin(), otherFunction->get_parameters().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
    454486       
Note: See TracChangeset for help on using the changeset viewer.