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.cc -- |
---|
8 | // |
---|
9 | // Author : Richard C. Bilson |
---|
10 | // Created On : Mon May 18 07:44:20 2015 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Sun Sep 3 20:46:44 2017 |
---|
13 | // Update Count : 68 |
---|
14 | // |
---|
15 | |
---|
16 | #include "SynTree/Statement.h" |
---|
17 | |
---|
18 | #include <stddef.h> // for NULL |
---|
19 | #include <cassert> // for assert, assertf |
---|
20 | #include <iostream> // for operator<<, basic_ostream, endl |
---|
21 | #include <list> // for list, list<>::const_iterator, _Lis... |
---|
22 | #include <string> // for operator<<, string, char_traits |
---|
23 | |
---|
24 | #include "Common/SemanticError.h" // for SemanticError |
---|
25 | #include "Common/utility.h" // for maybeClone, cloneAll, deleteAll |
---|
26 | #include "Declaration.h" // for Declaration |
---|
27 | #include "Expression.h" // for Expression, ConstantExpr |
---|
28 | #include "Statement.h" // for Statement, ForStmt, AsmStmt, Catch... |
---|
29 | #include "SynTree/Label.h" // for Label, operator<< |
---|
30 | |
---|
31 | using std::string; |
---|
32 | using std::endl; |
---|
33 | |
---|
34 | Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {} |
---|
35 | |
---|
36 | void Statement::print( std::ostream & os, Indenter indent ) const { |
---|
37 | if ( ! labels.empty() ) { |
---|
38 | os << indent << "... Labels: {"; |
---|
39 | for ( const Label & l : labels ) { |
---|
40 | os << l << ","; |
---|
41 | } |
---|
42 | os << "}" << endl; |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | Statement::~Statement() {} |
---|
47 | |
---|
48 | ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {} |
---|
49 | |
---|
50 | ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} |
---|
51 | |
---|
52 | ExprStmt::~ExprStmt() { |
---|
53 | delete expr; |
---|
54 | } |
---|
55 | |
---|
56 | void ExprStmt::print( std::ostream &os, Indenter indent ) const { |
---|
57 | os << "Expression Statement:" << endl << indent+1; |
---|
58 | expr->print( os, indent+1 ); |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | AsmStmt::AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {} |
---|
63 | |
---|
64 | AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) { |
---|
65 | cloneAll( other.output, output ); |
---|
66 | cloneAll( other.input, input ); |
---|
67 | cloneAll( other.clobber, clobber ); |
---|
68 | } |
---|
69 | |
---|
70 | AsmStmt::~AsmStmt() { |
---|
71 | delete instruction; |
---|
72 | deleteAll( output ); |
---|
73 | deleteAll( input ); |
---|
74 | deleteAll( clobber ); |
---|
75 | } |
---|
76 | |
---|
77 | void AsmStmt::print( std::ostream &os, Indenter indent ) const { |
---|
78 | os << "Assembler Statement:" << endl; |
---|
79 | os << indent+1 << "instruction: " << endl << indent; |
---|
80 | instruction->print( os, indent+1 ); |
---|
81 | if ( ! output.empty() ) { |
---|
82 | os << endl << indent+1 << "output: " << endl; |
---|
83 | printAll( output, os, indent+1 ); |
---|
84 | } // if |
---|
85 | if ( ! input.empty() ) { |
---|
86 | os << indent+1 << "input: " << endl; |
---|
87 | printAll( input, os, indent+1 ); |
---|
88 | } // if |
---|
89 | if ( ! clobber.empty() ) { |
---|
90 | os << indent+1 << "clobber: " << endl; |
---|
91 | printAll( clobber, os, indent+1 ); |
---|
92 | } // if |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {} |
---|
97 | |
---|
98 | void DirectiveStmt::print( std::ostream &os, Indenter ) const { |
---|
99 | os << "GCC Directive:" << directive << endl; |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; |
---|
104 | |
---|
105 | BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) : |
---|
106 | Statement(), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) { |
---|
107 | //actually this is a syntactic error signaled by the parser |
---|
108 | if ( type == BranchStmt::Goto && target.empty() ) { |
---|
109 | SemanticError( target.get_statement()->location, "goto without target"); |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticErrorException ) : |
---|
114 | Statement(), computedTarget( computedTarget ), type( type ) { |
---|
115 | if ( type != BranchStmt::Goto || computedTarget == nullptr ) { |
---|
116 | SemanticError( computedTarget->location, "Computed target not valid in branch statement"); |
---|
117 | } |
---|
118 | } |
---|
119 | |
---|
120 | void BranchStmt::print( std::ostream &os, Indenter indent ) const { |
---|
121 | os << "Branch (" << brType[type] << ")" << endl ; |
---|
122 | if ( target != "" ) os << indent+1 << "with target: " << target << endl; |
---|
123 | if ( originalTarget != "" ) os << indent+1 << "with original target: " << originalTarget << endl; |
---|
124 | if ( computedTarget != nullptr ) os << indent+1 << "with computed target: " << computedTarget << endl; |
---|
125 | } |
---|
126 | |
---|
127 | ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {} |
---|
128 | |
---|
129 | ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} |
---|
130 | |
---|
131 | ReturnStmt::~ReturnStmt() { |
---|
132 | delete expr; |
---|
133 | } |
---|
134 | |
---|
135 | void ReturnStmt::print( std::ostream &os, Indenter indent ) const { |
---|
136 | os << "Return Statement, returning: "; |
---|
137 | if ( expr != nullptr ) { |
---|
138 | os << endl << indent+1; |
---|
139 | expr->print( os, indent+1 ); |
---|
140 | } |
---|
141 | os << endl; |
---|
142 | } |
---|
143 | |
---|
144 | IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ): |
---|
145 | Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {} |
---|
146 | |
---|
147 | IfStmt::IfStmt( const IfStmt & other ) : |
---|
148 | Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) { |
---|
149 | cloneAll( other.initialization, initialization ); |
---|
150 | } |
---|
151 | |
---|
152 | IfStmt::~IfStmt() { |
---|
153 | deleteAll( initialization ); |
---|
154 | delete condition; |
---|
155 | delete thenPart; |
---|
156 | delete elsePart; |
---|
157 | } |
---|
158 | |
---|
159 | void IfStmt::print( std::ostream &os, Indenter indent ) const { |
---|
160 | os << "If on condition: " << endl; |
---|
161 | os << indent+1; |
---|
162 | condition->print( os, indent+1 ); |
---|
163 | |
---|
164 | if ( !initialization.empty() ) { |
---|
165 | os << indent << "... with initialization: \n"; |
---|
166 | for ( const Statement * stmt : initialization ) { |
---|
167 | os << indent+1; |
---|
168 | stmt->print( os, indent+1 ); |
---|
169 | } |
---|
170 | os << endl; |
---|
171 | } |
---|
172 | |
---|
173 | os << indent << "... then: " << endl; |
---|
174 | |
---|
175 | os << indent+1; |
---|
176 | thenPart->print( os, indent+1 ); |
---|
177 | |
---|
178 | if ( elsePart != 0 ) { |
---|
179 | os << indent << "... else: " << endl; |
---|
180 | os << indent+1; |
---|
181 | elsePart->print( os, indent+1 ); |
---|
182 | } // if |
---|
183 | } |
---|
184 | |
---|
185 | SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ): |
---|
186 | Statement(), condition( condition ), statements( statements ) { |
---|
187 | } |
---|
188 | |
---|
189 | SwitchStmt::SwitchStmt( const SwitchStmt & other ): |
---|
190 | Statement( other ), condition( maybeClone( other.condition ) ) { |
---|
191 | cloneAll( other.statements, statements ); |
---|
192 | } |
---|
193 | |
---|
194 | SwitchStmt::~SwitchStmt() { |
---|
195 | delete condition; |
---|
196 | // destroy statements |
---|
197 | deleteAll( statements ); |
---|
198 | } |
---|
199 | |
---|
200 | void SwitchStmt::print( std::ostream &os, Indenter indent ) const { |
---|
201 | os << "Switch on condition: "; |
---|
202 | condition->print( os ); |
---|
203 | os << endl; |
---|
204 | |
---|
205 | for ( const Statement * stmt : statements ) { |
---|
206 | stmt->print( os, indent+1 ); |
---|
207 | } |
---|
208 | } |
---|
209 | |
---|
210 | CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) : |
---|
211 | Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) { |
---|
212 | if ( isDefault() && condition != 0 ) SemanticError( condition, "default case with condition: " ); |
---|
213 | } |
---|
214 | |
---|
215 | CaseStmt::CaseStmt( const CaseStmt & other ) : |
---|
216 | Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) { |
---|
217 | cloneAll( other.stmts, stmts ); |
---|
218 | } |
---|
219 | |
---|
220 | CaseStmt::~CaseStmt() { |
---|
221 | delete condition; |
---|
222 | deleteAll( stmts ); |
---|
223 | } |
---|
224 | |
---|
225 | CaseStmt * CaseStmt::makeDefault( const std::list<Label> & labels, std::list<Statement *> stmts ) { |
---|
226 | CaseStmt * stmt = new CaseStmt( nullptr, stmts, true ); |
---|
227 | stmt->labels = labels; |
---|
228 | return stmt; |
---|
229 | } |
---|
230 | |
---|
231 | void CaseStmt::print( std::ostream &os, Indenter indent ) const { |
---|
232 | if ( isDefault() ) os << indent << "Default "; |
---|
233 | else { |
---|
234 | os << indent << "Case "; |
---|
235 | condition->print( os, indent ); |
---|
236 | } // if |
---|
237 | os << endl; |
---|
238 | |
---|
239 | for ( Statement * stmt : stmts ) { |
---|
240 | os << indent+1; |
---|
241 | stmt->print( os, indent+1 ); |
---|
242 | } |
---|
243 | } |
---|
244 | |
---|
245 | WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ): |
---|
246 | Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) { |
---|
247 | } |
---|
248 | |
---|
249 | WhileStmt::WhileStmt( const WhileStmt & other ): |
---|
250 | Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) { |
---|
251 | } |
---|
252 | |
---|
253 | WhileStmt::~WhileStmt() { |
---|
254 | delete body; |
---|
255 | delete condition; |
---|
256 | } |
---|
257 | |
---|
258 | void WhileStmt::print( std::ostream &os, Indenter indent ) const { |
---|
259 | os << "While on condition: " << endl ; |
---|
260 | condition->print( os, indent+1 ); |
---|
261 | |
---|
262 | os << indent << "... with body: " << endl; |
---|
263 | |
---|
264 | if ( body != 0 ) body->print( os, indent+1 ); |
---|
265 | } |
---|
266 | |
---|
267 | ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ): |
---|
268 | Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) { |
---|
269 | } |
---|
270 | |
---|
271 | ForStmt::ForStmt( const ForStmt & other ): |
---|
272 | Statement( other ), condition( maybeClone( other.condition ) ), increment( maybeClone( other.increment ) ), body( maybeClone( other.body ) ) { |
---|
273 | cloneAll( other.initialization, initialization ); |
---|
274 | |
---|
275 | } |
---|
276 | |
---|
277 | ForStmt::~ForStmt() { |
---|
278 | deleteAll( initialization ); |
---|
279 | delete condition; |
---|
280 | delete increment; |
---|
281 | delete body; |
---|
282 | } |
---|
283 | |
---|
284 | void ForStmt::print( std::ostream &os, Indenter indent ) const { |
---|
285 | Statement::print( os, indent ); // print labels |
---|
286 | |
---|
287 | os << "For Statement" << endl; |
---|
288 | |
---|
289 | if ( ! initialization.empty() ) { |
---|
290 | os << indent << "... initialization: \n"; |
---|
291 | for ( Statement * stmt : initialization ) { |
---|
292 | os << indent+1; |
---|
293 | stmt->print( os, indent+1 ); |
---|
294 | } |
---|
295 | } |
---|
296 | |
---|
297 | if ( condition != nullptr ) { |
---|
298 | os << indent << "... condition: \n" << indent+1; |
---|
299 | condition->print( os, indent+1 ); |
---|
300 | } |
---|
301 | |
---|
302 | if ( increment != nullptr ) { |
---|
303 | os << "\n" << indent << "... increment: \n" << indent+1; |
---|
304 | increment->print( os, indent+1 ); |
---|
305 | } |
---|
306 | |
---|
307 | if ( body != 0 ) { |
---|
308 | os << "\n" << indent << "... with body: \n" << indent+1; |
---|
309 | body->print( os, indent+1 ); |
---|
310 | } |
---|
311 | os << endl; |
---|
312 | } |
---|
313 | |
---|
314 | ThrowStmt::ThrowStmt( Kind kind, Expression * expr, Expression * target ) : |
---|
315 | Statement(), kind(kind), expr(expr), target(target) { |
---|
316 | assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." ); |
---|
317 | } |
---|
318 | |
---|
319 | ThrowStmt::ThrowStmt( const ThrowStmt &other ) : |
---|
320 | Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) { |
---|
321 | } |
---|
322 | |
---|
323 | ThrowStmt::~ThrowStmt() { |
---|
324 | delete expr; |
---|
325 | delete target; |
---|
326 | } |
---|
327 | |
---|
328 | void ThrowStmt::print( std::ostream &os, Indenter indent) const { |
---|
329 | if ( target ) os << "Non-Local "; |
---|
330 | os << "Throw Statement, raising: "; |
---|
331 | expr->print(os, indent+1); |
---|
332 | if ( target ) { |
---|
333 | os << "... at: "; |
---|
334 | target->print(os, indent+1); |
---|
335 | } |
---|
336 | } |
---|
337 | |
---|
338 | TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) : |
---|
339 | Statement(), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) { |
---|
340 | } |
---|
341 | |
---|
342 | TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) { |
---|
343 | cloneAll( other.handlers, handlers ); |
---|
344 | } |
---|
345 | |
---|
346 | TryStmt::~TryStmt() { |
---|
347 | delete block; |
---|
348 | deleteAll( handlers ); |
---|
349 | delete finallyBlock; |
---|
350 | } |
---|
351 | |
---|
352 | void TryStmt::print( std::ostream &os, Indenter indent ) const { |
---|
353 | os << "Try Statement" << endl; |
---|
354 | os << indent << "... with block:" << endl << indent+1; |
---|
355 | block->print( os, indent+1 ); |
---|
356 | |
---|
357 | // handlers |
---|
358 | os << indent << "... and handlers:" << endl; |
---|
359 | for ( const CatchStmt * stmt : handlers ) { |
---|
360 | os << indent+1; |
---|
361 | stmt->print( os, indent+1 ); |
---|
362 | } |
---|
363 | |
---|
364 | // finally block |
---|
365 | if ( finallyBlock != 0 ) { |
---|
366 | os << indent << "... and finally:" << endl << indent+1; |
---|
367 | finallyBlock->print( os, indent+1 ); |
---|
368 | } // if |
---|
369 | } |
---|
370 | |
---|
371 | CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) : |
---|
372 | Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) { |
---|
373 | assertf( decl, "Catch clause must have a declaration." ); |
---|
374 | } |
---|
375 | |
---|
376 | CatchStmt::CatchStmt( const CatchStmt & other ) : |
---|
377 | Statement( other ), kind ( other.kind ), decl ( maybeClone( other.decl ) ), cond ( maybeClone( other.cond ) ), body( maybeClone( other.body ) ) { |
---|
378 | } |
---|
379 | |
---|
380 | CatchStmt::~CatchStmt() { |
---|
381 | delete decl; |
---|
382 | delete body; |
---|
383 | } |
---|
384 | |
---|
385 | void CatchStmt::print( std::ostream &os, Indenter indent ) const { |
---|
386 | os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; |
---|
387 | |
---|
388 | os << indent << "... catching: "; |
---|
389 | decl->printShort( os, indent+1 ); |
---|
390 | os << endl; |
---|
391 | |
---|
392 | if ( cond ) { |
---|
393 | os << indent << "... with conditional:" << endl << indent+1; |
---|
394 | cond->print( os, indent+1 ); |
---|
395 | } |
---|
396 | |
---|
397 | os << indent << "... with block:" << endl; |
---|
398 | os << indent+1; |
---|
399 | body->print( os, indent+1 ); |
---|
400 | } |
---|
401 | |
---|
402 | |
---|
403 | FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) { |
---|
404 | } |
---|
405 | |
---|
406 | FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) { |
---|
407 | } |
---|
408 | |
---|
409 | FinallyStmt::~FinallyStmt() { |
---|
410 | delete block; |
---|
411 | } |
---|
412 | |
---|
413 | void FinallyStmt::print( std::ostream &os, Indenter indent ) const { |
---|
414 | os << "Finally Statement" << endl; |
---|
415 | os << indent << "... with block:" << endl << indent+1; |
---|
416 | block->print( os, indent+1 ); |
---|
417 | } |
---|
418 | |
---|
419 | WaitForStmt::WaitForStmt() : Statement() { |
---|
420 | timeout.time = nullptr; |
---|
421 | timeout.statement = nullptr; |
---|
422 | timeout.condition = nullptr; |
---|
423 | orelse .statement = nullptr; |
---|
424 | orelse .condition = nullptr; |
---|
425 | } |
---|
426 | |
---|
427 | WaitForStmt::WaitForStmt( const WaitForStmt & other ) : Statement( other ) { |
---|
428 | clauses.reserve( other.clauses.size() ); |
---|
429 | for( auto & ocl : other.clauses ) { |
---|
430 | clauses.emplace_back(); |
---|
431 | clauses.back().target.function = ocl.target.function->clone(); |
---|
432 | cloneAll( ocl.target.arguments, clauses.back().target.arguments ); |
---|
433 | clauses.back().statement = ocl.statement->clone(); |
---|
434 | clauses.back().condition = ocl.condition->clone(); |
---|
435 | } |
---|
436 | |
---|
437 | timeout.time = other.timeout.time ->clone(); |
---|
438 | timeout.statement = other.timeout.statement->clone(); |
---|
439 | timeout.condition = other.timeout.condition->clone(); |
---|
440 | orelse .statement = other.orelse .statement->clone(); |
---|
441 | orelse .condition = other.orelse .condition->clone(); |
---|
442 | } |
---|
443 | |
---|
444 | WaitForStmt::~WaitForStmt() { |
---|
445 | for( auto & clause : clauses ) { |
---|
446 | delete clause.target.function; |
---|
447 | deleteAll( clause.target.arguments ); |
---|
448 | delete clause.statement; |
---|
449 | delete clause.condition; |
---|
450 | } |
---|
451 | |
---|
452 | delete timeout.time; |
---|
453 | delete timeout.statement; |
---|
454 | delete timeout.condition; |
---|
455 | |
---|
456 | delete orelse.statement; |
---|
457 | delete orelse.condition; |
---|
458 | } |
---|
459 | |
---|
460 | void WaitForStmt::print( std::ostream &os, Indenter indent ) const { |
---|
461 | os << "Waitfor Statement" << endl; |
---|
462 | indent += 1; |
---|
463 | for( auto & clause : clauses ) { |
---|
464 | os << indent << "target function :"; |
---|
465 | if(clause.target.function) { clause.target.function->print(os, indent + 1); } |
---|
466 | os << endl << indent << "with arguments :" << endl; |
---|
467 | for( auto & thing : clause.target.arguments) { |
---|
468 | if(thing) { thing->print(os, indent + 1); } |
---|
469 | } |
---|
470 | os << indent << " with statment :" << endl; |
---|
471 | if(clause.statement) { clause.statement->print(os, indent + 1); } |
---|
472 | |
---|
473 | os << indent << " with condition :" << endl; |
---|
474 | if(clause.condition) { clause.condition->print(os, indent + 1); } |
---|
475 | } |
---|
476 | |
---|
477 | os << indent << " timeout of :" << endl; |
---|
478 | if(timeout.time) { timeout.time->print(os, indent + 1); } |
---|
479 | |
---|
480 | os << indent << " with statment :" << endl; |
---|
481 | if(timeout.statement) { timeout.statement->print(os, indent + 1); } |
---|
482 | |
---|
483 | os << indent << " with condition :" << endl; |
---|
484 | if(timeout.condition) { timeout.condition->print(os, indent + 1); } |
---|
485 | |
---|
486 | |
---|
487 | os << indent << " else :" << endl; |
---|
488 | if(orelse.statement) { orelse.statement->print(os, indent + 1); } |
---|
489 | |
---|
490 | os << indent << " with condition :" << endl; |
---|
491 | if(orelse.condition) { orelse.condition->print(os, indent + 1); } |
---|
492 | } |
---|
493 | |
---|
494 | |
---|
495 | WithStmt::WithStmt( const std::list< Expression * > & exprs, Statement * stmt ) : Statement(), exprs( exprs ), stmt( stmt ) {} |
---|
496 | WithStmt::WithStmt( const WithStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) { |
---|
497 | cloneAll( other.exprs, exprs ); |
---|
498 | } |
---|
499 | WithStmt::~WithStmt() { |
---|
500 | deleteAll( exprs ); |
---|
501 | delete stmt; |
---|
502 | } |
---|
503 | |
---|
504 | void WithStmt::print( std::ostream & os, Indenter indent ) const { |
---|
505 | os << "With statement" << endl; |
---|
506 | os << indent << "... with expressions: " << endl; |
---|
507 | printAll( exprs, os, indent+1 ); |
---|
508 | os << indent << "... with statement:" << endl << indent+1; |
---|
509 | stmt->print( os, indent+1 ); |
---|
510 | } |
---|
511 | |
---|
512 | |
---|
513 | NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) { |
---|
514 | } |
---|
515 | |
---|
516 | void NullStmt::print( std::ostream &os, Indenter indent ) const { |
---|
517 | os << "Null Statement" << endl; |
---|
518 | Statement::print( os, indent ); |
---|
519 | } |
---|
520 | |
---|
521 | ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement(), callStmt( callStmt ) { |
---|
522 | assert( callStmt ); |
---|
523 | } |
---|
524 | |
---|
525 | ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ) : Statement( other ), callStmt( maybeClone( other.callStmt ) ) { |
---|
526 | } |
---|
527 | |
---|
528 | ImplicitCtorDtorStmt::~ImplicitCtorDtorStmt() { |
---|
529 | delete callStmt; |
---|
530 | } |
---|
531 | |
---|
532 | void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const { |
---|
533 | os << "Implicit Ctor Dtor Statement" << endl; |
---|
534 | os << indent << "... with Ctor/Dtor: "; |
---|
535 | callStmt->print( os, indent+1); |
---|
536 | os << endl; |
---|
537 | } |
---|
538 | |
---|
539 | // Local Variables: // |
---|
540 | // tab-width: 4 // |
---|
541 | // mode: c++ // |
---|
542 | // compile-command: "make install" // |
---|
543 | // End: // |
---|