Changeset ce8c12f for src/GenPoly
- Timestamp:
- May 15, 2017, 11:30:26 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- d36c117
- Parents:
- 65aca88
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Lvalue.cc
r65aca88 rce8c12f 32 32 #include "Common/UniqueName.h" 33 33 #include "Common/utility.h" 34 #include "InitTweak/InitTweak.h" 34 35 35 36 namespace GenPoly { … … 40 41 class Pass1 : public Mutator { 41 42 public: 43 typedef Mutator Parent; 42 44 Pass1(); 43 45 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 ); 44 49 virtual Expression *mutate( ApplicationExpr *appExpr ); 45 50 virtual Statement *mutate( ReturnStmt *appExpr ); … … 105 110 } // if 106 111 return funcDecl; 112 } 113 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 ); 107 127 } 108 128 … … 165 185 } 166 186 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 167 197 Expression * GeneralizedLvalue::mutate( AddressExpr * addrExpr ) { 168 198 addrExpr = safe_dynamic_cast< AddressExpr * >( Parent::mutate( addrExpr ) ); … … 178 208 delete addrExpr; 179 209 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 else 212 Expression *& arg = InitTweak::getCallArg( addrExpr->get_arg(), 0 ); 213 Expression * inner = arg; 214 arg = nullptr; 215 delete addrExpr; 216 return inner; 180 217 } 181 218 return addrExpr;
Note: See TracChangeset
for help on using the changeset viewer.