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 | 35 +++------------------------------- dlls/vbscript/vbscript.c | 41 ++++++++++++++++++++++++++++++++++++++++ dlls/vbscript/vbscript.h | 3 +++ 3 files changed, 47 insertions(+), 32 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index aea1533..7dac715 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -1954,38 +1954,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; - code->last_global_var = var; - } - - 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; - code->last_func = new_func; - } - - 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->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 ed71f04..aa00381 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -82,6 +82,47 @@ 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; + code->last_global_var = var; + } + + 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; + code->last_func = func; + } + + 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; + 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 22e8cc8..74381c4 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -348,8 +348,11 @@ struct _vbscode_t { unsigned bstr_cnt; heap_pool_t heap;
+ dynamic_var_t *global_vars; dynamic_var_t *last_global_var; + function_t *funcs; function_t *last_func; + class_desc_t *classes; class_desc_t *last_class;
struct list entry;