Changes in src/InitTweak/InitTweak.h [335d81f:f5c3b6c]
- File:
-
- 1 edited
-
src/InitTweak/InitTweak.h (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/InitTweak.h
r335d81f rf5c3b6c 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // InitTweak.h --7 // RemoveInit.h -- 8 8 // 9 9 // Author : Rob Schluntz 10 10 // Created On : Fri May 13 11:26:36 2016 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Jul 19 14:18:00 201913 // Update Count : 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:30:33 2017 13 // Update Count : 4 14 14 // 15 15 … … 19 19 #include <memory> // for shared_ptr 20 20 #include <string> // for string, allocator 21 #include <vector>22 21 23 #include "AST/Fwd.hpp" // for AST nodes24 22 #include "SynTree/SynTree.h" // for Visitor Nodes 25 23 26 24 // helper functions for initialization 27 25 namespace 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 ); 34 31 35 32 /// returns the base type of the first parameter to a constructor/destructor/assignment function … … 44 41 /// transform Initializer into an argument list that can be passed to a call expression 45 42 std::list< Expression * > makeInitList( Initializer * init ); 46 std::vector< ast::ptr< ast::Expr > > makeInitList( const ast::Init * init );47 43 48 44 /// True if the resolver should try to construct dwt … … 61 57 /// returns the declaration of the function called by the expr (must be ApplicationExpr or UntypedExpr) 62 58 DeclarationWithType * getFunction( Expression * expr ); 63 const DeclarationWithType * getFunction( const Expression * expr );64 const ast::DeclWithType * getFunction( const ast::Expr * expr );65 59 66 60 /// Non-Null if expr is a call expression whose target function is intrinsic 67 61 ApplicationExpr * isIntrinsicCallExpr( Expression * expr ); 68 const ast::ApplicationExpr * isIntrinsicCallExpr( const ast::Expr * expr);69 62 70 63 /// True if stmt is a call statement where the function called is intrinsic and takes one parameter. … … 72 65 /// Currently has assertions that make it less than fully general. 73 66 bool isIntrinsicSingleArgCallStmt( Statement * stmt ); 74 bool isIntrinsicSingleArgCallStmt( const ast::Stmt * stmt );75 67 76 68 /// True if stmt is a call statement where the function called is intrinsic. … … 79 71 /// get all Ctor/Dtor call expressions from a Statement 80 72 void collectCtorDtorCalls( Statement * stmt, std::list< Expression * > & matches ); 81 std::vector< ast::ptr< ast::Expr > > collectCtorDtorCalls( const ast::Stmt * stmt );82 73 83 74 /// get the Ctor/Dtor call expression from a Statement that looks like a generated ctor/dtor call … … 86 77 /// returns the name of the function being called 87 78 std::string getFunctionName( Expression * expr ); 88 std::string getFunctionName( const ast::Expr * expr );89 79 90 80 /// returns the argument to a call expression in position N indexed from 0 91 81 Expression *& getCallArg( Expression * callExpr, unsigned int pos ); 92 const ast::Expr * getCallArg( const ast::Expr * call, unsigned pos );93 82 94 83 /// returns the base type of a PointerType or ArrayType, else returns NULL 95 84 Type * getPointerBase( Type * ); 96 const ast::Type* getPointerBase( const ast::Type* );97 85 98 86 /// returns the argument if it is a PointerType or ArrayType, else returns NULL … … 103 91 bool isConstExpr( Initializer * init ); 104 92 105 class InitExpander _old{93 class InitExpander { 106 94 public: 107 95 // expand by stepping through init to get each list of arguments 108 InitExpander _old( Initializer * init );96 InitExpander( Initializer * init ); 109 97 110 98 // always expand to expr 111 InitExpander _old( Expression * expr );99 InitExpander( Expression * expr ); 112 100 113 101 // iterator-like interface 114 102 std::list< Expression * > operator*(); 115 InitExpander _old& operator++();103 InitExpander & operator++(); 116 104 117 105 // builds statement which has the same semantics as a C-style list initializer … … 132 120 IndexList indices; 133 121 }; 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 arguments148 InitExpander_new( const ast::Init * init );149 150 /// Always expand to expression151 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 array157 /// initializers) using callExpr as the base expression to perform initialization.158 /// Mutates callExpr159 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 };167 122 } // namespace 168 123
Note:
See TracChangeset
for help on using the changeset viewer.