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 : Wed Feb 2 20:15:30 2022 |
---|
13 | // Update Count : 98 |
---|
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( const 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 void accept( Visitor & v ) const override = 0; |
---|
48 | virtual Statement * acceptMutator( Mutator & m ) override = 0; |
---|
49 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
50 | }; |
---|
51 | |
---|
52 | class CompoundStmt : public Statement { |
---|
53 | public: |
---|
54 | std::list<Statement*> kids; |
---|
55 | |
---|
56 | CompoundStmt(); |
---|
57 | CompoundStmt( std::list<Statement *> stmts ); |
---|
58 | CompoundStmt( const CompoundStmt & other ); |
---|
59 | virtual ~CompoundStmt(); |
---|
60 | |
---|
61 | std::list<Statement*>& get_kids() { return kids; } |
---|
62 | void push_back( Statement * stmt ) { kids.push_back( stmt ); } |
---|
63 | void push_front( Statement * stmt ) { kids.push_front( stmt ); } |
---|
64 | |
---|
65 | virtual CompoundStmt * clone() const override { return new CompoundStmt( *this ); } |
---|
66 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
67 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
68 | virtual CompoundStmt * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
69 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
70 | }; |
---|
71 | |
---|
72 | class NullStmt : public Statement { |
---|
73 | public: |
---|
74 | NullStmt( const std::list<Label> & labels = {} ); |
---|
75 | |
---|
76 | virtual NullStmt * clone() const override { return new NullStmt( *this ); } |
---|
77 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
78 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
79 | virtual NullStmt * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
80 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
81 | }; |
---|
82 | |
---|
83 | class ExprStmt : public Statement { |
---|
84 | public: |
---|
85 | Expression * expr; |
---|
86 | |
---|
87 | ExprStmt( Expression * expr ); |
---|
88 | ExprStmt( const ExprStmt & other ); |
---|
89 | virtual ~ExprStmt(); |
---|
90 | |
---|
91 | Expression * get_expr() { return expr; } |
---|
92 | void set_expr( Expression * newValue ) { expr = newValue; } |
---|
93 | |
---|
94 | virtual ExprStmt * clone() const override { return new ExprStmt( *this ); } |
---|
95 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
96 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
97 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
98 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
99 | }; |
---|
100 | |
---|
101 | class AsmStmt : public Statement { |
---|
102 | public: |
---|
103 | bool voltile; |
---|
104 | Expression * instruction; |
---|
105 | std::list<Expression *> output, input; |
---|
106 | std::list<ConstantExpr *> clobber; |
---|
107 | std::list<Label> gotolabels; |
---|
108 | |
---|
109 | AsmStmt( bool voltile, Expression * instruction, const std::list<Expression *> output, const std::list<Expression *> input, const std::list<ConstantExpr *> clobber, const std::list<Label> gotolabels ); |
---|
110 | AsmStmt( const AsmStmt & other ); |
---|
111 | virtual ~AsmStmt(); |
---|
112 | |
---|
113 | bool get_voltile() { return voltile; } |
---|
114 | void set_voltile( bool newValue ) { voltile = newValue; } |
---|
115 | Expression * get_instruction() { return instruction; } |
---|
116 | void set_instruction( Expression * newValue ) { instruction = newValue; } |
---|
117 | std::list<Expression *> & get_output() { return output; } |
---|
118 | void set_output( const std::list<Expression *> & newValue ) { output = newValue; } |
---|
119 | std::list<Expression *> & get_input() { return input; } |
---|
120 | void set_input( const std::list<Expression *> & newValue ) { input = newValue; } |
---|
121 | std::list<ConstantExpr *> & get_clobber() { return clobber; } |
---|
122 | void set_clobber( const std::list<ConstantExpr *> & newValue ) { clobber = newValue; } |
---|
123 | std::list<Label> & get_gotolabels() { return gotolabels; } |
---|
124 | void set_gotolabels( const std::list<Label> & newValue ) { gotolabels = newValue; } |
---|
125 | |
---|
126 | virtual AsmStmt * clone() const override { return new AsmStmt( *this ); } |
---|
127 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
128 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
129 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
130 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
131 | }; |
---|
132 | |
---|
133 | class DirectiveStmt : public Statement { |
---|
134 | public: |
---|
135 | std::string directive; |
---|
136 | |
---|
137 | DirectiveStmt( const std::string & ); |
---|
138 | virtual ~DirectiveStmt(){} |
---|
139 | |
---|
140 | virtual DirectiveStmt * clone() const override { return new DirectiveStmt( *this ); } |
---|
141 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
142 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
143 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
144 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
145 | }; |
---|
146 | |
---|
147 | class IfStmt : public Statement { |
---|
148 | public: |
---|
149 | Expression * condition; |
---|
150 | Statement * then; |
---|
151 | Statement * else_; |
---|
152 | std::list<Statement *> initialization; |
---|
153 | |
---|
154 | IfStmt( Expression * condition, Statement * then, Statement * else_, |
---|
155 | const std::list<Statement *> initialization = std::list<Statement *>() ); |
---|
156 | IfStmt( const IfStmt & other ); |
---|
157 | virtual ~IfStmt(); |
---|
158 | |
---|
159 | std::list<Statement *> & get_initialization() { return initialization; } |
---|
160 | Expression * get_condition() { return condition; } |
---|
161 | void set_condition( Expression * newValue ) { condition = newValue; } |
---|
162 | Statement * get_then() { return then; } |
---|
163 | void set_then( Statement * newValue ) { then = newValue; } |
---|
164 | Statement * get_else() { return else_; } |
---|
165 | void set_else( Statement * newValue ) { else_ = newValue; } |
---|
166 | |
---|
167 | virtual IfStmt * clone() const override { return new IfStmt( *this ); } |
---|
168 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
169 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
170 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
171 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
172 | }; |
---|
173 | |
---|
174 | class SwitchStmt : public Statement { |
---|
175 | public: |
---|
176 | Expression * condition; |
---|
177 | std::list<Statement *> statements; |
---|
178 | |
---|
179 | SwitchStmt( Expression * condition, const std::list<Statement *> & statements ); |
---|
180 | SwitchStmt( const SwitchStmt & other ); |
---|
181 | virtual ~SwitchStmt(); |
---|
182 | |
---|
183 | Expression * get_condition() { return condition; } |
---|
184 | void set_condition( Expression * newValue ) { condition = newValue; } |
---|
185 | |
---|
186 | std::list<Statement *> & get_statements() { return statements; } |
---|
187 | |
---|
188 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
189 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
190 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
191 | |
---|
192 | virtual SwitchStmt * clone() const override { return new SwitchStmt( *this ); } |
---|
193 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
194 | |
---|
195 | }; |
---|
196 | |
---|
197 | class CaseStmt : public Statement { |
---|
198 | public: |
---|
199 | Expression * condition; |
---|
200 | std::list<Statement *> stmts; |
---|
201 | |
---|
202 | CaseStmt( Expression * conditions, const std::list<Statement *> & stmts, bool isdef = false ); |
---|
203 | CaseStmt( const CaseStmt & other ); |
---|
204 | virtual ~CaseStmt(); |
---|
205 | |
---|
206 | static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() ); |
---|
207 | |
---|
208 | bool isDefault() const { return _isDefault; } |
---|
209 | void set_default(bool b) { _isDefault = b; } |
---|
210 | |
---|
211 | Expression * & get_condition() { return condition; } |
---|
212 | void set_condition( Expression * newValue ) { condition = newValue; } |
---|
213 | |
---|
214 | std::list<Statement *> & get_statements() { return stmts; } |
---|
215 | void set_statements( std::list<Statement *> & newValue ) { stmts = newValue; } |
---|
216 | |
---|
217 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
218 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
219 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
220 | |
---|
221 | virtual CaseStmt * clone() const override { return new CaseStmt( *this ); } |
---|
222 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
223 | private: |
---|
224 | bool _isDefault; |
---|
225 | }; |
---|
226 | |
---|
227 | class WhileDoStmt : public Statement { |
---|
228 | public: |
---|
229 | Expression * condition; |
---|
230 | Statement * body; |
---|
231 | Statement * else_; |
---|
232 | std::list<Statement *> initialization; |
---|
233 | bool isDoWhile; |
---|
234 | |
---|
235 | WhileDoStmt( Expression * condition, Statement * body, const std::list<Statement *> & initialization, bool isDoWhile = false ); |
---|
236 | WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const std::list<Statement *> & initialization, bool isDoWhile = false ); |
---|
237 | WhileDoStmt( const WhileDoStmt & other ); |
---|
238 | virtual ~WhileDoStmt(); |
---|
239 | |
---|
240 | Expression * get_condition() { return condition; } |
---|
241 | void set_condition( Expression * newValue ) { condition = newValue; } |
---|
242 | Statement * get_body() { return body; } |
---|
243 | void set_body( Statement * newValue ) { body = newValue; } |
---|
244 | bool get_isDoWhile() { return isDoWhile; } |
---|
245 | void set_isDoWhile( bool newValue ) { isDoWhile = newValue; } |
---|
246 | |
---|
247 | virtual WhileDoStmt * clone() const override { return new WhileDoStmt( *this ); } |
---|
248 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
249 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
250 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
251 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
252 | }; |
---|
253 | |
---|
254 | class ForStmt : public Statement { |
---|
255 | public: |
---|
256 | std::list<Statement *> initialization; |
---|
257 | Expression * condition; |
---|
258 | Expression * increment; |
---|
259 | Statement * body; |
---|
260 | Statement * else_; |
---|
261 | |
---|
262 | ForStmt( const std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr, Statement * else_ = nullptr ); |
---|
263 | ForStmt( const ForStmt & other ); |
---|
264 | virtual ~ForStmt(); |
---|
265 | |
---|
266 | std::list<Statement *> & get_initialization() { return initialization; } |
---|
267 | Expression * get_condition() { return condition; } |
---|
268 | void set_condition( Expression * newValue ) { condition = newValue; } |
---|
269 | Expression * get_increment() { return increment; } |
---|
270 | void set_increment( Expression * newValue ) { increment = newValue; } |
---|
271 | Statement * get_body() { return body; } |
---|
272 | void set_body( Statement * newValue ) { body = newValue; } |
---|
273 | |
---|
274 | virtual ForStmt * clone() const override { return new ForStmt( *this ); } |
---|
275 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
276 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
277 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
278 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
279 | }; |
---|
280 | |
---|
281 | class BranchStmt : public Statement { |
---|
282 | public: |
---|
283 | enum Type { Goto, Break, Continue, FallThrough, FallThroughDefault, BranchStmts }; |
---|
284 | |
---|
285 | // originalTarget kept for error messages. |
---|
286 | const Label originalTarget; |
---|
287 | Label target; |
---|
288 | Expression * computedTarget; |
---|
289 | Type type; |
---|
290 | |
---|
291 | BranchStmt( Label target, Type ); |
---|
292 | BranchStmt( Expression * computedTarget, Type ); |
---|
293 | |
---|
294 | Label get_originalTarget() { return originalTarget; } |
---|
295 | Label get_target() { return target; } |
---|
296 | void set_target( Label newValue ) { target = newValue; } |
---|
297 | |
---|
298 | Expression * get_computedTarget() { return computedTarget; } |
---|
299 | void set_target( Expression * newValue ) { computedTarget = newValue; } |
---|
300 | |
---|
301 | Type get_type() { return type; } |
---|
302 | const char * get_typename() { return brType[ type ]; } |
---|
303 | |
---|
304 | virtual BranchStmt * clone() const override { return new BranchStmt( *this ); } |
---|
305 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
306 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
307 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
308 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
309 | private: |
---|
310 | static const char * brType[]; |
---|
311 | }; |
---|
312 | |
---|
313 | class ReturnStmt : public Statement { |
---|
314 | public: |
---|
315 | Expression * expr; |
---|
316 | |
---|
317 | ReturnStmt( Expression * expr ); |
---|
318 | ReturnStmt( const ReturnStmt & other ); |
---|
319 | virtual ~ReturnStmt(); |
---|
320 | |
---|
321 | Expression * get_expr() { return expr; } |
---|
322 | void set_expr( Expression * newValue ) { expr = newValue; } |
---|
323 | |
---|
324 | virtual ReturnStmt * clone() const override { return new ReturnStmt( *this ); } |
---|
325 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
326 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
327 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
328 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
329 | }; |
---|
330 | |
---|
331 | class ThrowStmt : public Statement { |
---|
332 | public: |
---|
333 | enum Kind { Terminate, Resume }; |
---|
334 | |
---|
335 | const Kind kind; |
---|
336 | Expression * expr; |
---|
337 | Expression * target; |
---|
338 | |
---|
339 | ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr ); |
---|
340 | ThrowStmt( const ThrowStmt & other ); |
---|
341 | virtual ~ThrowStmt(); |
---|
342 | |
---|
343 | Kind get_kind() { return kind; } |
---|
344 | Expression * get_expr() { return expr; } |
---|
345 | void set_expr( Expression * newExpr ) { expr = newExpr; } |
---|
346 | Expression * get_target() { return target; } |
---|
347 | void set_target( Expression * newTarget ) { target = newTarget; } |
---|
348 | |
---|
349 | virtual ThrowStmt * clone() const override { return new ThrowStmt( *this ); } |
---|
350 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
351 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
352 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
353 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
354 | }; |
---|
355 | |
---|
356 | class TryStmt : public Statement { |
---|
357 | public: |
---|
358 | CompoundStmt * block; |
---|
359 | std::list<CatchStmt *> handlers; |
---|
360 | FinallyStmt * finallyBlock; |
---|
361 | |
---|
362 | TryStmt( CompoundStmt * tryBlock, const std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr ); |
---|
363 | TryStmt( const TryStmt & other ); |
---|
364 | virtual ~TryStmt(); |
---|
365 | |
---|
366 | CompoundStmt * get_block() const { return block; } |
---|
367 | void set_block( CompoundStmt * newValue ) { block = newValue; } |
---|
368 | std::list<CatchStmt *>& get_catchers() { return handlers; } |
---|
369 | |
---|
370 | FinallyStmt * get_finally() const { return finallyBlock; } |
---|
371 | void set_finally( FinallyStmt * newValue ) { finallyBlock = newValue; } |
---|
372 | |
---|
373 | virtual TryStmt * clone() const override { return new TryStmt( *this ); } |
---|
374 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
375 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
376 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
377 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
378 | }; |
---|
379 | |
---|
380 | class CatchStmt : public Statement { |
---|
381 | public: |
---|
382 | enum Kind { Terminate, Resume }; |
---|
383 | |
---|
384 | const Kind kind; |
---|
385 | Declaration * decl; |
---|
386 | Expression * cond; |
---|
387 | Statement * body; |
---|
388 | |
---|
389 | CatchStmt( Kind kind, Declaration * decl, |
---|
390 | Expression * cond, Statement * body ); |
---|
391 | CatchStmt( const CatchStmt & other ); |
---|
392 | virtual ~CatchStmt(); |
---|
393 | |
---|
394 | Kind get_kind() { return kind; } |
---|
395 | Declaration * get_decl() { return decl; } |
---|
396 | void set_decl( Declaration * newValue ) { decl = newValue; } |
---|
397 | Expression * get_cond() { return cond; } |
---|
398 | void set_cond( Expression * newCond ) { cond = newCond; } |
---|
399 | Statement * get_body() { return body; } |
---|
400 | void set_body( Statement * newValue ) { body = newValue; } |
---|
401 | |
---|
402 | virtual CatchStmt * clone() const override { return new CatchStmt( *this ); } |
---|
403 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
404 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
405 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
406 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
407 | }; |
---|
408 | |
---|
409 | class FinallyStmt : public Statement { |
---|
410 | public: |
---|
411 | CompoundStmt * block; |
---|
412 | |
---|
413 | FinallyStmt( CompoundStmt * block ); |
---|
414 | FinallyStmt( const FinallyStmt & other ); |
---|
415 | virtual ~FinallyStmt(); |
---|
416 | |
---|
417 | CompoundStmt * get_block() const { return block; } |
---|
418 | void set_block( CompoundStmt * newValue ) { block = newValue; } |
---|
419 | |
---|
420 | virtual FinallyStmt * clone() const override { return new FinallyStmt( *this ); } |
---|
421 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
422 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
423 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
424 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
425 | }; |
---|
426 | |
---|
427 | class SuspendStmt : public Statement { |
---|
428 | public: |
---|
429 | CompoundStmt * then = nullptr; |
---|
430 | enum Type { None, Coroutine, Generator } type = None; |
---|
431 | |
---|
432 | SuspendStmt() = default; |
---|
433 | SuspendStmt( const SuspendStmt & ); |
---|
434 | virtual ~SuspendStmt(); |
---|
435 | |
---|
436 | virtual SuspendStmt * clone() const override { return new SuspendStmt( *this ); } |
---|
437 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
438 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
439 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
440 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
441 | }; |
---|
442 | |
---|
443 | class WaitForStmt : public Statement { |
---|
444 | public: |
---|
445 | |
---|
446 | struct Target { |
---|
447 | Expression * function; |
---|
448 | std::list<Expression * > arguments; |
---|
449 | }; |
---|
450 | |
---|
451 | struct Clause { |
---|
452 | Target target; |
---|
453 | Statement * statement; |
---|
454 | Expression * condition; |
---|
455 | }; |
---|
456 | |
---|
457 | WaitForStmt(); |
---|
458 | WaitForStmt( const WaitForStmt & ); |
---|
459 | virtual ~WaitForStmt(); |
---|
460 | |
---|
461 | std::vector<Clause> clauses; |
---|
462 | |
---|
463 | struct { |
---|
464 | Expression * time; |
---|
465 | Statement * statement; |
---|
466 | Expression * condition; |
---|
467 | } timeout; |
---|
468 | |
---|
469 | struct { |
---|
470 | Statement * statement; |
---|
471 | Expression * condition; |
---|
472 | } orelse; |
---|
473 | |
---|
474 | virtual WaitForStmt * clone() const override { return new WaitForStmt( *this ); } |
---|
475 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
476 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
477 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
478 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
479 | |
---|
480 | }; |
---|
481 | |
---|
482 | // class WithStmt : public Statement { |
---|
483 | // public: |
---|
484 | // std::list< Expression * > exprs; |
---|
485 | // Statement * stmt; |
---|
486 | |
---|
487 | // WithStmt( const std::list< Expression * > & exprs, Statement * stmt ); |
---|
488 | // WithStmt( const WithStmt & other ); |
---|
489 | // virtual ~WithStmt(); |
---|
490 | |
---|
491 | // virtual WithStmt * clone() const override { return new WithStmt( *this ); } |
---|
492 | // virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
493 | // virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
494 | // virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
495 | // virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
496 | // }; |
---|
497 | |
---|
498 | |
---|
499 | // represents a declaration that occurs as part of a compound statement |
---|
500 | class DeclStmt : public Statement { |
---|
501 | public: |
---|
502 | Declaration * decl; |
---|
503 | |
---|
504 | DeclStmt( Declaration * decl ); |
---|
505 | DeclStmt( const DeclStmt & other ); |
---|
506 | virtual ~DeclStmt(); |
---|
507 | |
---|
508 | Declaration * get_decl() const { return decl; } |
---|
509 | void set_decl( Declaration * newValue ) { decl = newValue; } |
---|
510 | |
---|
511 | virtual DeclStmt * clone() const override { return new DeclStmt( *this ); } |
---|
512 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
513 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
514 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
515 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
516 | }; |
---|
517 | |
---|
518 | |
---|
519 | /// represents an implicit application of a constructor or destructor. Qualifiers are replaced immediately before and |
---|
520 | /// after the call so that qualified objects can be constructed with the same functions as unqualified objects. |
---|
521 | class ImplicitCtorDtorStmt : public Statement { |
---|
522 | public: |
---|
523 | // the constructor/destructor call statement; owned here for a while, eventually transferred elsewhere |
---|
524 | Statement * callStmt; |
---|
525 | |
---|
526 | ImplicitCtorDtorStmt( Statement * callStmt ); |
---|
527 | ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); |
---|
528 | virtual ~ImplicitCtorDtorStmt(); |
---|
529 | |
---|
530 | Statement * get_callStmt() const { return callStmt; } |
---|
531 | void set_callStmt( Statement * newValue ) { callStmt = newValue; } |
---|
532 | |
---|
533 | virtual ImplicitCtorDtorStmt * clone() const override { return new ImplicitCtorDtorStmt( *this ); } |
---|
534 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
535 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
536 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
537 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
538 | }; |
---|
539 | |
---|
540 | class MutexStmt : public Statement { |
---|
541 | public: |
---|
542 | Statement * stmt; |
---|
543 | std::list<Expression *> mutexObjs; // list of mutex objects to acquire |
---|
544 | |
---|
545 | MutexStmt( Statement * stmt, const std::list<Expression *> mutexObjs ); |
---|
546 | MutexStmt( const MutexStmt & other ); |
---|
547 | virtual ~MutexStmt(); |
---|
548 | |
---|
549 | virtual MutexStmt * clone() const override { return new MutexStmt( *this ); } |
---|
550 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
551 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
552 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
553 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
554 | }; |
---|
555 | |
---|
556 | // Local Variables: // |
---|
557 | // tab-width: 4 // |
---|
558 | // mode: c++ // |
---|
559 | // compile-command: "make install" // |
---|
560 | // End: // |
---|