Changes in / [d2ded3e7:4673385]
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CastCost.cc
rd2ded3e7 r4673385 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 06:57:43 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun May 17 06:59:10201513 // Update Count : 211 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon Oct 05 14:48:45 2015 13 // Update Count : 5 14 14 // 15 15 … … 56 56 return Cost::infinity; 57 57 } else { 58 // xxx - why are we adding cost 0 here? 58 59 return converter.get_cost() + Cost( 0, 0, 0 ); 59 60 } // if … … 82 83 newEnv.add( pointerType->get_forall() ); 83 84 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 ) { 86 87 cost = Cost( 0, 0, 1 ); 87 } else if ( assignResult < 0 ) {88 } else if ( castResult < 0 ) { 88 89 cost = Cost( 1, 0, 0 ); 89 90 } // if -
src/ResolvExpr/PtrsAssignable.cc
rd2ded3e7 r4673385 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 11:44:11 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun May 17 11:47:36201513 // Update Count : 211 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon Sep 21 14:34:58 2015 13 // Update Count : 7 14 14 // 15 15 … … 106 106 void PtrsAssignable::visit( TypeInstType *inst ) { 107 107 EqvClass eqvClass; 108 if ( env.lookup( inst->get_name(), eqvClass ) ) {108 if ( env.lookup( inst->get_name(), eqvClass ) && eqvClass.type ) { 109 109 result = ptrsAssignable( eqvClass.type, dest, env ); 110 110 } else { -
src/ResolvExpr/PtrsCastable.cc
rd2ded3e7 r4673385 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 11:48:00 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun May 17 11:51:17201513 // Update Count : 211 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon Oct 05 14:49:12 2015 13 // Update Count : 7 14 14 // 15 15 … … 133 133 134 134 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; 136 136 } 137 137 -
src/ResolvExpr/Unify.cc
rd2ded3e7 r4673385 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:27:10 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jun 26 14:57:05201513 // Update Count : 711 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Sep 02 14:43:22 2015 13 // Update Count : 36 14 14 // 15 15 … … 28 28 29 29 30 // #define DEBUG30 // #define DEBUG 31 31 32 32 namespace ResolvExpr { … … 80 80 bool typesCompatible( Type *first, Type *second, const SymTab::Indexer &indexer, const TypeEnvironment &env ) { 81 81 TypeEnvironment newEnv; 82 OpenVarSet openVars ;82 OpenVarSet openVars, closedVars; // added closedVars 83 83 AssertionSet needAssertions, haveAssertions; 84 84 Type *newFirst = first->clone(), *newSecond = second->clone(); 85 85 env.apply( newFirst ); 86 86 env.apply( newSecond ); 87 88 // do we need to do this? Seems like we do, types should be able to be compatible if they 89 // have free variables that can unify 90 findOpenVars( newFirst, openVars, closedVars, needAssertions, haveAssertions, false ); 91 findOpenVars( newSecond, openVars, closedVars, needAssertions, haveAssertions, true ); 92 87 93 bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 88 94 delete newFirst; … … 425 431 426 432 void Unify::visit(ArrayType *arrayType) { 427 // XXX -- compare array dimension428 433 ArrayType *otherArray = dynamic_cast< ArrayType* >( type2 ); 429 if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) { 434 // to unify, array types must both be VLA or both not VLA 435 // and must both have a dimension expression or not have a dimension 436 if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() 437 && ((arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0) 438 || (arrayType->get_dimension() == 0 && otherArray->get_dimension() == 0))) { 439 440 // not positive this is correct in all cases, but it's needed for typedefs 441 if ( arrayType->get_isVarLen() || otherArray->get_isVarLen() ) { 442 return; 443 } 444 445 if ( ! arrayType->get_isVarLen() && ! otherArray->get_isVarLen() && 446 arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0 ) { 447 ConstantExpr * ce1 = dynamic_cast< ConstantExpr * >( arrayType->get_dimension() ); 448 ConstantExpr * ce2 = dynamic_cast< ConstantExpr * >( otherArray->get_dimension() ); 449 assert(ce1 && ce2); 450 451 Constant * c1 = ce1->get_constant(); 452 Constant * c2 = ce2->get_constant(); 453 454 if ( c1->get_value() != c2->get_value() ) { 455 // does not unify if the dimension is different 456 return; 457 } 458 } 459 430 460 result = unifyExact( arrayType->get_base(), otherArray->get_base(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 431 461 } // if … … 435 465 bool unifyDeclList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 436 466 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { 467 // Type * commonType; 468 // if ( ! unifyInexact( (*list1Begin)->get_type(), (*list2Begin)->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode( true, true ), indexer, commonType ) ) { 437 469 if ( ! unifyExact( (*list1Begin)->get_type(), (*list2Begin)->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ) ) { 438 470 return false; … … 449 481 FunctionType *otherFunction = dynamic_cast< FunctionType* >( type2 ); 450 482 if ( otherFunction && functionType->get_isVarArgs() == otherFunction->get_isVarArgs() ) { 451 483 452 484 if ( unifyDeclList( functionType->get_parameters().begin(), functionType->get_parameters().end(), otherFunction->get_parameters().begin(), otherFunction->get_parameters().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) { 453 485 -
src/SymTab/Validate.cc
rd2ded3e7 r4673385 54 54 #include "MakeLibCfa.h" 55 55 #include "TypeEquality.h" 56 #include "ResolvExpr/typeops.h" 56 57 57 58 #define debugPrint( x ) if ( doDebug ) { std::cout << x; } … … 851 852 Type * t1 = tyDecl->get_base(); 852 853 Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base(); 853 if ( ! typeEquals( t1, t2, true) ) {854 if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) { 854 855 throw SemanticError( "cannot redefine typedef: " + tyDecl->get_name() ); 855 856 } -
src/SynTree/ObjectDecl.cc
rd2ded3e7 r4673385 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Jul 13 18:08:27201513 // Update Count : 1 611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Sep 29 14:13:01 2015 13 // Update Count : 18 14 14 // 15 15 … … 52 52 get_type()->print( os, indent ); 53 53 } else { 54 os << " untyped entity ";54 os << " untyped entity "; 55 55 } // if 56 56 57 57 if ( init ) { 58 os << " with initializer ";58 os << " with initializer "; 59 59 init->print( os, indent ); 60 60 } // if 61 61 62 62 if ( bitfieldWidth ) { 63 os << " with bitfield width ";63 os << " with bitfield width "; 64 64 bitfieldWidth->print( os ); 65 65 } // if
Note:
See TracChangeset
for help on using the changeset viewer.