Module: wine Branch: master Commit: 622eb728d75b701b6ab54312a1ac7627993fb92c URL: http://source.winehq.org/git/wine.git/?a=commit;h=622eb728d75b701b6ab54312a1...
Author: Jacek Caban jacek@codeweavers.com Date: Mon May 1 18:30:06 2017 +0200
jscript: Added new opcode to enter catch block and use it to setup the scope.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/compile.c | 4 ++++ dlls/jscript/engine.c | 48 ++++++++++++++++++++++++++---------------------- dlls/jscript/engine.h | 1 + 3 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 3770767..662326b 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -1720,6 +1720,10 @@ static HRESULT compile_try_statement(compiler_ctx_t *ctx, try_statement_t *stat)
instr_ptr(ctx, push_except)->u.arg[0].uint = ctx->code_off;
+ hres = push_instr_bstr(ctx, OP_enter_catch, ident); + if(FAILED(hres)) + return hres; + hres = compile_statement(ctx, &catch_ctx, stat->catch_block->statement); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 90e6f8f..4aee171 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -968,6 +968,26 @@ static HRESULT interp_end_finally(script_ctx_t *ctx) return S_OK; }
+static HRESULT interp_enter_catch(script_ctx_t *ctx) +{ + const BSTR ident = get_op_bstr(ctx, 0); + jsdisp_t *scope_obj; + jsval_t v; + HRESULT hres; + + hres = create_dispex(ctx, NULL, NULL, &scope_obj); + if(FAILED(hres)) + return hres; + + v = stack_pop(ctx); + hres = jsdisp_propput_name(scope_obj, ident, v); + jsval_release(v); + if(SUCCEEDED(hres)) + hres = scope_push(ctx->call_ctx->scope, scope_obj, to_disp(scope_obj), &ctx->call_ctx->scope); + jsdisp_release(scope_obj); + return hres; +} + /* ECMA-262 3rd Edition 13 */ static HRESULT interp_func(script_ctx_t *ctx) { @@ -2655,6 +2675,7 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres) }
except_frame = frame->except_frame; + ident = except_frame->ident; frame->except_frame = except_frame->next;
assert(except_frame->stack_top <= ctx->stack_top); @@ -2664,37 +2685,20 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres) scope_pop(&frame->scope);
frame->ip = except_frame->catch_off; + if(ident) assert(frame->bytecode->instrs[frame->ip].op == OP_enter_catch);
except_val = ctx->ei.val; ctx->ei.val = jsval_undefined(); clear_ei(ctx);
- ident = except_frame->ident; heap_free(except_frame);
- if(ident) { - jsdisp_t *scope_obj; - - hres = create_dispex(ctx, NULL, NULL, &scope_obj); - if(SUCCEEDED(hres)) { - hres = jsdisp_propput_name(scope_obj, ident, except_val); - if(FAILED(hres)) - jsdisp_release(scope_obj); - } - jsval_release(except_val); - if(FAILED(hres)) - return hres; - - hres = scope_push(frame->scope, scope_obj, to_disp(scope_obj), &frame->scope); - jsdisp_release(scope_obj); - }else { - hres = stack_push(ctx, except_val); - if(FAILED(hres)) - return hres; + hres = stack_push(ctx, except_val); + if(FAILED(hres)) + return hres;
+ if(!ident) hres = stack_push(ctx, jsval_bool(FALSE)); - } - return hres; }
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index f5b484b..bf74576 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -35,6 +35,7 @@ X(div, 1, 0,0) \ X(double, 1, ARG_DBL, 0) \ X(end_finally,1, 0,0) \ + X(enter_catch,1, ARG_BSTR, 0) \ X(eq, 1, 0,0) \ X(eq2, 1, 0,0) \ X(forin, 0, ARG_ADDR, 0) \