Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r849720f re67991f  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug 15 13:43:00 2019
    13 // Update Count     : 64
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Feb 19 18:10:55 2019
     13// Update Count     : 60
    1414//
    1515
     
    1919#include <iostream>                  // for ostream, operator<<, basic_ostream
    2020#include <list>                      // for list, _List_iterator, list<>::co...
    21 #include <set>                       // for set
    2221
    2322#include "Common/utility.h"          // for maybeClone, cloneAll, deleteAll
     
    6463}
    6564
    66 bool Expression::get_lvalue() const {
    67         return false;
    68 }
    69 
    7065void Expression::print( std::ostream & os, Indenter indent ) const {
    7166        printInferParams( inferParams, os, indent+1, 0 );
     
    139134}
    140135
    141 bool VariableExpr::get_lvalue() const {
    142         // It isn't always an lvalue, but it is never an rvalue.
    143         return true;
    144 }
    145 
    146136VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
    147137        VariableExpr * funcExpr = new VariableExpr( func );
     
    262252}
    263253
     254AttrExpr::AttrExpr( Expression * attr, Expression * expr_ ) :
     255                Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
     256}
     257
     258AttrExpr::AttrExpr( Expression * attr, Type * type_ ) :
     259                Expression(), attr( attr ), expr(0), type(type_), isType(true) {
     260}
     261
     262AttrExpr::AttrExpr( const AttrExpr & other ) :
     263                Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
     264}
     265
     266AttrExpr::~AttrExpr() {
     267        delete attr;
     268        delete expr;
     269        delete type;
     270}
     271
     272void AttrExpr::print( std::ostream & os, Indenter indent) const {
     273        os << "Attr ";
     274        attr->print( os, indent+1);
     275        if ( isType || expr ) {
     276                os << "applied to: ";
     277                if (isType) type->print(os, indent+1);
     278                else expr->print(os, indent+1);
     279        } // if
     280        Expression::print( os, indent );
     281}
     282
    264283CastExpr::CastExpr( Expression * arg, Type * toType, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) {
    265284        set_result(toType);
     
    275294CastExpr::~CastExpr() {
    276295        delete arg;
    277 }
    278 
    279 bool CastExpr::get_lvalue() const {
    280         // This is actually wrong by C, but it works with our current set-up.
    281         return arg->get_lvalue();
    282296}
    283297
     
    362376}
    363377
    364 bool UntypedMemberExpr::get_lvalue() const {
    365         return aggregate->get_lvalue();
    366 }
    367 
    368378void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const {
    369379        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    395405        // don't delete the member declaration, since it points somewhere else in the tree
    396406        delete aggregate;
    397 }
    398 
    399 bool MemberExpr::get_lvalue() const {
    400         // This is actually wrong by C, but it works with our current set-up.
    401         return true;
    402407}
    403408
     
    452457}
    453458
    454 bool UntypedExpr::get_lvalue() const {
    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);
    459 }
    460459
    461460void UntypedExpr::print( std::ostream & os, Indenter indent ) const {
     
    516515        delete arg2;
    517516        delete arg3;
    518 }
    519 
    520 bool ConditionalExpr::get_lvalue() const {
    521         return false;
    522517}
    523518
     
    578573}
    579574
    580 bool ConstructorExpr::get_lvalue() const {
    581         return false;
    582 }
    583 
    584575void ConstructorExpr::print( std::ostream & os, Indenter indent ) const {
    585576        os <<  "Constructor Expression: " << std::endl << indent+1;
     
    599590CompoundLiteralExpr::~CompoundLiteralExpr() {
    600591        delete initializer;
    601 }
    602 
    603 bool CompoundLiteralExpr::get_lvalue() const {
    604         return true;
    605592}
    606593
     
    654641                result = new VoidType( Type::Qualifiers() );
    655642        }
    656 }
    657 bool StmtExpr::get_lvalue() const {
    658         return false;
    659643}
    660644void StmtExpr::print( std::ostream & os, Indenter indent ) const {
Note: See TracChangeset for help on using the changeset viewer.