Changeset f9cebb5 for src/SymTab
- Timestamp:
- Aug 4, 2016, 4:10:06 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 4819cac
- Parents:
- 73bf8cf2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.h
r73bf8cf2 rf9cebb5 37 37 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. 38 38 template< typename OutputIterator > 39 voidgenCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true );39 Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true ); 40 40 41 41 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types. 42 /// optionally returns a statement which must be inserted prior to the containing loop, if there is one 42 43 template< typename OutputIterator > 43 voidgenScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) {44 Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) { 44 45 // want to be able to generate assignment, ctor, and dtor generically, 45 46 // so fname is either ?=?, ?{}, or ^?{} … … 63 64 fExpr->get_args().push_back( dstParam ); 64 65 65 Statement * listInit = srcParam.buildListInit( fExpr ); 66 if ( listInit ) { 67 *out++ = listInit; 68 } 66 Statement * listInit = srcParam.buildListInit( fExpr ); 69 67 70 71 68 std::list< Expression * > args = *++srcParam; 69 fExpr->get_args().splice( fExpr->get_args().end(), args ); 72 70 73 71 *out++ = new ExprStmt( noLabels, fExpr ); 74 72 75 srcParam.clearArrayIndices(); 73 srcParam.clearArrayIndices(); 74 75 return listInit; 76 76 } 77 77 … … 125 125 srcParam.addArrayIndex( new VariableExpr( index ), array->get_dimension()->clone() ); 126 126 127 // if ( srcParam ) {128 // UntypedExpr *srcIndex = new UntypedExpr( new NameExpr( "?[?]" ) );129 // srcIndex->get_args().push_back( srcParam );130 // srcIndex->get_args().push_back( new VariableExpr( index ) );131 // srcParam = srcIndex;132 // }133 134 127 // for stmt's body, eventually containing call 135 128 CompoundStmt * body = new CompoundStmt( noLabels ); 136 genCall( srcParam, dstParam, fname, back_inserter( body->get_kids() ), array->get_base(), addCast, forward );129 Statement * listInit = genCall( srcParam, dstParam, fname, back_inserter( body->get_kids() ), array->get_base(), addCast, forward ); 137 130 138 131 // block containing for stmt and index variable … … 140 133 CompoundStmt * block = new CompoundStmt( noLabels ); 141 134 block->get_kids().push_back( new DeclStmt( noLabels, index ) ); 135 if ( listInit ) block->get_kids().push_back( listInit ); 142 136 block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, body ) ); 143 137 … … 146 140 147 141 template< typename OutputIterator > 148 voidgenCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) {142 Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) { 149 143 if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) { 150 144 genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward ); 145 return 0; 151 146 } else { 152 genScalarCall( srcParam, dstParam, fname, out, type, addCast );147 return genScalarCall( srcParam, dstParam, fname, out, type, addCast ); 153 148 } 154 149 } … … 171 166 // currently genCall should produce at most one element, but if that changes then the next line needs to be updated to grab the statement which contains the call 172 167 assert( stmts.size() <= 1 ); 173 174 175 176 177 178 179 180 181 182 183 168 if ( stmts.size() == 1 ) { 169 Statement * callStmt = stmts.front(); 170 if ( addCast ) { 171 // implicitly generated ctor/dtor calls should be wrapped 172 // so that later passes are aware they were generated. 173 // xxx - don't mark as an implicit ctor/dtor if obj is a bitfield, 174 // because this causes the address to be taken at codegen, which is illegal in C. 175 callStmt = new ImplicitCtorDtorStmt( callStmt ); 176 } 177 *out++ = callStmt; 178 } 184 179 } 185 180 } // namespace SymTab
Note: See TracChangeset
for help on using the changeset viewer.