| [0dd3a2f] | 1 | //
 | 
|---|
 | 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
 | 
|---|
 | 3 | //
 | 
|---|
 | 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
 | 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
 | 6 | //
 | 
|---|
| [3be261a] | 7 | // Statement.h --
 | 
|---|
| [0dd3a2f] | 8 | //
 | 
|---|
 | 9 | // Author           : Richard C. Bilson
 | 
|---|
 | 10 | // Created On       : Mon May 18 07:44:20 2015
 | 
|---|
| [4e06c1e] | 11 | // Last Modified By : Peter A. Buhr
 | 
|---|
| [1d4580a] | 12 | // Last Modified On : Fri Aug 12 13:57:46 2016
 | 
|---|
 | 13 | // Update Count     : 65
 | 
|---|
| [0dd3a2f] | 14 | //
 | 
|---|
 | 15 | 
 | 
|---|
| [51b73452] | 16 | #ifndef STATEMENT_H
 | 
|---|
 | 17 | #define STATEMENT_H
 | 
|---|
 | 18 | 
 | 
|---|
 | 19 | #include "SynTree.h"
 | 
|---|
 | 20 | #include "Visitor.h"
 | 
|---|
 | 21 | #include "Mutator.h"
 | 
|---|
 | 22 | #include "Common/SemanticError.h"
 | 
|---|
| [f1b1e4c] | 23 | #include "Type.h"
 | 
|---|
| [0f8e4ac] | 24 | #include "Label.h"
 | 
|---|
| [51b73452] | 25 | 
 | 
|---|
| [0dd3a2f] | 26 | class Statement {
 | 
|---|
 | 27 |   public:
 | 
|---|
 | 28 |         Statement( std::list<Label> labels );
 | 
|---|
 | 29 |         virtual ~Statement();
 | 
|---|
| [51b73452] | 30 | 
 | 
|---|
| [0dd3a2f] | 31 |         std::list<Label> & get_labels() { return labels; }
 | 
|---|
| [de62360d] | 32 |         const std::list<Label> & get_labels() const { return labels; }
 | 
|---|
| [51b73452] | 33 | 
 | 
|---|
| [0dd3a2f] | 34 |         virtual Statement *clone() const = 0;
 | 
|---|
 | 35 |         virtual void accept( Visitor &v ) = 0;
 | 
|---|
 | 36 |         virtual Statement *acceptMutator( Mutator &m ) = 0;
 | 
|---|
| [de62360d] | 37 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 38 |   protected:
 | 
|---|
 | 39 |         std::list<Label> labels;
 | 
|---|
| [51b73452] | 40 | };
 | 
|---|
 | 41 | 
 | 
|---|
| [0dd3a2f] | 42 | class CompoundStmt : public Statement {
 | 
|---|
 | 43 |   public:
 | 
|---|
 | 44 |         CompoundStmt( std::list<Label> labels );
 | 
|---|
 | 45 |         CompoundStmt( const CompoundStmt &other );
 | 
|---|
 | 46 |         virtual ~CompoundStmt();
 | 
|---|
| [51b73452] | 47 | 
 | 
|---|
| [0dd3a2f] | 48 |         std::list<Statement*>& get_kids() { return kids; }
 | 
|---|
| [51b73452] | 49 | 
 | 
|---|
| [0dd3a2f] | 50 |         virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); }
 | 
|---|
 | 51 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 52 |         virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 53 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 54 |   private:
 | 
|---|
 | 55 |         std::list<Statement*> kids;
 | 
|---|
| [51b73452] | 56 | };
 | 
|---|
 | 57 | 
 | 
|---|
| [0dd3a2f] | 58 | class ExprStmt : public Statement {
 | 
|---|
 | 59 |   public:
 | 
|---|
 | 60 |         ExprStmt( std::list<Label> labels, Expression *expr );
 | 
|---|
| [3be261a] | 61 |         ExprStmt( const ExprStmt &other );
 | 
|---|
| [0dd3a2f] | 62 |         virtual ~ExprStmt();
 | 
|---|
| [51b73452] | 63 | 
 | 
|---|
| [0dd3a2f] | 64 |         Expression *get_expr() { return expr; }
 | 
|---|
 | 65 |         void set_expr( Expression *newValue ) { expr = newValue; }
 | 
|---|
| [51b73452] | 66 | 
 | 
|---|
| [0dd3a2f] | 67 |         virtual ExprStmt *clone() const { return new ExprStmt( *this ); }
 | 
|---|
 | 68 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 69 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 70 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 71 |   private:
 | 
|---|
 | 72 |         Expression *expr;
 | 
|---|
 | 73 | };
 | 
|---|
| [51b73452] | 74 | 
 | 
|---|
| [7f5566b] | 75 | class AsmStmt : public Statement {
 | 
|---|
 | 76 |   public:
 | 
|---|
 | 77 |         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 );
 | 
|---|
| [3be261a] | 78 |         AsmStmt( const AsmStmt &other );
 | 
|---|
| [7f5566b] | 79 |         virtual ~AsmStmt();
 | 
|---|
 | 80 | 
 | 
|---|
 | 81 |         bool get_voltile() { return voltile; }
 | 
|---|
 | 82 |         void set_voltile( bool newValue ) { voltile = newValue; }
 | 
|---|
 | 83 |         ConstantExpr *get_instruction() { return instruction; }
 | 
|---|
 | 84 |         void set_instruction( ConstantExpr *newValue ) { instruction = newValue; }
 | 
|---|
 | 85 |         std::list<Expression *> &get_output() { return output; }
 | 
|---|
 | 86 |         void set_output( const std::list<Expression *> &newValue ) { output = newValue; }
 | 
|---|
 | 87 |         std::list<Expression *> &get_input() { return input; }
 | 
|---|
 | 88 |         void set_input( const std::list<Expression *> &newValue ) { input = newValue; }
 | 
|---|
 | 89 |         std::list<ConstantExpr *> &get_clobber() { return clobber; }
 | 
|---|
 | 90 |         void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; }
 | 
|---|
 | 91 |         std::list<Label> &get_gotolabels() { return gotolabels; }
 | 
|---|
 | 92 |         void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; }
 | 
|---|
 | 93 | 
 | 
|---|
 | 94 |         virtual AsmStmt *clone() const { return new AsmStmt( *this ); }
 | 
|---|
 | 95 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 96 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
 | 97 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
 | 98 |   private:
 | 
|---|
 | 99 |         bool voltile;
 | 
|---|
 | 100 |         ConstantExpr *instruction;
 | 
|---|
 | 101 |         std::list<Expression *> output, input;
 | 
|---|
 | 102 |         std::list<ConstantExpr *> clobber;
 | 
|---|
 | 103 |         std::list<Label> gotolabels;
 | 
|---|
 | 104 | };
 | 
|---|
 | 105 | 
 | 
|---|
| [0dd3a2f] | 106 | class IfStmt : public Statement {
 | 
|---|
 | 107 |   public:
 | 
|---|
 | 108 |         IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
 | 
|---|
| [3be261a] | 109 |         IfStmt( const IfStmt &other );
 | 
|---|
| [0dd3a2f] | 110 |         virtual ~IfStmt();
 | 
|---|
 | 111 | 
 | 
|---|
 | 112 |         Expression *get_condition() { return condition; }
 | 
|---|
 | 113 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
 | 114 |         Statement *get_thenPart() { return thenPart; }
 | 
|---|
 | 115 |         void set_thenPart( Statement *newValue ) { thenPart = newValue; }
 | 
|---|
 | 116 |         Statement *get_elsePart() { return elsePart; }
 | 
|---|
 | 117 |         void set_elsePart( Statement *newValue ) { elsePart = newValue; }
 | 
|---|
| [3be261a] | 118 | 
 | 
|---|
| [0dd3a2f] | 119 |         virtual IfStmt *clone() const { return new IfStmt( *this ); }
 | 
|---|
 | 120 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 121 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 122 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 123 |   private:
 | 
|---|
 | 124 |         Expression *condition;
 | 
|---|
 | 125 |         Statement *thenPart;
 | 
|---|
 | 126 |         Statement *elsePart;
 | 
|---|
| [51b73452] | 127 | };
 | 
|---|
 | 128 | 
 | 
|---|
| [0dd3a2f] | 129 | class SwitchStmt : public Statement {
 | 
|---|
 | 130 |   public:
 | 
|---|
| [8688ce1] | 131 |         SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
 | 
|---|
| [3be261a] | 132 |         SwitchStmt( const SwitchStmt &other );
 | 
|---|
| [0dd3a2f] | 133 |         virtual ~SwitchStmt();
 | 
|---|
| [51b73452] | 134 | 
 | 
|---|
| [0dd3a2f] | 135 |         Expression *get_condition() { return condition; }
 | 
|---|
 | 136 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
| [51b73452] | 137 | 
 | 
|---|
| [8688ce1] | 138 |         std::list<Statement *> & get_statements() { return statements; }
 | 
|---|
| [51b73452] | 139 | 
 | 
|---|
| [0dd3a2f] | 140 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 141 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [51b73452] | 142 | 
 | 
|---|
| [0dd3a2f] | 143 |         virtual SwitchStmt *clone() const { return new SwitchStmt( *this ); }
 | 
|---|
| [de62360d] | 144 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 145 |   private:
 | 
|---|
 | 146 |         Expression * condition;
 | 
|---|
| [8688ce1] | 147 |         std::list<Statement *> statements;
 | 
|---|
| [51b73452] | 148 | };
 | 
|---|
 | 149 | 
 | 
|---|
| [0dd3a2f] | 150 | class CaseStmt : public Statement {
 | 
|---|
 | 151 |   public:
 | 
|---|
| [8688ce1] | 152 |         CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
 | 
|---|
| [3be261a] | 153 |         CaseStmt( const CaseStmt &other );
 | 
|---|
| [0dd3a2f] | 154 |         virtual ~CaseStmt();
 | 
|---|
 | 155 | 
 | 
|---|
| [8688ce1] | 156 |         static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() );
 | 
|---|
| [b2152e7a] | 157 | 
 | 
|---|
| [de62360d] | 158 |         bool isDefault() const { return _isDefault; }
 | 
|---|
| [0dd3a2f] | 159 |         void set_default(bool b) { _isDefault = b; }
 | 
|---|
 | 160 | 
 | 
|---|
 | 161 |         Expression * &get_condition() { return condition; }
 | 
|---|
 | 162 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
 | 163 | 
 | 
|---|
 | 164 |         std::list<Statement *> &get_statements() { return stmts; }
 | 
|---|
 | 165 |         void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
 | 
|---|
| [3be261a] | 166 | 
 | 
|---|
| [0dd3a2f] | 167 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 168 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
 | 169 | 
 | 
|---|
 | 170 |         virtual CaseStmt *clone() const { return new CaseStmt( *this ); }
 | 
|---|
| [de62360d] | 171 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 172 |   private:
 | 
|---|
 | 173 |         Expression * condition;
 | 
|---|
 | 174 |         std::list<Statement *> stmts;
 | 
|---|
 | 175 |         bool _isDefault;
 | 
|---|
| [51b73452] | 176 | };
 | 
|---|
 | 177 | 
 | 
|---|
| [0dd3a2f] | 178 | class WhileStmt : public Statement {
 | 
|---|
 | 179 |   public:
 | 
|---|
 | 180 |         WhileStmt( std::list<Label> labels, Expression *condition,
 | 
|---|
 | 181 |                Statement *body, bool isDoWhile = false );
 | 
|---|
| [3be261a] | 182 |         WhileStmt( const WhileStmt &other );
 | 
|---|
| [0dd3a2f] | 183 |         virtual ~WhileStmt();
 | 
|---|
 | 184 | 
 | 
|---|
 | 185 |         Expression *get_condition() { return condition; }
 | 
|---|
 | 186 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
 | 187 |         Statement *get_body() { return body; }
 | 
|---|
 | 188 |         void set_body( Statement *newValue ) { body = newValue; }
 | 
|---|
 | 189 |         bool get_isDoWhile() { return isDoWhile; }
 | 
|---|
 | 190 |         void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
 | 
|---|
| [3be261a] | 191 | 
 | 
|---|
| [0dd3a2f] | 192 |         virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
 | 
|---|
 | 193 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 194 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 195 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 196 |   private:
 | 
|---|
 | 197 |         Expression *condition;
 | 
|---|
 | 198 |         Statement *body;
 | 
|---|
 | 199 |         bool isDoWhile;
 | 
|---|
| [51b73452] | 200 | };
 | 
|---|
 | 201 | 
 | 
|---|
| [0dd3a2f] | 202 | class ForStmt : public Statement {
 | 
|---|
 | 203 |   public:
 | 
|---|
| [145f1fc] | 204 |         ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
 | 
|---|
| [0dd3a2f] | 205 |              Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
 | 
|---|
| [3be261a] | 206 |         ForStmt( const ForStmt &other );
 | 
|---|
| [0dd3a2f] | 207 |         virtual ~ForStmt();
 | 
|---|
 | 208 | 
 | 
|---|
| [145f1fc] | 209 |         std::list<Statement *> &get_initialization() { return initialization; }
 | 
|---|
 | 210 |         void set_initialization( std::list<Statement *> newValue ) { initialization = newValue; }
 | 
|---|
| [0dd3a2f] | 211 |         Expression *get_condition() { return condition; }
 | 
|---|
 | 212 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
 | 213 |         Expression *get_increment() { return increment; }
 | 
|---|
 | 214 |         void set_increment( Expression *newValue ) { increment = newValue; }
 | 
|---|
 | 215 |         Statement *get_body() { return body; }
 | 
|---|
 | 216 |         void set_body( Statement *newValue ) { body = newValue; }
 | 
|---|
| [3be261a] | 217 | 
 | 
|---|
| [0dd3a2f] | 218 |         virtual ForStmt *clone() const { return new ForStmt( *this ); }
 | 
|---|
 | 219 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 220 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 221 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 222 |   private:
 | 
|---|
| [145f1fc] | 223 |         std::list<Statement *> initialization;
 | 
|---|
| [0dd3a2f] | 224 |         Expression *condition;
 | 
|---|
 | 225 |         Expression *increment;
 | 
|---|
 | 226 |         Statement *body;
 | 
|---|
| [51b73452] | 227 | };
 | 
|---|
 | 228 | 
 | 
|---|
| [0dd3a2f] | 229 | class BranchStmt : public Statement {
 | 
|---|
 | 230 |   public:
 | 
|---|
| [de62360d] | 231 |         enum Type { Goto = 0, Break, Continue };
 | 
|---|
| [0dd3a2f] | 232 | 
 | 
|---|
 | 233 |         BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
 | 
|---|
 | 234 |         BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
 | 
|---|
 | 235 | 
 | 
|---|
| [be5aa1b] | 236 |         Label get_originalTarget() { return originalTarget; }
 | 
|---|
| [0dd3a2f] | 237 |         Label get_target() { return target; }
 | 
|---|
 | 238 |         void set_target( Label newValue ) { target = newValue; }
 | 
|---|
| [3be261a] | 239 | 
 | 
|---|
| [0dd3a2f] | 240 |         Expression *get_computedTarget() { return computedTarget; }
 | 
|---|
 | 241 |         void set_target( Expression * newValue ) { computedTarget = newValue; }
 | 
|---|
 | 242 | 
 | 
|---|
 | 243 |         Type get_type() { return type; }
 | 
|---|
 | 244 |         const char *get_typename() { return brType[ type ]; }
 | 
|---|
 | 245 | 
 | 
|---|
 | 246 |         virtual BranchStmt *clone() const { return new BranchStmt( *this ); }
 | 
|---|
 | 247 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 248 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 249 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 250 |   private:
 | 
|---|
 | 251 |         static const char *brType[];
 | 
|---|
| [be5aa1b] | 252 |         Label originalTarget;  // can give better error messages if we remember the label name that the user entered
 | 
|---|
| [0dd3a2f] | 253 |         Label target;
 | 
|---|
 | 254 |         Expression *computedTarget;
 | 
|---|
 | 255 |         Type type;
 | 
|---|
| [51b73452] | 256 | };
 | 
|---|
 | 257 | 
 | 
|---|
| [0dd3a2f] | 258 | class ReturnStmt : public Statement {
 | 
|---|
 | 259 |   public:
 | 
|---|
 | 260 |         ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
 | 
|---|
| [3be261a] | 261 |         ReturnStmt( const ReturnStmt &other );
 | 
|---|
| [0dd3a2f] | 262 |         virtual ~ReturnStmt();
 | 
|---|
 | 263 | 
 | 
|---|
 | 264 |         Expression *get_expr() { return expr; }
 | 
|---|
 | 265 |         void set_expr( Expression *newValue ) { expr = newValue; }
 | 
|---|
| [3be261a] | 266 | 
 | 
|---|
| [0dd3a2f] | 267 |         virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
 | 
|---|
 | 268 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 269 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 270 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 271 |   private:
 | 
|---|
 | 272 |         Expression *expr;
 | 
|---|
 | 273 |         bool isThrow;
 | 
|---|
| [51b73452] | 274 | };
 | 
|---|
 | 275 | 
 | 
|---|
 | 276 | 
 | 
|---|
| [0dd3a2f] | 277 | class NullStmt : public CompoundStmt {
 | 
|---|
 | 278 |   public:
 | 
|---|
 | 279 |         NullStmt();
 | 
|---|
 | 280 |         NullStmt( std::list<Label> labels );
 | 
|---|
| [51b73452] | 281 | 
 | 
|---|
| [0dd3a2f] | 282 |         virtual NullStmt *clone() const { return new NullStmt( *this ); }
 | 
|---|
 | 283 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 284 |         virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 285 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [3be261a] | 286 | 
 | 
|---|
| [0dd3a2f] | 287 |   private:
 | 
|---|
| [51b73452] | 288 | };
 | 
|---|
 | 289 | 
 | 
|---|
| [3be261a] | 290 | class TryStmt : public Statement {
 | 
|---|
| [0dd3a2f] | 291 |   public:
 | 
|---|
 | 292 |         TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
 | 
|---|
 | 293 |         TryStmt( const TryStmt &other );
 | 
|---|
 | 294 |         virtual ~TryStmt();
 | 
|---|
 | 295 | 
 | 
|---|
 | 296 |         CompoundStmt *get_block() const { return block; }
 | 
|---|
 | 297 |         void set_block( CompoundStmt *newValue ) { block = newValue; }
 | 
|---|
 | 298 |         std::list<Statement *>& get_catchers() { return handlers; }
 | 
|---|
 | 299 | 
 | 
|---|
 | 300 |         FinallyStmt *get_finally() const { return finallyBlock; }
 | 
|---|
 | 301 |         void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
 | 
|---|
 | 302 | 
 | 
|---|
 | 303 |         virtual TryStmt *clone() const { return new TryStmt( *this ); }
 | 
|---|
 | 304 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 305 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 306 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [3be261a] | 307 | 
 | 
|---|
| [0dd3a2f] | 308 |   private:
 | 
|---|
 | 309 |         CompoundStmt *block;
 | 
|---|
 | 310 |         std::list<Statement *> handlers;
 | 
|---|
 | 311 |         FinallyStmt *finallyBlock;
 | 
|---|
| [3be261a] | 312 | };
 | 
|---|
| [51b73452] | 313 | 
 | 
|---|
| [0dd3a2f] | 314 | class CatchStmt : public Statement {
 | 
|---|
 | 315 |   public:
 | 
|---|
| [1d4580a] | 316 |         CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool catchAny = false );
 | 
|---|
| [3be261a] | 317 |         CatchStmt( const CatchStmt &other );
 | 
|---|
| [0dd3a2f] | 318 |         virtual ~CatchStmt();
 | 
|---|
 | 319 | 
 | 
|---|
 | 320 |         Declaration *get_decl() { return decl; }
 | 
|---|
 | 321 |         void set_decl( Declaration *newValue ) { decl = newValue; }
 | 
|---|
 | 322 | 
 | 
|---|
 | 323 |         Statement *get_body() { return body; }
 | 
|---|
 | 324 |         void set_body( Statement *newValue ) { body = newValue; }
 | 
|---|
| [3be261a] | 325 | 
 | 
|---|
| [0dd3a2f] | 326 |         virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
 | 
|---|
 | 327 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 328 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 329 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [3be261a] | 330 | 
 | 
|---|
| [0dd3a2f] | 331 |   private:
 | 
|---|
 | 332 |         Declaration *decl;
 | 
|---|
 | 333 |         Statement *body;
 | 
|---|
 | 334 |         bool catchRest;
 | 
|---|
| [51b73452] | 335 | };
 | 
|---|
 | 336 | 
 | 
|---|
| [3be261a] | 337 | class FinallyStmt : public Statement {
 | 
|---|
| [0dd3a2f] | 338 |   public:
 | 
|---|
 | 339 |         FinallyStmt( std::list<Label> labels, CompoundStmt *block );
 | 
|---|
| [3be261a] | 340 |         FinallyStmt( const FinallyStmt &other );
 | 
|---|
| [0dd3a2f] | 341 |         virtual ~FinallyStmt();
 | 
|---|
 | 342 | 
 | 
|---|
 | 343 |         CompoundStmt *get_block() const { return block; }
 | 
|---|
 | 344 |         void set_block( CompoundStmt *newValue ) { block = newValue; }
 | 
|---|
| [3be261a] | 345 | 
 | 
|---|
| [0dd3a2f] | 346 |         virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
 | 
|---|
 | 347 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 348 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 349 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 350 |   private:
 | 
|---|
 | 351 |         CompoundStmt *block;
 | 
|---|
| [3be261a] | 352 | };
 | 
|---|
| [51b73452] | 353 | 
 | 
|---|
 | 354 | 
 | 
|---|
 | 355 | // represents a declaration that occurs as part of a compound statement
 | 
|---|
| [0dd3a2f] | 356 | class DeclStmt : public Statement {
 | 
|---|
 | 357 |   public:
 | 
|---|
 | 358 |         DeclStmt( std::list<Label> labels, Declaration *decl );
 | 
|---|
 | 359 |         DeclStmt( const DeclStmt &other );
 | 
|---|
 | 360 |         virtual ~DeclStmt();
 | 
|---|
 | 361 | 
 | 
|---|
| [f1b1e4c] | 362 |         Declaration *get_decl() const { return decl; }
 | 
|---|
| [0dd3a2f] | 363 |         void set_decl( Declaration *newValue ) { decl = newValue; }
 | 
|---|
 | 364 | 
 | 
|---|
 | 365 |         virtual DeclStmt *clone() const { return new DeclStmt( *this ); }
 | 
|---|
 | 366 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 367 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
| [de62360d] | 368 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
| [0dd3a2f] | 369 |   private:
 | 
|---|
 | 370 |         Declaration *decl;
 | 
|---|
| [51b73452] | 371 | };
 | 
|---|
 | 372 | 
 | 
|---|
| [f1b1e4c] | 373 | 
 | 
|---|
 | 374 | /// represents an implicit application of a constructor or destructor. Qualifiers are replaced
 | 
|---|
 | 375 | /// immediately before and after the call so that qualified objects can be constructed
 | 
|---|
 | 376 | /// with the same functions as unqualified objects.
 | 
|---|
 | 377 | class ImplicitCtorDtorStmt : public Statement {
 | 
|---|
 | 378 |   public:
 | 
|---|
 | 379 |         ImplicitCtorDtorStmt( Statement * callStmt );
 | 
|---|
 | 380 |         ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
 | 
|---|
 | 381 |         virtual ~ImplicitCtorDtorStmt();
 | 
|---|
 | 382 | 
 | 
|---|
 | 383 |         Statement *get_callStmt() const { return callStmt; }
 | 
|---|
 | 384 |         void set_callStmt( Statement * newValue ) { callStmt = newValue; }
 | 
|---|
 | 385 | 
 | 
|---|
 | 386 |         virtual ImplicitCtorDtorStmt *clone() const { return new ImplicitCtorDtorStmt( *this ); }
 | 
|---|
 | 387 |         virtual void accept( Visitor &v ) { v.visit( this ); }
 | 
|---|
 | 388 |         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
 | 
|---|
 | 389 |         virtual void print( std::ostream &os, int indent = 0 ) const;
 | 
|---|
 | 390 | 
 | 
|---|
 | 391 |   private:
 | 
|---|
 | 392 |         // Non-owned pointer to the constructor/destructor statement
 | 
|---|
 | 393 |         Statement * callStmt;
 | 
|---|
 | 394 | };
 | 
|---|
 | 395 | 
 | 
|---|
 | 396 | 
 | 
|---|
| [baf7fee] | 397 | std::ostream & operator<<( std::ostream & out, Statement * statement );
 | 
|---|
 | 398 | 
 | 
|---|
| [0dd3a2f] | 399 | #endif // STATEMENT_H
 | 
|---|
| [51b73452] | 400 | 
 | 
|---|
| [0dd3a2f] | 401 | // Local Variables: //
 | 
|---|
 | 402 | // tab-width: 4 //
 | 
|---|
 | 403 | // mode: c++ //
 | 
|---|
 | 404 | // compile-command: "make install" //
 | 
|---|
 | 405 | // End: //
 | 
|---|