Changeset 39f84a4 for src/SymTab
- Timestamp:
- Jul 29, 2016, 11:40:28 AM (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:
- 4d2434a
- Parents:
- 29e8bf5
- Location:
- src/SymTab
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r29e8bf5 r39f84a4 189 189 } 190 190 191 InitTweak::InitExpander srcParam( src ); 192 191 193 // assign to destination (and return value if generic) 192 194 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) ); 193 195 derefExpr->get_args().push_back( new VariableExpr( dstParam ) ); 194 196 Expression *dstselect = new MemberExpr( field, derefExpr ); 195 genImplicitCall( src , dstselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward );197 genImplicitCall( srcParam, dstselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward ); 196 198 197 199 if ( isGeneric && returnVal ) { … … 199 201 derefRet->get_args().push_back( new VariableExpr( returnVal ) ); 200 202 Expression *retselect = new MemberExpr( field, derefRet ); 201 genImplicitCall( src , retselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward );203 genImplicitCall( srcParam, retselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward ); 202 204 } // if 203 205 } -
src/SymTab/Autogen.h
r29e8bf5 r39f84a4 22 22 #include "SynTree/Declaration.h" 23 23 #include "SynTree/Initializer.h" 24 #include "InitTweak/InitTweak.h" 24 25 25 26 namespace SymTab { … … 36 37 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. 37 38 template< typename OutputIterator > 38 void genCall( Expression *srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool forward = true );39 void genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool forward = true ); 39 40 40 41 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types. 41 42 template< typename OutputIterator > 42 void genScalarCall( Expression *srcParam, Expression *dstParam, const std::string & fname, OutputIterator out ) {43 void genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out ) { 43 44 // want to be able to generate assignment, ctor, and dtor generically, 44 45 // so fname is either ?=?, ?{}, or ^?{} … … 48 49 fExpr->get_args().push_back( new AddressExpr( dstParam ) ); 49 50 50 if ( srcParam ) { 51 Statement * listInit = srcParam.buildListInit( fExpr ); 52 if ( listInit ) { 53 *out++ = listInit; 54 } 55 56 std::list< Expression * > args = *++srcParam; 57 fExpr->get_args().splice( fExpr->get_args().end(), args ); 58 /* if ( srcParam ) { 59 // xxx - 60 // make srcParam more complicated 61 // if srcParam contains 51 62 fExpr->get_args().push_back( srcParam ); 52 63 } 53 64 */ 54 65 *out++ = new ExprStmt( noLabels, fExpr ); 55 66 } … … 58 69 /// If forward is true, loop goes from 0 to N-1, else N-1 to 0 59 70 template< typename OutputIterator > 60 void genArrayCall( Expression *srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool forward = true ) {71 void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool forward = true ) { 61 72 static UniqueName indexName( "_index" ); 62 73 … … 100 111 dstParam = dstIndex; 101 112 102 // srcParam is NULL for default ctor/dtor 103 if ( srcParam ) { 104 UntypedExpr *srcIndex = new UntypedExpr( new NameExpr( "?[?]" ) ); 105 srcIndex->get_args().push_back( srcParam ); 106 srcIndex->get_args().push_back( new VariableExpr( index ) ); 107 srcParam = srcIndex; 108 } 113 // srcParam must keep track of the array indices to build the 114 // source parameter and/or array list initializer 115 srcParam.addArrayIndex( new VariableExpr( index ), array->get_dimension()->clone() ); 116 117 // if ( srcParam ) { 118 // UntypedExpr *srcIndex = new UntypedExpr( new NameExpr( "?[?]" ) ); 119 // srcIndex->get_args().push_back( srcParam ); 120 // srcIndex->get_args().push_back( new VariableExpr( index ) ); 121 // srcParam = srcIndex; 122 // } 109 123 110 124 // for stmt's body, eventually containing call … … 122 136 123 137 template< typename OutputIterator > 124 void genCall( Expression *srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool forward ) {138 void genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool forward ) { 125 139 if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) { 126 140 genArrayCall( srcParam, dstParam, fname, out, at, forward ); … … 135 149 /// ImplicitCtorDtorStmt node. 136 150 template< typename OutputIterator > 137 void genImplicitCall( Expression *srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, DeclarationWithType * decl, bool forward = true ) {151 void genImplicitCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, DeclarationWithType * decl, bool forward = true ) { 138 152 ObjectDecl *obj = dynamic_cast<ObjectDecl *>( decl ); 139 153 assert( obj );
Note: See TracChangeset
for help on using the changeset viewer.