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