Ignore:
Timestamp:
Sep 27, 2019, 3:35:46 PM (6 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
90ce35aa
Parents:
8e1467d (diff), 849720f (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:

Merged from master taking the lvalue changes to expression and everything before that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r8e1467d r4a60488  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb 19 18:10:55 2019
    13 // Update Count     : 60
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Aug 15 13:43:00 2019
     13// Update Count     : 64
    1414//
    1515
     
    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
     
    6364}
    6465
     66bool Expression::get_lvalue() const {
     67        return false;
     68}
     69
    6570void Expression::print( std::ostream & os, Indenter indent ) const {
    6671        printInferParams( inferParams, os, indent+1, 0 );
     
    134139}
    135140
     141bool VariableExpr::get_lvalue() const {
     142        // It isn't always an lvalue, but it is never an rvalue.
     143        return true;
     144}
     145
    136146VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
    137147        VariableExpr * funcExpr = new VariableExpr( func );
     
    252262}
    253263
    254 AttrExpr::AttrExpr( Expression * attr, Expression * expr_ ) :
    255                 Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
    256 }
    257 
    258 AttrExpr::AttrExpr( Expression * attr, Type * type_ ) :
    259                 Expression(), attr( attr ), expr(0), type(type_), isType(true) {
    260 }
    261 
    262 AttrExpr::AttrExpr( const AttrExpr & other ) :
    263                 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    264 }
    265 
    266 AttrExpr::~AttrExpr() {
    267         delete attr;
    268         delete expr;
    269         delete type;
    270 }
    271 
    272 void 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 
    283264CastExpr::CastExpr( Expression * arg, Type * toType, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) {
    284265        set_result(toType);
     
    294275CastExpr::~CastExpr() {
    295276        delete arg;
     277}
     278
     279bool CastExpr::get_lvalue() const {
     280        // This is actually wrong by C, but it works with our current set-up.
     281        return arg->get_lvalue();
    296282}
    297283
     
    376362}
    377363
     364bool UntypedMemberExpr::get_lvalue() const {
     365        return aggregate->get_lvalue();
     366}
     367
    378368void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const {
    379369        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    405395        // don't delete the member declaration, since it points somewhere else in the tree
    406396        delete aggregate;
     397}
     398
     399bool MemberExpr::get_lvalue() const {
     400        // This is actually wrong by C, but it works with our current set-up.
     401        return true;
    407402}
    408403
     
    457452}
    458453
     454bool 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}
    459460
    460461void UntypedExpr::print( std::ostream & os, Indenter indent ) const {
     
    515516        delete arg2;
    516517        delete arg3;
     518}
     519
     520bool ConditionalExpr::get_lvalue() const {
     521        return false;
    517522}
    518523
     
    573578}
    574579
     580bool ConstructorExpr::get_lvalue() const {
     581        return false;
     582}
     583
    575584void ConstructorExpr::print( std::ostream & os, Indenter indent ) const {
    576585        os <<  "Constructor Expression: " << std::endl << indent+1;
     
    590599CompoundLiteralExpr::~CompoundLiteralExpr() {
    591600        delete initializer;
     601}
     602
     603bool CompoundLiteralExpr::get_lvalue() const {
     604        return true;
    592605}
    593606
     
    641654                result = new VoidType( Type::Qualifiers() );
    642655        }
     656}
     657bool StmtExpr::get_lvalue() const {
     658        return false;
    643659}
    644660void StmtExpr::print( std::ostream & os, Indenter indent ) const {
Note: See TracChangeset for help on using the changeset viewer.