From daf0b8dad2f68292524787bf52e413b972cd2d13 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 17 Sep 2012 15:17:36 +0200 Subject: [PATCH] jscript: Store exception value as jsval_t instead of VARIANT. --- dlls/jscript/engine.c | 38 +++++++------------------------------- dlls/jscript/error.c | 2 +- dlls/jscript/jscript.c | 2 +- dlls/jscript/jscript.h | 11 ++++++----- dlls/jscript/jsutils.c | 2 +- dlls/jscript/regexp.c | 2 +- 6 files changed, 17 insertions(+), 40 deletions(-) diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 1cc8884e71b..10e47f61bfb 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -674,19 +674,9 @@ static HRESULT interp_case(exec_ctx_t *ctx) /* ECMA-262 3rd Edition 12.13 */ static HRESULT interp_throw(exec_ctx_t *ctx) { - VARIANT v; - jsval_t val; - HRESULT hres; - TRACE("\n"); - val = stack_pop(ctx); - hres = jsval_to_variant(val, &v); - jsval_release(val); - if(FAILED(hres)) - return hres; - - ctx->ei->var = v; + ctx->ei->val = stack_pop(ctx); return DISP_E_EXCEPTION; } @@ -778,9 +768,7 @@ static HRESULT interp_end_finally(exec_ctx_t *ctx) jsval_release(v); stack_popn(ctx, 1); - v = stack_pop(ctx); - hres = jsval_to_variant(v, &ctx->ei->var); - jsval_release(v); + ctx->ei->val = stack_pop(ctx); return SUCCEEDED(hres) ? DISP_E_EXCEPTION : hres; } @@ -2382,7 +2370,7 @@ OP_LIST static HRESULT unwind_exception(exec_ctx_t *ctx) { except_frame_t *except_frame; - VARIANT except_val; + jsval_t except_val; BSTR ident; HRESULT hres; @@ -2397,7 +2385,7 @@ static HRESULT unwind_exception(exec_ctx_t *ctx) ctx->ip = except_frame->catch_off; - except_val = ctx->ei->var; + except_val = ctx->ei->val; memset(ctx->ei, 0, sizeof(*ctx->ei)); ident = except_frame->ident; @@ -2408,30 +2396,18 @@ static HRESULT unwind_exception(exec_ctx_t *ctx) hres = create_dispex(ctx->script, NULL, NULL, &scope_obj); if(SUCCEEDED(hres)) { - jsval_t val; - - hres = variant_to_jsval(&except_val, &val); - if(SUCCEEDED(hres)) { - hres = jsdisp_propput_name(scope_obj, ident, val, ctx->ei); - jsval_release(val); - } + hres = jsdisp_propput_name(scope_obj, ident, except_val, ctx->ei); if(FAILED(hres)) jsdisp_release(scope_obj); } - VariantClear(&except_val); + jsval_release(except_val); if(FAILED(hres)) return hres; hres = scope_push(ctx->scope_chain, scope_obj, to_disp(scope_obj), &ctx->scope_chain); jsdisp_release(scope_obj); }else { - jsval_t exceptv; - - hres = variant_to_jsval(&except_val, &exceptv); - if(FAILED(hres)) - return hres; - - hres = stack_push(ctx, exceptv); + hres = stack_push(ctx, except_val); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c index 407bd3ba5a2..77497a9a538 100644 --- a/dlls/jscript/error.c +++ b/dlls/jscript/error.c @@ -400,7 +400,7 @@ static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, con return hres; if(ei) - var_set_jsdisp(&ei->var, err); + ei->val = jsval_obj(err); return error; } diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index bf6710b2736..f106be9a0af 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -110,7 +110,7 @@ static HRESULT exec_global_code(JScript *This, bytecode_t *code) memset(&jsexcept, 0, sizeof(jsexcept)); hres = exec_source(exec_ctx, code, &code->global_code, FALSE, &jsexcept, NULL); - VariantClear(&jsexcept.var); + jsval_release(jsexcept.val); exec_release(exec_ctx); IActiveScriptSite_OnLeaveScript(This->site); diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index ef20c54f312..41c67c9fa22 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -37,11 +37,7 @@ typedef struct _jsval_t jsval_t; typedef struct _script_ctx_t script_ctx_t; typedef struct _exec_ctx_t exec_ctx_t; typedef struct _dispex_prop_t dispex_prop_t; - -typedef struct { - EXCEPINFO ei; - VARIANT var; -} jsexcept_t; +typedef struct _jsexcept_t jsexcept_t; typedef struct { void **blocks; @@ -548,3 +544,8 @@ static inline LPWSTR heap_strdupW(LPCWSTR str) } #include "jsval.h" + +struct _jsexcept_t { + EXCEPINFO ei; + jsval_t val; +}; diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c index a4f84c55fc8..0439b10eaa3 100644 --- a/dlls/jscript/jsutils.c +++ b/dlls/jscript/jsutils.c @@ -1062,7 +1062,7 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY } if(FAILED(hres)) { - VariantClear(&ei.var); + jsval_release(ei.val); return hres; } diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c index e783c540a15..1c891a62f96 100644 --- a/dlls/jscript/regexp.c +++ b/dlls/jscript/regexp.c @@ -3525,7 +3525,7 @@ static INT index_from_val(script_ctx_t *ctx, jsval_t v) memset(&ei, 0, sizeof(ei)); hres = to_number_jsval(ctx, v, &ei, &n); if(FAILED(hres)) { /* FIXME: Move ignoring exceptions to to_primitive */ - VariantClear(&ei.var); + jsval_release(ei.val); return 0; }