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

jscript: Delay error object creation for builtin errors with message string until it's needed.

parent bcba0722
...@@ -2483,13 +2483,13 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t ...@@ -2483,13 +2483,13 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t
if(((desc->mask & PROPF_CONFIGURABLE) && (desc->flags & PROPF_CONFIGURABLE)) if(((desc->mask & PROPF_CONFIGURABLE) && (desc->flags & PROPF_CONFIGURABLE))
|| ((desc->mask & PROPF_ENUMERABLE) || ((desc->mask & PROPF_ENUMERABLE)
&& ((desc->flags & PROPF_ENUMERABLE) != (prop->flags & PROPF_ENUMERABLE)))) && ((desc->flags & PROPF_ENUMERABLE) != (prop->flags & PROPF_ENUMERABLE))))
return throw_type_error(obj->ctx, JS_E_NONCONFIGURABLE_REDEFINED, name); return throw_error(obj->ctx, JS_E_NONCONFIGURABLE_REDEFINED, name);
} }
if(desc->explicit_value || (desc->mask & PROPF_WRITABLE)) { if(desc->explicit_value || (desc->mask & PROPF_WRITABLE)) {
if(prop->type == PROP_ACCESSOR) { if(prop->type == PROP_ACCESSOR) {
if(!(prop->flags & PROPF_CONFIGURABLE)) if(!(prop->flags & PROPF_CONFIGURABLE))
return throw_type_error(obj->ctx, JS_E_NONCONFIGURABLE_REDEFINED, name); return throw_error(obj->ctx, JS_E_NONCONFIGURABLE_REDEFINED, name);
if(prop->u.accessor.getter) if(prop->u.accessor.getter)
jsdisp_release(prop->u.accessor.getter); jsdisp_release(prop->u.accessor.getter);
if(prop->u.accessor.setter) if(prop->u.accessor.setter)
...@@ -2504,7 +2504,7 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t ...@@ -2504,7 +2504,7 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t
}else { }else {
if(!(prop->flags & PROPF_CONFIGURABLE) && !(prop->flags & PROPF_WRITABLE)) { if(!(prop->flags & PROPF_CONFIGURABLE) && !(prop->flags & PROPF_WRITABLE)) {
if((desc->mask & PROPF_WRITABLE) && (desc->flags & PROPF_WRITABLE)) if((desc->mask & PROPF_WRITABLE) && (desc->flags & PROPF_WRITABLE))
return throw_type_error(obj->ctx, JS_E_NONWRITABLE_MODIFIED, name); return throw_error(obj->ctx, JS_E_NONWRITABLE_MODIFIED, name);
if(desc->explicit_value) { if(desc->explicit_value) {
if(prop->type == PROP_JSVAL) { if(prop->type == PROP_JSVAL) {
BOOL eq; BOOL eq;
...@@ -2512,7 +2512,7 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t ...@@ -2512,7 +2512,7 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(!eq) if(!eq)
return throw_type_error(obj->ctx, JS_E_NONWRITABLE_MODIFIED, name); return throw_error(obj->ctx, JS_E_NONWRITABLE_MODIFIED, name);
}else { }else {
FIXME("redefinition of property type %d\n", prop->type); FIXME("redefinition of property type %d\n", prop->type);
} }
...@@ -2533,7 +2533,7 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t ...@@ -2533,7 +2533,7 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t
}else if(desc->explicit_getter || desc->explicit_setter) { }else if(desc->explicit_getter || desc->explicit_setter) {
if(prop->type != PROP_ACCESSOR) { if(prop->type != PROP_ACCESSOR) {
if(!(prop->flags & PROPF_CONFIGURABLE)) if(!(prop->flags & PROPF_CONFIGURABLE))
return throw_type_error(obj->ctx, JS_E_NONCONFIGURABLE_REDEFINED, name); return throw_error(obj->ctx, JS_E_NONCONFIGURABLE_REDEFINED, name);
if(prop->type == PROP_JSVAL) if(prop->type == PROP_JSVAL)
jsval_release(prop->u.val); jsval_release(prop->u.val);
prop->type = PROP_ACCESSOR; prop->type = PROP_ACCESSOR;
...@@ -2541,7 +2541,7 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t ...@@ -2541,7 +2541,7 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t
}else if(!(prop->flags & PROPF_CONFIGURABLE)) { }else if(!(prop->flags & PROPF_CONFIGURABLE)) {
if((desc->explicit_getter && desc->getter != prop->u.accessor.getter) if((desc->explicit_getter && desc->getter != prop->u.accessor.getter)
|| (desc->explicit_setter && desc->setter != prop->u.accessor.setter)) || (desc->explicit_setter && desc->setter != prop->u.accessor.setter))
return throw_type_error(obj->ctx, JS_E_NONCONFIGURABLE_REDEFINED, name); return throw_error(obj->ctx, JS_E_NONCONFIGURABLE_REDEFINED, name);
} }
if(desc->explicit_getter) { if(desc->explicit_getter) {
......
...@@ -918,7 +918,7 @@ static HRESULT interp_throw_type(script_ctx_t *ctx) ...@@ -918,7 +918,7 @@ static HRESULT interp_throw_type(script_ctx_t *ctx)
TRACE("%08x %s\n", hres, debugstr_jsstr(str)); TRACE("%08x %s\n", hres, debugstr_jsstr(str));
ptr = jsstr_flatten(str); ptr = jsstr_flatten(str);
return ptr ? throw_type_error(ctx, hres, ptr) : E_OUTOFMEMORY; return ptr ? throw_error(ctx, hres, ptr) : E_OUTOFMEMORY;
} }
/* ECMA-262 3rd Edition 12.14 */ /* ECMA-262 3rd Edition 12.14 */
...@@ -1287,7 +1287,7 @@ static HRESULT identifier_value(script_ctx_t *ctx, BSTR identifier) ...@@ -1287,7 +1287,7 @@ static HRESULT identifier_value(script_ctx_t *ctx, BSTR identifier)
return hres; return hres;
if(exprval.type == EXPRVAL_INVALID) if(exprval.type == EXPRVAL_INVALID)
return throw_type_error(ctx, exprval.u.hres, identifier); return throw_error(ctx, exprval.u.hres, identifier);
hres = exprval_to_value(ctx, &exprval, &v); hres = exprval_to_value(ctx, &exprval, &v);
if(FAILED(hres)) if(FAILED(hres))
...@@ -2777,10 +2777,8 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres) ...@@ -2777,10 +2777,8 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres)
} }
frame = ctx->call_ctx; frame = ctx->call_ctx;
if(exception_hres != DISP_E_EXCEPTION) { if(exception_hres != DISP_E_EXCEPTION)
reset_ei(ei); throw_error(ctx, exception_hres, NULL);
ei->error = exception_hres;
}
set_error_location(ei, frame->bytecode, frame->bytecode->instrs[frame->ip].loc, IDS_RUNTIME_ERROR); set_error_location(ei, frame->bytecode, frame->bytecode->instrs[frame->ip].loc, IDS_RUNTIME_ERROR);
while(!frame->except_frame) { while(!frame->except_frame) {
......
...@@ -409,40 +409,15 @@ static jsstr_t *format_error_message(HRESULT error, const WCHAR *arg) ...@@ -409,40 +409,15 @@ static jsstr_t *format_error_message(HRESULT error, const WCHAR *arg)
return r; return r;
} }
static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr) HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{ {
jsdisp_t *err; jsexcept_t *ei = ctx->ei;
jsstr_t *msg; TRACE("%08x\n", error);
HRESULT hres; reset_ei(ei);
ei->error = error;
if(!is_jscript_error(error)) if(str)
return error; ei->message = format_error_message(error, str);
return DISP_E_EXCEPTION;
msg = format_error_message(error, str);
if(!msg)
return E_OUTOFMEMORY;
WARN("%s\n", debugstr_jsstr(msg));
hres = create_error(ctx, constr, error, msg, &err);
jsstr_release(msg);
if(FAILED(hres))
return hres;
reset_ei(ctx->ei);
ctx->ei->valid_value = TRUE;
ctx->ei->value = jsval_obj(err);
return error;
}
HRESULT throw_syntax_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{
return throw_error(ctx, error, str, ctx->syntax_error_constr);
}
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{
return throw_error(ctx, error, str, ctx->type_error_constr);
} }
void set_error_location(jsexcept_t *ei, bytecode_t *code, unsigned loc, unsigned source_id) void set_error_location(jsexcept_t *ei, bytecode_t *code, unsigned loc, unsigned source_id)
......
...@@ -312,7 +312,7 @@ HRESULT Function_get_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN; ...@@ -312,7 +312,7 @@ HRESULT Function_get_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
struct _function_code_t *Function_get_code(jsdisp_t*) DECLSPEC_HIDDEN; struct _function_code_t *Function_get_code(jsdisp_t*) DECLSPEC_HIDDEN;
#define DEFAULT_FUNCTION_VALUE {NULL, Function_value,0, Function_get_value} #define DEFAULT_FUNCTION_VALUE {NULL, Function_value,0, Function_get_value}
HRESULT throw_type_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN; HRESULT throw_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
jsdisp_t *create_builtin_error(script_ctx_t *ctx) DECLSPEC_HIDDEN; jsdisp_t *create_builtin_error(script_ctx_t *ctx) DECLSPEC_HIDDEN;
HRESULT create_object(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN; HRESULT create_object(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
......
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