From: David Kerkeslager Date: Tue, 12 Dec 2017 23:37:37 +0000 (-0500) Subject: Set the environment to the same variable name X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=1f2895250c61aeb81c0f0ba7efed156c9386dfac;p=fur Set the environment to the same variable name --- diff --git a/templates/function_definition.c b/templates/function_definition.c index 4635e9c..c483bda 100644 --- a/templates/function_definition.c +++ b/templates/function_definition.c @@ -1,8 +1,7 @@ -Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environment* parent, size_t argc, Stack* parentStack, jmp_buf parentJump) +Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environment* environment, size_t argc, Stack* parentStack, jmp_buf parentJump) { - Environment* environment = EnvironmentPool_allocate(environmentPool); - Environment_initialize(environment, parent); + environment = Environment_construct(environmentPool, environment); Stack stackMemory; Stack* stack = &stackMemory; @@ -33,6 +32,7 @@ Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environmen {{ statement }} {% endfor %} + // TODO Set the environment back to the parent environment Environment_setLive(environment, false); return result; } diff --git a/templates/program.c b/templates/program.c index 6b49881..f2fc244 100644 --- a/templates/program.c +++ b/templates/program.c @@ -522,6 +522,13 @@ Environment* EnvironmentPool_allocate(EnvironmentPool* self) return EnvironmentPool_allocate(previous->overflow); } +Environment* Environment_construct(EnvironmentPool* environmentPool, Environment* parent) +{ + Environment* environment = EnvironmentPool_allocate(environmentPool); + Environment_initialize(environment, parent); + return environment; +} + Object integerLiteral(int32_t literal) { Object result;