From 6fb9ec2ad402e9cce30dac407f975b70ae890862 Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 27 Apr 2024 05:51:16 +0000 Subject: [PATCH] should be fixed git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@76 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- Makefile | 2 +- Serenade/interpreter.c | 2 ++ Serenade/interpreter.h | 1 + Serenade/run.c | 4 +++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a676a01..3eab909 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ all: ./Tool ./config.h ./Serenade clean: $(MAKE) -C ./Tool clean - $(MAKE) -C ./Serenade clean + $(MAKE) -C ./Serenade clean SUFFIX_SO="$(SUFFIX_SO)" PREFIX_SO="$(PREFIX_SO)" rm -f config.h FILES = `find . -name "*.c" -or -name "*.h"` diff --git a/Serenade/interpreter.c b/Serenade/interpreter.c index 58eb16a..269208e 100644 --- a/Serenade/interpreter.c +++ b/Serenade/interpreter.c @@ -170,8 +170,10 @@ struct sn_interpreter* sn_create_interpreter(void) { struct sn_interpreter* sn = malloc(sizeof(struct sn_interpreter)); sn->variables = malloc(sizeof(struct sn_interpreter_kv*)); sn->variables[0] = NULL; + sn->local_variables = NULL; sn->generics = malloc(sizeof(struct sn_generic**)); sn->generics[0] = NULL; + sn->callstack = 0; return sn; } diff --git a/Serenade/interpreter.h b/Serenade/interpreter.h index 8e4b552..ebc3be0 100644 --- a/Serenade/interpreter.h +++ b/Serenade/interpreter.h @@ -37,6 +37,7 @@ struct sn_interpreter { struct sn_interpreter_kv** variables; struct sn_interpreter_kv** local_variables; struct sn_generic*** generics; + int callstack; }; struct sn_interpreter_kv { diff --git a/Serenade/run.c b/Serenade/run.c index 705c93f..fbc6612 100644 --- a/Serenade/run.c +++ b/Serenade/run.c @@ -48,10 +48,12 @@ struct sn_generic* run_code(struct sn_interpreter* sn, int argc, struct sn_gener int i; struct sn_interpreter_kv** old_kv = sn->local_variables; sn->local_variables = malloc(sizeof(struct sn_interpreter_kv*)); - sn->local_variables[i] = NULL; + sn->local_variables[0] = NULL; + sn->callstack++; for(i = 0; gens[i] != NULL; i++) { _sn_run(sn, gens[i]); } + sn->callstack--; free(sn->local_variables); sn->local_variables = old_kv; return r; -- 2.43.0