@@ -3409,6 +3409,37 @@ Local<Array> v8::Object::GetOwnPropertyNames() {
34093409}
34103410
34113411
3412+ static bool GetPredefinedToString (i::Handle<i::String> tag,
3413+ Local<String>* result) {
3414+ i::Isolate* i_isolate = tag->GetIsolate ();
3415+ Isolate* isolate = reinterpret_cast <Isolate*>(i_isolate);
3416+ i::Factory* factory = i_isolate->factory ();
3417+
3418+ if (i::String::Equals (tag, factory->Arguments_string ())) {
3419+ *result = v8::String::NewFromUtf8 (isolate, " [object ~Arguments]" );
3420+ } else if (i::String::Equals (tag, factory->Array_string ())) {
3421+ *result = v8::String::NewFromUtf8 (isolate, " [object ~Array]" );
3422+ } else if (i::String::Equals (tag, factory->Boolean_string ())) {
3423+ *result = v8::String::NewFromUtf8 (isolate, " [object ~Boolean]" );
3424+ } else if (i::String::Equals (tag, factory->Date_string ())) {
3425+ *result = v8::String::NewFromUtf8 (isolate, " [object ~Date]" );
3426+ } else if (i::String::Equals (tag, factory->Error_string ())) {
3427+ *result = v8::String::NewFromUtf8 (isolate, " [object ~Error]" );
3428+ } else if (i::String::Equals (tag, factory->Function_string ())) {
3429+ *result = v8::String::NewFromUtf8 (isolate, " [object ~Function]" );
3430+ } else if (i::String::Equals (tag, factory->Number_string ())) {
3431+ *result = v8::String::NewFromUtf8 (isolate, " [object ~Number]" );
3432+ } else if (i::String::Equals (tag, factory->RegExp_string ())) {
3433+ *result = v8::String::NewFromUtf8 (isolate, " [object ~RegExp]" );
3434+ } else if (i::String::Equals (tag, factory->String_string ())) {
3435+ *result = v8::String::NewFromUtf8 (isolate, " [object ~String]" );
3436+ } else {
3437+ return false ;
3438+ }
3439+ return true ;
3440+ }
3441+
3442+
34123443Local<String> v8::Object::ObjectProtoToString () {
34133444 i::Isolate* i_isolate = Utils::OpenHandle (this )->GetIsolate ();
34143445 Isolate* isolate = reinterpret_cast <Isolate*>(i_isolate);
@@ -3418,6 +3449,7 @@ Local<String> v8::Object::ObjectProtoToString() {
34183449 i::Handle<i::JSObject> self = Utils::OpenHandle (this );
34193450
34203451 i::Handle<i::Object> name (self->class_name (), i_isolate);
3452+ i::Handle<i::Object> tag;
34213453
34223454 // Native implementation of Object.prototype.toString (v8natives.js):
34233455 // var c = %_ClassOf(this);
@@ -3432,6 +3464,27 @@ Local<String> v8::Object::ObjectProtoToString() {
34323464 i_isolate->factory ()->Arguments_string ())) {
34333465 return v8::String::NewFromUtf8 (isolate, " [object Object]" );
34343466 } else {
3467+ if (internal::FLAG_harmony_tostring) {
3468+ i::Handle<i::Symbol> toStringTag =
3469+ Utils::OpenHandle (*Symbol::GetToStringTag (isolate));
3470+ EXCEPTION_PREAMBLE (i_isolate);
3471+ has_pending_exception =
3472+ !i::Runtime::GetObjectProperty (i_isolate, self, toStringTag)
3473+ .ToHandle (&tag);
3474+ EXCEPTION_BAILOUT_CHECK (i_isolate, Local<v8::String>());
3475+
3476+ if (!tag->IsUndefined ()) {
3477+ if (!tag->IsString ())
3478+ return v8::String::NewFromUtf8 (isolate, " [object ???]" );
3479+ i::Handle<i::String> tag_name = i::Handle<i::String>::cast (tag);
3480+ if (!i::String::Equals (class_name, tag_name)) {
3481+ Local<String> result;
3482+ if (GetPredefinedToString (tag_name, &result)) return result;
3483+
3484+ class_name = tag_name;
3485+ }
3486+ }
3487+ }
34353488 const char * prefix = " [object " ;
34363489 Local<String> str = Utils::ToLocal (class_name);
34373490 const char * postfix = " ]" ;
@@ -3774,11 +3827,6 @@ void v8::Object::TurnOnAccessCheck() {
37743827}
37753828
37763829
3777- bool v8::Object::IsDirty () {
3778- return Utils::OpenHandle (this )->IsDirty ();
3779- }
3780-
3781-
37823830Local<v8::Object> v8::Object::Clone () {
37833831 i::Isolate* isolate = Utils::OpenHandle (this )->GetIsolate ();
37843832 ON_BAILOUT (isolate, " v8::Object::Clone()" , return Local<Object>());
@@ -6250,6 +6298,11 @@ Local<Symbol> v8::Symbol::GetUnscopables(Isolate* isolate) {
62506298}
62516299
62526300
6301+ Local<Symbol> v8::Symbol::GetToStringTag (Isolate* isolate) {
6302+ return GetWellKnownSymbol (isolate, " Symbol.toStringTag" );
6303+ }
6304+
6305+
62536306Local<Private> v8::Private::New (Isolate* isolate, Local<String> name) {
62546307 i::Isolate* i_isolate = reinterpret_cast <i::Isolate*>(isolate);
62556308 LOG_API (i_isolate, " Private::New()" );
0 commit comments