[PATCH 1/7] vbscript: Store non-persistent code into the script dispatch object.

Gabriel Ivăncescu gabrielopcode at gmail.com
Tue Oct 29 10:19:34 CDT 2019


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

These patches correct the implementation so that it passes the tests at
the end of the series. Some changes are done to simplify the next patch in
the series.

I haven't sent the linked list->array conversion yet, because that is not
a functional change, just an optimization, so it will come after this is
corrected first.

 dlls/vbscript/compile.c  |  3 ++-
 dlls/vbscript/vbdisp.c   |  5 +++++
 dlls/vbscript/vbscript.c | 12 ++++++++++++
 dlls/vbscript/vbscript.h |  1 +
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index 2023261..fc94998 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -1948,7 +1948,6 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
     ctx.code = NULL;
     release_compiler(&ctx);
 
-    list_add_tail(&script->code_list, &code->entry);
     *ret = code;
     return S_OK;
 }
@@ -1975,6 +1974,8 @@ HRESULT compile_procedure(script_ctx_t *script, const WCHAR *src, const WCHAR *d
     desc->next = script->procs;
     script->procs = desc;
 
+    list_add_tail(&script->script_obj->code_list, &code->entry);
+
     *ret = desc;
     return S_OK;
 }
diff --git a/dlls/vbscript/vbdisp.c b/dlls/vbscript/vbdisp.c
index 1dd6d4e..7859abf 100644
--- a/dlls/vbscript/vbdisp.c
+++ b/dlls/vbscript/vbdisp.c
@@ -616,6 +616,10 @@ static ULONG WINAPI ScriptDisp_Release(IDispatchEx *iface)
 
     if(!ref) {
         assert(!This->ctx);
+
+        while (!list_empty(&This->code_list))
+            release_vbscode(LIST_ENTRY(list_head(&This->code_list), vbscode_t, entry));
+
         heap_free(This->ident_map);
         heap_free(This);
     }
@@ -827,6 +831,7 @@ HRESULT create_script_disp(script_ctx_t *ctx, ScriptDisp **ret)
     script_disp->IDispatchEx_iface.lpVtbl = &ScriptDispVtbl;
     script_disp->ref = 1;
     script_disp->ctx = ctx;
+    list_init(&script_disp->code_list);
 
     *ret = script_disp;
     return S_OK;
diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c
index 56c53b4..ca594f1 100644
--- a/dlls/vbscript/vbscript.c
+++ b/dlls/vbscript/vbscript.c
@@ -94,6 +94,10 @@ static void exec_queued_code(script_ctx_t *ctx)
         if(iter->pending_exec)
             exec_global_code(ctx, iter, NULL);
     }
+    LIST_FOR_EACH_ENTRY(iter, &ctx->script_obj->code_list, vbscode_t, entry) {
+        if(iter->pending_exec)
+            exec_global_code(ctx, iter, NULL);
+    }
 }
 
 IDispatch *lookup_named_item(script_ctx_t *ctx, const WCHAR *name, unsigned flags)
@@ -764,6 +768,7 @@ static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface,
 {
     VBScript *This = impl_from_IActiveScriptParse(iface);
     IDispatch *context = NULL;
+    struct list *list;
     vbscode_t *code;
     HRESULT hres;
 
@@ -786,6 +791,13 @@ static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface,
     if(FAILED(hres))
         return hres;
 
+    if(dwFlags & SCRIPTTEXT_ISPERSISTENT)
+        list = &This->ctx->code_list;
+    else
+        list = &This->ctx->script_obj->code_list;
+
+    list_add_tail(list, &code->entry);
+
     if(context)
         IDispatch_AddRef(code->context = context);
 
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 33eb1e8..cfa7469 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -131,6 +131,7 @@ typedef struct {
     unsigned ident_map_size;
 
     script_ctx_t *ctx;
+    struct list code_list;
 } ScriptDisp;
 
 typedef struct _builtin_prop_t builtin_prop_t;
-- 
2.21.0




More information about the wine-devel mailing list