Ignore:
Timestamp:
Jul 21, 2016, 11:19:24 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
b81adcc4
Parents:
5f98ce5
Message:

only generate array dimension constant inside of functions, recursively mutate array types into pointer types in function parameter lists, fix bug where global compound literal object is lost

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/GenInit.cc

    r5f98ce5 r40e636a  
    9090
    9191          private:
    92                 DeclarationWithType * mutate( ObjectDecl * objectDecl );
     92                virtual DeclarationWithType * mutate( ObjectDecl * objectDecl );
     93                virtual DeclarationWithType * mutate( FunctionDecl *functionDecl );
    9394                // should not traverse into any of these declarations to find objects
    9495                // that need to be constructed or destructed
     
    105106
    106107                DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass;
     108                bool inFunction = false;
    107109        };
    108110
     
    157159        void HoistArrayDimension::hoistArrayDimension( std::list< Declaration * > & translationUnit ) {
    158160                HoistArrayDimension hoister;
    159                 mutateAll( translationUnit, hoister );
     161                hoister.mutateDeclarationList( translationUnit );
    160162        }
    161163
     
    169171
    170172        void HoistArrayDimension::hoist( Type * type ) {
     173                // if in function, generate const size_t var
    171174                static UniqueName dimensionName( "_array_dim" );
    172175                if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
     176                        if ( ! inFunction ) return;
     177
    173178                        if ( ! arrayType->get_dimension() ) return; // xxx - recursive call to hoist?
    174179
     
    186191                        return;
    187192                }
     193        }
     194
     195        DeclarationWithType * HoistArrayDimension::mutate( FunctionDecl *functionDecl ) {
     196                bool oldInFunc = inFunction;
     197                inFunction = true;
     198                DeclarationWithType * decl = Parent::mutate( functionDecl );
     199                inFunction = oldInFunc;
     200                return decl;
    188201        }
    189202
Note: See TracChangeset for help on using the changeset viewer.