Changeset e3bf4cf


Ignore:
Timestamp:
Oct 31, 2022, 12:16:40 PM (2 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
994028dc
Parents:
637c139
Message:

Cleaning old box pass for easier translation. Used isInFunction() to simplify LayoutFunctionBuilder?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/GenPoly/Box.cc

    r637c139 re3bf4cf  
    6868                /// Adds layout-generation functions to polymorphic types.
    6969                class LayoutFunctionBuilder final : public WithDeclsToAdd, public WithVisitorRef<LayoutFunctionBuilder>, public WithShortCircuiting {
    70                         // Current level of nested functions:
    71                         unsigned int functionNesting = 0;
    7270                public:
    73                         void previsit( FunctionDecl *functionDecl );
    7471                        void previsit( StructDecl *structDecl );
    7572                        void previsit( UnionDecl *unionDecl );
     
    237234        ////////////////////////////////// LayoutFunctionBuilder ////////////////////////////////////////////
    238235
    239         void LayoutFunctionBuilder::previsit( FunctionDecl *functionDecl ) {
    240                 visit_children = false;
    241                 maybeAccept( functionDecl->get_functionType(), *visitor );
    242                 ++functionNesting;
    243                 maybeAccept( functionDecl->get_statements(), *visitor );
    244                 --functionNesting;
    245         }
    246 
    247236        /// Get a list of type declarations that will affect a layout function
    248237        std::list< TypeDecl* > takeOtypeOnly( std::list< TypeDecl* > &decls ) {
     
    271260
    272261        /// Builds a layout function declaration
    273         FunctionDecl *buildLayoutFunctionDecl( AggregateDecl *typeDecl, unsigned int functionNesting, FunctionType *layoutFnType ) {
     262        FunctionDecl *buildLayoutFunctionDecl( AggregateDecl *typeDecl, bool isInFunction, FunctionType *layoutFnType ) {
    274263                // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
    275264                // because each unit generates copies of the default routines for each aggregate.
    276265                FunctionDecl *layoutDecl = new FunctionDecl( layoutofName( typeDecl ),
    277                                                                                                          functionNesting > 0 ? Type::StorageClasses() : Type::StorageClasses( Type::Static ),
     266                                                                                                         isInFunction ? Type::StorageClasses() : Type::StorageClasses( Type::Static ),
    278267                                                                                                         LinkageSpec::AutoGen, layoutFnType, new CompoundStmt(),
    279268                                                                                                         std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) );
     
    347336
    348337                // build function decl
    349                 FunctionDecl *layoutDecl = buildLayoutFunctionDecl( structDecl, functionNesting, layoutFnType );
     338                FunctionDecl *layoutDecl = buildLayoutFunctionDecl( structDecl, isInFunction(), layoutFnType );
    350339
    351340                // calculate struct layout in function body
     
    401390
    402391                // build function decl
    403                 FunctionDecl *layoutDecl = buildLayoutFunctionDecl( unionDecl, functionNesting, layoutFnType );
     392                FunctionDecl *layoutDecl = buildLayoutFunctionDecl( unionDecl, isInFunction(), layoutFnType );
    404393
    405394                // calculate union layout in function body
Note: See TracChangeset for help on using the changeset viewer.