![]() |
rego-cpp 1.0.0
A C++ implementation of the Rego language and runtime
|
Represents an operand in the IR. More...
#include <rego.hh>
Public Member Functions | |
| Operand () | |
| Constructs an Operand with type None. | |
Static Public Member Functions | |
| static Operand | from_op (const Node &n) |
| Constructs an Operand from the specified node. | |
| static Operand | from_index (const Node &n) |
| Constructs an Operand from the specified node. Will have a type of Index. | |
| static Operand | from_value (const Node &n) |
| Constructs an Operand from the specified node. Will have a type of Value. | |
Public Attributes | ||
| OperandType | type | |
| The type of the operand. | ||
| union { | ||
| std::int64_t value | ||
| An integer value (if type is Value). | ||
| size_t index | ||
| A local index (if type is Local, String, or Index). | ||
| }; | ||
Friends | |
| std::ostream & | operator<< (std::ostream &stream, const Operand &op) |
| Writes the operand to a stream (used for debugging purposes). | |
Represents an operand in the IR.
In this implementation of the IR the operand is overloaded slightly. It is either (as in the specification) a local index, a string index, or a boolean value (true or false). However, to simplify the implementation, it can also be a raw local index (OperandType::Index) or a raw integer value (OperandType::Value). These two additional types allow for more flexibility in the IR representation. A type of None indicates that the operand is not used.
|
static |
Constructs an Operand from the specified node. Will have a type of Index.
| n | The node to construct the operand from. |
|
static |
Constructs an Operand from the specified node.
| n | The node to construct the operand from. |
|
static |
Constructs an Operand from the specified node. Will have a type of Value.
| n | The node to construct the operand from. |
|
friend |
Writes the operand to a stream (used for debugging purposes).
| stream | The stream to write to. |
| op | The operand to write. |