mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 22:45:03 +02:00

This commit is the initial sync of all files from ruby/yarp into ruby/ruby. Notably, it does the following: * Sync all ruby/yarp/lib/ files to ruby/ruby/lib/yarp * Sync all ruby/yarp/src/ files to ruby/ruby/yarp/ * Sync all ruby/yarp/test/ files to ruby/ruby/test/yarp
25 lines
526 B
C
25 lines
526 B
C
#include "yarp/util/yp_state_stack.h"
|
|
|
|
// Initializes the state stack to an empty stack.
|
|
void
|
|
yp_state_stack_init(yp_state_stack_t *stack) {
|
|
*stack = 0;
|
|
}
|
|
|
|
// Pushes a value onto the stack.
|
|
void
|
|
yp_state_stack_push(yp_state_stack_t *stack, bool value) {
|
|
*stack = (*stack << 1) | (value & 1);
|
|
}
|
|
|
|
// Pops a value off the stack.
|
|
void
|
|
yp_state_stack_pop(yp_state_stack_t *stack) {
|
|
*stack >>= 1;
|
|
}
|
|
|
|
// Returns the value at the top of the stack.
|
|
bool
|
|
yp_state_stack_p(yp_state_stack_t *stack) {
|
|
return *stack & 1;
|
|
}
|