Ignore:
Timestamp:
Aug 15, 2017, 1:21:03 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:
97e3296
Parents:
303406a (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

    r303406a rf710aca  
    9393        }
    9494
     95        // walk into tuple type and find the number of components
     96        size_t singleParameterSize( Type * type ) {
     97                if ( TupleType * tt = dynamic_cast< TupleType * >( type ) ) {
     98                        size_t sz = 0;
     99                        for ( Type * t : *tt ) {
     100                                sz += singleParameterSize( t );
     101                        }
     102                        return sz;
     103                } else {
     104                        return 1;
     105                }
     106        }
     107
     108        // find the total number of components in a parameter list
     109        size_t functionParameterSize( FunctionType * ftype ) {
     110                size_t sz = 0;
     111                for ( DeclarationWithType * p : ftype->get_parameters() ) {
     112                        sz += singleParameterSize( p->get_type() );
     113                }
     114                return sz;
     115        }
     116
    95117        bool needsTupleSpecialization( Type *formalType, Type *actualType ) {
    96118                // Needs tuple specialization if the structure of the formal type and actual type do not match.
     
    103125                        FunctionType * aftype = getFunctionType( actualType );
    104126                        assertf( aftype, "formal type is a function type, but actual type is not." );
     127                        // Can't tuple specialize if parameter sizes deeply-differ.
     128                        if ( functionParameterSize( fftype ) != functionParameterSize( aftype ) ) return false;
     129                        // tuple-parameter sizes are the same, but actual parameter sizes differ - must tuple specialize
    105130                        if ( fftype->get_parameters().size() != aftype->get_parameters().size() ) return true;
     131                        // total parameter size can be the same, while individual parameters can have different structure
    106132                        for ( auto params : group_iterate( fftype->get_parameters(), aftype->get_parameters() ) ) {
    107133                                DeclarationWithType * formal = std::get<0>(params);
Note: See TracChangeset for help on using the changeset viewer.