Bitcoin ABC 0.30.7
P2P Digital Currency
|
A data type to abstract out the condition stack during script execution. More...
#include <conditionstack.h>
Public Member Functions | |
bool | empty () const |
bool | all_true () const |
void | push_back (bool f) |
void | pop_back () |
void | toggle_top () |
Private Attributes | |
uint32_t | m_stack_size = 0 |
The size of the implied stack. More... | |
uint32_t | m_first_false_pos = NO_FALSE |
The position of the first false value on the implied stack, or NO_FALSE if all true. More... | |
Static Private Attributes | |
static constexpr uint32_t | NO_FALSE = std::numeric_limits<uint32_t>::max() |
A constant for m_first_false_pos to indicate there are no falses. More... | |
A data type to abstract out the condition stack during script execution.
Conceptually it acts like a vector of booleans, one for each level of nested IF/THEN/ELSE, indicating whether we're in the active or inactive branch of each.
The elements on the stack cannot be observed individually; we only need to expose whether the stack is empty and whether or not any false values are present at all. To implement OP_ELSE, a toggle_top modifier is added, which flips the last value without returning it.
This uses an optimized implementation that does not materialize the actual stack. Instead, it just stores the size of the would-be stack, and the position of the first false value in it.
Definition at line 28 of file conditionstack.h.
|
inline |
|
inline |
|
inline |
Definition at line 50 of file conditionstack.h.
|
inline |
|
inline |
Definition at line 58 of file conditionstack.h.
|
private |
The position of the first false value on the implied stack, or NO_FALSE if all true.
Definition at line 37 of file conditionstack.h.
|
private |
The size of the implied stack.
Definition at line 34 of file conditionstack.h.
|
staticconstexprprivate |
A constant for m_first_false_pos to indicate there are no falses.
Definition at line 31 of file conditionstack.h.