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

Side by Side Diff: src/v8natives.js

Issue 546803003: Update ObjectToString to Harmony-draft algorithm (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase, rename ObjectToString Created 6 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/symbol.js ('k') | src/weak-collection.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 "eval", GlobalEval 208 "eval", GlobalEval
209 )); 209 ));
210 } 210 }
211 211
212 SetUpGlobal(); 212 SetUpGlobal();
213 213
214 214
215 // ---------------------------------------------------------------------------- 215 // ----------------------------------------------------------------------------
216 // Object 216 // Object
217 217
218 var DefaultObjectToString = NoSideEffectsObjectToString;
218 // ECMA-262 - 15.2.4.2 219 // ECMA-262 - 15.2.4.2
219 function ObjectToString() { 220 function NoSideEffectsObjectToString() {
220 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; 221 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
221 if (IS_NULL(this)) return "[object Null]"; 222 if (IS_NULL(this)) return "[object Null]";
222 return "[object " + %_ClassOf(ToObject(this)) + "]"; 223 return "[object " + %_ClassOf(ToObject(this)) + "]";
223 } 224 }
224 225
225 226
226 // ECMA-262 - 15.2.4.3 227 // ECMA-262 - 15.2.4.3
227 function ObjectToLocaleString() { 228 function ObjectToLocaleString() {
228 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); 229 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString");
229 return this.toString(); 230 return this.toString();
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 function SetUpObject() { 1403 function SetUpObject() {
1403 %CheckIsBootstrapping(); 1404 %CheckIsBootstrapping();
1404 1405
1405 %SetNativeFlag($Object); 1406 %SetNativeFlag($Object);
1406 %SetCode($Object, ObjectConstructor); 1407 %SetCode($Object, ObjectConstructor);
1407 1408
1408 %AddNamedProperty($Object.prototype, "constructor", $Object, DONT_ENUM); 1409 %AddNamedProperty($Object.prototype, "constructor", $Object, DONT_ENUM);
1409 1410
1410 // Set up non-enumerable functions on the Object.prototype object. 1411 // Set up non-enumerable functions on the Object.prototype object.
1411 InstallFunctions($Object.prototype, DONT_ENUM, $Array( 1412 InstallFunctions($Object.prototype, DONT_ENUM, $Array(
1412 "toString", ObjectToString, 1413 "toString", NoSideEffectsObjectToString,
1413 "toLocaleString", ObjectToLocaleString, 1414 "toLocaleString", ObjectToLocaleString,
1414 "valueOf", ObjectValueOf, 1415 "valueOf", ObjectValueOf,
1415 "hasOwnProperty", ObjectHasOwnProperty, 1416 "hasOwnProperty", ObjectHasOwnProperty,
1416 "isPrototypeOf", ObjectIsPrototypeOf, 1417 "isPrototypeOf", ObjectIsPrototypeOf,
1417 "propertyIsEnumerable", ObjectPropertyIsEnumerable, 1418 "propertyIsEnumerable", ObjectPropertyIsEnumerable,
1418 "__defineGetter__", ObjectDefineGetter, 1419 "__defineGetter__", ObjectDefineGetter,
1419 "__lookupGetter__", ObjectLookupGetter, 1420 "__lookupGetter__", ObjectLookupGetter,
1420 "__defineSetter__", ObjectDefineSetter, 1421 "__defineSetter__", ObjectDefineSetter,
1421 "__lookupSetter__", ObjectLookupSetter 1422 "__lookupSetter__", ObjectLookupSetter
1422 )); 1423 ));
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 } 1902 }
1902 if (!IS_SPEC_FUNCTION(method)) { 1903 if (!IS_SPEC_FUNCTION(method)) {
1903 throw MakeTypeError('not_iterable', [obj]); 1904 throw MakeTypeError('not_iterable', [obj]);
1904 } 1905 }
1905 var iterator = %_CallFunction(obj, method); 1906 var iterator = %_CallFunction(obj, method);
1906 if (!IS_SPEC_OBJECT(iterator)) { 1907 if (!IS_SPEC_OBJECT(iterator)) {
1907 throw MakeTypeError('not_an_iterator', [iterator]); 1908 throw MakeTypeError('not_an_iterator', [iterator]);
1908 } 1909 }
1909 return iterator; 1910 return iterator;
1910 } 1911 }
OLDNEW
« no previous file with comments | « src/symbol.js ('k') | src/weak-collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698