| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
| 6 // in runtime.js: | 6 // in runtime.js: |
| 7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
| 8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
| 9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
| 10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 "eval", GlobalEval | 209 "eval", GlobalEval |
| 210 )); | 210 )); |
| 211 } | 211 } |
| 212 | 212 |
| 213 SetUpGlobal(); | 213 SetUpGlobal(); |
| 214 | 214 |
| 215 | 215 |
| 216 // ---------------------------------------------------------------------------- | 216 // ---------------------------------------------------------------------------- |
| 217 // Object | 217 // Object |
| 218 | 218 |
| 219 var DefaultObjectToString = NoSideEffectsObjectToString; | 219 var DefaultObjectToString = ObjectToString; |
| 220 // ECMA-262 - 15.2.4.2 | 220 // ECMA-262 - 15.2.4.2 |
| 221 function NoSideEffectsObjectToString() { | 221 function NoSideEffectsObjectToString() { |
| 222 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; | 222 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; |
| 223 if (IS_NULL(this)) return "[object Null]"; | 223 if (IS_NULL(this)) return "[object Null]"; |
| 224 return "[object " + %_ClassOf(TO_OBJECT_INLINE(this)) + "]"; | 224 return "[object " + %_ClassOf(TO_OBJECT_INLINE(this)) + "]"; |
| 225 } | 225 } |
| 226 | 226 |
| 227 | 227 |
| 228 function ObjectToString() { |
| 229 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; |
| 230 if (IS_NULL(this)) return "[object Null]"; |
| 231 var O = TO_OBJECT_INLINE(this); |
| 232 var builtinTag = %_ClassOf(O); |
| 233 var tag; |
| 234 |
| 235 // TODO(caitp): cannot wait to get rid of this flag :> |
| 236 if (harmony_tostring) { |
| 237 var tag = O[symbolToStringTag]; |
| 238 if (!IS_STRING(tag)) { |
| 239 tag = builtinTag; |
| 240 } |
| 241 } else { |
| 242 tag = builtinTag; |
| 243 } |
| 244 |
| 245 return `[object ${tag}]`; |
| 246 } |
| 247 |
| 248 |
| 228 // ECMA-262 - 15.2.4.3 | 249 // ECMA-262 - 15.2.4.3 |
| 229 function ObjectToLocaleString() { | 250 function ObjectToLocaleString() { |
| 230 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); | 251 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); |
| 231 return this.toString(); | 252 return this.toString(); |
| 232 } | 253 } |
| 233 | 254 |
| 234 | 255 |
| 235 // ECMA-262 - 15.2.4.4 | 256 // ECMA-262 - 15.2.4.4 |
| 236 function ObjectValueOf() { | 257 function ObjectValueOf() { |
| 237 return TO_OBJECT_INLINE(this); | 258 return TO_OBJECT_INLINE(this); |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 function SetUpObject() { | 1424 function SetUpObject() { |
| 1404 %CheckIsBootstrapping(); | 1425 %CheckIsBootstrapping(); |
| 1405 | 1426 |
| 1406 %SetNativeFlag($Object); | 1427 %SetNativeFlag($Object); |
| 1407 %SetCode($Object, ObjectConstructor); | 1428 %SetCode($Object, ObjectConstructor); |
| 1408 | 1429 |
| 1409 %AddNamedProperty($Object.prototype, "constructor", $Object, DONT_ENUM); | 1430 %AddNamedProperty($Object.prototype, "constructor", $Object, DONT_ENUM); |
| 1410 | 1431 |
| 1411 // Set up non-enumerable functions on the Object.prototype object. | 1432 // Set up non-enumerable functions on the Object.prototype object. |
| 1412 InstallFunctions($Object.prototype, DONT_ENUM, $Array( | 1433 InstallFunctions($Object.prototype, DONT_ENUM, $Array( |
| 1413 "toString", NoSideEffectsObjectToString, | 1434 "toString", ObjectToString, |
| 1414 "toLocaleString", ObjectToLocaleString, | 1435 "toLocaleString", ObjectToLocaleString, |
| 1415 "valueOf", ObjectValueOf, | 1436 "valueOf", ObjectValueOf, |
| 1416 "hasOwnProperty", ObjectHasOwnProperty, | 1437 "hasOwnProperty", ObjectHasOwnProperty, |
| 1417 "isPrototypeOf", ObjectIsPrototypeOf, | 1438 "isPrototypeOf", ObjectIsPrototypeOf, |
| 1418 "propertyIsEnumerable", ObjectPropertyIsEnumerable, | 1439 "propertyIsEnumerable", ObjectPropertyIsEnumerable, |
| 1419 "__defineGetter__", ObjectDefineGetter, | 1440 "__defineGetter__", ObjectDefineGetter, |
| 1420 "__lookupGetter__", ObjectLookupGetter, | 1441 "__lookupGetter__", ObjectLookupGetter, |
| 1421 "__defineSetter__", ObjectDefineSetter, | 1442 "__defineSetter__", ObjectDefineSetter, |
| 1422 "__lookupSetter__", ObjectLookupSetter | 1443 "__lookupSetter__", ObjectLookupSetter |
| 1423 )); | 1444 )); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 } | 1914 } |
| 1894 if (!IS_SPEC_FUNCTION(method)) { | 1915 if (!IS_SPEC_FUNCTION(method)) { |
| 1895 throw MakeTypeError('not_iterable', [obj]); | 1916 throw MakeTypeError('not_iterable', [obj]); |
| 1896 } | 1917 } |
| 1897 var iterator = %_CallFunction(obj, method); | 1918 var iterator = %_CallFunction(obj, method); |
| 1898 if (!IS_SPEC_OBJECT(iterator)) { | 1919 if (!IS_SPEC_OBJECT(iterator)) { |
| 1899 throw MakeTypeError('not_an_iterator', [iterator]); | 1920 throw MakeTypeError('not_an_iterator', [iterator]); |
| 1900 } | 1921 } |
| 1901 return iterator; | 1922 return iterator; |
| 1902 } | 1923 } |
| OLD | NEW |