From bd8572b576c8ce8396d3f50e458186787a3911fa Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 11 May 2004 06:13:17 +0000 Subject: [PATCH] Fix a bug that caused global variables in Dynamic Pascal to be incorrectly allocated as locals. --- ChangeLog | 4 ++++ dpas/dpas-parser.y | 2 +- dpas/dpas-scope.c | 5 +++++ dpas/dpas-scope.h | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d7f0308..00e3c0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,10 @@ * jit/jit-rules-interp.c, jit/jit-rules-interp.h: implement the exception-handling opcodes for the interpreter. + * dpas/dpas-parser.y, dpas/dpas-scope.c, dpas/dpas-scope.h: + fix a bug that caused global variables in Dynamic Pascal + to be incorrectly allocated as locals. + 2004-05-10 Rhys Weatherley * jit/jit-reg-alloc.c, jit/jit-reg-alloc.h, jit/jit-rules-interp.c: diff --git a/dpas/dpas-parser.y b/dpas/dpas-parser.y index a05c3e0..05dc8ad 100644 --- a/dpas/dpas-parser.y +++ b/dpas/dpas-parser.y @@ -1125,7 +1125,7 @@ VariableDeclaration } else { - if(dpas_current_function()) + if(!dpas_scope_is_module()) { jit_value_t value; value = jit_value_create diff --git a/dpas/dpas-scope.c b/dpas/dpas-scope.c index 50065f3..951b034 100644 --- a/dpas/dpas-scope.c +++ b/dpas/dpas-scope.c @@ -360,3 +360,8 @@ void dpas_scope_pop(void) dpas_scope_destroy(scope); } } + +int dpas_scope_is_module(void) +{ + return (dpas_scope_current()->parent == dpas_scope_global()); +} diff --git a/dpas/dpas-scope.h b/dpas/dpas-scope.h index b0f3770..6f41ce3 100644 --- a/dpas/dpas-scope.h +++ b/dpas/dpas-scope.h @@ -149,6 +149,11 @@ dpas_scope_t dpas_scope_push(void); */ void dpas_scope_pop(void); +/* + * Determine if the current scope is the module-global scope. + */ +int dpas_scope_is_module(void); + #ifdef __cplusplus }; #endif -- 2.47.3