pop_list()

Kind of a misnomer, you have to take the tail() of the stack yourself.
This function only returns the list from TOS.
This commit is contained in:
Simon Forman 2023-03-18 11:31:38 -07:00
parent d735d00016
commit 13d9d83383
1 changed files with 12 additions and 2 deletions

View File

@ -555,8 +555,9 @@ joy_eval(char *symbol, u32 stack, u32 expression)
return (u64)stack << 32 | expression;
}
u64
swaack(u32 stack, u32 expression)
u32
pop_list(u32 stack)
{
if (!stack) {
error = NOT_ENOUGH_VALUES_ON_STACK;
@ -567,6 +568,15 @@ swaack(u32 stack, u32 expression)
error = NOT_A_LIST;
return 0;
}
return list;
}
u64
swaack(u32 stack, u32 expression)
{
u32 list = pop_list(stack);
CHECK_ERROR
stack = cons(tail(stack), list);
CHECK_ERROR
return (u64)stack << 32 | expression;