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 #include "src/builtins.h" | 5 #include "src/builtins.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 } // namespace | 2218 } // namespace |
2219 | 2219 |
2220 | 2220 |
2221 // ES6 section 20.3.2 The Date Constructor for the [[Call]] case. | 2221 // ES6 section 20.3.2 The Date Constructor for the [[Call]] case. |
2222 BUILTIN(DateConstructor) { | 2222 BUILTIN(DateConstructor) { |
2223 HandleScope scope(isolate); | 2223 HandleScope scope(isolate); |
2224 double const time_val = JSDate::CurrentTimeValue(isolate); | 2224 double const time_val = JSDate::CurrentTimeValue(isolate); |
2225 char buffer[128]; | 2225 char buffer[128]; |
2226 Vector<char> str(buffer, arraysize(buffer)); | 2226 Vector<char> str(buffer, arraysize(buffer)); |
2227 ToDateString(time_val, str, isolate->date_cache()); | 2227 ToDateString(time_val, str, isolate->date_cache()); |
2228 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 2228 Handle<String> result; |
| 2229 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2230 isolate, result, |
| 2231 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 2232 return *result; |
2229 } | 2233 } |
2230 | 2234 |
2231 | 2235 |
2232 // ES6 section 20.3.2 The Date Constructor for the [[Construct]] case. | 2236 // ES6 section 20.3.2 The Date Constructor for the [[Construct]] case. |
2233 BUILTIN(DateConstructor_ConstructStub) { | 2237 BUILTIN(DateConstructor_ConstructStub) { |
2234 HandleScope scope(isolate); | 2238 HandleScope scope(isolate); |
2235 int const argc = args.length() - 1; | 2239 int const argc = args.length() - 1; |
2236 Handle<JSFunction> target = args.target(); | 2240 Handle<JSFunction> target = args.target(); |
2237 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); | 2241 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); |
2238 double time_val; | 2242 double time_val; |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2798 } | 2802 } |
2799 | 2803 |
2800 | 2804 |
2801 // ES6 section 20.3.4.35 Date.prototype.toDateString ( ) | 2805 // ES6 section 20.3.4.35 Date.prototype.toDateString ( ) |
2802 BUILTIN(DatePrototypeToDateString) { | 2806 BUILTIN(DatePrototypeToDateString) { |
2803 HandleScope scope(isolate); | 2807 HandleScope scope(isolate); |
2804 CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString"); | 2808 CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString"); |
2805 char buffer[128]; | 2809 char buffer[128]; |
2806 Vector<char> str(buffer, arraysize(buffer)); | 2810 Vector<char> str(buffer, arraysize(buffer)); |
2807 ToDateString(date->value()->Number(), str, isolate->date_cache(), kDateOnly); | 2811 ToDateString(date->value()->Number(), str, isolate->date_cache(), kDateOnly); |
2808 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 2812 Handle<String> result; |
| 2813 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2814 isolate, result, |
| 2815 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 2816 return *result; |
2809 } | 2817 } |
2810 | 2818 |
2811 | 2819 |
2812 // ES6 section 20.3.4.36 Date.prototype.toISOString ( ) | 2820 // ES6 section 20.3.4.36 Date.prototype.toISOString ( ) |
2813 BUILTIN(DatePrototypeToISOString) { | 2821 BUILTIN(DatePrototypeToISOString) { |
2814 HandleScope scope(isolate); | 2822 HandleScope scope(isolate); |
2815 CHECK_RECEIVER(JSDate, date, "Date.prototype.toISOString"); | 2823 CHECK_RECEIVER(JSDate, date, "Date.prototype.toISOString"); |
2816 double const time_val = date->value()->Number(); | 2824 double const time_val = date->value()->Number(); |
2817 if (std::isnan(time_val)) { | 2825 if (std::isnan(time_val)) { |
2818 THROW_NEW_ERROR_RETURN_FAILURE( | 2826 THROW_NEW_ERROR_RETURN_FAILURE( |
(...skipping 19 matching lines...) Expand all Loading... |
2838 } | 2846 } |
2839 | 2847 |
2840 | 2848 |
2841 // ES6 section 20.3.4.41 Date.prototype.toString ( ) | 2849 // ES6 section 20.3.4.41 Date.prototype.toString ( ) |
2842 BUILTIN(DatePrototypeToString) { | 2850 BUILTIN(DatePrototypeToString) { |
2843 HandleScope scope(isolate); | 2851 HandleScope scope(isolate); |
2844 CHECK_RECEIVER(JSDate, date, "Date.prototype.toString"); | 2852 CHECK_RECEIVER(JSDate, date, "Date.prototype.toString"); |
2845 char buffer[128]; | 2853 char buffer[128]; |
2846 Vector<char> str(buffer, arraysize(buffer)); | 2854 Vector<char> str(buffer, arraysize(buffer)); |
2847 ToDateString(date->value()->Number(), str, isolate->date_cache()); | 2855 ToDateString(date->value()->Number(), str, isolate->date_cache()); |
2848 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 2856 Handle<String> result; |
| 2857 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2858 isolate, result, |
| 2859 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 2860 return *result; |
2849 } | 2861 } |
2850 | 2862 |
2851 | 2863 |
2852 // ES6 section 20.3.4.42 Date.prototype.toTimeString ( ) | 2864 // ES6 section 20.3.4.42 Date.prototype.toTimeString ( ) |
2853 BUILTIN(DatePrototypeToTimeString) { | 2865 BUILTIN(DatePrototypeToTimeString) { |
2854 HandleScope scope(isolate); | 2866 HandleScope scope(isolate); |
2855 CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString"); | 2867 CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString"); |
2856 char buffer[128]; | 2868 char buffer[128]; |
2857 Vector<char> str(buffer, arraysize(buffer)); | 2869 Vector<char> str(buffer, arraysize(buffer)); |
2858 ToDateString(date->value()->Number(), str, isolate->date_cache(), kTimeOnly); | 2870 ToDateString(date->value()->Number(), str, isolate->date_cache(), kTimeOnly); |
2859 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 2871 Handle<String> result; |
| 2872 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2873 isolate, result, |
| 2874 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 2875 return *result; |
2860 } | 2876 } |
2861 | 2877 |
2862 | 2878 |
2863 // ES6 section 20.3.4.43 Date.prototype.toUTCString ( ) | 2879 // ES6 section 20.3.4.43 Date.prototype.toUTCString ( ) |
2864 BUILTIN(DatePrototypeToUTCString) { | 2880 BUILTIN(DatePrototypeToUTCString) { |
2865 HandleScope scope(isolate); | 2881 HandleScope scope(isolate); |
2866 CHECK_RECEIVER(JSDate, date, "Date.prototype.toUTCString"); | 2882 CHECK_RECEIVER(JSDate, date, "Date.prototype.toUTCString"); |
2867 double const time_val = date->value()->Number(); | 2883 double const time_val = date->value()->Number(); |
2868 if (std::isnan(time_val)) { | 2884 if (std::isnan(time_val)) { |
2869 return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date"); | 2885 return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date"); |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4005 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4021 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
4006 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4022 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
4007 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4023 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
4008 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4024 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
4009 #undef DEFINE_BUILTIN_ACCESSOR_C | 4025 #undef DEFINE_BUILTIN_ACCESSOR_C |
4010 #undef DEFINE_BUILTIN_ACCESSOR_A | 4026 #undef DEFINE_BUILTIN_ACCESSOR_A |
4011 | 4027 |
4012 | 4028 |
4013 } // namespace internal | 4029 } // namespace internal |
4014 } // namespace v8 | 4030 } // namespace v8 |
OLD | NEW |