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