Jacek Caban : jscript: Call script_parse from compile_script, not the other way around.

Alexandre Julliard julliard at winehq.org
Tue Mar 13 13:50:35 CDT 2012


Module: wine
Branch: master
Commit: be29a73845461aff1ae5c6572699127be87d4005
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=be29a73845461aff1ae5c6572699127be87d4005

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Mar 12 19:22:59 2012 +0100

jscript: Call script_parse from compile_script, not the other way around.

---

 dlls/jscript/compile.c  |   17 ++++++++++++++---
 dlls/jscript/engine.h   |    2 +-
 dlls/jscript/function.c |    2 +-
 dlls/jscript/global.c   |    2 +-
 dlls/jscript/jscript.c  |    4 ++--
 dlls/jscript/parser.y   |    2 --
 6 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 8d1487b..dc6f099 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -1778,13 +1778,24 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source,
     return S_OK;
 }
 
-HRESULT compile_script(parser_ctx_t *parser, BOOL from_eval)
+HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimiter, BOOL from_eval,
+        parser_ctx_t **ret)
 {
+    parser_ctx_t *parser;
     HRESULT hres;
 
-    hres = init_compiler(parser);
+    hres = script_parse(ctx, code, delimiter, from_eval, &parser);
     if(FAILED(hres))
         return hres;
 
-    return compile_function(parser->compiler, parser->source, from_eval);
+    hres = init_compiler(parser);
+    if(SUCCEEDED(hres))
+        hres = compile_function(parser->compiler, parser->source, from_eval);
+    if(FAILED(hres)) {
+        parser_release(parser);
+        return hres;
+    }
+
+    *ret = parser;
+    return S_OK;
 }
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 7135578..73553b6 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -577,4 +577,4 @@ typedef struct {
     prop_val_t *property_list;
 } property_value_expression_t;
 
-HRESULT compile_script(parser_ctx_t*,BOOL) DECLSPEC_HIDDEN;
+HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,BOOL,parser_ctx_t**) DECLSPEC_HIDDEN;
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index abccae5..23f7e47 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -774,7 +774,7 @@ static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t
     if(FAILED(hres))
         return hres;
 
-    hres = script_parse(ctx, str, NULL, FALSE, &parser);
+    hres = compile_script(ctx, str, NULL, FALSE, &parser);
     heap_free(str);
     if(FAILED(hres))
         return hres;
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index 620b554..8a6fe38 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -371,7 +371,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
     }
 
     TRACE("parsing %s\n", debugstr_w(V_BSTR(arg)));
-    hres = script_parse(ctx, V_BSTR(arg), NULL, TRUE, &parser_ctx);
+    hres = compile_script(ctx, V_BSTR(arg), NULL, TRUE, &parser_ctx);
     if(FAILED(hres)) {
         WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(arg)), hres);
         return throw_syntax_error(ctx, ei, hres, NULL);
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index 8b0c28b..81c8f21 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -762,7 +762,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
     if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
         return E_UNEXPECTED;
 
-    hres = script_parse(This->ctx, pstrCode, pstrDelimiter, FALSE, &parser_ctx);
+    hres = compile_script(This->ctx, pstrCode, pstrDelimiter, FALSE, &parser_ctx);
     if(FAILED(hres))
         return hres;
 
@@ -829,7 +829,7 @@ static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptPars
     if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
         return E_UNEXPECTED;
 
-    hres = script_parse(This->ctx, pstrCode, pstrDelimiter, FALSE, &parser_ctx);
+    hres = compile_script(This->ctx, pstrCode, pstrDelimiter, FALSE, &parser_ctx);
     if(FAILED(hres)) {
         WARN("Parse failed %08x\n", hres);
         return hres;
diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y
index 2a42034..66b5476 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -1582,8 +1582,6 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite
     parser_parse(parser_ctx);
     jsheap_clear(mark);
     hres = parser_ctx->hres;
-    if(SUCCEEDED(hres))
-        hres = compile_script(parser_ctx, from_eval);
     if(FAILED(hres)) {
         parser_release(parser_ctx);
         return hres;




More information about the wine-cvs mailing list