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