Ignore:
Timestamp:
Jun 20, 2019, 6:50:42 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
9af00d23
Parents:
234b1cb
Message:

new AST porting

  • mostly InitTweak? autogeneration
  • added some convenience methods
    • nullptr assignment for ast::ptr
    • convenience wrapper ctors for AddressExpr?, CastExpr? that draw location from first arg
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.h

    r234b1cb rb8524ca  
    4444        /// transform Initializer into an argument list that can be passed to a call expression
    4545        std::list< Expression * > makeInitList( Initializer * init );
     46        std::vector< ast::ptr< ast::Expr > > makeInitList( const ast::Init * init );
    4647
    4748        /// True if the resolver should try to construct dwt
     
    101102        bool isConstExpr( Initializer * init );
    102103
    103         class InitExpander {
     104        class InitExpander_old {
    104105        public:
    105106                // expand by stepping through init to get each list of arguments
    106                 InitExpander( Initializer * init );
     107                InitExpander_old( Initializer * init );
    107108
    108109                // always expand to expr
    109                 InitExpander( Expression * expr );
     110                InitExpander_old( Expression * expr );
    110111
    111112                // iterator-like interface
    112113                std::list< Expression * > operator*();
    113                 InitExpander & operator++();
     114                InitExpander_old & operator++();
    114115
    115116                // builds statement which has the same semantics as a C-style list initializer
     
    130131                IndexList indices;
    131132        };
     133
     134        class InitExpander_new {
     135        public:
     136                using IndexList = std::vector< ast::ptr< ast::Expr > >;
     137                class ExpanderImpl;
     138
     139        private:
     140                std::shared_ptr< ExpanderImpl > expander;
     141                std::vector< ast::ptr< ast::Expr > > crnt;
     142                // invariant: list of size 2N (elements come in pairs [index, dimension])
     143                IndexList indices;
     144
     145        public:
     146                /// Expand by stepping through init to get each list of arguments
     147                InitExpander_new( const ast::Init * init );
     148
     149                /// Always expand to expression
     150                InitExpander_new( const ast::Expr * expr );
     151
     152                std::vector< ast::ptr< ast::Expr > > operator* ();
     153                InitExpander_new & operator++ ();
     154
     155                /// builds statement which has the same semantics as a C-style list initializer (for array
     156                /// initializers) using callExpr as the base expression to perform initialization
     157                ast::ptr< ast::Stmt > buildListInit( const ast::UntypedExpr * callExpr );
     158
     159                void addArrayIndex( const ast::Expr * index, const ast::Expr * dimension );
     160
     161                void clearArrayIndices();
     162
     163                bool addReference();
     164        };
    132165} // namespace
    133166
Note: See TracChangeset for help on using the changeset viewer.