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/Statement.h

    rcbce272 r65cdc1e  
    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 : Sat Jul 22 09:54:32 2017
    13 // Update Count     : 68
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Aug  3 14:08:00 2017
     13// Update Count     : 69
    1414//
    1515
     
    2626class Statement : public BaseSyntaxNode {
    2727  public:
     28        std::list<Label> labels;
     29
    2830        Statement( std::list<Label> labels );
    2931        virtual ~Statement();
     
    3638        virtual Statement *acceptMutator( Mutator &m ) = 0;
    3739        virtual void print( std::ostream &os, int indent = 0 ) const;
    38   protected:
    39         std::list<Label> labels;
    4040};
    4141
    4242class CompoundStmt : public Statement {
    4343  public:
     44        std::list<Statement*> kids;
     45
    4446        CompoundStmt( std::list<Label> labels );
    4547        CompoundStmt( const CompoundStmt &other );
     
    5456        virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    5557        virtual void print( std::ostream &os, int indent = 0 ) const;
    56   private:
    57         std::list<Statement*> kids;
    5858};
    5959
     
    6767        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    6868        virtual void print( std::ostream &os, int indent = 0 ) const;
    69 
    70   private:
    7169};
    7270
    7371class ExprStmt : public Statement {
    7472  public:
     73        Expression *expr;
     74
    7575        ExprStmt( std::list<Label> labels, Expression *expr );
    7676        ExprStmt( const ExprStmt &other );
     
    8484        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    8585        virtual void print( std::ostream &os, int indent = 0 ) const;
    86   private:
    87         Expression *expr;
    8886};
    8987
    9088class AsmStmt : public Statement {
    9189  public:
     90        bool voltile;
     91        ConstantExpr *instruction;
     92        std::list<Expression *> output, input;
     93        std::list<ConstantExpr *> clobber;
     94        std::list<Label> gotolabels;
     95
    9296        AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
    9397        AsmStmt( const AsmStmt &other );
     
    111115        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    112116        virtual void print( std::ostream &os, int indent = 0 ) const;
    113   private:
    114         bool voltile;
    115         ConstantExpr *instruction;
    116         std::list<Expression *> output, input;
    117         std::list<ConstantExpr *> clobber;
    118         std::list<Label> gotolabels;
    119117};
    120118
    121119class IfStmt : public Statement {
    122120  public:
     121        Expression *condition;
     122        Statement *thenPart;
     123        Statement *elsePart;
     124
    123125        IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
    124126        IfStmt( const IfStmt &other );
     
    136138        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    137139        virtual void print( std::ostream &os, int indent = 0 ) const;
    138   private:
    139         Expression *condition;
    140         Statement *thenPart;
    141         Statement *elsePart;
    142140};
    143141
    144142class SwitchStmt : public Statement {
    145143  public:
     144        Expression * condition;
     145
    146146        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
    147147        SwitchStmt( const SwitchStmt &other );
     
    159159        virtual void print( std::ostream &os, int indent = 0 ) const;
    160160  private:
     161        std::list<Statement *> statements;
     162};
     163
     164class CaseStmt : public Statement {
     165  public:
    161166        Expression * condition;
    162         std::list<Statement *> statements;
    163 };
    164 
    165 class CaseStmt : public Statement {
    166   public:
     167        std::list<Statement *> stmts;
     168
    167169        CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    168170        CaseStmt( const CaseStmt &other );
     
    186188        virtual void print( std::ostream &os, int indent = 0 ) const;
    187189  private:
    188         Expression * condition;
    189         std::list<Statement *> stmts;
    190190        bool _isDefault;
    191191};
     
    193193class WhileStmt : public Statement {
    194194  public:
     195        Expression *condition;
     196        Statement *body;
     197        bool isDoWhile;
     198
    195199        WhileStmt( std::list<Label> labels, Expression *condition,
    196200               Statement *body, bool isDoWhile = false );
     
    209213        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    210214        virtual void print( std::ostream &os, int indent = 0 ) const;
    211   private:
     215};
     216
     217class ForStmt : public Statement {
     218  public:
     219        std::list<Statement *> initialization;
    212220        Expression *condition;
     221        Expression *increment;
    213222        Statement *body;
    214         bool isDoWhile;
    215 };
    216 
    217 class ForStmt : public Statement {
    218   public:
     223
    219224        ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
    220225             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
     
    235240        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    236241        virtual void print( std::ostream &os, int indent = 0 ) const;
    237   private:
    238         std::list<Statement *> initialization;
    239         Expression *condition;
    240         Expression *increment;
    241         Statement *body;
    242242};
    243243
     
    245245  public:
    246246        enum Type { Goto = 0, Break, Continue };
     247
     248        // originalTarget kept for error messages.
     249        const Label originalTarget;
     250        Label target;
     251        Expression *computedTarget;
     252        Type type;
    247253
    248254        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
     
    265271  private:
    266272        static const char *brType[];
    267         Label originalTarget;  // can give better error messages if we remember the label name that the user entered
    268         Label target;
    269         Expression *computedTarget;
    270         Type type;
    271273};
    272274
    273275class ReturnStmt : public Statement {
    274276  public:
     277        Expression *expr;
     278
    275279        ReturnStmt( std::list<Label> labels, Expression *expr );
    276280        ReturnStmt( const ReturnStmt &other );
     
    284288        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    285289        virtual void print( std::ostream &os, int indent = 0 ) const;
    286   private:
    287         Expression *expr;
    288290};
    289291
     
    291293  public:
    292294        enum Kind { Terminate, Resume };
     295
     296        const Kind kind;
     297        Expression * expr;
     298        Expression * target;
    293299
    294300        ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr );
     
    306312        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    307313        virtual void print( std::ostream &os, int indent = 0 ) const;
    308   private:
    309         Kind kind;
    310         Expression * expr;
    311         Expression * target;
    312314};
    313315
    314316class TryStmt : public Statement {
    315317  public:
     318        CompoundStmt *block;
     319        std::list<CatchStmt *> handlers;
     320        FinallyStmt *finallyBlock;
     321
    316322        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    317323        TryStmt( const TryStmt &other );
     
    329335        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    330336        virtual void print( std::ostream &os, int indent = 0 ) const;
    331 
    332   private:
    333         CompoundStmt *block;
    334         std::list<CatchStmt *> handlers;
    335         FinallyStmt *finallyBlock;
    336337};
    337338
     
    339340  public:
    340341        enum Kind { Terminate, Resume };
     342
     343        const Kind kind;
     344        Declaration *decl;
     345        Expression *cond;
     346        Statement *body;
    341347
    342348        CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl,
     
    357363        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    358364        virtual void print( std::ostream &os, int indent = 0 ) const;
    359 
    360   private:
    361         Kind kind;
    362         Declaration *decl;
    363         Expression *cond;
    364         Statement *body;
    365365};
    366366
    367367class FinallyStmt : public Statement {
    368368  public:
     369        CompoundStmt *block;
     370
    369371        FinallyStmt( std::list<Label> labels, CompoundStmt *block );
    370372        FinallyStmt( const FinallyStmt &other );
     
    378380        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    379381        virtual void print( std::ostream &os, int indent = 0 ) const;
    380   private:
    381         CompoundStmt *block;
    382382};
    383383
     
    386386class DeclStmt : public Statement {
    387387  public:
     388        Declaration *decl;
     389
    388390        DeclStmt( std::list<Label> labels, Declaration *decl );
    389391        DeclStmt( const DeclStmt &other );
     
    397399        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    398400        virtual void print( std::ostream &os, int indent = 0 ) const;
    399   private:
    400         Declaration *decl;
    401401};
    402402
     
    407407class ImplicitCtorDtorStmt : public Statement {
    408408  public:
     409        // Non-owned pointer to the constructor/destructor statement
     410        Statement * callStmt;
     411
    409412        ImplicitCtorDtorStmt( Statement * callStmt );
    410413        ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
     
    418421        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    419422        virtual void print( std::ostream &os, int indent = 0 ) const;
    420 
    421   private:
    422         // Non-owned pointer to the constructor/destructor statement
    423         Statement * callStmt;
    424423};
    425424
Note: See TracChangeset for help on using the changeset viewer.