Changeset b6fd751 for src/GenPoly/Lvalue.cc
- Timestamp:
- Nov 8, 2016, 4:09:58 PM (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:
- a29be37
- Parents:
- 066d77a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Lvalue.cc
r066d77a rb6fd751 55 55 private: 56 56 }; 57 58 /// GCC-like Generalized Lvalues (which have since been removed from GCC) 59 /// https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Lvalues.html#Lvalues 60 /// Replaces &(a,b) with (a, &b), &(a ? b : c) with (a ? &b : &c) 61 class GeneralizedLvalue : public Mutator { 62 typedef Mutator Parent; 63 64 virtual Expression * mutate( AddressExpr * addressExpr ); 65 }; 57 66 } // namespace 58 67 … … 60 69 Pass1 p1; 61 70 Pass2 p2; 71 GeneralizedLvalue genLval; 62 72 mutateAll( translationUnit, p1 ); 63 73 acceptAll( translationUnit, p2 ); 74 mutateAll( translationUnit, genLval ); 64 75 } 65 76 … … 153 164 Visitor::visit( funType ); 154 165 } 166 167 Expression * GeneralizedLvalue::mutate( AddressExpr * addrExpr ) { 168 addrExpr = safe_dynamic_cast< AddressExpr * >( Parent::mutate( addrExpr ) ); 169 if ( CommaExpr * commaExpr = dynamic_cast< CommaExpr * >( addrExpr->get_arg() ) ) { 170 Expression * arg1 = commaExpr->get_arg1()->clone(); 171 Expression * arg2 = commaExpr->get_arg2()->clone(); 172 delete addrExpr; 173 return new CommaExpr( arg1, new AddressExpr( arg2 ) ); 174 } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( addrExpr->get_arg() ) ) { 175 Expression * arg1 = condExpr->get_arg1()->clone(); 176 Expression * arg2 = condExpr->get_arg2()->clone(); 177 Expression * arg3 = condExpr->get_arg3()->clone(); 178 delete addrExpr; 179 return new ConditionalExpr( arg1, new AddressExpr( arg2 ), new AddressExpr( arg3 ) ); 180 } 181 return addrExpr; 182 } 155 183 } // namespace 156 184 } // namespace GenPoly
Note: See TracChangeset
for help on using the changeset viewer.