From 13d9d83383609c3e3174834bc611f21188067195 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sat, 18 Mar 2023 11:31:38 -0700 Subject: [PATCH] pop_list() Kind of a misnomer, you have to take the tail() of the stack yourself. This function only returns the list from TOS. --- implementations/uvm-ncc/joy.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/implementations/uvm-ncc/joy.c b/implementations/uvm-ncc/joy.c index 4dff1dd..360cd2b 100644 --- a/implementations/uvm-ncc/joy.c +++ b/implementations/uvm-ncc/joy.c @@ -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;