Changeset dd0c97b for src


Ignore:
Timestamp:
Jan 11, 2017, 3:29:33 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
d3a85240
Parents:
627f585
Message:

prevent generic parameters from polluting the outer scope in Box Pass2

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r627f585 rdd0c97b  
    136136                        template< typename DeclClass >
    137137                        DeclClass *handleDecl( DeclClass *decl, Type *type );
    138 
    139                         using PolyMutator::mutate;
     138                        template< typename AggDecl >
     139                        AggDecl * handleAggDecl( AggDecl * aggDecl );
     140
     141                        typedef PolyMutator Parent;
     142                        using Parent::mutate;
    140143                        virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override;
    141144                        virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override;
     145                        virtual StructDecl *mutate( StructDecl *structDecl ) override;
     146                        virtual UnionDecl *mutate( UnionDecl *unionDecl ) override;
    142147                        virtual TypeDecl *mutate( TypeDecl *typeDecl ) override;
    143148                        virtual TypedefDecl *mutate( TypedefDecl *typedefDecl ) override;
     
    12751280                template< typename DeclClass >
    12761281                DeclClass * Pass2::handleDecl( DeclClass *decl, Type *type ) {
    1277                         DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) );
     1282                        DeclClass *ret = static_cast< DeclClass *>( Parent::mutate( decl ) );
    12781283
    12791284                        return ret;
     
    13091314                }
    13101315
     1316                template< typename AggDecl >
     1317                AggDecl * Pass2::handleAggDecl( AggDecl * aggDecl ) {
     1318                        // prevent tyVars from leaking into containing scope
     1319                        scopeTyVars.beginScope();
     1320                        Parent::mutate( aggDecl );
     1321                        scopeTyVars.endScope();
     1322                        return aggDecl;
     1323                }
     1324
     1325                StructDecl * Pass2::mutate( StructDecl *aggDecl ) {
     1326                        return handleAggDecl( aggDecl );
     1327                }
     1328
     1329                UnionDecl * Pass2::mutate( UnionDecl *aggDecl ) {
     1330                        return handleAggDecl( aggDecl );
     1331                }
     1332
    13111333                TypeDecl * Pass2::mutate( TypeDecl *typeDecl ) {
    13121334                        addToTyVarMap( typeDecl, scopeTyVars );
     
    13141336                                return handleDecl( typeDecl, typeDecl->get_base() );
    13151337                        } else {
    1316                                 return Mutator::mutate( typeDecl );
     1338                                return Parent::mutate( typeDecl );
    13171339                        }
    13181340                }
     
    13261348                        makeTyVarMap( pointerType, scopeTyVars );
    13271349
    1328                         Type *ret = Mutator::mutate( pointerType );
     1350                        Type *ret = Parent::mutate( pointerType );
    13291351
    13301352                        scopeTyVars.endScope();
  • src/tests/.expect/tupleVariadic.txt

    r627f585 rdd0c97b  
    99called ?{} with a: 10 2 3 4
    1010array = { 10, 2, 3, 4, }
     11copy=111111
    1112calling func
    1213called process(int) 3
  • src/tests/tupleVariadic.c

    r627f585 rdd0c97b  
    8989}
    9090
     91forall(otype T)
     92T * copy(T x) {
     93        // test calling new inside a polymorphic function
     94        return new(x);
     95}
     96
    9197int main() {
    9298        array * x0 = new();
     
    104110        array * x4 = new(10, 2, 3, 4);
    105111        print(x4);
     112
     113        int * ptr = copy(111111);
     114        printf("copy=%d\n", *ptr);
     115
    106116        printf("calling func\n");
    107117        func(3, 2.0, 111, 4.145);
Note: See TracChangeset for help on using the changeset viewer.