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

Side by Side Diff: src/date.js

Issue 1324713002: [es6] Implement Date.prototype[@@toPrimitive] as C++ builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address Michi's comments. Created 5 years, 3 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
« no previous file with comments | « src/compiler/linkage.cc ('k') | src/objects.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 var $createDate; 5 var $createDate;
6 6
7 // ------------------------------------------------------------------- 7 // -------------------------------------------------------------------
8 8
9 (function(global, utils) { 9 (function(global, utils) {
10 10
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 358
359 // ECMA 262 - 15.9.5.7 359 // ECMA 262 - 15.9.5.7
360 function DateToLocaleTimeString() { 360 function DateToLocaleTimeString() {
361 CHECK_DATE(this); 361 CHECK_DATE(this);
362 var t = UTC_DATE_VALUE(this); 362 var t = UTC_DATE_VALUE(this);
363 if (NUMBER_IS_NAN(t)) return kInvalidDate; 363 if (NUMBER_IS_NAN(t)) return kInvalidDate;
364 return TimeString(this); 364 return TimeString(this);
365 } 365 }
366 366
367 367
368 // 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint )
369 function DateToPrimitive(hint) {
370 if (!IS_SPEC_OBJECT(this)) {
371 throw MakeTypeError(kIncompatibleMethodReceiver,
372 "Date.prototype [ @@toPrimitive ]", this);
373 }
374 if (hint === "default") {
375 hint = "string";
376 } else if (hint !== "number" && hint !== "string") {
377 throw MakeTypeError(kInvalidHint, hint);
378 }
379 return %OrdinaryToPrimitive(this, hint);
380 }
381
382
383 // ECMA 262 - 15.9.5.8 368 // ECMA 262 - 15.9.5.8
384 function DateValueOf() { 369 function DateValueOf() {
385 CHECK_DATE(this); 370 CHECK_DATE(this);
386 return UTC_DATE_VALUE(this); 371 return UTC_DATE_VALUE(this);
387 } 372 }
388 373
389 374
390 // ECMA 262 - 15.9.5.9 375 // ECMA 262 - 15.9.5.9
391 function DateGetTime() { 376 function DateGetTime() {
392 CHECK_DATE(this); 377 CHECK_DATE(this);
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 826
842 // Set up non-enumerable properties of the Date object itself. 827 // Set up non-enumerable properties of the Date object itself.
843 utils.InstallFunctions(GlobalDate, DONT_ENUM, [ 828 utils.InstallFunctions(GlobalDate, DONT_ENUM, [
844 "UTC", DateUTC, 829 "UTC", DateUTC,
845 "parse", DateParse, 830 "parse", DateParse,
846 "now", DateNow 831 "now", DateNow
847 ]); 832 ]);
848 833
849 // Set up non-enumerable constructor property of the Date prototype object. 834 // Set up non-enumerable constructor property of the Date prototype object.
850 %AddNamedProperty(GlobalDate.prototype, "constructor", GlobalDate, DONT_ENUM); 835 %AddNamedProperty(GlobalDate.prototype, "constructor", GlobalDate, DONT_ENUM);
851 utils.SetFunctionName(DateToPrimitive, toPrimitiveSymbol);
852 %AddNamedProperty(GlobalDate.prototype, toPrimitiveSymbol, DateToPrimitive,
853 DONT_ENUM | READ_ONLY);
854 836
855 // Set up non-enumerable functions of the Date prototype object and 837 // Set up non-enumerable functions of the Date prototype object and
856 // set their names. 838 // set their names.
857 utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [ 839 utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
858 "toString", DateToString, 840 "toString", DateToString,
859 "toDateString", DateToDateString, 841 "toDateString", DateToDateString,
860 "toTimeString", DateToTimeString, 842 "toTimeString", DateToTimeString,
861 "toLocaleString", DateToLocaleString, 843 "toLocaleString", DateToLocaleString,
862 "toLocaleDateString", DateToLocaleDateString, 844 "toLocaleDateString", DateToLocaleDateString,
863 "toLocaleTimeString", DateToLocaleTimeString, 845 "toLocaleTimeString", DateToLocaleTimeString,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 "toUTCString", DateToUTCString, 881 "toUTCString", DateToUTCString,
900 "getYear", DateGetYear, 882 "getYear", DateGetYear,
901 "setYear", DateSetYear, 883 "setYear", DateSetYear,
902 "toISOString", DateToISOString, 884 "toISOString", DateToISOString,
903 "toJSON", DateToJSON 885 "toJSON", DateToJSON
904 ]); 886 ]);
905 887
906 %InstallToContext(["create_date_fun", CreateDate]); 888 %InstallToContext(["create_date_fun", CreateDate]);
907 889
908 }) 890 })
OLDNEW
« no previous file with comments | « src/compiler/linkage.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698