Changeset 0f9e4403 for src/ResolvExpr/Unify.cc
- Timestamp:
- Apr 15, 2016, 12:03:11 PM (10 years ago)
- 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, with_gc
- Children:
- 29ad0ac
- Parents:
- c5833e8 (diff), 37f0da8 (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. - File:
-
- 1 edited
-
src/ResolvExpr/Unify.cc (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Unify.cc
rc5833e8 r0f9e4403 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Unify.cc -- 7 // Unify.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:27:10 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Sep 02 14:43:22 201513 // Update Count : 3 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:37:05 2016 13 // Update Count : 37 14 14 // 15 15 … … 38 38 WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; } 39 39 operator bool() { return widenFirst && widenSecond; } 40 40 41 41 bool widenFirst : 1, widenSecond : 1; 42 42 }; … … 45 45 public: 46 46 Unify( Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ); 47 47 48 48 bool get_result() const { return result; } 49 49 private: … … 56 56 virtual void visit(UnionInstType *aggregateUseType); 57 57 virtual void visit(EnumInstType *aggregateUseType); 58 virtual void visit( ContextInstType *aggregateUseType);58 virtual void visit(TraitInstType *aggregateUseType); 59 59 virtual void visit(TypeInstType *aggregateUseType); 60 60 virtual void visit(TupleType *tupleType); 61 virtual void visit(VarArgsType *varArgsType); 61 62 62 63 template< typename RefType > void handleRefType( RefType *inst, Type *other ); … … 78 79 bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer, Type *&common ); 79 80 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ); 80 81 81 82 bool typesCompatible( Type *first, Type *second, const SymTab::Indexer &indexer, const TypeEnvironment &env ) { 82 83 TypeEnvironment newEnv; … … 136 137 case TypeDecl::Dtype: 137 138 return ! isFtype( type, indexer ); 138 139 139 140 case TypeDecl::Ftype: 140 141 return isFtype( type, indexer ); … … 195 196 bool widen1 = false, widen2 = false; 196 197 Type *type1 = 0, *type2 = 0; 197 198 198 199 if ( env.lookup( var1->get_name(), class1 ) ) { 199 200 hasClass1 = true; … … 216 217 widen2 = widenMode.widenSecond && class2.allowWidening; 217 218 } // if 218 219 219 220 if ( type1 && type2 ) { 220 221 // std::cout << "has type1 && type2" << std::endl; … … 435 436 // to unify, array types must both be VLA or both not VLA 436 437 // 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))) { 438 if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) { 440 439 441 440 // not positive this is correct in all cases, but it's needed for typedefs … … 448 447 ConstantExpr * ce1 = dynamic_cast< ConstantExpr * >( arrayType->get_dimension() ); 449 448 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; 449 // see C11 Reference Manual 6.7.6.2.6 450 // two array types with size specifiers that are integer constant expressions are 451 // compatible if both size specifiers have the same constant value 452 if ( ce1 && ce2 ) { 453 Constant * c1 = ce1->get_constant(); 454 Constant * c2 = ce2->get_constant(); 455 456 if ( c1->get_value() != c2->get_value() ) { 457 // does not unify if the dimension is different 458 return; 459 } 458 460 } 459 461 } … … 484 486 485 487 if ( unifyDeclList( functionType->get_parameters().begin(), functionType->get_parameters().end(), otherFunction->get_parameters().begin(), otherFunction->get_parameters().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) { 486 488 487 489 if ( unifyDeclList( functionType->get_returnVals().begin(), functionType->get_returnVals().end(), otherFunction->get_returnVals().begin(), otherFunction->get_returnVals().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) { 488 490 … … 539 541 } 540 542 541 void Unify::visit( ContextInstType *contextInst) {543 void Unify::visit(TraitInstType *contextInst) { 542 544 handleRefType( contextInst, type2 ); 543 545 } … … 582 584 } 583 585 586 void Unify::visit(VarArgsType *varArgsType) { 587 result = dynamic_cast< VarArgsType* >( type2 ); 588 } 589 584 590 } // namespace ResolvExpr 585 591
Note:
See TracChangeset
for help on using the changeset viewer.