Jacek Caban : jscript: Use bytecode for throw statement.

Alexandre Julliard julliard at winehq.org
Wed Dec 28 13:44:34 CST 2011


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Dec 28 12:06:17 2011 +0100

jscript: Use bytecode for throw statement.

---

 dlls/jscript/compile.c |   14 ++++++++++++++
 dlls/jscript/engine.c  |   12 ++----------
 dlls/jscript/engine.h  |    2 +-
 dlls/jscript/parser.y  |    2 +-
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index c02db25..9e8cb47 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -1299,6 +1299,18 @@ static HRESULT compile_switch_statement(compiler_ctx_t *ctx, switch_statement_t
     return S_OK;
 }
 
+/* ECMA-262 3rd Edition    12.13 */
+static HRESULT compile_throw_statement(compiler_ctx_t *ctx, expression_statement_t *stat)
+{
+    HRESULT hres;
+
+    hres = compile_expression(ctx, stat->expr);
+    if(FAILED(hres))
+        return hres;
+
+    return push_instr(ctx, OP_throw) == -1 ? E_OUTOFMEMORY : S_OK;
+}
+
 static HRESULT compile_statement(compiler_ctx_t *ctx, statement_t *stat)
 {
     switch(stat->type) {
@@ -1318,6 +1330,8 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_t *stat)
         return push_instr(ctx, OP_label) == -1 ? E_OUTOFMEMORY : S_OK; /* FIXME */
     case STAT_SWITCH:
         return compile_switch_statement(ctx, (switch_statement_t*)stat);
+    case STAT_THROW:
+        return compile_throw_statement(ctx, (expression_statement_t*)stat);
     case STAT_VAR:
         return compile_var_statement(ctx, (var_statement_t*)stat);
     case STAT_WHILE:
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 5c4852b..b7b3248 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1234,19 +1234,11 @@ HRESULT switch_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type
 }
 
 /* ECMA-262 3rd Edition    12.13 */
-HRESULT throw_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
+static HRESULT interp_throw(exec_ctx_t *ctx)
 {
-    expression_statement_t *stat = (expression_statement_t*)_stat;
-    VARIANT val;
-    HRESULT hres;
-
     TRACE("\n");
 
-    hres = expr_eval(ctx, stat->expr, &rt->ei, &val);
-    if(FAILED(hres))
-        return hres;
-
-    rt->ei.var = val;
+    ctx->rt->ei.var = *stack_pop(ctx);
     return DISP_E_EXCEPTION;
 }
 
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 147bcad..9aa5616 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -99,6 +99,7 @@ typedef struct _func_stack {
     X(rshift2,    1, 0,0)                  \
     X(str,        1, ARG_STR,    0)        \
     X(this,       1, 0,0)                  \
+    X(throw,      0, 0,0)                  \
     X(throw_ref,  0, ARG_UINT,   0)        \
     X(throw_type, 0, ARG_UINT,   ARG_STR)  \
     X(tonum,      1, 0,0)                  \
@@ -413,7 +414,6 @@ HRESULT break_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*)
 HRESULT return_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
 HRESULT with_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
 HRESULT switch_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
-HRESULT throw_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
 HRESULT try_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
 
 typedef struct {
diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y
index a184202..570eb5b 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -847,7 +847,7 @@ static const statement_eval_t stat_eval_table[] = {
     compiled_statement_eval,
     return_statement_eval,
     compiled_statement_eval,
-    throw_statement_eval,
+    compiled_statement_eval,
     try_statement_eval,
     compiled_statement_eval,
     compiled_statement_eval,




More information about the wine-cvs mailing list