polserver/pol-core/bscript/compiler/model/FlowControlLabel.h
Eric Swanson 95e604e417
Add support for if-then-else statements (#259)
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.
2020-08-30 17:03:26 -07:00

31 lines
653 B
C++

#ifndef POLSERVER_FLOWCONTROLLABEL_H
#define POLSERVER_FLOWCONTROLLABEL_H
#include <vector>
#include <optional>
namespace Pol::Bscript::Compiler
{
class InstructionEmitter;
class FlowControlLabel
{
public:
FlowControlLabel();
bool has_address() const;
unsigned address() const;
const std::vector<unsigned>& get_referencing_instruction_addresses() const;
void assign_address( unsigned );
void add_referencing_instruction_address( unsigned );
private:
std::optional<unsigned> maybe_address;
std::vector<unsigned> referencing_instruction_addresses;
};
} // namespace Pol::Bscript::Compiler
#endif // POLSERVER_FLOWCONTROLLABEL_H