Commit daf0b8da authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Store exception value as jsval_t instead of VARIANT.

parent 80f7f3c2
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
};
......@@ -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;
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment