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