Changes in src/SynTree/Statement.cc [135b431:b0dfbc4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
r135b431 rb0dfbc4 89 89 90 90 BranchStmt::BranchStmt( std::list<Label> labels, Label target, Type type ) throw ( SemanticError ) : 91 Statement( labels ), originalTarget( target ), target( target ), computedTarget( NULL), type( type ) {91 Statement( labels ), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) { 92 92 //actually this is a syntactic error signaled by the parser 93 if ( type == BranchStmt::Goto && target.empty() ) 93 if ( type == BranchStmt::Goto && target.empty() ) { 94 94 throw SemanticError("goto without target"); 95 } 95 96 } 96 97 97 98 BranchStmt::BranchStmt( std::list<Label> labels, Expression *computedTarget, Type type ) throw ( SemanticError ) : 98 99 Statement( labels ), computedTarget( computedTarget ), type( type ) { 99 if ( type != BranchStmt::Goto || computedTarget == 0 )100 if ( type != BranchStmt::Goto || computedTarget == nullptr ) { 100 101 throw SemanticError("Computed target not valid in branch statement"); 102 } 101 103 } 102 104 103 105 void BranchStmt::print( std::ostream &os, int indent ) const { 104 106 os << string( indent, ' ' ) << "Branch (" << brType[type] << ")" << endl ; 107 if ( target != "" ) os << string( indent+2, ' ' ) << "with target: " << target << endl; 108 if ( originalTarget != "" ) os << string( indent+2, ' ' ) << "with original target: " << originalTarget << endl; 109 if ( computedTarget != nullptr ) os << string( indent+2, ' ' ) << "with computed target: " << computedTarget << endl; 105 110 } 106 111
Note: See TracChangeset
for help on using the changeset viewer.