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