Ignore:
Timestamp:
Apr 25, 2018, 4:55:53 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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.
Message:

Merge remote-tracking branch 'origin/master' into with_gc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CommonType.cc

    r2efe4b8 r1cdfa82  
    2828
    2929// #define DEBUG
     30#ifdef DEBUG
     31#define PRINT(x) x
     32#else
     33#define PRINT(x)
     34#endif
    3035
    3136namespace ResolvExpr {
     
    7075                // need unify to bind type variables
    7176                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                        )
    7380                        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                                )
    7584                                common->get_qualifiers() |= t1->get_qualifiers();
    7685                                common->get_qualifiers() |= t2->get_qualifiers();
     
    7887                        }
    7988                }
    80                 // std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl;
     89                PRINT(
     90                        std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl;
     91                )
    8192                return nullptr;
    8293        }
     
    90101                        int diff = depth1-depth2;
    91102                        // 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;
    93104
    94105                        // special case where one type has a reference depth of 1 larger than the other
    95106                        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                                )
    97110                                Type * result = nullptr;
    98111                                ReferenceType * ref1 = dynamic_cast< ReferenceType * >( type1 );
     
    109122                                if ( result && ref1 ) {
    110123                                        // 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                                        )
    112127                                        result = new ReferenceType( ref1->get_qualifiers(), result );
    113128                                }
    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                                )
    115132                                return result;
    116133                        }
Note: See TracChangeset for help on using the changeset viewer.