Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Unified Diff: src/objects.cc

Issue 2603493002: Remove duplicate C++ implementation of Object.prototype.toString (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 0df16fb8c5e1340b9da92728d70a64af31ce10a9..fb860a8f5bed924036568ef78e9b084235577e49 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -16290,94 +16290,6 @@ bool JSObject::WasConstructedFromApiFunction() {
return is_api_object;
}
-MaybeHandle<String> Object::ObjectProtoToString(Isolate* isolate,
- Handle<Object> object) {
- if (*object == isolate->heap()->undefined_value()) {
- return isolate->factory()->undefined_to_string();
- }
- if (*object == isolate->heap()->null_value()) {
- return isolate->factory()->null_to_string();
- }
-
- Handle<JSReceiver> receiver =
- Object::ToObject(isolate, object).ToHandleChecked();
-
- // For proxies, we must check IsArray() before get(toStringTag) to comply
- // with the specification
- Maybe<bool> is_array = Nothing<bool>();
- InstanceType instance_type = receiver->map()->instance_type();
- if (instance_type == JS_PROXY_TYPE) {
- is_array = Object::IsArray(receiver);
- MAYBE_RETURN(is_array, MaybeHandle<String>());
- }
-
- Handle<String> tag;
- Handle<Object> to_string_tag;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, to_string_tag,
- JSReceiver::GetProperty(receiver,
- isolate->factory()->to_string_tag_symbol()),
- String);
- if (to_string_tag->IsString()) {
- tag = Handle<String>::cast(to_string_tag);
- } else {
- switch (instance_type) {
- case JS_API_OBJECT_TYPE:
- case JS_SPECIAL_API_OBJECT_TYPE:
- tag = handle(receiver->class_name(), isolate);
- break;
- case JS_ARGUMENTS_TYPE:
- return isolate->factory()->arguments_to_string();
- case JS_ARRAY_TYPE:
- return isolate->factory()->array_to_string();
- case JS_BOUND_FUNCTION_TYPE:
- case JS_FUNCTION_TYPE:
- return isolate->factory()->function_to_string();
- case JS_ERROR_TYPE:
- return isolate->factory()->error_to_string();
- case JS_DATE_TYPE:
- return isolate->factory()->date_to_string();
- case JS_REGEXP_TYPE:
- return isolate->factory()->regexp_to_string();
- case JS_PROXY_TYPE: {
- if (is_array.FromJust()) {
- return isolate->factory()->array_to_string();
- }
- if (receiver->IsCallable()) {
- return isolate->factory()->function_to_string();
- }
- return isolate->factory()->object_to_string();
- }
- case JS_VALUE_TYPE: {
- Object* value = JSValue::cast(*receiver)->value();
- if (value->IsString()) {
- return isolate->factory()->string_to_string();
- }
- if (value->IsNumber()) {
- return isolate->factory()->number_to_string();
- }
- if (value->IsBoolean()) {
- return isolate->factory()->boolean_to_string();
- }
- if (value->IsSymbol()) {
- return isolate->factory()->object_to_string();
- }
- UNREACHABLE();
- tag = handle(receiver->class_name(), isolate);
- break;
- }
- default:
- return isolate->factory()->object_to_string();
- }
- }
-
- IncrementalStringBuilder builder(isolate);
- builder.AppendCString("[object ");
- builder.AppendString(tag);
- builder.AppendCharacter(']');
- return builder.Finish();
-}
-
const char* Symbol::PrivateSymbolToName() const {
Heap* heap = GetIsolate()->heap();
#define SYMBOL_CHECK_AND_PRINT(name) \
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698