Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Lvalue.cc

    rce8c12f r8ca3a72  
    3232#include "Common/UniqueName.h"
    3333#include "Common/utility.h"
    34 #include "InitTweak/InitTweak.h"
    3534
    3635namespace GenPoly {
    3736        namespace {
    38                 const std::list<Label> noLabels;
    39 
    4037                /// Replace uses of lvalue returns with appropriate pointers
    4138                class Pass1 : public Mutator {
    4239                  public:
    43                         typedef Mutator Parent;
    4440                        Pass1();
    4541
    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 );
    4942                        virtual Expression *mutate( ApplicationExpr *appExpr );
    5043                        virtual Statement *mutate( ReturnStmt *appExpr );
     
    112105                }
    113106
    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 
    129107                Expression * Pass1::mutate( ApplicationExpr *appExpr ) {
    130108                        appExpr->get_function()->acceptMutator( *this );
     
    185163                }
    186164
    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 
    197165                Expression * GeneralizedLvalue::mutate( AddressExpr * addrExpr ) {
    198166                        addrExpr = safe_dynamic_cast< AddressExpr * >( Parent::mutate( addrExpr ) );
     
    208176                                delete addrExpr;
    209177                                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;
    217178                        }
    218179                        return addrExpr;
Note: See TracChangeset for help on using the changeset viewer.