Ignore:
Timestamp:
Feb 25, 2020, 1:17:33 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
7dc2e015
Parents:
9fb8f01 (diff), dd9e1ca (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:

resolve conflict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r9fb8f01 r3d5701e  
    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 : Wed Dec 11 07:55:15 2019
     13// Update Count     : 70
    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
    23 #include "Declaration.h"             // for ObjectDecl, DeclarationWithType
    2424#include "Expression.h"              // for Expression, ImplicitCopyCtorExpr
    2525#include "InitTweak/InitTweak.h"     // for getCallArg, getPointerBase
     
    6464
    6565bool Expression::get_lvalue() const {
    66         assert( !result->get_lvalue() );
    6766        return false;
    6867}
     
    115114        assert( var->get_type() );
    116115        Type * type = var->get_type()->clone();
    117         type->set_lvalue( true );
    118116
    119117        // xxx - doesn't quite work yet - get different alternatives with the same cost
     
    125123        //      long long int value;
    126124        //      if ( decl->valueOf( var, value ) ) {
    127         //              type->set_lvalue( false );
     125        //              type->set_lvalue( false ); // Would have to move to get_lvalue.
    128126        //      }
    129127        // }
     
    140138
    141139bool VariableExpr::get_lvalue() const {
    142         return result->get_lvalue();
     140        // It isn't always an lvalue, but it is never an rvalue.
     141        return true;
    143142}
    144143
     
    277276
    278277bool CastExpr::get_lvalue() const {
    279         return result->get_lvalue();
     278        // This is actually wrong by C, but it works with our current set-up.
     279        return arg->get_lvalue();
    280280}
    281281
     
    293293}
    294294
    295 KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) {
     295KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ) : Expression(), arg(arg), target( target ) {
    296296}
    297297
     
    303303}
    304304
    305 const std::string & KeywordCastExpr::targetString() const {
    306         static const std::string targetStrs[] = {
    307                 "coroutine", "thread", "monitor"
    308         };
    309         static_assert(
    310                 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS),
    311                 "Each KeywordCastExpr::Target should have a corresponding string representation"
    312         );
    313         return targetStrs[(unsigned long)target];
     305const char * KeywordCastExpr::targetString() const {
     306        return AggregateDecl::aggrString( target );
    314307}
    315308
     
    360353}
    361354
     355bool UntypedMemberExpr::get_lvalue() const {
     356        return aggregate->get_lvalue();
     357}
     358
    362359void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const {
    363360        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    378375        sub.apply( res );
    379376        result = res;
    380         result->set_lvalue( true );
    381377        result->get_qualifiers() |= aggregate->result->get_qualifiers();
    382378}
     
    392388
    393389bool MemberExpr::get_lvalue() const {
    394         assert( result->get_lvalue() );
     390        // This is actually wrong by C, but it works with our current set-up.
    395391        return true;
    396392}
     
    427423                        // if references are still allowed in the AST, dereference returns a reference
    428424                        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 );
    432425                }
    433426        }
     
    447440
    448441bool UntypedExpr::get_lvalue() const {
    449         return result->get_lvalue();
     442        // from src/GenPoly/Lvalue.cc: isIntrinsicReference
     443        static std::set<std::string> lvalueFunctions = { "*?", "?[?]" };
     444        std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) );
     445        return lvalueFunctions.count(fname);
    450446}
    451447
     
    510506
    511507bool ConditionalExpr::get_lvalue() const {
    512         return result->get_lvalue();
     508        return false;
    513509}
    514510
     
    523519}
    524520
    525 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
     521AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( other.inout ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
    526522
    527523
    528524void AsmExpr::print( std::ostream & os, Indenter indent ) const {
    529525        os << "Asm Expression: " << std::endl;
    530         if ( inout ) inout->print( os, indent+1 );
     526        if ( !inout.empty() ) os <<  "[" << inout << "] ";
    531527        if ( constraint ) constraint->print( os, indent+1 );
    532528        if ( operand ) operand->print( os, indent+1 );
     
    570566
    571567bool ConstructorExpr::get_lvalue() const {
    572         return result->get_lvalue();
     568        return false;
    573569}
    574570
     
    582578CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
    583579        assert( type && initializer );
    584         type->set_lvalue( true );
    585580        set_result( type );
    586581}
     
    593588
    594589bool CompoundLiteralExpr::get_lvalue() const {
    595         assert( result->get_lvalue() );
    596590        return true;
    597591}
     
    648642}
    649643bool StmtExpr::get_lvalue() const {
    650         return result->get_lvalue();
     644        return false;
    651645}
    652646void StmtExpr::print( std::ostream & os, Indenter indent ) const {
Note: See TracChangeset for help on using the changeset viewer.