Ignore:
Timestamp:
Aug 11, 2017, 10:33:37 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
54cd58b0
Parents:
3d4b23fa (diff), 59a75cb (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:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.h

    r3d4b23fa r0720e049  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jun 12 13:35:00 2017
    13 // Update Count     : 67
     12// Last Modified On : Thr Aug  3 14:08:00 2017
     13// Update Count     : 69
    1414//
    1515
    16 #ifndef STATEMENT_H
    17 #define STATEMENT_H
     16#pragma once
    1817
    1918#include "BaseSyntaxNode.h"
     
    2726class Statement : public BaseSyntaxNode {
    2827  public:
     28        std::list<Label> labels;
     29
    2930        Statement( std::list<Label> labels );
    3031        virtual ~Statement();
     
    3738        virtual Statement *acceptMutator( Mutator &m ) = 0;
    3839        virtual void print( std::ostream &os, int indent = 0 ) const;
    39   protected:
    40         std::list<Label> labels;
    4140};
    4241
    4342class CompoundStmt : public Statement {
    4443  public:
     44        std::list<Statement*> kids;
     45
    4546        CompoundStmt( std::list<Label> labels );
    4647        CompoundStmt( const CompoundStmt &other );
     
    5556        virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    5657        virtual void print( std::ostream &os, int indent = 0 ) const;
    57   private:
    58         std::list<Statement*> kids;
    5958};
    6059
     
    6867        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    6968        virtual void print( std::ostream &os, int indent = 0 ) const;
    70 
    71   private:
    7269};
    7370
    7471class ExprStmt : public Statement {
    7572  public:
     73        Expression *expr;
     74
    7675        ExprStmt( std::list<Label> labels, Expression *expr );
    7776        ExprStmt( const ExprStmt &other );
     
    8584        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    8685        virtual void print( std::ostream &os, int indent = 0 ) const;
    87   private:
    88         Expression *expr;
    8986};
    9087
    9188class AsmStmt : public Statement {
    9289  public:
     90        bool voltile;
     91        ConstantExpr *instruction;
     92        std::list<Expression *> output, input;
     93        std::list<ConstantExpr *> clobber;
     94        std::list<Label> gotolabels;
     95
    9396        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 );
    9497        AsmStmt( const AsmStmt &other );
     
    112115        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    113116        virtual void print( std::ostream &os, int indent = 0 ) const;
    114   private:
    115         bool voltile;
    116         ConstantExpr *instruction;
    117         std::list<Expression *> output, input;
    118         std::list<ConstantExpr *> clobber;
    119         std::list<Label> gotolabels;
    120117};
    121118
    122119class IfStmt : public Statement {
    123120  public:
     121        Expression *condition;
     122        Statement *thenPart;
     123        Statement *elsePart;
     124
    124125        IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
    125126        IfStmt( const IfStmt &other );
     
    137138        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    138139        virtual void print( std::ostream &os, int indent = 0 ) const;
    139   private:
    140         Expression *condition;
    141         Statement *thenPart;
    142         Statement *elsePart;
    143140};
    144141
    145142class SwitchStmt : public Statement {
    146143  public:
     144        Expression * condition;
     145
    147146        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
    148147        SwitchStmt( const SwitchStmt &other );
     
    160159        virtual void print( std::ostream &os, int indent = 0 ) const;
    161160  private:
     161        std::list<Statement *> statements;
     162};
     163
     164class CaseStmt : public Statement {
     165  public:
    162166        Expression * condition;
    163         std::list<Statement *> statements;
    164 };
    165 
    166 class CaseStmt : public Statement {
    167   public:
     167        std::list<Statement *> stmts;
     168
    168169        CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    169170        CaseStmt( const CaseStmt &other );
     
    187188        virtual void print( std::ostream &os, int indent = 0 ) const;
    188189  private:
    189         Expression * condition;
    190         std::list<Statement *> stmts;
    191190        bool _isDefault;
    192191};
     
    194193class WhileStmt : public Statement {
    195194  public:
     195        Expression *condition;
     196        Statement *body;
     197        bool isDoWhile;
     198
    196199        WhileStmt( std::list<Label> labels, Expression *condition,
    197200               Statement *body, bool isDoWhile = false );
     
    210213        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    211214        virtual void print( std::ostream &os, int indent = 0 ) const;
    212   private:
     215};
     216
     217class ForStmt : public Statement {
     218  public:
     219        std::list<Statement *> initialization;
    213220        Expression *condition;
     221        Expression *increment;
    214222        Statement *body;
    215         bool isDoWhile;
    216 };
    217 
    218 class ForStmt : public Statement {
    219   public:
     223
    220224        ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
    221225             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
     
    236240        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    237241        virtual void print( std::ostream &os, int indent = 0 ) const;
    238   private:
    239         std::list<Statement *> initialization;
    240         Expression *condition;
    241         Expression *increment;
    242         Statement *body;
    243242};
    244243
     
    246245  public:
    247246        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;
    248253
    249254        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
     
    266271  private:
    267272        static const char *brType[];
    268         Label originalTarget;  // can give better error messages if we remember the label name that the user entered
    269         Label target;
    270         Expression *computedTarget;
    271         Type type;
    272273};
    273274
    274275class ReturnStmt : public Statement {
    275276  public:
     277        Expression *expr;
     278
    276279        ReturnStmt( std::list<Label> labels, Expression *expr );
    277280        ReturnStmt( const ReturnStmt &other );
     
    285288        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    286289        virtual void print( std::ostream &os, int indent = 0 ) const;
    287   private:
    288         Expression *expr;
    289290};
    290291
     
    292293  public:
    293294        enum Kind { Terminate, Resume };
     295
     296        const Kind kind;
     297        Expression * expr;
     298        Expression * target;
    294299
    295300        ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr );
     
    307312        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    308313        virtual void print( std::ostream &os, int indent = 0 ) const;
    309   private:
    310         Kind kind;
    311         Expression * expr;
    312         Expression * target;
    313314};
    314315
    315316class TryStmt : public Statement {
    316317  public:
     318        CompoundStmt *block;
     319        std::list<CatchStmt *> handlers;
     320        FinallyStmt *finallyBlock;
     321
    317322        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    318323        TryStmt( const TryStmt &other );
     
    330335        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    331336        virtual void print( std::ostream &os, int indent = 0 ) const;
    332 
    333   private:
    334         CompoundStmt *block;
    335         std::list<CatchStmt *> handlers;
    336         FinallyStmt *finallyBlock;
    337337};
    338338
     
    340340  public:
    341341        enum Kind { Terminate, Resume };
     342
     343        const Kind kind;
     344        Declaration *decl;
     345        Expression *cond;
     346        Statement *body;
    342347
    343348        CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl,
     
    358363        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    359364        virtual void print( std::ostream &os, int indent = 0 ) const;
    360 
    361   private:
    362         Kind kind;
    363         Declaration *decl;
    364         Expression *cond;
    365         Statement *body;
    366365};
    367366
    368367class FinallyStmt : public Statement {
    369368  public:
     369        CompoundStmt *block;
     370
    370371        FinallyStmt( std::list<Label> labels, CompoundStmt *block );
    371372        FinallyStmt( const FinallyStmt &other );
     
    379380        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    380381        virtual void print( std::ostream &os, int indent = 0 ) const;
    381   private:
    382         CompoundStmt *block;
    383382};
    384383
     
    387386class DeclStmt : public Statement {
    388387  public:
     388        Declaration *decl;
     389
    389390        DeclStmt( std::list<Label> labels, Declaration *decl );
    390391        DeclStmt( const DeclStmt &other );
     
    398399        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    399400        virtual void print( std::ostream &os, int indent = 0 ) const;
    400   private:
    401         Declaration *decl;
    402401};
    403402
     
    408407class ImplicitCtorDtorStmt : public Statement {
    409408  public:
     409        // Non-owned pointer to the constructor/destructor statement
     410        Statement * callStmt;
     411
    410412        ImplicitCtorDtorStmt( Statement * callStmt );
    411413        ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
     
    419421        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    420422        virtual void print( std::ostream &os, int indent = 0 ) const;
    421 
    422   private:
    423         // Non-owned pointer to the constructor/destructor statement
    424         Statement * callStmt;
    425423};
    426424
    427425
    428426std::ostream & operator<<( std::ostream & out, const Statement * statement );
    429 
    430 #endif // STATEMENT_H
    431427
    432428// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.