Ignore:
Timestamp:
Aug 15, 2017, 1:38:10 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
c6c6f2ae
Parents:
be9288a (diff), ae4038d (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Specialize.cc

    rbe9288a rbd098ea  
    101101        }
    102102
     103        // walk into tuple type and find the number of components
     104        size_t singleParameterSize( Type * type ) {
     105                if ( TupleType * tt = dynamic_cast< TupleType * >( type ) ) {
     106                        size_t sz = 0;
     107                        for ( Type * t : *tt ) {
     108                                sz += singleParameterSize( t );
     109                        }
     110                        return sz;
     111                } else {
     112                        return 1;
     113                }
     114        }
     115
     116        // find the total number of components in a parameter list
     117        size_t functionParameterSize( FunctionType * ftype ) {
     118                size_t sz = 0;
     119                for ( DeclarationWithType * p : ftype->get_parameters() ) {
     120                        sz += singleParameterSize( p->get_type() );
     121                }
     122                return sz;
     123        }
     124
    103125        bool needsTupleSpecialization( Type *formalType, Type *actualType ) {
    104126                // Needs tuple specialization if the structure of the formal type and actual type do not match.
     
    111133                        FunctionType * aftype = getFunctionType( actualType );
    112134                        assertf( aftype, "formal type is a function type, but actual type is not." );
     135                        // Can't tuple specialize if parameter sizes deeply-differ.
     136                        if ( functionParameterSize( fftype ) != functionParameterSize( aftype ) ) return false;
     137                        // tuple-parameter sizes are the same, but actual parameter sizes differ - must tuple specialize
    113138                        if ( fftype->get_parameters().size() != aftype->get_parameters().size() ) return true;
     139                        // total parameter size can be the same, while individual parameters can have different structure
    114140                        for ( auto params : group_iterate( fftype->get_parameters(), aftype->get_parameters() ) ) {
    115141                                DeclarationWithType * formal = std::get<0>(params);
Note: See TracChangeset for help on using the changeset viewer.