Changeset 1cdfa82 for src/ResolvExpr/CommonType.cc
- Timestamp:
- Apr 25, 2018, 4:55:53 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- 42107b4
- Parents:
- 2efe4b8 (diff), 9d5fb67 (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
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CommonType.cc
r2efe4b8 r1cdfa82 28 28 29 29 // #define DEBUG 30 #ifdef DEBUG 31 #define PRINT(x) x 32 #else 33 #define PRINT(x) 34 #endif 30 35 31 36 namespace ResolvExpr { … … 70 75 // need unify to bind type variables 71 76 if ( unify( t1, t2, env, have, need, newOpen, indexer, common ) ) { 72 // std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl; 77 PRINT( 78 std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl; 79 ) 73 80 if ( (widenFirst || t2->get_qualifiers() <= t1->get_qualifiers()) && (widenSecond || t1->get_qualifiers() <= t2->get_qualifiers()) ) { 74 // std::cerr << "widen okay" << std::endl; 81 PRINT( 82 std::cerr << "widen okay" << std::endl; 83 ) 75 84 common->get_qualifiers() |= t1->get_qualifiers(); 76 85 common->get_qualifiers() |= t2->get_qualifiers(); … … 78 87 } 79 88 } 80 // std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl; 89 PRINT( 90 std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl; 91 ) 81 92 return nullptr; 82 93 } … … 90 101 int diff = depth1-depth2; 91 102 // TODO: should it be possible for commonType to generate complicated conversions? I would argue no, only conversions that involve types of the same reference level or a difference of 1 should be allowed. 92 if ( diff > 1 || diff < -1 ) return nullptr;103 // if ( diff > 1 || diff < -1 ) return nullptr; 93 104 94 105 // special case where one type has a reference depth of 1 larger than the other 95 106 if ( diff > 0 || diff < 0 ) { 96 // std::cerr << "reference depth diff: " << diff << std::endl; 107 PRINT( 108 std::cerr << "reference depth diff: " << diff << std::endl; 109 ) 97 110 Type * result = nullptr; 98 111 ReferenceType * ref1 = dynamic_cast< ReferenceType * >( type1 ); … … 109 122 if ( result && ref1 ) { 110 123 // formal is reference, so result should be reference 111 // std::cerr << "formal is reference; result should be reference" << std::endl; 124 PRINT( 125 std::cerr << "formal is reference; result should be reference" << std::endl; 126 ) 112 127 result = new ReferenceType( ref1->get_qualifiers(), result ); 113 128 } 114 // std::cerr << "common type of reference [" << type1 << "] and [" << type2 << "] is [" << result << "]" << std::endl; 129 PRINT( 130 std::cerr << "common type of reference [" << type1 << "] and [" << type2 << "] is [" << result << "]" << std::endl; 131 ) 115 132 return result; 116 133 }
Note: See TracChangeset
for help on using the changeset viewer.