mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
Adds: - ast/Block: a block scope that allows declaring local variables - ast/IfThenElseStatement: AST node for if..elseif..else..endif statements - model/FlowControlLabel: provides an anchor for jumps or calls. - Function calls, break statements, continue statements, and loops will all use these.
36 lines
860 B
C++
36 lines
860 B
C++
#include "FlowControlLabel.h"
|
|
|
|
#include <stdexcept>
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
FlowControlLabel::FlowControlLabel() : maybe_address(), referencing_instruction_addresses() {}
|
|
|
|
bool FlowControlLabel::has_address() const
|
|
{
|
|
return maybe_address.has_value();
|
|
}
|
|
|
|
unsigned FlowControlLabel::address() const
|
|
{
|
|
return maybe_address.value();
|
|
}
|
|
|
|
const std::vector<unsigned>& FlowControlLabel::get_referencing_instruction_addresses() const
|
|
{
|
|
return referencing_instruction_addresses;
|
|
}
|
|
|
|
void FlowControlLabel::assign_address( unsigned address )
|
|
{
|
|
if ( maybe_address.has_value() )
|
|
throw std::runtime_error( "Label address assigned twice" );
|
|
maybe_address = address;
|
|
}
|
|
|
|
void FlowControlLabel::add_referencing_instruction_address( unsigned address )
|
|
{
|
|
referencing_instruction_addresses.push_back( address );
|
|
}
|
|
|
|
} // namespace Pol::Bscript::Compiler
|