diff --git a/src/c/stacks.d b/src/c/stacks.d index 01c214598..07b6c51e6 100644 --- a/src/c/stacks.d +++ b/src/c/stacks.d @@ -874,6 +874,31 @@ ecl_stack_push(cl_object self, cl_object elt) return self; } +cl_object +ecl_stack_pop(cl_object self) +{ + cl_index fillp = self->vector.fillp; + cl_object elt = ECL_NIL; + if (ecl_unlikely(fillp == 0)) { + ecl_internal_error("ecl_stack_pop: stack underflow"); + } + elt = self->vector.self.t[fillp-1]; + self->vector.self.t[fillp-1] = ECL_NIL; + self->vector.fillp--; + return elt; +} + +cl_object +ecl_stack_dup(cl_object self) +{ + cl_index fillp = self->vector.fillp; + if (ecl_unlikely(fillp == 0)) { + ecl_internal_error("ecl_stack_dup: empty stack"); + } + ecl_stack_push(self, self->vector.self.t[fillp-1]); + return self; +} + cl_object ecl_stack_del(cl_object self, cl_object elt) { @@ -899,3 +924,15 @@ ecl_stack_popu(cl_object self) self->vector.self.t[self->vector.fillp] = ECL_NIL; return result; } + +void +ecl_stack_grow(cl_object self, cl_index n) +{ + self->vector.fillp += n; +} + +void +ecl_stack_drop(cl_object self, cl_index n) +{ + self->vector.fillp -= n; +}