From: Rhys Weatherley Date: Tue, 11 May 2004 06:13:17 +0000 (+0000) Subject: Fix a bug that caused global variables in Dynamic Pascal X-Git-Tag: r.0.0.2~18 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=bd8572b576c8ce8396d3f50e458186787a3911fa;p=francis%2Flibjit.git Fix a bug that caused global variables in Dynamic Pascal to be incorrectly allocated as locals. --- 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