Set the environment to the same variable name
[fur] / templates / function_definition.c
1
2 Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environment* environment, size_t argc, Stack* parentStack, jmp_buf parentJump)
3 {
4   environment = Environment_construct(environmentPool, environment);
5
6   Stack stackMemory;
7   Stack* stack = &stackMemory;
8   Stack_initialize(stack);
9
10   jmp_buf jump;
11   if(setjmp(jump) != 0)
12   {
13     fprintf(stderr, "\tin {{name}}\n");
14
15     while(Stack_any(stack))
16     {
17       Object item = Stack_pop(stack);
18       Object_deinitialize(&item);
19     }
20     Environment_setLive(environment, false);
21
22     longjmp(parentJump, 1);
23   }
24
25   Object result = builtin$nil;
26
27   {% for argument_name in argument_name_list|reverse %}
28   Environment_set(environment, "{{ argument_name }}", Stack_pop(parentStack));
29   {% endfor %}
30
31   {% for statement in statement_list %}
32   {{ statement }}
33   {% endfor %}
34
35   // TODO Set the environment back to the parent environment
36   Environment_setLive(environment, false);
37   return result;
38 }