Changeset 4b8f918


Ignore:
Timestamp:
Apr 12, 2016, 2:30:22 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
b52d900
Parents:
df2be83
Message:

Fix modularization for generic types, so that caller is only required to pass layout for complete generic types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rdf2be83 r4b8f918  
    664664                        if ( functionDecl->get_statements() ) {         // empty routine body ?
    665665                                doBeginScope();
    666                                 scopeTyVars.beginScope();;
     666                                scopeTyVars.beginScope();
    667667                                assignOps.beginScope();
    668668                                DeclarationWithType *oldRetval = retval;
     
    741741
    742742                void Pass1::passArgTypeVars( ApplicationExpr *appExpr, Type *parmType, Type *argBaseType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars, std::set< std::string > &seenTypes ) {
    743                         Type *polyBase = hasPolyBase( parmType, exprTyVars );
    744                         if ( polyBase && ! dynamic_cast< TypeInstType* >( polyBase ) ) {
    745                                 std::string typeName = mangleType( polyBase );
     743                        Type *polyType = isPolyType( parmType, exprTyVars );
     744                        if ( polyType && ! dynamic_cast< TypeInstType* >( polyType ) ) {
     745                                std::string typeName = mangleType( polyType );
    746746                                if ( seenTypes.count( typeName ) ) return;
    747747
     
    750750                                arg = appExpr->get_args().insert( arg, new AlignofExpr( argBaseType->clone() ) );
    751751                                arg++;
    752                                 if ( dynamic_cast< StructInstType* >( polyBase ) ) {
     752                                if ( dynamic_cast< StructInstType* >( polyType ) ) {
    753753                                        if ( StructInstType *argBaseStructType = dynamic_cast< StructInstType* >( argBaseType ) ) {
    754754                                                // zero-length arrays are forbidden by C, so don't pass offset for empty struct
     
    13011301
    13021302                        boxParams( appExpr, function, arg, exprTyVars );
    1303 
    13041303                        passAdapters( appExpr, function, exprTyVars );
    13051304
     
    15911590                        std::set< std::string > seenTypes; // sizeofName for generic types we've seen
    15921591                        for ( std::list< DeclarationWithType* >::const_iterator fnParm = last; fnParm != funcType->get_parameters().end(); ++fnParm ) {
    1593                                 Type *polyBase = hasPolyBase( (*fnParm)->get_type(), scopeTyVars );
    1594                                 if ( polyBase && ! dynamic_cast< TypeInstType* >( polyBase ) ) {
    1595                                         std::string typeName = mangleType( polyBase );
     1592                                Type *polyType = isPolyType( (*fnParm)->get_type(), scopeTyVars );
     1593                                if ( polyType && ! dynamic_cast< TypeInstType* >( polyType ) ) {
     1594                                        std::string typeName = mangleType( polyType );
    15961595                                        if ( seenTypes.count( typeName ) ) continue;
    15971596
     
    16071606                                        ++last;
    16081607
    1609                                         if ( StructInstType *polyBaseStruct = dynamic_cast< StructInstType* >( polyBase ) ) {
     1608                                        if ( StructInstType *polyBaseStruct = dynamic_cast< StructInstType* >( polyType ) ) {
    16101609                                                // NOTE zero-length arrays are illegal in C, so empty structs have no offset array
    16111610                                                if ( ! polyBaseStruct->get_baseStruct()->get_members().empty() ) {
     
    18201819                }
    18211820
    1822 ////////////////////////////////////////// MemberExprFixer ////////////////////////////////////////////////////
     1821////////////////////////////////////////// PolyGenericCalculator ////////////////////////////////////////////////////
    18231822
    18241823                template< typename DeclClass >
     
    18671866                        for ( std::list< DeclarationWithType* >::const_iterator fnParm = funcType->get_parameters().begin(); fnParm != funcType->get_parameters().end(); ++fnParm ) {
    18681867                                // condition here duplicates that in Pass2::mutate( FunctionType* )
    1869                                 Type *polyBase = hasPolyBase( (*fnParm)->get_type(), scopeTyVars );
    1870                                 if ( polyBase && ! dynamic_cast< TypeInstType* >( polyBase ) ) {
    1871                                         knownLayouts.insert( mangleType( polyBase ) );
     1868                                Type *polyType = isPolyType( (*fnParm)->get_type(), scopeTyVars );
     1869                                if ( polyType && ! dynamic_cast< TypeInstType* >( polyType ) ) {
     1870                                        knownLayouts.insert( mangleType( polyType ) );
    18721871                                }
    18731872                        }
Note: See TracChangeset for help on using the changeset viewer.