Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.hpp

    re67991f rcf32116  
    99// Author           : Aaron B. Moss
    1010// Created On       : Fri May 10 10:30:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Created On       : Fri May 10 10:30:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Andrew Beach
     12// Created On       : Thr Sep 26 12:51:00 2019
     13// Update Count     : 2
    1414//
    1515
     
    3030
    3131// Must be included in *all* AST classes; should be #undef'd at the end of the file
    32 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
     32#define MUTATE_FRIEND \
     33    template<typename node_t> friend node_t * mutate(const node_t * node); \
     34        template<typename node_t> friend node_t * shallowCopy(const node_t * node);
     35
    3336
    3437class ConverterOldToNew;
     
    184187
    185188        Expr * set_extension( bool ex ) { extension = ex; return this; }
     189        virtual bool get_lvalue() const;
    186190
    187191        virtual const Expr * accept( Visitor & v ) const override = 0;
     
    200204        ApplicationExpr( const CodeLocation & loc, const Expr * f, std::vector<ptr<Expr>> && as = {} );
    201205
     206        bool get_lvalue() const final;
     207
    202208        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
    203209private:
     
    214220        UntypedExpr( const CodeLocation & loc, const Expr * f, std::vector<ptr<Expr>> && as = {} )
    215221        : Expr( loc ), func( f ), args( std::move(as) ) {}
     222
     223        bool get_lvalue() const final;
    216224
    217225        /// Creates a new dereference expression
     
    290298        CastExpr( const Expr * a ) : CastExpr( a->location, a, GeneratedCast ) {}
    291299
     300        bool get_lvalue() const final;
     301
    292302        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
    293303private:
     
    337347        : Expr( loc ), member( mem ), aggregate( agg ) { assert( aggregate ); }
    338348
     349        bool get_lvalue() const final;
     350
    339351        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
    340352private:
     
    351363        MemberExpr( const CodeLocation & loc, const DeclWithType * mem, const Expr * agg );
    352364
     365        bool get_lvalue() const final;
     366
    353367        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
    354368private:
    355369        MemberExpr * clone() const override { return new MemberExpr{ *this }; }
    356370        MUTATE_FRIEND
     371
     372        // Custructor overload meant only for AST conversion
     373        enum NoOpConstruction { NoOpConstructionChosen };
     374        MemberExpr( const CodeLocation & loc, const DeclWithType * mem, const Expr * agg,
     375            NoOpConstruction overloadSelector );
     376        friend class ::ConverterOldToNew;
     377        friend class ::ConverterNewToOld;
    357378};
    358379
     
    364385        VariableExpr( const CodeLocation & loc );
    365386        VariableExpr( const CodeLocation & loc, const DeclWithType * v );
     387
     388        bool get_lvalue() const final;
    366389
    367390        /// generates a function pointer for a given function
     
    531554
    532555        CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 )
    533         : Expr( loc ), arg1( a1 ), arg2( a2 ) {}
     556        : Expr( loc ), arg1( a1 ), arg2( a2 ) {
     557                this->result = a2->result;
     558        }
     559
     560        bool get_lvalue() const final;
    534561
    535562        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
     
    604631        CompoundLiteralExpr( const CodeLocation & loc, const Type * t, const Init * i );
    605632
     633        bool get_lvalue() const final;
     634
    606635        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
    607636private:
     
    659688
    660689        TupleIndexExpr( const CodeLocation & loc, const Expr * t, unsigned i );
     690
     691        bool get_lvalue() const final;
    661692
    662693        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
Note: See TracChangeset for help on using the changeset viewer.