Changeset 4e2f1b2 for src/SymTab
- Timestamp:
- Feb 23, 2024, 3:59:35 PM (11 months ago)
- Branches:
- master
- Children:
- 1761046
- Parents:
- d06273c
- Location:
- src/SymTab
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/GenImplicitCall.cpp
rd06273c r4e2f1b2 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // GenImplicitCall. hpp --7 // GenImplicitCall.cpp -- Generate code for implicit operator calls. 8 8 // 9 9 // Author : Andrew Beach … … 31 31 namespace { 32 32 33 template< typename OutIter > 33 using Inserter = std::back_insert_iterator<std::list<ast::ptr<ast::Stmt>>>; 34 34 35 ast::ptr< ast::Stmt > genCall( 35 36 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 36 const CodeLocation & loc, const std::string & fname, OutIter && out,37 const CodeLocation & loc, const std::string & fname, Inserter && out, 37 38 const ast::Type * type, const ast::Type * addCast, LoopDirection forward = LoopForward ); 38 39 … … 41 42 /// optionally returns a statement which must be inserted prior to the containing loop, if 42 43 /// there is one 43 template< typename OutIter >44 44 ast::ptr< ast::Stmt > genScalarCall( 45 45 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 46 const CodeLocation & loc, std::string fname, OutIter && out, const ast::Type * type,46 const CodeLocation & loc, std::string fname, Inserter && out, const ast::Type * type, 47 47 const ast::Type * addCast = nullptr 48 48 ) { … … 97 97 /// Store in out a loop which calls fname on each element of the array with srcParam and 98 98 /// dstParam as arguments. If forward is true, loop goes from 0 to N-1, else N-1 to 0 99 template< typename OutIter >100 99 void genArrayCall( 101 100 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 102 const CodeLocation & loc, const std::string & fname, OutIter && out,101 const CodeLocation & loc, const std::string & fname, Inserter && out, 103 102 const ast::ArrayType * array, const ast::Type * addCast = nullptr, 104 103 LoopDirection forward = LoopForward … … 166 165 } 167 166 168 template< typename OutIter >169 167 ast::ptr< ast::Stmt > genCall( 170 168 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 171 const CodeLocation & loc, const std::string & fname, OutIter && out,169 const CodeLocation & loc, const std::string & fname, Inserter && out, 172 170 const ast::Type * type, const ast::Type * addCast, LoopDirection forward 173 171 ) { 174 172 if ( auto at = dynamic_cast< const ast::ArrayType * >( type ) ) { 175 173 genArrayCall( 176 srcParam, dstParam, loc, fname, std::forward< OutIter >(out), at, addCast,174 srcParam, dstParam, loc, fname, std::forward< Inserter&& >( out ), at, addCast, 177 175 forward ); 178 176 return {}; 179 177 } else { 180 178 return genScalarCall( 181 srcParam, dstParam, loc, fname, std::forward< OutIter>( out ), type, addCast );179 srcParam, dstParam, loc, fname, std::forward< Inserter&& >( out ), type, addCast ); 182 180 } 183 181 } … … 185 183 } // namespace 186 184 187 ast::ptr< ast::Stmt >genImplicitCall(185 const ast::Stmt * genImplicitCall( 188 186 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 189 187 const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj, … … 191 189 ) { 192 190 // unnamed bit fields are not copied as they cannot be accessed 193 if ( isUnnamedBitfield( obj ) ) return {};191 if ( isUnnamedBitfield( obj ) ) return nullptr; 194 192 195 193 ast::ptr< ast::Type > addCast; … … 199 197 } 200 198 201 std:: vector< ast::ptr< ast::Stmt > > stmts;199 std::list< ast::ptr< ast::Stmt > > stmts; 202 200 genCall( 203 201 srcParam, dstParam, loc, fname, back_inserter( stmts ), obj->type, addCast, forward ); 204 202 205 if ( stmts.empty() ) { 206 return {}; 207 } else if ( stmts.size() == 1 ) { 208 const ast::Stmt * callStmt = stmts.front(); 209 if ( addCast ) { 210 // implicitly generated ctor/dtor calls should be wrapped so that later passes are 211 // aware they were generated. 212 callStmt = new ast::ImplicitCtorDtorStmt( callStmt->location, callStmt ); 213 } 214 return callStmt; 215 } else { 216 assert( false ); 217 return {}; 218 } 203 if ( stmts.empty() ) return nullptr; 204 assert( stmts.size() == 1 ); 205 206 const ast::Stmt * callStmt = stmts.front().release(); 207 // Implicitly generated ctor/dtor calls should be wrapped so that 208 // later passes are aware they were generated. 209 if ( addCast ) { 210 callStmt = new ast::ImplicitCtorDtorStmt( callStmt->location, callStmt ); 211 } 212 return callStmt; 219 213 } 220 214 … … 226 220 // compile-command: "make install" // 227 221 // End: // 228 229 -
src/SymTab/GenImplicitCall.hpp
rd06273c r4e2f1b2 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // GenImplicitCall.hpp -- 7 // GenImplicitCall.hpp -- Generate code for implicit operator calls. 8 8 // 9 9 // Author : Andrew Beach … … 25 25 /// Returns a generated call expression to function fname with srcParam and 26 26 /// dstParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. 27 ast::ptr<ast::Stmt>genImplicitCall(27 const ast::Stmt * genImplicitCall( 28 28 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 29 29 const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj,
Note: See TracChangeset
for help on using the changeset viewer.