From: David Kerkeslager Date: Tue, 12 Dec 2017 23:58:42 +0000 (-0500) Subject: Reuse the parent stack in current stack frame X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=eec2a40d60e5f6a00b5013ef46d2ed2925f23da5;p=fur Reuse the parent stack in current stack frame --- diff --git a/templates/function_definition.c b/templates/function_definition.c index 9af7632..ce869b2 100644 --- a/templates/function_definition.c +++ b/templates/function_definition.c @@ -1,9 +1,8 @@ -Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environment* environment, size_t argc, Stack* parentStack, jmp_buf parentJump) +Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environment* environment, size_t argc, Stack* stack, jmp_buf parentJump) { environment = Environment_construct(environmentPool, environment); - Stack* stack = Stack_construct(); StackSnapshot stackSnapshot = Stack_takeSnapshot(stack); jmp_buf jump; @@ -14,15 +13,13 @@ Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environmen Stack_rewind(stack, stackSnapshot); Environment_setLive(environment, false); - Stack_destruct(stack); - longjmp(parentJump, 1); } Object result = builtin$nil; {% for argument_name in argument_name_list|reverse %} - Environment_set(environment, "{{ argument_name }}", Stack_pop(parentStack)); + Environment_set(environment, "{{ argument_name }}", Stack_pop(stack)); {% endfor %} {% for statement in statement_list %} @@ -31,7 +28,5 @@ Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environmen // TODO Set the environment back to the parent environment Environment_setLive(environment, false); - - Stack_destruct(stack); return result; }