Changeset 849720f for src


Ignore:
Timestamp:
Sep 23, 2019, 4:59:33 PM (5 years ago)
Author:
Andrew Beach <ajbeach@…>
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:
4a60488, b4f8808
Parents:
abec2f8
Message:

lvalue should now always come directly from the expression.

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    rabec2f8 r849720f  
    157157                        if ( typesCompatibleIgnoreQualifiers( src, destAsRef->base, indexer, env ) ) {
    158158                                PRINT( std::cerr << "converting compatible base type" << std::endl; )
    159                                 assert( src->get_lvalue() == srcIsLvalue );
    160159                                if ( srcIsLvalue ) {
    161160                                        PRINT(
  • src/SynTree/ApplicationExpr.cc

    rabec2f8 r849720f  
    2525#include "Declaration.h"         // for Declaration
    2626#include "Expression.h"          // for ParamEntry, ApplicationExpr, Expression
     27#include "InitTweak/InitTweak.h" // for getFunction
    2728#include "ResolvExpr/typeops.h"  // for extractResultType
    2829#include "Type.h"                // for Type, PointerType, FunctionType
     
    7778
    7879bool ApplicationExpr::get_lvalue() const {
    79         return result->get_lvalue();
     80        // from src/GenPoly/Lvalue.cc: isIntrinsicReference
     81        static std::set<std::string> lvalueFunctions = { "*?", "?[?]" };
     82        if ( const DeclarationWithType * func = InitTweak::getFunction( this ) ) {
     83                return func->linkage == LinkageSpec::Intrinsic && lvalueFunctions.count(func->name);
     84        }
     85        return false;
    8086}
    8187
  • src/SynTree/CommaExpr.cc

    rabec2f8 r849720f  
    4040
    4141bool CommaExpr::get_lvalue() const {
    42         // xxx - as above, shouldn't be an lvalue but that information is used anyways.
    43         return result->get_lvalue();
     42        // This is wrong by C, but the current implementation uses it.
     43        return arg2->get_lvalue();
    4444}
    4545
  • 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 {
  • src/SynTree/Expression.h

    rabec2f8 r849720f  
    275275        virtual ~UntypedMemberExpr();
    276276
     277        bool get_lvalue() const final;
     278
    277279        Expression * get_member() const { return member; }
    278280        void set_member( Expression * newValue ) { member = newValue; }
  • src/SynTree/TupleExpr.cc

    rabec2f8 r849720f  
    5858
    5959bool TupleExpr::get_lvalue() const {
    60         return result->get_lvalue();
     60        return false;
    6161}
    6262
     
    8383
    8484bool TupleIndexExpr::get_lvalue() const {
    85         assert( result->get_lvalue() );
    86         return true;
     85        return tuple->get_lvalue();
    8786}
    8887
Note: See TracChangeset for help on using the changeset viewer.