Ignore:
Timestamp:
Aug 9, 2017, 3:21:58 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
0ec9229
Parents:
cbce272
Message:

Syntax Nodes give public access to the fields with effective public access.X

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.h

    rcbce272 r65cdc1e  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:27:00 2017
    13 // Update Count     : 43
     12// Last Modified On : Fri Aug  8 11:54:00 2017
     13// Update Count     : 44
    1414//
    1515
     
    2929class Expression : public BaseSyntaxNode{
    3030  public:
     31        Type * result;
     32        TypeSubstitution * env;
     33        Expression * argName; // if expression is used as an argument, it can be "designated" by this name
     34        bool extension = false;
     35
    3136        Expression( Expression * _aname = nullptr );
    3237        Expression( const Expression & other );
     
    4954        virtual Expression * acceptMutator( Mutator & m ) = 0;
    5055        virtual void print( std::ostream & os, int indent = 0 ) const;
    51   protected:
    52         Type * result;
    53         TypeSubstitution * env;
    54         Expression * argName; // if expression is used as an argument, it can be "designated" by this name
    55         bool extension = false;
    5656};
    5757
     
    7979class ApplicationExpr : public Expression {
    8080  public:
     81        Expression * function;
     82
    8183        ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    8284        ApplicationExpr( const ApplicationExpr & other );
     
    9294        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    9395        virtual void print( std::ostream & os, int indent = 0 ) const;
     96
    9497  private:
    95         Expression * function;
    9698        std::list<Expression *> args;
    9799        InferredParams inferParams;
     
    103105class UntypedExpr : public Expression {
    104106  public:
     107        Expression * function;
     108        std::list<Expression*> args;
     109
    105110        UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >(), Expression *_aname = nullptr );
    106111        UntypedExpr( const UntypedExpr & other );
     
    123128        virtual void print( std::ostream & os, int indent = 0 ) const;
    124129        virtual void printArgs(std::ostream & os, int indent = 0) const;
    125   private:
    126         Expression * function;
    127         std::list<Expression*> args;
    128130};
    129131
     
    131133class NameExpr : public Expression {
    132134  public:
     135        std::string name;
     136
    133137        NameExpr( std::string name, Expression *_aname = nullptr );
    134138        NameExpr( const NameExpr & other );
     
    142146        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    143147        virtual void print( std::ostream & os, int indent = 0 ) const;
    144   private:
    145         std::string name;
    146148};
    147149
     
    152154class AddressExpr : public Expression {
    153155  public:
     156        Expression * arg;
     157
    154158        AddressExpr( Expression * arg, Expression *_aname = nullptr );
    155159        AddressExpr( const AddressExpr & other );
     
    163167        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    164168        virtual void print( std::ostream & os, int indent = 0 ) const;
    165   private:
    166         Expression * arg;
    167169};
    168170
     
    170172class LabelAddressExpr : public Expression {
    171173  public:
     174        Expression * arg;
     175
    172176        LabelAddressExpr( Expression * arg );
    173177        LabelAddressExpr( const LabelAddressExpr & other );
     
    181185        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    182186        virtual void print( std::ostream & os, int indent = 0 ) const;
    183   private:
    184         Expression * arg;
    185187};
    186188
     
    188190class CastExpr : public Expression {
    189191  public:
     192        Expression * arg;
     193
    190194        CastExpr( Expression * arg, Expression *_aname = nullptr );
    191195        CastExpr( Expression * arg, Type * toType, Expression *_aname = nullptr );
     
    200204        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    201205        virtual void print( std::ostream & os, int indent = 0 ) const;
    202   private:
    203         Expression * arg;
    204206};
    205207
     
    207209class VirtualCastExpr : public Expression {
    208210  public:
     211        Expression * arg;
     212
    209213        VirtualCastExpr( Expression * arg, Type * toType );
    210214        VirtualCastExpr( const VirtualCastExpr & other );
     
    218222        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    219223        virtual void print( std::ostream & os, int indent = 0 ) const;
    220   private:
    221         Expression * arg;
    222224};
    223225
     
    225227class UntypedMemberExpr : public Expression {
    226228  public:
     229        Expression * member;
     230        Expression * aggregate;
     231
    227232        UntypedMemberExpr( Expression * member, Expression * aggregate, Expression *_aname = nullptr );
    228233        UntypedMemberExpr( const UntypedMemberExpr & other );
     
    238243        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    239244        virtual void print( std::ostream & os, int indent = 0 ) const;
    240   private:
    241         Expression * member;
    242         Expression * aggregate;
    243245};
    244246
     
    247249class MemberExpr : public Expression {
    248250  public:
     251        DeclarationWithType * member;
     252        Expression * aggregate;
     253
    249254        MemberExpr( DeclarationWithType * member, Expression * aggregate, Expression *_aname = nullptr );
    250255        MemberExpr( const MemberExpr & other );
     
    260265        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    261266        virtual void print( std::ostream & os, int indent = 0 ) const;
    262   private:
    263         DeclarationWithType * member;
    264         Expression * aggregate;
    265267};
    266268
     
    269271class VariableExpr : public Expression {
    270272  public:
     273        DeclarationWithType * var;
     274
    271275        VariableExpr( DeclarationWithType * var, Expression *_aname = nullptr );
    272276        VariableExpr( const VariableExpr & other );
     
    280284        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    281285        virtual void print( std::ostream & os, int indent = 0 ) const;
    282   private:
    283         DeclarationWithType * var;
    284286};
    285287
     
    287289class ConstantExpr : public Expression {
    288290  public:
     291        Constant constant;
     292
    289293        ConstantExpr( Constant constant, Expression *_aname = nullptr );
    290294        ConstantExpr( const ConstantExpr & other );
     
    298302        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    299303        virtual void print( std::ostream & os, int indent = 0 ) const;
    300   private:
    301         Constant constant;
    302304};
    303305
     
    305307class SizeofExpr : public Expression {
    306308  public:
     309        Expression * expr;
     310        Type * type;
     311        bool isType;
     312
    307313        SizeofExpr( Expression * expr, Expression *_aname = nullptr );
    308314        SizeofExpr( const SizeofExpr & other );
     
    321327        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    322328        virtual void print( std::ostream & os, int indent = 0 ) const;
    323   private:
     329};
     330
     331/// AlignofExpr represents an alignof expression
     332class AlignofExpr : public Expression {
     333  public:
    324334        Expression * expr;
    325335        Type * type;
    326336        bool isType;
    327 };
    328 
    329 /// AlignofExpr represents an alignof expression
    330 class AlignofExpr : public Expression {
    331   public:
     337
    332338        AlignofExpr( Expression * expr, Expression *_aname = nullptr );
    333339        AlignofExpr( const AlignofExpr & other );
     
    346352        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    347353        virtual void print( std::ostream & os, int indent = 0 ) const;
    348   private:
    349         Expression * expr;
    350         Type * type;
    351         bool isType;
    352354};
    353355
     
    355357class UntypedOffsetofExpr : public Expression {
    356358  public:
     359        Type * type;
     360        std::string member;
     361
    357362        UntypedOffsetofExpr( Type * type, const std::string & member, Expression *_aname = nullptr );
    358363        UntypedOffsetofExpr( const UntypedOffsetofExpr & other );
     
    368373        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    369374        virtual void print( std::ostream & os, int indent = 0 ) const;
    370   private:
    371         Type * type;
    372         std::string member;
    373375};
    374376
     
    376378class OffsetofExpr : public Expression {
    377379  public:
     380        Type * type;
     381        DeclarationWithType * member;
     382
    378383        OffsetofExpr( Type * type, DeclarationWithType * member, Expression *_aname = nullptr );
    379384        OffsetofExpr( const OffsetofExpr & other );
     
    389394        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    390395        virtual void print( std::ostream & os, int indent = 0 ) const;
    391   private:
    392         Type * type;
    393         DeclarationWithType * member;
    394396};
    395397
     
    397399class OffsetPackExpr : public Expression {
    398400public:
     401        StructInstType * type;
     402
    399403        OffsetPackExpr( StructInstType * type_, Expression * aname_ = 0 );
    400404        OffsetPackExpr( const OffsetPackExpr & other );
     
    407411        virtual void accept( Visitor & v ) { v.visit( this ); }
    408412        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    409 
    410         virtual void print( std::ostream & os, int indent = 0 ) const;
    411 
    412 private:
    413         StructInstType * type;
     413        virtual void print( std::ostream & os, int indent = 0 ) const;
    414414};
    415415
     
    417417class AttrExpr : public Expression {
    418418  public:
     419        Expression * attr;
     420        Expression * expr;
     421        Type * type;
     422        bool isType;
     423
    419424        AttrExpr(Expression * attr, Expression * expr, Expression *_aname = nullptr );
    420425        AttrExpr( const AttrExpr & other );
     
    435440        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    436441        virtual void print( std::ostream & os, int indent = 0 ) const;
    437   private:
    438         Expression * attr;
    439         Expression * expr;
    440         Type * type;
    441         bool isType;
    442442};
    443443
     
    445445class LogicalExpr : public Expression {
    446446  public:
     447        Expression * arg1;
     448        Expression * arg2;
     449
    447450        LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true, Expression *_aname = nullptr );
    448451        LogicalExpr( const LogicalExpr & other );
     
    459462        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    460463        virtual void print( std::ostream & os, int indent = 0 ) const;
     464
    461465  private:
     466        bool isAnd;
     467};
     468
     469/// ConditionalExpr represents the three-argument conditional ( p ? a : b )
     470class ConditionalExpr : public Expression {
     471  public:
    462472        Expression * arg1;
    463473        Expression * arg2;
    464         bool isAnd;
    465 };
    466 
    467 /// ConditionalExpr represents the three-argument conditional ( p ? a : b )
    468 class ConditionalExpr : public Expression {
    469   public:
     474        Expression * arg3;
     475
    470476        ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3, Expression *_aname = nullptr );
    471477        ConditionalExpr( const ConditionalExpr & other );
     
    483489        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    484490        virtual void print( std::ostream & os, int indent = 0 ) const;
    485   private:
     491};
     492
     493/// CommaExpr represents the sequence operator ( a, b )
     494class CommaExpr : public Expression {
     495  public:
    486496        Expression * arg1;
    487497        Expression * arg2;
    488         Expression * arg3;
    489 };
    490 
    491 /// CommaExpr represents the sequence operator ( a, b )
    492 class CommaExpr : public Expression {
    493   public:
     498
    494499        CommaExpr( Expression * arg1, Expression * arg2, Expression *_aname = nullptr );
    495500        CommaExpr( const CommaExpr & other );
     
    505510        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    506511        virtual void print( std::ostream & os, int indent = 0 ) const;
    507   private:
    508         Expression * arg1;
    509         Expression * arg2;
    510512};
    511513
     
    513515class TypeExpr : public Expression {
    514516  public:
     517        Type * type;
     518
    515519        TypeExpr( Type * type );
    516520        TypeExpr( const TypeExpr & other );
     
    524528        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    525529        virtual void print( std::ostream & os, int indent = 0 ) const;
    526   private:
    527         Type * type;
    528530};
    529531
     
    531533class AsmExpr : public Expression {
    532534  public:
     535        Expression * inout;
     536        ConstantExpr * constraint;
     537        Expression * operand;
     538
    533539        AsmExpr( Expression * inout, ConstantExpr * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
    534540        AsmExpr( const AsmExpr & other );
     
    548554        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    549555        virtual void print( std::ostream & os, int indent = 0 ) const;
    550   private:
     556
    551557        // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints
    552         Expression * inout;
    553         ConstantExpr * constraint;
    554         Expression * operand;
    555558};
    556559
     
    559562class ImplicitCopyCtorExpr : public Expression {
    560563public:
    561         ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
    562         ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
    563         virtual ~ImplicitCopyCtorExpr();
    564 
    565         ApplicationExpr * get_callExpr() const { return callExpr; }
    566         void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; }
    567 
    568         std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
    569         std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
    570         std::list< Expression * > & get_dtors() { return dtors; }
    571 
    572         virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); }
    573         virtual void accept( Visitor & v ) { v.visit( this ); }
    574         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    575         virtual void print( std::ostream & os, int indent = 0 ) const;
    576   private:
    577564        ApplicationExpr * callExpr;
    578565        std::list< ObjectDecl * > tempDecls;
    579566        std::list< ObjectDecl * > returnDecls;
    580567        std::list< Expression * > dtors;
     568
     569        ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
     570        ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
     571        virtual ~ImplicitCopyCtorExpr();
     572
     573        ApplicationExpr * get_callExpr() const { return callExpr; }
     574        void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; }
     575
     576        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
     577        std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
     578        std::list< Expression * > & get_dtors() { return dtors; }
     579
     580        virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); }
     581        virtual void accept( Visitor & v ) { v.visit( this ); }
     582        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     583        virtual void print( std::ostream & os, int indent = 0 ) const;
    581584};
    582585
     
    584587class ConstructorExpr : public Expression {
    585588public:
     589        Expression * callExpr;
     590
    586591        ConstructorExpr( Expression * callExpr );
    587592        ConstructorExpr( const ConstructorExpr & other );
     
    595600        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    596601        virtual void print( std::ostream & os, int indent = 0 ) const;
    597 private:
    598         Expression * callExpr;
    599602};
    600603
     
    602605class CompoundLiteralExpr : public Expression {
    603606  public:
     607        Initializer * initializer;
     608
    604609        CompoundLiteralExpr( Type * type, Initializer * initializer );
    605610        CompoundLiteralExpr( const CompoundLiteralExpr & other );
     
    613618        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    614619        virtual void print( std::ostream & os, int indent = 0 ) const;
    615   private:
    616         Initializer * initializer;
    617620};
    618621
     
    620623class RangeExpr : public Expression {
    621624  public:
     625        Expression * low, * high;
     626
    622627        RangeExpr( Expression * low, Expression * high );
    623628        RangeExpr( const RangeExpr & other );
     
    632637        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    633638        virtual void print( std::ostream & os, int indent = 0 ) const;
    634   private:
    635         Expression * low, * high;
    636639};
    637640
     
    639642class UntypedTupleExpr : public Expression {
    640643  public:
     644        std::list<Expression*> exprs;
     645
    641646        UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr );
    642647        UntypedTupleExpr( const UntypedTupleExpr & other );
     
    649654        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    650655        virtual void print( std::ostream & os, int indent = 0 ) const;
    651   private:
    652         std::list<Expression*> exprs;
    653656};
    654657
     
    656659class TupleExpr : public Expression {
    657660  public:
     661        std::list<Expression*> exprs;
     662
    658663        TupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr );
    659664        TupleExpr( const TupleExpr & other );
     
    666671        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    667672        virtual void print( std::ostream & os, int indent = 0 ) const;
    668   private:
    669         std::list<Expression*> exprs;
    670673};
    671674
     
    673676class TupleIndexExpr : public Expression {
    674677  public:
     678        Expression * tuple;
     679        unsigned int index;
     680
    675681        TupleIndexExpr( Expression * tuple, unsigned int index );
    676682        TupleIndexExpr( const TupleIndexExpr & other );
     
    686692        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    687693        virtual void print( std::ostream & os, int indent = 0 ) const;
    688   private:
    689         Expression * tuple;
    690         unsigned int index;
    691694};
    692695
     
    694697class TupleAssignExpr : public Expression {
    695698  public:
     699        StmtExpr * stmtExpr = nullptr;
     700
    696701        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr );
    697702        TupleAssignExpr( const TupleAssignExpr & other );
     
    705710        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    706711        virtual void print( std::ostream & os, int indent = 0 ) const;
    707   private:
    708         StmtExpr * stmtExpr = nullptr;
    709712};
    710713
     
    712715class StmtExpr : public Expression {
    713716public:
     717        CompoundStmt * statements;
     718        std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression
     719        std::list< Expression * > dtors; // destructor(s) for return variable(s)
     720
    714721        StmtExpr( CompoundStmt * statements );
    715722        StmtExpr( const StmtExpr & other );
     
    726733        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    727734        virtual void print( std::ostream & os, int indent = 0 ) const;
    728 private:
    729         CompoundStmt * statements;
    730         std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression
    731         std::list< Expression * > dtors; // destructor(s) for return variable(s)
    732735};
    733736
    734737class UniqueExpr : public Expression {
    735738public:
     739        Expression * expr;
     740        ObjectDecl * object;
     741        VariableExpr * var;
     742
    736743        UniqueExpr( Expression * expr, long long idVal = -1 );
    737744        UniqueExpr( const UniqueExpr & other );
     
    753760        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    754761        virtual void print( std::ostream & os, int indent = 0 ) const;
     762
    755763private:
    756         Expression * expr;
    757         ObjectDecl * object;
    758         VariableExpr * var;
    759764        int id;
    760765        static long long count;
     
    773778class UntypedInitExpr : public Expression {
    774779public:
     780        Expression * expr;
     781        std::list<InitAlternative> initAlts;
     782
    775783        UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
    776784        UntypedInitExpr( const UntypedInitExpr & other );
     
    786794        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    787795        virtual void print( std::ostream & os, int indent = 0 ) const;
    788 private:
    789         Expression * expr;
    790         std::list<InitAlternative> initAlts;
    791796};
    792797
    793798class InitExpr : public Expression {
    794799public:
     800        Expression * expr;
     801        Designation * designation;
     802
    795803        InitExpr( Expression * expr, Designation * designation );
    796804        InitExpr( const InitExpr & other );
     
    807815        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    808816        virtual void print( std::ostream & os, int indent = 0 ) const;
    809 private:
    810         Expression * expr;
    811         Designation * designation;
    812817};
    813818
Note: See TracChangeset for help on using the changeset viewer.