Ignore:
Timestamp:
Sep 20, 2016, 4:47:34 PM (5 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
1132b62
Parents:
aefcc3b (diff), db46512 (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' into tuples

Conflicts:

src/Makefile.in
src/ResolvExpr/Unify.cc
src/SynTree/Type.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    raefcc3b r23b6643f  
    160160                        // xxx - not positive this is correct, but appears to allow casting int => enum
    161161                        cost = Cost( 1, 0, 0 );
    162     } // if
     162                } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {
     163                        cost = Cost( 1, 0, 0 );
     164                } // if
    163165        }
    164166
     
    175177                                } // if
    176178                        } // if
     179                } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {
     180                        cost = Cost( 1, 0, 0 );
    177181                } // if
    178182        }
     
    256260                }
    257261        }
     262
     263        void ConversionCost::visit(ZeroType *zeroType) {
     264                if ( dynamic_cast< ZeroType* >( dest ) ) {
     265                        cost = Cost::zero;
     266                } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {
     267                        // copied from visit(BasicType*) for signed int, but +1 for safe conversions
     268                        int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->get_kind() ];
     269                        if ( tableResult == -1 ) {
     270                                cost = Cost( 1, 0, 0 );
     271                        } else {
     272                                cost = Cost( 0, 0, tableResult + 1 );
     273                        }
     274                } else if ( dynamic_cast< PointerType* >( dest ) ) {
     275                        cost = Cost( 0, 0, 1 );
     276                }
     277        }
     278
     279        void ConversionCost::visit(OneType *oneType) {
     280                if ( dynamic_cast< OneType* >( dest ) ) {
     281                        cost = Cost::zero;
     282                } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {
     283                        // copied from visit(BasicType*) for signed int, but +1 for safe conversions
     284                        int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->get_kind() ];
     285                        if ( tableResult == -1 ) {
     286                                cost = Cost( 1, 0, 0 );
     287                        } else {
     288                                cost = Cost( 0, 0, tableResult + 1 );
     289                        }
     290                }
     291        }
    258292} // namespace ResolvExpr
    259293
Note: See TracChangeset for help on using the changeset viewer.