| [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
 | 
|---|
| [936e9f4] | 11 | // Last Modified By : Peter A. Buhr
 | 
|---|
| [6a276a0] | 12 | // Last Modified On : Thu Mar  8 14:53:02 2018
 | 
|---|
 | 13 | // Update Count     : 78
 | 
|---|
| [0dd3a2f] | 14 | //
 | 
|---|
 | 15 | 
 | 
|---|
| [6b0b624] | 16 | #pragma once
 | 
|---|
| [51b73452] | 17 | 
 | 
|---|
| [ea6332d] | 18 | #include <iosfwd>                  // for ostream
 | 
|---|
 | 19 | #include <list>                    // for list
 | 
|---|
 | 20 | #include <memory>                  // for allocator
 | 
|---|
| [135b431] | 21 | #include <vector>                        // for vector
 | 
|---|
| [ea6332d] | 22 | 
 | 
|---|
 | 23 | #include "BaseSyntaxNode.h"        // for BaseSyntaxNode
 | 
|---|
 | 24 | #include "Common/SemanticError.h"  // for SemanticError
 | 
|---|
 | 25 | #include "Label.h"                 // for Label
 | 
|---|
 | 26 | #include "Mutator.h"               // for Mutator
 | 
|---|
 | 27 | #include "Visitor.h"               // for Visitor
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 | class CatchStmt;
 | 
|---|
 | 30 | class ConstantExpr;
 | 
|---|
 | 31 | class Declaration;
 | 
|---|
 | 32 | class Expression;
 | 
|---|
 | 33 | class FinallyStmt;
 | 
|---|
| [51b73452] | 34 | 
 | 
|---|
| [294647b] | 35 | class Statement : public BaseSyntaxNode {
 | 
|---|
| [0dd3a2f] | 36 |   public:
 | 
|---|
| [65cdc1e] | 37 |         std::list<Label> labels;
 | 
|---|
 | 38 | 
 | 
|---|
| [ba3706f] | 39 |         Statement( const std::list<Label> & labels = {} );
 | 
|---|
| [0dd3a2f] | 40 |         virtual ~Statement();
 | 
|---|
| [51b73452] | 41 | 
 | 
|---|
| [0dd3a2f] | 42 |         std::list<Label> & get_labels() { return labels; }
 | 
|---|
| [de62360d] | 43 |         const std::list<Label> & get_labels() const { return labels; }
 | 
|---|
| [51b73452] | 44 | 
 | 
|---|
| [fa16264] | 45 |         virtual Statement *clone() const override = 0;
 | 
|---|
| [e149f77] | 46 |         virtual void accept( Visitor &v ) override = 0;
 | 
|---|
| [fa16264] | 47 |         virtual Statement *acceptMutator( Mutator &m ) override = 0;
 | 
|---|
| [50377a4] | 48 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [51b73452] | 49 | };
 | 
|---|
 | 50 | 
 | 
|---|
| [0dd3a2f] | 51 | class CompoundStmt : public Statement {
 | 
|---|
 | 52 |   public:
 | 
|---|
| [65cdc1e] | 53 |         std::list<Statement*> kids;
 | 
|---|
 | 54 | 
 | 
|---|
| [ba3706f] | 55 |         CompoundStmt();
 | 
|---|
| [a2dbad10] | 56 |         CompoundStmt( std::list<Statement *> stmts );
 | 
|---|
| [0dd3a2f] | 57 |         CompoundStmt( const CompoundStmt &other );
 | 
|---|
 | 58 |         virtual ~CompoundStmt();
 | 
|---|
| [51b73452] | 59 | 
 | 
|---|
| [0dd3a2f] | 60 |         std::list<Statement*>& get_kids() { return kids; }
 | 
|---|
| [c8dfcd3] | 61 |         void push_back( Statement * stmt ) { kids.push_back( stmt ); }
 | 
|---|
 | 62 |         void push_front( Statement * stmt ) { kids.push_front( stmt ); }
 | 
|---|
| [51b73452] | 63 | 
 | 
|---|
| [e149f77] | 64 |         virtual CompoundStmt *clone() const override { return new CompoundStmt( *this ); }
 | 
|---|
 | 65 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 66 |         virtual CompoundStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 67 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [51b73452] | 68 | };
 | 
|---|
 | 69 | 
 | 
|---|
| [70d826cd] | 70 | class NullStmt : public Statement {
 | 
|---|
| [daf1af8] | 71 |   public:
 | 
|---|
| [ba3706f] | 72 |         NullStmt( const std::list<Label> & labels = {} );
 | 
|---|
| [daf1af8] | 73 | 
 | 
|---|
| [e149f77] | 74 |         virtual NullStmt *clone() const override { return new NullStmt( *this ); }
 | 
|---|
 | 75 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 76 |         virtual NullStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 77 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [daf1af8] | 78 | };
 | 
|---|
 | 79 | 
 | 
|---|
| [0dd3a2f] | 80 | class ExprStmt : public Statement {
 | 
|---|
 | 81 |   public:
 | 
|---|
| [65cdc1e] | 82 |         Expression *expr;
 | 
|---|
 | 83 | 
 | 
|---|
| [ba3706f] | 84 |         ExprStmt( Expression *expr );
 | 
|---|
| [3be261a] | 85 |         ExprStmt( const ExprStmt &other );
 | 
|---|
| [0dd3a2f] | 86 |         virtual ~ExprStmt();
 | 
|---|
| [51b73452] | 87 | 
 | 
|---|
| [0dd3a2f] | 88 |         Expression *get_expr() { return expr; }
 | 
|---|
 | 89 |         void set_expr( Expression *newValue ) { expr = newValue; }
 | 
|---|
| [51b73452] | 90 | 
 | 
|---|
| [e149f77] | 91 |         virtual ExprStmt *clone() const override { return new ExprStmt( *this ); }
 | 
|---|
 | 92 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 93 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 94 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [0dd3a2f] | 95 | };
 | 
|---|
| [51b73452] | 96 | 
 | 
|---|
| [7f5566b] | 97 | class AsmStmt : public Statement {
 | 
|---|
 | 98 |   public:
 | 
|---|
| [65cdc1e] | 99 |         bool voltile;
 | 
|---|
| [e612146c] | 100 |         Expression *instruction;
 | 
|---|
| [65cdc1e] | 101 |         std::list<Expression *> output, input;
 | 
|---|
 | 102 |         std::list<ConstantExpr *> clobber;
 | 
|---|
 | 103 |         std::list<Label> gotolabels;
 | 
|---|
 | 104 | 
 | 
|---|
| [ba3706f] | 105 |         AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
 | 
|---|
| [3be261a] | 106 |         AsmStmt( const AsmStmt &other );
 | 
|---|
| [7f5566b] | 107 |         virtual ~AsmStmt();
 | 
|---|
 | 108 | 
 | 
|---|
 | 109 |         bool get_voltile() { return voltile; }
 | 
|---|
 | 110 |         void set_voltile( bool newValue ) { voltile = newValue; }
 | 
|---|
| [e612146c] | 111 |         Expression * get_instruction() { return instruction; }
 | 
|---|
 | 112 |         void set_instruction( Expression * newValue ) { instruction = newValue; }
 | 
|---|
 | 113 |         std::list<Expression *> & get_output() { return output; }
 | 
|---|
 | 114 |         void set_output( const std::list<Expression *> & newValue ) { output = newValue; }
 | 
|---|
 | 115 |         std::list<Expression *> & get_input() { return input; }
 | 
|---|
| [7f5566b] | 116 |         void set_input( const std::list<Expression *> &newValue ) { input = newValue; }
 | 
|---|
| [e612146c] | 117 |         std::list<ConstantExpr *> & get_clobber() { return clobber; }
 | 
|---|
| [7f5566b] | 118 |         void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; }
 | 
|---|
| [e612146c] | 119 |         std::list<Label> & get_gotolabels() { return gotolabels; }
 | 
|---|
| [7f5566b] | 120 |         void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; }
 | 
|---|
 | 121 | 
 | 
|---|
| [e612146c] | 122 |         virtual AsmStmt * clone() const { return new AsmStmt( *this ); }
 | 
|---|
 | 123 |         virtual void accept( Visitor & v ) { v.visit( this ); }
 | 
|---|
 | 124 |         virtual Statement * acceptMutator( Mutator & m ) { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 125 |         virtual void print( std::ostream & os, Indenter indent = {} ) const;
 | 
|---|
| [7f5566b] | 126 | };
 | 
|---|
 | 127 | 
 | 
|---|
| [cc32d83] | 128 | class DirectiveStmt : public Statement {
 | 
|---|
 | 129 |         public:
 | 
|---|
 | 130 |         std::string directive;
 | 
|---|
 | 131 | 
 | 
|---|
 | 132 |         DirectiveStmt( const std::string & );
 | 
|---|
 | 133 |         virtual ~DirectiveStmt(){}
 | 
|---|
 | 134 | 
 | 
|---|
 | 135 |         virtual DirectiveStmt * clone() const { return new DirectiveStmt( *this ); }
 | 
|---|
 | 136 |         virtual void accept( Visitor & v ) { v.visit( this ); }
 | 
|---|
 | 137 |         virtual Statement * acceptMutator( Mutator & m ) { return m.mutate( this ); }
 | 
|---|
 | 138 |         virtual void print( std::ostream & os, Indenter indent = {} ) const;
 | 
|---|
 | 139 | };
 | 
|---|
 | 140 | 
 | 
|---|
| [0dd3a2f] | 141 | class IfStmt : public Statement {
 | 
|---|
 | 142 |   public:
 | 
|---|
| [65cdc1e] | 143 |         Expression *condition;
 | 
|---|
 | 144 |         Statement *thenPart;
 | 
|---|
 | 145 |         Statement *elsePart;
 | 
|---|
| [6d49ea3] | 146 |         std::list<Statement *> initialization;
 | 
|---|
| [65cdc1e] | 147 | 
 | 
|---|
| [ba3706f] | 148 |         IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart,
 | 
|---|
| [6d49ea3] | 149 |                         std::list<Statement *> initialization = std::list<Statement *>() );
 | 
|---|
| [3be261a] | 150 |         IfStmt( const IfStmt &other );
 | 
|---|
| [0dd3a2f] | 151 |         virtual ~IfStmt();
 | 
|---|
 | 152 | 
 | 
|---|
| [936e9f4] | 153 |         std::list<Statement *> &get_initialization() { return initialization; }
 | 
|---|
| [0dd3a2f] | 154 |         Expression *get_condition() { return condition; }
 | 
|---|
 | 155 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
 | 156 |         Statement *get_thenPart() { return thenPart; }
 | 
|---|
 | 157 |         void set_thenPart( Statement *newValue ) { thenPart = newValue; }
 | 
|---|
 | 158 |         Statement *get_elsePart() { return elsePart; }
 | 
|---|
 | 159 |         void set_elsePart( Statement *newValue ) { elsePart = newValue; }
 | 
|---|
| [3be261a] | 160 | 
 | 
|---|
| [e149f77] | 161 |         virtual IfStmt *clone() const override { return new IfStmt( *this ); }
 | 
|---|
 | 162 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 163 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 164 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [51b73452] | 165 | };
 | 
|---|
 | 166 | 
 | 
|---|
| [0dd3a2f] | 167 | class SwitchStmt : public Statement {
 | 
|---|
 | 168 |   public:
 | 
|---|
| [65cdc1e] | 169 |         Expression * condition;
 | 
|---|
| [871cdb4] | 170 |         std::list<Statement *> statements;
 | 
|---|
| [65cdc1e] | 171 | 
 | 
|---|
| [ba3706f] | 172 |         SwitchStmt( Expression *condition, const std::list<Statement *> &statements );
 | 
|---|
| [3be261a] | 173 |         SwitchStmt( const SwitchStmt &other );
 | 
|---|
| [0dd3a2f] | 174 |         virtual ~SwitchStmt();
 | 
|---|
| [51b73452] | 175 | 
 | 
|---|
| [0dd3a2f] | 176 |         Expression *get_condition() { return condition; }
 | 
|---|
 | 177 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
| [51b73452] | 178 | 
 | 
|---|
| [8688ce1] | 179 |         std::list<Statement *> & get_statements() { return statements; }
 | 
|---|
| [51b73452] | 180 | 
 | 
|---|
| [e149f77] | 181 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 182 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [51b73452] | 183 | 
 | 
|---|
| [e149f77] | 184 |         virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); }
 | 
|---|
| [50377a4] | 185 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [871cdb4] | 186 | 
 | 
|---|
| [51b73452] | 187 | };
 | 
|---|
 | 188 | 
 | 
|---|
| [0dd3a2f] | 189 | class CaseStmt : public Statement {
 | 
|---|
 | 190 |   public:
 | 
|---|
| [65cdc1e] | 191 |         Expression * condition;
 | 
|---|
 | 192 |         std::list<Statement *> stmts;
 | 
|---|
 | 193 | 
 | 
|---|
| [a16764a6] | 194 |         CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw (SemanticErrorException);
 | 
|---|
| [3be261a] | 195 |         CaseStmt( const CaseStmt &other );
 | 
|---|
| [0dd3a2f] | 196 |         virtual ~CaseStmt();
 | 
|---|
 | 197 | 
 | 
|---|
| [ba3706f] | 198 |         static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() );
 | 
|---|
| [b2152e7a] | 199 | 
 | 
|---|
| [de62360d] | 200 |         bool isDefault() const { return _isDefault; }
 | 
|---|
| [0dd3a2f] | 201 |         void set_default(bool b) { _isDefault = b; }
 | 
|---|
 | 202 | 
 | 
|---|
 | 203 |         Expression * &get_condition() { return condition; }
 | 
|---|
 | 204 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
 | 205 | 
 | 
|---|
 | 206 |         std::list<Statement *> &get_statements() { return stmts; }
 | 
|---|
 | 207 |         void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
 | 
|---|
| [3be261a] | 208 | 
 | 
|---|
| [e149f77] | 209 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 210 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [0dd3a2f] | 211 | 
 | 
|---|
| [e149f77] | 212 |         virtual CaseStmt *clone() const override { return new CaseStmt( *this ); }
 | 
|---|
| [50377a4] | 213 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [0dd3a2f] | 214 |   private:
 | 
|---|
 | 215 |         bool _isDefault;
 | 
|---|
| [51b73452] | 216 | };
 | 
|---|
 | 217 | 
 | 
|---|
| [0dd3a2f] | 218 | class WhileStmt : public Statement {
 | 
|---|
 | 219 |   public:
 | 
|---|
| [65cdc1e] | 220 |         Expression *condition;
 | 
|---|
 | 221 |         Statement *body;
 | 
|---|
| [ee3c93d] | 222 |         std::list<Statement *> initialization;
 | 
|---|
| [65cdc1e] | 223 |         bool isDoWhile;
 | 
|---|
 | 224 | 
 | 
|---|
| [ba3706f] | 225 |         WhileStmt( Expression *condition,
 | 
|---|
| [ee3c93d] | 226 |                Statement *body, std::list<Statement *> & initialization, bool isDoWhile = false );
 | 
|---|
| [3be261a] | 227 |         WhileStmt( const WhileStmt &other );
 | 
|---|
| [0dd3a2f] | 228 |         virtual ~WhileStmt();
 | 
|---|
 | 229 | 
 | 
|---|
 | 230 |         Expression *get_condition() { return condition; }
 | 
|---|
 | 231 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
 | 232 |         Statement *get_body() { return body; }
 | 
|---|
 | 233 |         void set_body( Statement *newValue ) { body = newValue; }
 | 
|---|
 | 234 |         bool get_isDoWhile() { return isDoWhile; }
 | 
|---|
 | 235 |         void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
 | 
|---|
| [3be261a] | 236 | 
 | 
|---|
| [e149f77] | 237 |         virtual WhileStmt *clone() const override { return new WhileStmt( *this ); }
 | 
|---|
 | 238 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 239 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 240 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [51b73452] | 241 | };
 | 
|---|
 | 242 | 
 | 
|---|
| [0dd3a2f] | 243 | class ForStmt : public Statement {
 | 
|---|
 | 244 |   public:
 | 
|---|
| [65cdc1e] | 245 |         std::list<Statement *> initialization;
 | 
|---|
 | 246 |         Expression *condition;
 | 
|---|
 | 247 |         Expression *increment;
 | 
|---|
 | 248 |         Statement *body;
 | 
|---|
 | 249 | 
 | 
|---|
| [ba3706f] | 250 |         ForStmt( std::list<Statement *> initialization,
 | 
|---|
| [0dd3a2f] | 251 |              Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
 | 
|---|
| [3be261a] | 252 |         ForStmt( const ForStmt &other );
 | 
|---|
| [0dd3a2f] | 253 |         virtual ~ForStmt();
 | 
|---|
 | 254 | 
 | 
|---|
| [145f1fc] | 255 |         std::list<Statement *> &get_initialization() { return initialization; }
 | 
|---|
| [0dd3a2f] | 256 |         Expression *get_condition() { return condition; }
 | 
|---|
 | 257 |         void set_condition( Expression *newValue ) { condition = newValue; }
 | 
|---|
 | 258 |         Expression *get_increment() { return increment; }
 | 
|---|
 | 259 |         void set_increment( Expression *newValue ) { increment = newValue; }
 | 
|---|
 | 260 |         Statement *get_body() { return body; }
 | 
|---|
 | 261 |         void set_body( Statement *newValue ) { body = newValue; }
 | 
|---|
| [3be261a] | 262 | 
 | 
|---|
| [e149f77] | 263 |         virtual ForStmt *clone() const override { return new ForStmt( *this ); }
 | 
|---|
 | 264 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 265 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 266 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [51b73452] | 267 | };
 | 
|---|
 | 268 | 
 | 
|---|
| [0dd3a2f] | 269 | class BranchStmt : public Statement {
 | 
|---|
 | 270 |   public:
 | 
|---|
| [6a276a0] | 271 |         enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault };
 | 
|---|
| [0dd3a2f] | 272 | 
 | 
|---|
| [65cdc1e] | 273 |         // originalTarget kept for error messages.
 | 
|---|
 | 274 |         const Label originalTarget;
 | 
|---|
 | 275 |         Label target;
 | 
|---|
 | 276 |         Expression *computedTarget;
 | 
|---|
 | 277 |         Type type;
 | 
|---|
 | 278 | 
 | 
|---|
| [a16764a6] | 279 |         BranchStmt( Label target, Type ) throw (SemanticErrorException);
 | 
|---|
 | 280 |         BranchStmt( Expression *computedTarget, Type ) throw (SemanticErrorException);
 | 
|---|
| [0dd3a2f] | 281 | 
 | 
|---|
| [be5aa1b] | 282 |         Label get_originalTarget() { return originalTarget; }
 | 
|---|
| [0dd3a2f] | 283 |         Label get_target() { return target; }
 | 
|---|
 | 284 |         void set_target( Label newValue ) { target = newValue; }
 | 
|---|
| [3be261a] | 285 | 
 | 
|---|
| [0dd3a2f] | 286 |         Expression *get_computedTarget() { return computedTarget; }
 | 
|---|
 | 287 |         void set_target( Expression * newValue ) { computedTarget = newValue; }
 | 
|---|
 | 288 | 
 | 
|---|
 | 289 |         Type get_type() { return type; }
 | 
|---|
 | 290 |         const char *get_typename() { return brType[ type ]; }
 | 
|---|
 | 291 | 
 | 
|---|
| [e149f77] | 292 |         virtual BranchStmt *clone() const override { return new BranchStmt( *this ); }
 | 
|---|
 | 293 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 294 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 295 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [0dd3a2f] | 296 |   private:
 | 
|---|
 | 297 |         static const char *brType[];
 | 
|---|
| [51b73452] | 298 | };
 | 
|---|
 | 299 | 
 | 
|---|
| [0dd3a2f] | 300 | class ReturnStmt : public Statement {
 | 
|---|
 | 301 |   public:
 | 
|---|
| [65cdc1e] | 302 |         Expression *expr;
 | 
|---|
 | 303 | 
 | 
|---|
| [ba3706f] | 304 |         ReturnStmt( Expression *expr );
 | 
|---|
| [3be261a] | 305 |         ReturnStmt( const ReturnStmt &other );
 | 
|---|
| [0dd3a2f] | 306 |         virtual ~ReturnStmt();
 | 
|---|
 | 307 | 
 | 
|---|
 | 308 |         Expression *get_expr() { return expr; }
 | 
|---|
 | 309 |         void set_expr( Expression *newValue ) { expr = newValue; }
 | 
|---|
| [3be261a] | 310 | 
 | 
|---|
| [e149f77] | 311 |         virtual ReturnStmt *clone() const override { return new ReturnStmt( *this ); }
 | 
|---|
 | 312 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 313 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 314 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [51b73452] | 315 | };
 | 
|---|
 | 316 | 
 | 
|---|
| [daf1af8] | 317 | class ThrowStmt : public Statement {
 | 
|---|
| [0dd3a2f] | 318 |   public:
 | 
|---|
| [daf1af8] | 319 |         enum Kind { Terminate, Resume };
 | 
|---|
| [51b73452] | 320 | 
 | 
|---|
| [65cdc1e] | 321 |         const Kind kind;
 | 
|---|
 | 322 |         Expression * expr;
 | 
|---|
 | 323 |         Expression * target;
 | 
|---|
 | 324 | 
 | 
|---|
| [ba3706f] | 325 |         ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr );
 | 
|---|
| [daf1af8] | 326 |         ThrowStmt( const ThrowStmt &other );
 | 
|---|
 | 327 |         virtual ~ThrowStmt();
 | 
|---|
 | 328 | 
 | 
|---|
 | 329 |         Kind get_kind() { return kind; }
 | 
|---|
 | 330 |         Expression * get_expr() { return expr; }
 | 
|---|
 | 331 |         void set_expr( Expression * newExpr ) { expr = newExpr; }
 | 
|---|
 | 332 |         Expression * get_target() { return target; }
 | 
|---|
 | 333 |         void set_target( Expression * newTarget ) { target = newTarget; }
 | 
|---|
 | 334 | 
 | 
|---|
| [e149f77] | 335 |         virtual ThrowStmt *clone() const override { return new ThrowStmt( *this ); }
 | 
|---|
 | 336 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 337 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 338 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [51b73452] | 339 | };
 | 
|---|
 | 340 | 
 | 
|---|
| [3be261a] | 341 | class TryStmt : public Statement {
 | 
|---|
| [0dd3a2f] | 342 |   public:
 | 
|---|
| [871cdb4] | 343 |         CompoundStmt * block;
 | 
|---|
| [65cdc1e] | 344 |         std::list<CatchStmt *> handlers;
 | 
|---|
| [871cdb4] | 345 |         FinallyStmt * finallyBlock;
 | 
|---|
| [65cdc1e] | 346 | 
 | 
|---|
| [ba3706f] | 347 |         TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
 | 
|---|
| [0dd3a2f] | 348 |         TryStmt( const TryStmt &other );
 | 
|---|
 | 349 |         virtual ~TryStmt();
 | 
|---|
 | 350 | 
 | 
|---|
 | 351 |         CompoundStmt *get_block() const { return block; }
 | 
|---|
 | 352 |         void set_block( CompoundStmt *newValue ) { block = newValue; }
 | 
|---|
| [046e04a] | 353 |         std::list<CatchStmt *>& get_catchers() { return handlers; }
 | 
|---|
| [0dd3a2f] | 354 | 
 | 
|---|
 | 355 |         FinallyStmt *get_finally() const { return finallyBlock; }
 | 
|---|
 | 356 |         void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
 | 
|---|
 | 357 | 
 | 
|---|
| [e149f77] | 358 |         virtual TryStmt *clone() const override { return new TryStmt( *this ); }
 | 
|---|
 | 359 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 360 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 361 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [3be261a] | 362 | };
 | 
|---|
| [51b73452] | 363 | 
 | 
|---|
| [0dd3a2f] | 364 | class CatchStmt : public Statement {
 | 
|---|
 | 365 |   public:
 | 
|---|
| [ca78437] | 366 |         enum Kind { Terminate, Resume };
 | 
|---|
 | 367 | 
 | 
|---|
| [65cdc1e] | 368 |         const Kind kind;
 | 
|---|
 | 369 |         Declaration *decl;
 | 
|---|
 | 370 |         Expression *cond;
 | 
|---|
 | 371 |         Statement *body;
 | 
|---|
 | 372 | 
 | 
|---|
| [ba3706f] | 373 |         CatchStmt( Kind kind, Declaration *decl,
 | 
|---|
| [ca78437] | 374 |                    Expression *cond, Statement *body );
 | 
|---|
| [3be261a] | 375 |         CatchStmt( const CatchStmt &other );
 | 
|---|
| [0dd3a2f] | 376 |         virtual ~CatchStmt();
 | 
|---|
 | 377 | 
 | 
|---|
| [ca78437] | 378 |         Kind get_kind() { return kind; }
 | 
|---|
| [0dd3a2f] | 379 |         Declaration *get_decl() { return decl; }
 | 
|---|
 | 380 |         void set_decl( Declaration *newValue ) { decl = newValue; }
 | 
|---|
| [ca78437] | 381 |         Expression *get_cond() { return cond; }
 | 
|---|
 | 382 |         void set_cond( Expression *newCond ) { cond = newCond; }
 | 
|---|
| [0dd3a2f] | 383 |         Statement *get_body() { return body; }
 | 
|---|
 | 384 |         void set_body( Statement *newValue ) { body = newValue; }
 | 
|---|
| [3be261a] | 385 | 
 | 
|---|
| [e149f77] | 386 |         virtual CatchStmt *clone() const override { return new CatchStmt( *this ); }
 | 
|---|
 | 387 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 388 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 389 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [51b73452] | 390 | };
 | 
|---|
 | 391 | 
 | 
|---|
| [3be261a] | 392 | class FinallyStmt : public Statement {
 | 
|---|
| [0dd3a2f] | 393 |   public:
 | 
|---|
| [65cdc1e] | 394 |         CompoundStmt *block;
 | 
|---|
 | 395 | 
 | 
|---|
| [ba3706f] | 396 |         FinallyStmt( CompoundStmt *block );
 | 
|---|
| [3be261a] | 397 |         FinallyStmt( const FinallyStmt &other );
 | 
|---|
| [0dd3a2f] | 398 |         virtual ~FinallyStmt();
 | 
|---|
 | 399 | 
 | 
|---|
 | 400 |         CompoundStmt *get_block() const { return block; }
 | 
|---|
 | 401 |         void set_block( CompoundStmt *newValue ) { block = newValue; }
 | 
|---|
| [3be261a] | 402 | 
 | 
|---|
| [e149f77] | 403 |         virtual FinallyStmt *clone() const override { return new FinallyStmt( *this ); }
 | 
|---|
 | 404 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 405 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 406 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [3be261a] | 407 | };
 | 
|---|
| [51b73452] | 408 | 
 | 
|---|
| [135b431] | 409 | class WaitForStmt : public Statement {
 | 
|---|
 | 410 |   public:
 | 
|---|
 | 411 | 
 | 
|---|
 | 412 |         struct Target {
 | 
|---|
 | 413 |                 Expression * function;
 | 
|---|
 | 414 |                 std::list<Expression * > arguments;
 | 
|---|
 | 415 |         };
 | 
|---|
 | 416 | 
 | 
|---|
 | 417 |         struct Clause {
 | 
|---|
 | 418 |                 Target       target;
 | 
|---|
 | 419 |                 Statement  * statement;
 | 
|---|
 | 420 |                 Expression * condition;
 | 
|---|
 | 421 |         };
 | 
|---|
 | 422 | 
 | 
|---|
| [ba3706f] | 423 |         WaitForStmt();
 | 
|---|
| [135b431] | 424 |         WaitForStmt( const WaitForStmt & );
 | 
|---|
 | 425 |         virtual ~WaitForStmt();
 | 
|---|
 | 426 | 
 | 
|---|
 | 427 |         std::vector<Clause> clauses;
 | 
|---|
 | 428 | 
 | 
|---|
 | 429 |         struct {
 | 
|---|
 | 430 |                 Expression * time;
 | 
|---|
 | 431 |                 Statement  * statement;
 | 
|---|
 | 432 |                 Expression * condition;
 | 
|---|
 | 433 |         } timeout;
 | 
|---|
 | 434 | 
 | 
|---|
 | 435 |         struct {
 | 
|---|
 | 436 |                 Statement  * statement;
 | 
|---|
 | 437 |                 Expression * condition;
 | 
|---|
 | 438 |         } orelse;
 | 
|---|
 | 439 | 
 | 
|---|
| [e149f77] | 440 |         virtual WaitForStmt *clone() const override { return new WaitForStmt( *this ); }
 | 
|---|
 | 441 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 442 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 443 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [135b431] | 444 | 
 | 
|---|
 | 445 | };
 | 
|---|
 | 446 | 
 | 
|---|
| [61255ad] | 447 | class WithStmt : public Statement {
 | 
|---|
 | 448 | public:
 | 
|---|
 | 449 |         std::list< Expression * > exprs;
 | 
|---|
 | 450 |         Statement * stmt;
 | 
|---|
 | 451 | 
 | 
|---|
 | 452 |         WithStmt( const std::list< Expression * > & exprs, Statement * stmt );
 | 
|---|
 | 453 |         WithStmt( const WithStmt & other );
 | 
|---|
 | 454 |         virtual ~WithStmt();
 | 
|---|
 | 455 | 
 | 
|---|
 | 456 |         virtual WithStmt * clone() const override { return new WithStmt( *this ); }
 | 
|---|
 | 457 |         virtual void accept( Visitor & v ) override { v.visit( this ); }
 | 
|---|
 | 458 |         virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
 | 
|---|
 | 459 |         virtual void print( std::ostream & os, Indenter indent = {} ) const override;
 | 
|---|
 | 460 | };
 | 
|---|
 | 461 | 
 | 
|---|
| [51b73452] | 462 | 
 | 
|---|
 | 463 | // represents a declaration that occurs as part of a compound statement
 | 
|---|
| [0dd3a2f] | 464 | class DeclStmt : public Statement {
 | 
|---|
 | 465 |   public:
 | 
|---|
| [65cdc1e] | 466 |         Declaration *decl;
 | 
|---|
 | 467 | 
 | 
|---|
| [ba3706f] | 468 |         DeclStmt( Declaration *decl );
 | 
|---|
| [0dd3a2f] | 469 |         DeclStmt( const DeclStmt &other );
 | 
|---|
 | 470 |         virtual ~DeclStmt();
 | 
|---|
 | 471 | 
 | 
|---|
| [f1b1e4c] | 472 |         Declaration *get_decl() const { return decl; }
 | 
|---|
| [0dd3a2f] | 473 |         void set_decl( Declaration *newValue ) { decl = newValue; }
 | 
|---|
 | 474 | 
 | 
|---|
| [e149f77] | 475 |         virtual DeclStmt *clone() const override { return new DeclStmt( *this ); }
 | 
|---|
 | 476 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 477 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 478 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [51b73452] | 479 | };
 | 
|---|
 | 480 | 
 | 
|---|
| [f1b1e4c] | 481 | 
 | 
|---|
 | 482 | /// represents an implicit application of a constructor or destructor. Qualifiers are replaced
 | 
|---|
 | 483 | /// immediately before and after the call so that qualified objects can be constructed
 | 
|---|
 | 484 | /// with the same functions as unqualified objects.
 | 
|---|
 | 485 | class ImplicitCtorDtorStmt : public Statement {
 | 
|---|
 | 486 |   public:
 | 
|---|
| [65cdc1e] | 487 |         // Non-owned pointer to the constructor/destructor statement
 | 
|---|
 | 488 |         Statement * callStmt;
 | 
|---|
 | 489 | 
 | 
|---|
| [f1b1e4c] | 490 |         ImplicitCtorDtorStmt( Statement * callStmt );
 | 
|---|
 | 491 |         ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
 | 
|---|
 | 492 |         virtual ~ImplicitCtorDtorStmt();
 | 
|---|
 | 493 | 
 | 
|---|
 | 494 |         Statement *get_callStmt() const { return callStmt; }
 | 
|---|
 | 495 |         void set_callStmt( Statement * newValue ) { callStmt = newValue; }
 | 
|---|
 | 496 | 
 | 
|---|
| [e149f77] | 497 |         virtual ImplicitCtorDtorStmt *clone() const override { return new ImplicitCtorDtorStmt( *this ); }
 | 
|---|
 | 498 |         virtual void accept( Visitor &v ) override { v.visit( this ); }
 | 
|---|
 | 499 |         virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
 | 
|---|
| [50377a4] | 500 |         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
 | 
|---|
| [f1b1e4c] | 501 | };
 | 
|---|
 | 502 | 
 | 
|---|
| [0dd3a2f] | 503 | // Local Variables: //
 | 
|---|
 | 504 | // tab-width: 4 //
 | 
|---|
 | 505 | // mode: c++ //
 | 
|---|
 | 506 | // compile-command: "make install" //
 | 
|---|
 | 507 | // End: //
 | 
|---|