Ignore:
Timestamp:
Sep 23, 2019, 4:59:33 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4a60488, b4f8808
Parents:
abec2f8
Message:

lvalue should now always come directly from the expression.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rabec2f8 r849720f  
    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}
     
    140140
    141141bool VariableExpr::get_lvalue() const {
    142         return result->get_lvalue();
     142        // It isn't always an lvalue, but it is never an rvalue.
     143        return true;
    143144}
    144145
     
    277278
    278279bool CastExpr::get_lvalue() const {
    279         return result->get_lvalue();
     280        // This is actually wrong by C, but it works with our current set-up.
     281        return arg->get_lvalue();
    280282}
    281283
     
    360362}
    361363
     364bool UntypedMemberExpr::get_lvalue() const {
     365        return aggregate->get_lvalue();
     366}
     367
    362368void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const {
    363369        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    392398
    393399bool MemberExpr::get_lvalue() const {
    394         assert( result->get_lvalue() );
     400        // This is actually wrong by C, but it works with our current set-up.
    395401        return true;
    396402}
     
    447453
    448454bool UntypedExpr::get_lvalue() const {
    449         return result->get_lvalue();
     455        // from src/GenPoly/Lvalue.cc: isIntrinsicReference
     456        static std::set<std::string> lvalueFunctions = { "*?", "?[?]" };
     457        std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) );
     458        return lvalueFunctions.count(fname);
    450459}
    451460
     
    510519
    511520bool ConditionalExpr::get_lvalue() const {
    512         return result->get_lvalue();
     521        return false;
    513522}
    514523
     
    570579
    571580bool ConstructorExpr::get_lvalue() const {
    572         return result->get_lvalue();
     581        return false;
    573582}
    574583
     
    593602
    594603bool CompoundLiteralExpr::get_lvalue() const {
    595         assert( result->get_lvalue() );
    596604        return true;
    597605}
     
    648656}
    649657bool StmtExpr::get_lvalue() const {
    650         return result->get_lvalue();
     658        return false;
    651659}
    652660void StmtExpr::print( std::ostream & os, Indenter indent ) const {
Note: See TracChangeset for help on using the changeset viewer.