Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/vbscript/compile.c | 60 +++++++++++++++++----------------------- dlls/vbscript/vbscript.c | 35 +++++++++++++++++++++++ dlls/vbscript/vbscript.h | 3 ++ 3 files changed, 64 insertions(+), 34 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 42aaf92..be4b37d 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -1780,9 +1780,10 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
static BOOL lookup_script_identifier(script_ctx_t *script, const WCHAR *identifier) { - dynamic_var_t **vars = script->global_vars; - function_t **funcs = script->global_funcs; + dynamic_var_t *var, **vars = script->global_vars; + function_t *func, **funcs = script->global_funcs; class_desc_t *class; + vbscode_t *code; UINT i;
for(i = 0; i < script->global_vars_num; i++) { @@ -1800,6 +1801,26 @@ static BOOL lookup_script_identifier(script_ctx_t *script, const WCHAR *identifi return TRUE; }
+ LIST_FOR_EACH_ENTRY(code, &script->code_list, vbscode_t, entry) { + if(!code->pending_exec) + continue; + + for(var = code->global_vars; var; var = var->next) { + if(!wcsicmp(var->name, identifier)) + return TRUE; + } + + for(func = code->funcs; func; func = func->next) { + if(!wcsicmp(func->name, identifier)) + return TRUE; + } + + for(class = code->classes; class; class = class->next) { + if(!wcsicmp(class->name, identifier)) + return TRUE; + } + } + return FALSE; }
@@ -1954,38 +1975,9 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli return compile_error(script, hres); }
- if(ctx.global_vars) { - dynamic_var_t *var; - - for (var = ctx.global_vars; var; var = var->next) - if (!add_global_var(script, var)) { - release_compiler(&ctx); - return compile_error(script, E_OUTOFMEMORY); - } - } - - if(ctx.funcs) { - for (new_func = ctx.funcs; new_func; new_func = new_func->next) - if (!add_global_func(script, new_func)) { - release_compiler(&ctx); - return compile_error(script, E_OUTOFMEMORY); - } - } - - if(ctx.classes) { - class_desc_t *class = ctx.classes; - - while(1) { - class->ctx = script; - if(!class->next) - break; - class = class->next; - } - - class->next = script->classes; - script->classes = ctx.classes; - code->last_class = class; - } + code->global_vars = ctx.global_vars; + code->funcs = ctx.funcs; + code->classes = ctx.classes;
if(TRACE_ON(vbscript_disas)) dump_code(&ctx); diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index 2ffd6fd..9165759 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -82,6 +82,41 @@ static inline BOOL is_started(VBScript *This)
static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code, VARIANT *res) { + if (code->global_vars) + { + dynamic_var_t *var; + + for (var = code->global_vars; var; var = var->next) + if (!add_global_var(ctx, var)) + return E_OUTOFMEMORY; + } + + if (code->funcs) + { + function_t *func; + + for (func = code->funcs; func; func = func->next) + if (!add_global_func(ctx, func)) + return E_OUTOFMEMORY; + } + + if (code->classes) + { + class_desc_t *class = code->classes; + + while (1) + { + class->ctx = ctx; + if (!class->next) + break; + class = class->next; + } + + class->next = ctx->classes; + ctx->classes = code->classes; + code->last_class = class; + } + code->pending_exec = FALSE; return exec_script(ctx, TRUE, &code->main_code, NULL, NULL, res); } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 74fef1a..24ff84d 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -350,6 +350,9 @@ struct _vbscode_t { unsigned bstr_cnt; heap_pool_t heap;
+ dynamic_var_t *global_vars; + function_t *funcs; + class_desc_t *classes; class_desc_t *last_class;
struct list entry;