Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.h

    r335d81f rf5c3b6c  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // InitTweak.h --
     7// RemoveInit.h --
    88//
    99// Author           : Rob Schluntz
    1010// Created On       : Fri May 13 11:26:36 2016
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul 19 14:18:00 2019
    13 // Update Count     : 6
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 22 09:30:33 2017
     13// Update Count     : 4
    1414//
    1515
     
    1919#include <memory>             // for shared_ptr
    2020#include <string>             // for string, allocator
    21 #include <vector>
    2221
    23 #include "AST/Fwd.hpp"        // for AST nodes
    2422#include "SynTree/SynTree.h"  // for Visitor Nodes
    2523
    2624// helper functions for initialization
    2725namespace InitTweak {
    28         const FunctionDecl * isAssignment( const Declaration * decl );
    29         const FunctionDecl * isDestructor( const Declaration * decl );
    30         const FunctionDecl * isDefaultConstructor( const Declaration * decl );
    31         const FunctionDecl * isCopyConstructor( const Declaration * decl );
    32         const FunctionDecl * isCopyFunction( const Declaration * decl, const std::string & fname );
    33         bool isCopyFunction( const ast::FunctionDecl * decl );
     26        FunctionDecl * isAssignment( Declaration * decl );
     27        FunctionDecl * isDestructor( Declaration * decl );
     28        FunctionDecl * isDefaultConstructor( Declaration * decl );
     29        FunctionDecl * isCopyConstructor( Declaration * decl );
     30        FunctionDecl * isCopyFunction( Declaration * decl, const std::string & fname );
    3431
    3532        /// returns the base type of the first parameter to a constructor/destructor/assignment function
     
    4441        /// transform Initializer into an argument list that can be passed to a call expression
    4542        std::list< Expression * > makeInitList( Initializer * init );
    46         std::vector< ast::ptr< ast::Expr > > makeInitList( const ast::Init * init );
    4743
    4844        /// True if the resolver should try to construct dwt
     
    6157        /// returns the declaration of the function called by the expr (must be ApplicationExpr or UntypedExpr)
    6258        DeclarationWithType * getFunction( Expression * expr );
    63         const DeclarationWithType * getFunction( const Expression * expr );
    64         const ast::DeclWithType * getFunction( const ast::Expr * expr );
    6559
    6660        /// Non-Null if expr is a call expression whose target function is intrinsic
    6761        ApplicationExpr * isIntrinsicCallExpr( Expression * expr );
    68         const ast::ApplicationExpr * isIntrinsicCallExpr( const ast::Expr * expr);
    6962
    7063        /// True if stmt is a call statement where the function called is intrinsic and takes one parameter.
     
    7265        /// Currently has assertions that make it less than fully general.
    7366        bool isIntrinsicSingleArgCallStmt( Statement * stmt );
    74         bool isIntrinsicSingleArgCallStmt( const ast::Stmt * stmt );
    7567
    7668        /// True if stmt is a call statement where the function called is intrinsic.
     
    7971        /// get all Ctor/Dtor call expressions from a Statement
    8072        void collectCtorDtorCalls( Statement * stmt, std::list< Expression * > & matches );
    81         std::vector< ast::ptr< ast::Expr > > collectCtorDtorCalls( const ast::Stmt * stmt );
    8273
    8374        /// get the Ctor/Dtor call expression from a Statement that looks like a generated ctor/dtor call
     
    8677        /// returns the name of the function being called
    8778        std::string getFunctionName( Expression * expr );
    88         std::string getFunctionName( const ast::Expr * expr );
    8979
    9080        /// returns the argument to a call expression in position N indexed from 0
    9181        Expression *& getCallArg( Expression * callExpr, unsigned int pos );
    92         const ast::Expr * getCallArg( const ast::Expr * call, unsigned pos );
    9382
    9483        /// returns the base type of a PointerType or ArrayType, else returns NULL
    9584        Type * getPointerBase( Type * );
    96         const ast::Type* getPointerBase( const ast::Type* );
    9785
    9886        /// returns the argument if it is a PointerType or ArrayType, else returns NULL
     
    10391        bool isConstExpr( Initializer * init );
    10492
    105         class InitExpander_old {
     93        class InitExpander {
    10694        public:
    10795                // expand by stepping through init to get each list of arguments
    108                 InitExpander_old( Initializer * init );
     96                InitExpander( Initializer * init );
    10997
    11098                // always expand to expr
    111                 InitExpander_old( Expression * expr );
     99                InitExpander( Expression * expr );
    112100
    113101                // iterator-like interface
    114102                std::list< Expression * > operator*();
    115                 InitExpander_old & operator++();
     103                InitExpander & operator++();
    116104
    117105                // builds statement which has the same semantics as a C-style list initializer
     
    132120                IndexList indices;
    133121        };
    134 
    135         class InitExpander_new {
    136         public:
    137                 using IndexList = std::vector< ast::ptr< ast::Expr > >;
    138                 class ExpanderImpl;
    139 
    140         private:
    141                 std::shared_ptr< ExpanderImpl > expander;
    142                 std::vector< ast::ptr< ast::Expr > > crnt;
    143                 // invariant: list of size 2N (elements come in pairs [index, dimension])
    144                 IndexList indices;
    145 
    146         public:
    147                 /// Expand by stepping through init to get each list of arguments
    148                 InitExpander_new( const ast::Init * init );
    149 
    150                 /// Always expand to expression
    151                 InitExpander_new( const ast::Expr * expr );
    152 
    153                 std::vector< ast::ptr< ast::Expr > > operator* ();
    154                 InitExpander_new & operator++ ();
    155 
    156                 /// builds statement which has the same semantics as a C-style list initializer (for array
    157                 /// initializers) using callExpr as the base expression to perform initialization.
    158                 /// Mutates callExpr
    159                 ast::ptr< ast::Stmt > buildListInit( ast::UntypedExpr * callExpr );
    160 
    161                 void addArrayIndex( const ast::Expr * index, const ast::Expr * dimension );
    162 
    163                 void clearArrayIndices();
    164 
    165                 bool addReference();
    166         };
    167122} // namespace
    168123
Note: See TracChangeset for help on using the changeset viewer.