Ignore:
Timestamp:
Oct 4, 2019, 9:59:01 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
65e10b2
Parents:
970141d (diff), 73fad25 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r970141d r19858f6  
    1919#include <iostream>                  // for ostream, operator<<, basic_ostream
    2020#include <list>                      // for list, _List_iterator, list<>::co...
     21#include <set>                       // for set
    2122
    2223#include "Common/utility.h"          // for maybeClone, cloneAll, deleteAll
     
    6465
    6566bool Expression::get_lvalue() const {
    66         assert( !result->get_lvalue() );
    6767        return false;
    6868}
     
    115115        assert( var->get_type() );
    116116        Type * type = var->get_type()->clone();
    117         type->set_lvalue( true );
    118117
    119118        // xxx - doesn't quite work yet - get different alternatives with the same cost
     
    125124        //      long long int value;
    126125        //      if ( decl->valueOf( var, value ) ) {
    127         //              type->set_lvalue( false );
     126        //              type->set_lvalue( false ); // Would have to move to get_lvalue.
    128127        //      }
    129128        // }
     
    140139
    141140bool VariableExpr::get_lvalue() const {
    142         return result->get_lvalue();
     141        // It isn't always an lvalue, but it is never an rvalue.
     142        return true;
    143143}
    144144
     
    277277
    278278bool CastExpr::get_lvalue() const {
    279         return result->get_lvalue();
     279        // This is actually wrong by C, but it works with our current set-up.
     280        return arg->get_lvalue();
    280281}
    281282
     
    360361}
    361362
     363bool UntypedMemberExpr::get_lvalue() const {
     364        return aggregate->get_lvalue();
     365}
     366
    362367void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const {
    363368        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    378383        sub.apply( res );
    379384        result = res;
    380         result->set_lvalue( true );
    381385        result->get_qualifiers() |= aggregate->result->get_qualifiers();
    382386}
     
    392396
    393397bool MemberExpr::get_lvalue() const {
    394         assert( result->get_lvalue() );
     398        // This is actually wrong by C, but it works with our current set-up.
    395399        return true;
    396400}
     
    427431                        // if references are still allowed in the AST, dereference returns a reference
    428432                        ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) );
    429                 } else {
    430                         // references have been removed, in which case dereference returns an lvalue of the base type.
    431                         ret->result->set_lvalue( true );
    432433                }
    433434        }
     
    447448
    448449bool UntypedExpr::get_lvalue() const {
    449         return result->get_lvalue();
     450        // from src/GenPoly/Lvalue.cc: isIntrinsicReference
     451        static std::set<std::string> lvalueFunctions = { "*?", "?[?]" };
     452        std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) );
     453        return lvalueFunctions.count(fname);
    450454}
    451455
     
    510514
    511515bool ConditionalExpr::get_lvalue() const {
    512         return result->get_lvalue();
     516        return false;
    513517}
    514518
     
    570574
    571575bool ConstructorExpr::get_lvalue() const {
    572         return result->get_lvalue();
     576        return false;
    573577}
    574578
     
    582586CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
    583587        assert( type && initializer );
    584         type->set_lvalue( true );
    585588        set_result( type );
    586589}
     
    593596
    594597bool CompoundLiteralExpr::get_lvalue() const {
    595         assert( result->get_lvalue() );
    596598        return true;
    597599}
     
    648650}
    649651bool StmtExpr::get_lvalue() const {
    650         return result->get_lvalue();
     652        return false;
    651653}
    652654void StmtExpr::print( std::ostream & os, Indenter indent ) const {
Note: See TracChangeset for help on using the changeset viewer.