Changeset f678663e for src/Parser/StatementNode.cc
- Timestamp:
- Jul 30, 2015, 4:08:34 PM (10 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:
- 8c84ebd, ae4c85a
- Parents:
- 5aa708c (diff), 093f1a0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/Parser/StatementNode.cc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r5aa708c rf678663e 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 16 16:20:24201513 // Update Count : 3012 // Last Modified On : Thu Jul 30 14:39:39 2015 13 // Update Count : 130 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( const 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 ) { … … 60 60 } 61 61 62 StatementNode::StatementNode( Type t, ExpressionNode *ctrl_label, StatementNode *block_ ) : 63 type( t ), control( ctrl_label ), block( block_), labels( 0 ), target( 0 ), decl( 0 ), isCatchRest ( false ) { 64 if ( t == Default ) 65 control = 0; 62 StatementNode::StatementNode( Type t, ExpressionNode *ctrl_label, StatementNode *block ) : type( t ), control( ctrl_label ), block( block ), labels( 0 ), target( 0 ), decl( 0 ), isCatchRest ( false ) { 63 this->control = ( t == Default ) ? 0 : control; 66 64 } 67 65 68 StatementNode::StatementNode( Type t, string *_target ) : 69 type( t ), control( 0 ), block( 0 ), labels( 0 ), target(_target ), decl( 0 ), isCatchRest ( false ) {} 66 StatementNode::StatementNode( Type t, string *target ) : type( t ), control( 0 ), block( 0 ), labels( 0 ), target( target ), decl( 0 ), isCatchRest ( false ) {} 70 67 71 68 StatementNode::~StatementNode() { … … 113 110 if ( control && e ) 114 111 control->add_to_list( e ); // xxx - check this 115 116 112 return this; 117 113 } … … 142 138 143 139 void StatementNode::print( std::ostream &os, int indent ) const { 144 if ( ! labels.empty() ) {140 if ( ! labels.empty() ) { 145 141 std::list<std::string>::const_iterator i; 146 142 … … 168 164 if ( decl ) { 169 165 os << string( indent + ParseNode::indent_by, ' ' ) << "Declaration: " << endl; 170 decl->print( os, indent + 2 *ParseNode::indent_by );166 decl->print( os, indent + 2 * ParseNode::indent_by ); 171 167 } else if ( isCatchRest ) { 172 168 os << string( indent + ParseNode::indent_by, ' ' ) << "Catches the rest " << endl; … … 176 172 } // if 177 173 if ( control ) { 178 os << string( indent + ParseNode::indent_by, ' ' ) << " Expression: " << endl;179 control->printList( os, indent + 2 *ParseNode::indent_by );174 os << string( indent + ParseNode::indent_by, ' ' ) << "Control: " << endl; 175 control->printList( os, indent + 2 * ParseNode::indent_by ); 180 176 } // if 181 177 if ( block ) { 182 178 os << string( indent + ParseNode::indent_by, ' ' ) << "Branches of execution: " << endl; 183 block->printList( os, indent + 2 *ParseNode::indent_by );179 block->printList( os, indent + 2 * ParseNode::indent_by ); 184 180 } // if 185 181 if ( target ) { … … 311 307 return new FinallyStmt( labs, block ); 312 308 } 309 case Asm: 310 assert( false ); 313 311 default: 314 312 // shouldn't be here … … 316 314 } // switch 317 315 } 316 318 317 319 318 CompoundStmtNode::CompoundStmtNode() : first( 0 ), last( 0 ) {} … … 360 359 } 361 360 361 362 AsmStmtNode::AsmStmtNode( Type t, bool voltile, ConstantNode *instruction, ExpressionNode *output, ExpressionNode *input, ConstantNode *clobber, LabelNode *gotolabels ) : 363 StatementNode( t ), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ) { 364 if ( gotolabels ) { 365 this->gotolabels = gotolabels->get_labels(); 366 delete gotolabels; 367 } // if 368 } 369 370 AsmStmtNode::~AsmStmtNode() { 371 delete instruction; delete output; delete input; delete clobber; 372 } 373 374 void AsmStmtNode::print( std::ostream &os, int indent ) const { 375 StatementNode::print( os, indent ); // print statement labels 376 os << string( indent + ParseNode::indent_by, ' ' ) << "volatile:" << voltile << endl; 377 if ( instruction ) { 378 os << string( indent + ParseNode::indent_by, ' ' ) << "Instruction:" << endl; 379 instruction->printList( os, indent + 2 * ParseNode::indent_by ); 380 } // if 381 if ( output ) { 382 os << string( indent + ParseNode::indent_by, ' ' ) << "Output:" << endl; 383 output->printList( os, indent + 2 * ParseNode::indent_by ); 384 } // if 385 if ( input ) { 386 os << string( indent + ParseNode::indent_by, ' ' ) << "Input:" << endl; 387 input->printList( os, indent + 2 * ParseNode::indent_by ); 388 } // if 389 if ( clobber ) { 390 os << string( indent + ParseNode::indent_by, ' ' ) << "Clobber:" << endl; 391 clobber->printList( os, indent + 2 * ParseNode::indent_by ); 392 } // if 393 if ( ! gotolabels.empty() ) { 394 os << string( indent + ParseNode::indent_by, ' ' ) << "Goto Labels:" << endl; 395 os << string( indent + 2 * ParseNode::indent_by, ' ' ); 396 for ( std::list<std::string>::const_iterator i = gotolabels.begin();; ) { 397 os << *i; 398 i++; 399 if ( i == gotolabels.end() ) break; 400 os << ", "; 401 } 402 os << endl; 403 } // if 404 } 405 406 Statement *AsmStmtNode::build() const { 407 std::list<Label> labs; 408 409 if ( ! get_labels().empty() ) { 410 std::back_insert_iterator< std::list<Label> > lab_it( labs ); 411 copy( get_labels().begin(), get_labels().end(), lab_it ); 412 } // if 413 414 std::list< Expression * > out, in; 415 std::list< ConstantExpr * > clob; 416 buildList( output, out ); 417 buildList( input, in ); 418 buildList( clobber, clob ); 419 std::list< Label > gotolabs = gotolabels; 420 return new AsmStmt( labs, voltile, (ConstantExpr *)maybeBuild< Expression >( instruction ), out, in, clob, gotolabs ); 421 } 422 423 362 424 void NullStmtNode::print( ostream &os, int indent ) const { 363 425 os << string( indent, ' ' ) << "Null Statement:" << endl;
Note:
See TracChangeset
for help on using the changeset viewer.