Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
This is temporary (instead of using an array which will come later), to keep it simpler and with less changes.
dlls/vbscript/compile.c | 32 +++----------------------------- dlls/vbscript/vbscript.c | 38 ++++++++++++++++++++++++++++++++++++++ dlls/vbscript/vbscript.h | 4 ++++ 3 files changed, 45 insertions(+), 29 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 6ab8352..0b49380 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -1913,35 +1913,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->next; var = var->next); - - var->next = script->script_obj->global_vars; - script->script_obj->global_vars = ctx.global_vars; - } - - if(ctx.funcs) { - for(new_func = ctx.funcs; new_func->next; new_func = new_func->next); - - new_func->next = script->script_obj->global_funcs; - script->script_obj->global_funcs = ctx.funcs; - } - - if(ctx.classes) { - class_desc_t *class = ctx.classes; - - while(1) { - class->ctx = script; - if(!class->next) - break; - class = class->next; - } - - class->next = script->script_obj->classes; - script->script_obj->classes = ctx.classes; - } + 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 f4ac249..79a27d1 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -82,6 +82,44 @@ static inline BOOL is_started(VBScript *This)
static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code, VARIANT *res) { + ScriptDisp *obj = ctx->script_obj; + + if (code->global_vars) + { + dynamic_var_t *var; + + for (var = code->global_vars; var->next; var = var->next); + + var->next = obj->global_vars; + obj->global_vars = code->global_vars; + } + + if (code->funcs) + { + function_t *func; + + for (func = code->funcs; func->next; func = func->next); + + func->next = obj->global_funcs; + obj->global_funcs = code->funcs; + } + + if (code->classes) + { + class_desc_t *class = code->classes; + + for (;;) + { + class->ctx = ctx; + if (!class->next) + break; + class = class->next; + } + + class->next = obj->classes; + obj->classes = code->classes; + } + return exec_script(ctx, TRUE, &code->main_code, NULL, NULL, res); }
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 9ce309e..568c1a5 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -347,6 +347,10 @@ struct _vbscode_t { unsigned bstr_cnt; heap_pool_t heap;
+ dynamic_var_t *global_vars; + function_t *funcs; + class_desc_t *classes; + struct list entry; };