Changes in src/Parser/StatementNode.cc [59db689:843054c2]
- File:
-
- 1 edited
-
src/Parser/StatementNode.cc (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r59db689 r843054c2 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 6 23:25:41201513 // Update Count : 1912 // Last Modified On : Sat May 16 15:10:45 2015 13 // Update Count : 7 14 14 // 15 15 … … 36 36 StatementNode::StatementNode() : ParseNode(), control( 0 ), block( 0 ), labels( 0 ), target( 0 ), decl( 0 ), isCatchRest ( false ) {} 37 37 38 StatementNode::StatementNode( const string *name_ ) : ParseNode( name_), control( 0 ), block( 0 ), labels( 0 ), target( 0 ), decl( 0 ), isCatchRest ( false ) {}38 StatementNode::StatementNode( string name_) : ParseNode( name_), control( 0 ), block( 0 ), labels( 0 ), target( 0 ), decl( 0 ), isCatchRest ( false ) {} 39 39 40 40 StatementNode::StatementNode( DeclarationNode *decl ) : type( Decl ), control( 0 ), block( 0 ), labels( 0 ), target( 0 ), isCatchRest ( false ) { … … 49 49 next->set_next( new StatementNode( dynamic_cast< DeclarationNode* >( decl->get_link() ) ) ); 50 50 decl->set_next( 0 ); 51 } // if51 } 52 52 } else { 53 53 if ( decl->get_link() ) { 54 54 next = new StatementNode( dynamic_cast< DeclarationNode* >( decl->get_link() ) ); 55 55 decl->set_next( 0 ); 56 } // if56 } 57 57 this->decl = decl; 58 } // if59 } // if58 } 59 } 60 60 } 61 61 … … 67 67 68 68 StatementNode::StatementNode( Type t, string *_target ) : 69 type( t ), control( 0 ), block( 0 ), labels( 0 ), target(_target ), decl( 0 ), isCatchRest ( false ) {}69 type( t ), control( 0 ), block( 0 ), labels( 0 ), target(_target ), decl( 0 ), isCatchRest ( false ) {} 70 70 71 71 StatementNode::~StatementNode() { … … 98 98 } else { 99 99 newnode->target = 0; 100 } // if100 } 101 101 newnode->decl = maybeClone( decl ); 102 102 return newnode; … … 125 125 } 126 126 127 StatementNode *StatementNode::add_label( conststd::string *l ) {127 StatementNode *StatementNode::add_label( std::string *l ) { 128 128 if ( l != 0 ) { 129 129 if ( labels == 0 ) … … 132 132 labels->push_front(*l ); 133 133 delete l; 134 } // if134 } 135 135 return this; 136 136 } … … 151 151 else 152 152 block->set_link( stmt ); 153 } // if153 } 154 154 return this; 155 155 } … … 165 165 else 166 166 block->set_link( stmt ); 167 } // if167 } 168 168 return this; 169 169 } 170 170 171 171 void StatementNode::print( std::ostream &os, int indent ) const { 172 if ( labels != 0 ) {172 if ( labels != 0 ) 173 173 if ( ! labels->empty()) { 174 174 std::list<std::string>::const_iterator i; 175 175 176 os << string( indent, ' ');176 os << '\r' << string( indent, ' '); 177 177 for ( i = labels->begin(); i != labels->end(); i++ ) 178 178 os << *i << ":"; 179 179 os << endl; 180 } // if 181 } // if 180 } 182 181 183 182 switch ( type ) { … … 194 193 break; 195 194 default: 196 os << string( indent, ' ') << StatementNode::StType[type] << endl;195 os << '\r' << string( indent, ' ') << StatementNode::StType[type] << endl; 197 196 if ( type == Catch ) { 198 197 if ( decl ) { 199 os << string( indent + ParseNode::indent_by, ' ' ) << "Declaration: " << endl;198 os << '\r' << string( indent + ParseNode::indent_by, ' ' ) << "Declaration: " << endl; 200 199 decl->print( os, indent + 2*ParseNode::indent_by ); 201 200 } else if ( isCatchRest ) { 202 os << string( indent + ParseNode::indent_by, ' ' ) << "Catches the rest " << endl;201 os << '\r' << string( indent + ParseNode::indent_by, ' ' ) << "Catches the rest " << endl; 203 202 } else { 204 203 ; // should never reach here 205 } // if206 } // if204 } 205 } 207 206 if ( control ) { 208 os << string( indent + ParseNode::indent_by, ' ' ) << "Expression: " << endl;207 os << '\r' << string( indent + ParseNode::indent_by, ' ' ) << "Expression: " << endl; 209 208 control->printList( os, indent + 2*ParseNode::indent_by ); 210 } // if209 } 211 210 if ( block ) { 212 os << string( indent + ParseNode::indent_by, ' ' ) << "Branches of execution: " << endl;211 os << '\r' << string( indent + ParseNode::indent_by, ' ' ) << "Branches of execution: " << endl; 213 212 block->printList( os, indent + 2*ParseNode::indent_by ); 214 } // if213 } 215 214 if ( target ) { 216 os << string( indent + ParseNode::indent_by, ' ' ) << "Target: " << get_target() << endl;217 } // if215 os << '\r' << string( indent + ParseNode::indent_by, ' ' ) << "Target: " << get_target() << endl; 216 } 218 217 break; 219 } // switch218 } 220 219 } 221 220 … … 228 227 std::back_insert_iterator< std::list<Label> > lab_it( labs ); 229 228 copy( labels->begin(), labels->end(), lab_it ); 230 } // if229 } 231 230 232 231 // try { … … 255 254 elseb = branches.front(); 256 255 branches.pop_front(); 257 } // if256 } 258 257 return new IfStmt( labs, notZeroExpr( get_control()->build() ), thenb, elseb ); 259 258 } … … 300 299 assert( get_control() != 0 ); 301 300 return new BranchStmt( labs, get_control()->build(), BranchStmt::Goto ); 302 } // if301 } 303 302 304 303 return new BranchStmt( labs, get_target(), BranchStmt::Goto ); … … 323 322 if ( ( finallyBlock = dynamic_cast<FinallyStmt *>( branches.back())) ) { 324 323 branches.pop_back(); 325 } // if324 } 326 325 return new TryStmt( labs, tryBlock, branches, finallyBlock ); 327 326 } … … 343 342 // shouldn't be here 344 343 return 0; 345 } // switch 346 } 347 348 CompoundStmtNode::CompoundStmtNode() : first( 0 ), last( 0 ) {} 349 350 CompoundStmtNode::CompoundStmtNode( const string *name_ ) : StatementNode( name_ ), first( 0 ), last( 0 ) {} 351 352 CompoundStmtNode::CompoundStmtNode( StatementNode *stmt ) : first( stmt ) { 344 } 345 } 346 347 CompoundStmtNode::CompoundStmtNode() : first( 0 ), last( 0 ) { 348 } 349 350 CompoundStmtNode::CompoundStmtNode( string *name_) : StatementNode(*name_), first( 0 ), last( 0 ) { 351 } 352 353 CompoundStmtNode::CompoundStmtNode( StatementNode *stmt ): first( stmt ) { 353 354 if ( first ) { 354 355 last = ( StatementNode *)( stmt->get_last()); 355 356 } else { 356 357 last = 0; 357 } // if358 } 358 359 } 359 360 … … 366 367 last->set_link( stmt ); 367 368 last = ( StatementNode *)( stmt->get_link()); 368 } // if369 } 369 370 } 370 371 … … 372 373 if ( first ) { 373 374 first->printList( os, indent+2 ); 374 } // if375 } 375 376 } 376 377 … … 382 383 std::back_insert_iterator< std::list<Label> > lab_it( labs ); 383 384 copy( labels->begin(), labels->end(), lab_it ); 384 } // if385 } 385 386 386 387 CompoundStmt *cs = new CompoundStmt( labs ); … … 390 391 391 392 void NullStmtNode::print( ostream &os, int indent ) const { 392 os << string( indent, ' ') << "Null Statement:" << endl;393 os << "\r" << string( indent, ' ') << "Null Statement:" << endl; 393 394 } 394 395
Note:
See TracChangeset
for help on using the changeset viewer.