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