polserver/pol-core/bscript/compiler/ast/JumpStatement.cpp
Eric Swanson 92ba5be8cf
Add break and continue statements. (#270)
Adds:
- ast/JumpStatement: AST node for break and continue statements
2020-09-04 18:21:08 -07:00

31 lines
740 B
C++

#include "JumpStatement.h"
#include <format/format.h>
#include "NodeVisitor.h"
namespace Pol::Bscript::Compiler
{
JumpStatement::JumpStatement( const SourceLocation& source_location, JumpType jump_type,
std::string label )
: Statement( source_location ),
jump_type( jump_type ),
label( std::move( label ) ),
flow_control_label(),
local_variables_to_remove( 0 )
{
}
void JumpStatement::accept( NodeVisitor& visitor )
{
visitor.visit_jump_statement( *this );
}
void JumpStatement::describe_to( fmt::Writer& w ) const
{
w << (jump_type == Break ? "break-statement" : "continue-statement");
if ( !label.empty() )
w << "(" << label << ")";
}
} // namespace Pol::Bscript::Compiler