Changes in src/GenPoly/Lvalue.cc [ce8c12f:8ca3a72]
- File:
-
- 1 edited
-
src/GenPoly/Lvalue.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Lvalue.cc
rce8c12f r8ca3a72 32 32 #include "Common/UniqueName.h" 33 33 #include "Common/utility.h" 34 #include "InitTweak/InitTweak.h"35 34 36 35 namespace GenPoly { 37 36 namespace { 38 const std::list<Label> noLabels;39 40 37 /// Replace uses of lvalue returns with appropriate pointers 41 38 class Pass1 : public Mutator { 42 39 public: 43 typedef Mutator Parent;44 40 Pass1(); 45 41 46 // xxx - should this happen to every expression with reference result type? probably just appexpr and varexpr?47 virtual Type *mutate( ReferenceType * refType );48 virtual Expression *mutate( VariableExpr *varExpr );49 42 virtual Expression *mutate( ApplicationExpr *appExpr ); 50 43 virtual Statement *mutate( ReturnStmt *appExpr ); … … 112 105 } 113 106 114 Type * Pass1::mutate( ReferenceType * refType ) {115 Type * base = refType->get_base();116 refType->set_base( nullptr );117 delete refType;118 return new PointerType( Type::Qualifiers(), base );119 }120 121 Expression * Pass1::mutate( VariableExpr *varExpr ) {122 if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( varExpr->get_result() ) ) {123 varExpr->set_result( refType->acceptMutator( *this ) );124 return UntypedExpr::createDeref( varExpr );125 }126 return Parent::mutate( varExpr );127 }128 129 107 Expression * Pass1::mutate( ApplicationExpr *appExpr ) { 130 108 appExpr->get_function()->acceptMutator( *this ); … … 185 163 } 186 164 187 bool isDeref( Expression * expr ) {188 if ( UntypedExpr * untyped = dynamic_cast< UntypedExpr * >( expr ) ) {189 return InitTweak::getFunctionName( untyped ) == "*?";190 } else if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * > ( expr ) ) {191 return InitTweak::getFunctionName( appExpr ) == "*?";192 } else {193 return false;194 }195 }196 197 165 Expression * GeneralizedLvalue::mutate( AddressExpr * addrExpr ) { 198 166 addrExpr = safe_dynamic_cast< AddressExpr * >( Parent::mutate( addrExpr ) ); … … 208 176 delete addrExpr; 209 177 return new ConditionalExpr( arg1, new AddressExpr( arg2 ), new AddressExpr( arg3 ) ); 210 } else if ( isDeref( addrExpr->get_arg() ) ) {211 // xxx - this doesn't belong here -- move it somewhere else212 Expression *& arg = InitTweak::getCallArg( addrExpr->get_arg(), 0 );213 Expression * inner = arg;214 arg = nullptr;215 delete addrExpr;216 return inner;217 178 } 218 179 return addrExpr;
Note:
See TracChangeset
for help on using the changeset viewer.