mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-10 07:00:20 -07:00
[nucl] stacks: add a few unsafe operations
This commit is contained in:
parent
1f07d7530e
commit
9da5576fc1
1 changed files with 37 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue