Changeset 1db21619 for src/Parser/StatementNode.cc
- Timestamp:
- Jul 16, 2015, 5:28:24 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 994ec2c
- Parents:
- 724c2b6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r724c2b6 r1db21619 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 14:59:41 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T ue Jul 14 12:20:44 201513 // Update Count : 2111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 16 16:20:24 2015 13 // Update Count : 30 14 14 // 15 15 … … 72 72 delete control; 73 73 delete block; 74 delete labels;75 74 delete target; 76 75 delete decl; … … 103 102 } 104 103 105 void StatementNode::set_control( ExpressionNode *c ) {106 control = c;107 }108 109 StatementNode * StatementNode::set_block( StatementNode *b ) {110 block = b;111 112 return this;113 }114 115 ExpressionNode *StatementNode::get_control() const {116 return control;117 }118 119 StatementNode *StatementNode::get_block() const {120 return block;121 }122 123 StatementNode::Type StatementNode::get_type() const {124 return type;125 }126 127 104 StatementNode *StatementNode::add_label( const std::string *l ) { 128 105 if ( l != 0 ) { 129 if ( labels == 0 ) 130 labels = new std::list<std::string>(); 131 132 labels->push_front(*l ); 106 labels.push_front( *l ); 133 107 delete l; 134 108 } // if 135 109 return this; 136 110 } 137 138 std::list<std::string> *StatementNode::get_labels() const { return labels; }139 111 140 112 StatementNode *StatementNode::add_controlexp( ExpressionNode *e ) { … … 170 142 171 143 void StatementNode::print( std::ostream &os, int indent ) const { 172 if ( labels != 0 ) { 173 if ( ! labels->empty()) { 174 std::list<std::string>::const_iterator i; 175 176 os << string( indent, ' ' ); 177 for ( i = labels->begin(); i != labels->end(); i++ ) 178 os << *i << ":"; 179 os << endl; 180 } // if 144 if ( ! labels.empty()) { 145 std::list<std::string>::const_iterator i; 146 147 os << string( indent, ' ' ); 148 for ( i = labels.begin(); i != labels.end(); i++ ) 149 os << *i << ":"; 150 os << endl; 181 151 } // if 182 152 … … 225 195 std::list<Label> labs; 226 196 227 if ( labels != 0) {197 if ( ! labels.empty() ) { 228 198 std::back_insert_iterator< std::list<Label> > lab_it( labs ); 229 copy( labels ->begin(), labels->end(), lab_it );199 copy( labels.begin(), labels.end(), lab_it ); 230 200 } // if 231 201 … … 274 244 if ( ctl->get_init() != 0 ) { 275 245 buildList( ctl->get_init(), init ); 276 } 246 } // if 277 247 278 248 Expression *cond = 0; … … 378 348 Statement *CompoundStmtNode::build() const { 379 349 std::list<Label> labs; 380 std::list<std::string> *labels = get_labels();381 382 if ( labels != 0) {350 const std::list<std::string> &labels = get_labels(); 351 352 if ( ! labels.empty() ) { 383 353 std::back_insert_iterator< std::list<Label> > lab_it( labs ); 384 copy( labels ->begin(), labels->end(), lab_it );354 copy( labels.begin(), labels.end(), lab_it ); 385 355 } // if 386 356
Note: See TracChangeset
for help on using the changeset viewer.