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 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2597 } // namespace | 2597 } // namespace |
2598 | 2598 |
2599 | 2599 |
2600 // ES6 section 20.3.2 The Date Constructor for the [[Call]] case. | 2600 // ES6 section 20.3.2 The Date Constructor for the [[Call]] case. |
2601 BUILTIN(DateConstructor) { | 2601 BUILTIN(DateConstructor) { |
2602 HandleScope scope(isolate); | 2602 HandleScope scope(isolate); |
2603 double const time_val = JSDate::CurrentTimeValue(isolate); | 2603 double const time_val = JSDate::CurrentTimeValue(isolate); |
2604 char buffer[128]; | 2604 char buffer[128]; |
2605 Vector<char> str(buffer, arraysize(buffer)); | 2605 Vector<char> str(buffer, arraysize(buffer)); |
2606 ToDateString(time_val, str, isolate->date_cache()); | 2606 ToDateString(time_val, str, isolate->date_cache()); |
2607 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 2607 Handle<String> result; |
| 2608 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2609 isolate, result, |
| 2610 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 2611 return *result; |
2608 } | 2612 } |
2609 | 2613 |
2610 | 2614 |
2611 // ES6 section 20.3.2 The Date Constructor for the [[Construct]] case. | 2615 // ES6 section 20.3.2 The Date Constructor for the [[Construct]] case. |
2612 BUILTIN(DateConstructor_ConstructStub) { | 2616 BUILTIN(DateConstructor_ConstructStub) { |
2613 HandleScope scope(isolate); | 2617 HandleScope scope(isolate); |
2614 int const argc = args.length() - 1; | 2618 int const argc = args.length() - 1; |
2615 Handle<JSFunction> target = args.target<JSFunction>(); | 2619 Handle<JSFunction> target = args.target<JSFunction>(); |
2616 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); | 2620 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); |
2617 double time_val; | 2621 double time_val; |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3177 } | 3181 } |
3178 | 3182 |
3179 | 3183 |
3180 // ES6 section 20.3.4.35 Date.prototype.toDateString ( ) | 3184 // ES6 section 20.3.4.35 Date.prototype.toDateString ( ) |
3181 BUILTIN(DatePrototypeToDateString) { | 3185 BUILTIN(DatePrototypeToDateString) { |
3182 HandleScope scope(isolate); | 3186 HandleScope scope(isolate); |
3183 CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString"); | 3187 CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString"); |
3184 char buffer[128]; | 3188 char buffer[128]; |
3185 Vector<char> str(buffer, arraysize(buffer)); | 3189 Vector<char> str(buffer, arraysize(buffer)); |
3186 ToDateString(date->value()->Number(), str, isolate->date_cache(), kDateOnly); | 3190 ToDateString(date->value()->Number(), str, isolate->date_cache(), kDateOnly); |
3187 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 3191 Handle<String> result; |
| 3192 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 3193 isolate, result, |
| 3194 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 3195 return *result; |
3188 } | 3196 } |
3189 | 3197 |
3190 | 3198 |
3191 // ES6 section 20.3.4.36 Date.prototype.toISOString ( ) | 3199 // ES6 section 20.3.4.36 Date.prototype.toISOString ( ) |
3192 BUILTIN(DatePrototypeToISOString) { | 3200 BUILTIN(DatePrototypeToISOString) { |
3193 HandleScope scope(isolate); | 3201 HandleScope scope(isolate); |
3194 CHECK_RECEIVER(JSDate, date, "Date.prototype.toISOString"); | 3202 CHECK_RECEIVER(JSDate, date, "Date.prototype.toISOString"); |
3195 double const time_val = date->value()->Number(); | 3203 double const time_val = date->value()->Number(); |
3196 if (std::isnan(time_val)) { | 3204 if (std::isnan(time_val)) { |
3197 THROW_NEW_ERROR_RETURN_FAILURE( | 3205 THROW_NEW_ERROR_RETURN_FAILURE( |
(...skipping 19 matching lines...) Expand all Loading... |
3217 } | 3225 } |
3218 | 3226 |
3219 | 3227 |
3220 // ES6 section 20.3.4.41 Date.prototype.toString ( ) | 3228 // ES6 section 20.3.4.41 Date.prototype.toString ( ) |
3221 BUILTIN(DatePrototypeToString) { | 3229 BUILTIN(DatePrototypeToString) { |
3222 HandleScope scope(isolate); | 3230 HandleScope scope(isolate); |
3223 CHECK_RECEIVER(JSDate, date, "Date.prototype.toString"); | 3231 CHECK_RECEIVER(JSDate, date, "Date.prototype.toString"); |
3224 char buffer[128]; | 3232 char buffer[128]; |
3225 Vector<char> str(buffer, arraysize(buffer)); | 3233 Vector<char> str(buffer, arraysize(buffer)); |
3226 ToDateString(date->value()->Number(), str, isolate->date_cache()); | 3234 ToDateString(date->value()->Number(), str, isolate->date_cache()); |
3227 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 3235 Handle<String> result; |
| 3236 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 3237 isolate, result, |
| 3238 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 3239 return *result; |
3228 } | 3240 } |
3229 | 3241 |
3230 | 3242 |
3231 // ES6 section 20.3.4.42 Date.prototype.toTimeString ( ) | 3243 // ES6 section 20.3.4.42 Date.prototype.toTimeString ( ) |
3232 BUILTIN(DatePrototypeToTimeString) { | 3244 BUILTIN(DatePrototypeToTimeString) { |
3233 HandleScope scope(isolate); | 3245 HandleScope scope(isolate); |
3234 CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString"); | 3246 CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString"); |
3235 char buffer[128]; | 3247 char buffer[128]; |
3236 Vector<char> str(buffer, arraysize(buffer)); | 3248 Vector<char> str(buffer, arraysize(buffer)); |
3237 ToDateString(date->value()->Number(), str, isolate->date_cache(), kTimeOnly); | 3249 ToDateString(date->value()->Number(), str, isolate->date_cache(), kTimeOnly); |
3238 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 3250 Handle<String> result; |
| 3251 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 3252 isolate, result, |
| 3253 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 3254 return *result; |
3239 } | 3255 } |
3240 | 3256 |
3241 | 3257 |
3242 // ES6 section 20.3.4.43 Date.prototype.toUTCString ( ) | 3258 // ES6 section 20.3.4.43 Date.prototype.toUTCString ( ) |
3243 BUILTIN(DatePrototypeToUTCString) { | 3259 BUILTIN(DatePrototypeToUTCString) { |
3244 HandleScope scope(isolate); | 3260 HandleScope scope(isolate); |
3245 CHECK_RECEIVER(JSDate, date, "Date.prototype.toUTCString"); | 3261 CHECK_RECEIVER(JSDate, date, "Date.prototype.toUTCString"); |
3246 double const time_val = date->value()->Number(); | 3262 double const time_val = date->value()->Number(); |
3247 if (std::isnan(time_val)) { | 3263 if (std::isnan(time_val)) { |
3248 return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date"); | 3264 return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date"); |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4463 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4479 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
4464 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4480 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
4465 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4481 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
4466 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4482 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
4467 #undef DEFINE_BUILTIN_ACCESSOR_C | 4483 #undef DEFINE_BUILTIN_ACCESSOR_C |
4468 #undef DEFINE_BUILTIN_ACCESSOR_A | 4484 #undef DEFINE_BUILTIN_ACCESSOR_A |
4469 | 4485 |
4470 | 4486 |
4471 } // namespace internal | 4487 } // namespace internal |
4472 } // namespace v8 | 4488 } // namespace v8 |
OLD | NEW |