[nucl] stacks: add a few unsafe operations

This commit is contained in:
Daniel Kochmański 2025-05-25 13:38:27 +02:00
parent 1f07d7530e
commit 9da5576fc1

View file

@ -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;
}