| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index 72af664b0847d9b359e0e08bfadadf64b7fbb1a9..07b28536e959baeba7782629e98b43ca7d041d85 100644
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -2813,34 +2813,23 @@ bool Value::IsUint32() const {
|
| }
|
|
|
|
|
| -static bool CheckConstructor(i::Isolate* isolate,
|
| - i::Handle<i::JSObject> obj,
|
| - const char* class_name) {
|
| - i::Handle<i::Object> constr(obj->map()->GetConstructor(), isolate);
|
| - if (!constr->IsJSFunction()) return false;
|
| - i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(constr);
|
| - return func->shared()->native() && constr.is_identical_to(
|
| - i::Object::GetProperty(isolate,
|
| - isolate->js_builtins_object(),
|
| - class_name).ToHandleChecked());
|
| -}
|
| -
|
| -
|
| bool Value::IsNativeError() const {
|
| i::Handle<i::Object> obj = Utils::OpenHandle(this);
|
| - if (obj->IsJSObject()) {
|
| - i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj));
|
| - i::Isolate* isolate = js_obj->GetIsolate();
|
| - return CheckConstructor(isolate, js_obj, "$Error") ||
|
| - CheckConstructor(isolate, js_obj, "$EvalError") ||
|
| - CheckConstructor(isolate, js_obj, "$RangeError") ||
|
| - CheckConstructor(isolate, js_obj, "$ReferenceError") ||
|
| - CheckConstructor(isolate, js_obj, "$SyntaxError") ||
|
| - CheckConstructor(isolate, js_obj, "$TypeError") ||
|
| - CheckConstructor(isolate, js_obj, "$URIError");
|
| - } else {
|
| - return false;
|
| - }
|
| + if (!obj->IsJSObject()) return false;
|
| + i::Handle<i::JSObject> js_obj = i::Handle<i::JSObject>::cast(obj);
|
| + i::Isolate* isolate = js_obj->GetIsolate();
|
| + i::Handle<i::Object> constructor(js_obj->map()->GetConstructor(), isolate);
|
| + if (!constructor->IsJSFunction()) return false;
|
| + i::Handle<i::JSFunction> function =
|
| + i::Handle<i::JSFunction>::cast(constructor);
|
| + if (!function->shared()->native()) return false;
|
| + return function.is_identical_to(isolate->error_function()) ||
|
| + function.is_identical_to(isolate->eval_error_function()) ||
|
| + function.is_identical_to(isolate->range_error_function()) ||
|
| + function.is_identical_to(isolate->reference_error_function()) ||
|
| + function.is_identical_to(isolate->syntax_error_function()) ||
|
| + function.is_identical_to(isolate->type_error_function()) ||
|
| + function.is_identical_to(isolate->uri_error_function());
|
| }
|
|
|
|
|
| @@ -7640,26 +7629,27 @@ String::Value::~Value() {
|
| }
|
|
|
|
|
| -#define DEFINE_ERROR(NAME) \
|
| - Local<Value> Exception::NAME(v8::Local<v8::String> raw_message) { \
|
| - i::Isolate* isolate = i::Isolate::Current(); \
|
| - LOG_API(isolate, #NAME); \
|
| - ENTER_V8(isolate); \
|
| - i::Object* error; \
|
| - { \
|
| - i::HandleScope scope(isolate); \
|
| - i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \
|
| - error = *isolate->factory()->NewError("$" #NAME, message); \
|
| - } \
|
| - i::Handle<i::Object> result(error, isolate); \
|
| - return Utils::ToLocal(result); \
|
| - }
|
| -
|
| -DEFINE_ERROR(RangeError)
|
| -DEFINE_ERROR(ReferenceError)
|
| -DEFINE_ERROR(SyntaxError)
|
| -DEFINE_ERROR(TypeError)
|
| -DEFINE_ERROR(Error)
|
| +#define DEFINE_ERROR(NAME, name) \
|
| + Local<Value> Exception::NAME(v8::Local<v8::String> raw_message) { \
|
| + i::Isolate* isolate = i::Isolate::Current(); \
|
| + LOG_API(isolate, #NAME); \
|
| + ENTER_V8(isolate); \
|
| + i::Object* error; \
|
| + { \
|
| + i::HandleScope scope(isolate); \
|
| + i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \
|
| + i::Handle<i::JSFunction> constructor = isolate->name##_function(); \
|
| + error = *isolate->factory()->NewError(constructor, message); \
|
| + } \
|
| + i::Handle<i::Object> result(error, isolate); \
|
| + return Utils::ToLocal(result); \
|
| + }
|
| +
|
| +DEFINE_ERROR(RangeError, range_error)
|
| +DEFINE_ERROR(ReferenceError, reference_error)
|
| +DEFINE_ERROR(SyntaxError, syntax_error)
|
| +DEFINE_ERROR(TypeError, type_error)
|
| +DEFINE_ERROR(Error, error)
|
|
|
| #undef DEFINE_ERROR
|
|
|
|
|