Jacek Caban : jscript: Use bytecode for execution main code block in exec_source.

Alexandre Julliard julliard at winehq.org
Mon Dec 19 13:39:23 CST 2011


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Dec 19 14:59:12 2011 +0100

jscript: Use bytecode for execution main code block in exec_source.

---

 dlls/jscript/compile.c |    7 +++++--
 dlls/jscript/engine.c  |   19 +++++++------------
 dlls/jscript/engine.h  |    2 +-
 3 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 0c9ce64..5306f8b 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -931,7 +931,7 @@ HRESULT compile_subscript(parser_ctx_t *parser, expression_t *expr, BOOL do_ret,
     return push_instr(parser->compiler, OP_ret) == -1 ? E_OUTOFMEMORY : S_OK;
 }
 
-HRESULT compile_subscript_stat(parser_ctx_t *parser, statement_t *stat, unsigned *ret_off)
+HRESULT compile_subscript_stat(parser_ctx_t *parser, statement_t *stat, BOOL compile_block, unsigned *ret_off)
 {
     HRESULT hres;
 
@@ -942,7 +942,10 @@ HRESULT compile_subscript_stat(parser_ctx_t *parser, statement_t *stat, unsigned
         return hres;
 
     *ret_off = parser->compiler->code_off;
-    hres = compile_statement(parser->compiler, stat);
+    if(compile_block && stat->next)
+        hres = compile_block_statement(parser->compiler, stat);
+    else
+        hres = compile_statement(parser->compiler, stat);
     if(FAILED(hres))
         return hres;
 
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 2311ea0..61ed5c5 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -513,8 +513,7 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so
     function_declaration_t *func;
     parser_ctx_t *prev_parser;
     var_list_t *var;
-    VARIANT val, tmp;
-    statement_t *stat;
+    VARIANT val;
     exec_ctx_t *prev_ctx;
     return_type_t rt;
     HRESULT hres = S_OK;
@@ -560,15 +559,11 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so
     memset(&rt, 0, sizeof(rt));
     rt.type = RT_NORMAL;
 
-    for(stat = source->statement; stat; stat = stat->next) {
-        hres = stat_eval(script, stat, &rt, &tmp);
-        if(FAILED(hres))
-            break;
-
-        VariantClear(&val);
-        val = tmp;
-        if(rt.type != RT_NORMAL)
-            break;
+    if(source->statement) {
+        if(source->statement->instr_off == -1)
+            hres = compile_subscript_stat(ctx->parser, source->statement, TRUE, &source->statement->instr_off);
+        if(SUCCEEDED(hres))
+            hres = compiled_statement_eval(script, source->statement, &rt, &val);
     }
 
     script->exec_ctx = prev_ctx;
@@ -3005,7 +3000,7 @@ HRESULT compiled_statement_eval(script_ctx_t *ctx, statement_t *stat, return_typ
     TRACE("\n");
 
     if(stat->instr_off == -1) {
-        hres = compile_subscript_stat(exec_ctx->parser, stat, &stat->instr_off);
+        hres = compile_subscript_stat(exec_ctx->parser, stat, FALSE, &stat->instr_off);
         if(FAILED(hres))
             return hres;
     }
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index bcba203..93ab007 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -590,4 +590,4 @@ typedef struct {
 } property_value_expression_t;
 
 HRESULT compile_subscript(parser_ctx_t*,expression_t*,BOOL,unsigned*) DECLSPEC_HIDDEN;
-HRESULT compile_subscript_stat(parser_ctx_t*,statement_t*,unsigned*) DECLSPEC_HIDDEN;
+HRESULT compile_subscript_stat(parser_ctx_t*,statement_t*,BOOL,unsigned*) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list