blob: 4f4f986fd26bc904f45c92c2b202732d0a4cf709 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright 2013 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
"use strict";
// This file relies on the fact that the following declaration has been made
// in runtime.js and symbol.js:
// var $Object = global.Object;
DefaultObjectToString = ObjectToStringHarmony;
// ES6 draft 08-24-14, section 19.1.3.6
function ObjectToStringHarmony() {
if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
if (IS_NULL(this)) return "[object Null]";
var O = ToObject(this);
var builtinTag = %_ClassOf(O);
var tag = O[symbolToStringTag];
if (!IS_STRING(tag)) {
tag = builtinTag;
}
return "[object " + tag + "]";
}
function HarmonyToStringExtendSymbolPrototype() {
%CheckIsBootstrapping();
InstallConstants(global.Symbol, $Array(
// TODO(dslomov, caitp): Move to symbol.js when shipping
"toStringTag", symbolToStringTag
));
}
HarmonyToStringExtendSymbolPrototype();
function HarmonyToStringExtendObjectPrototype() {
%CheckIsBootstrapping();
// Can't use InstallFunctions() because will fail in Debug mode.
// Emulate InstallFunctions() here.
%FunctionSetName(ObjectToStringHarmony, "toString");
%FunctionRemovePrototype(ObjectToStringHarmony);
%SetNativeFlag(ObjectToStringHarmony);
// Set up the non-enumerable functions on the Array prototype object.
var desc = ToPropertyDescriptor({
value: ObjectToStringHarmony
});
DefineOwnProperty($Object.prototype, "toString", desc, false);
%ToFastProperties($Object.prototype);
}
HarmonyToStringExtendObjectPrototype();
|