| 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-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/api-natives.h" | 9 #include "src/api-natives.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2743 } // namespace | 2743 } // namespace |
| 2744 | 2744 |
| 2745 | 2745 |
| 2746 // ES6 section 20.3.2 The Date Constructor for the [[Call]] case. | 2746 // ES6 section 20.3.2 The Date Constructor for the [[Call]] case. |
| 2747 BUILTIN(DateConstructor) { | 2747 BUILTIN(DateConstructor) { |
| 2748 HandleScope scope(isolate); | 2748 HandleScope scope(isolate); |
| 2749 double const time_val = JSDate::CurrentTimeValue(isolate); | 2749 double const time_val = JSDate::CurrentTimeValue(isolate); |
| 2750 char buffer[128]; | 2750 char buffer[128]; |
| 2751 Vector<char> str(buffer, arraysize(buffer)); | 2751 Vector<char> str(buffer, arraysize(buffer)); |
| 2752 ToDateString(time_val, str, isolate->date_cache()); | 2752 ToDateString(time_val, str, isolate->date_cache()); |
| 2753 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 2753 Handle<String> result; |
| 2754 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2755 isolate, result, |
| 2756 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 2757 return *result; |
| 2754 } | 2758 } |
| 2755 | 2759 |
| 2756 | 2760 |
| 2757 // ES6 section 20.3.2 The Date Constructor for the [[Construct]] case. | 2761 // ES6 section 20.3.2 The Date Constructor for the [[Construct]] case. |
| 2758 BUILTIN(DateConstructor_ConstructStub) { | 2762 BUILTIN(DateConstructor_ConstructStub) { |
| 2759 HandleScope scope(isolate); | 2763 HandleScope scope(isolate); |
| 2760 int const argc = args.length() - 1; | 2764 int const argc = args.length() - 1; |
| 2761 Handle<JSFunction> target = args.target<JSFunction>(); | 2765 Handle<JSFunction> target = args.target<JSFunction>(); |
| 2762 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); | 2766 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); |
| 2763 double time_val; | 2767 double time_val; |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3323 } | 3327 } |
| 3324 | 3328 |
| 3325 | 3329 |
| 3326 // ES6 section 20.3.4.35 Date.prototype.toDateString ( ) | 3330 // ES6 section 20.3.4.35 Date.prototype.toDateString ( ) |
| 3327 BUILTIN(DatePrototypeToDateString) { | 3331 BUILTIN(DatePrototypeToDateString) { |
| 3328 HandleScope scope(isolate); | 3332 HandleScope scope(isolate); |
| 3329 CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString"); | 3333 CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString"); |
| 3330 char buffer[128]; | 3334 char buffer[128]; |
| 3331 Vector<char> str(buffer, arraysize(buffer)); | 3335 Vector<char> str(buffer, arraysize(buffer)); |
| 3332 ToDateString(date->value()->Number(), str, isolate->date_cache(), kDateOnly); | 3336 ToDateString(date->value()->Number(), str, isolate->date_cache(), kDateOnly); |
| 3333 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 3337 Handle<String> result; |
| 3338 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 3339 isolate, result, |
| 3340 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 3341 return *result; |
| 3334 } | 3342 } |
| 3335 | 3343 |
| 3336 | 3344 |
| 3337 // ES6 section 20.3.4.36 Date.prototype.toISOString ( ) | 3345 // ES6 section 20.3.4.36 Date.prototype.toISOString ( ) |
| 3338 BUILTIN(DatePrototypeToISOString) { | 3346 BUILTIN(DatePrototypeToISOString) { |
| 3339 HandleScope scope(isolate); | 3347 HandleScope scope(isolate); |
| 3340 CHECK_RECEIVER(JSDate, date, "Date.prototype.toISOString"); | 3348 CHECK_RECEIVER(JSDate, date, "Date.prototype.toISOString"); |
| 3341 double const time_val = date->value()->Number(); | 3349 double const time_val = date->value()->Number(); |
| 3342 if (std::isnan(time_val)) { | 3350 if (std::isnan(time_val)) { |
| 3343 THROW_NEW_ERROR_RETURN_FAILURE( | 3351 THROW_NEW_ERROR_RETURN_FAILURE( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3363 } | 3371 } |
| 3364 | 3372 |
| 3365 | 3373 |
| 3366 // ES6 section 20.3.4.41 Date.prototype.toString ( ) | 3374 // ES6 section 20.3.4.41 Date.prototype.toString ( ) |
| 3367 BUILTIN(DatePrototypeToString) { | 3375 BUILTIN(DatePrototypeToString) { |
| 3368 HandleScope scope(isolate); | 3376 HandleScope scope(isolate); |
| 3369 CHECK_RECEIVER(JSDate, date, "Date.prototype.toString"); | 3377 CHECK_RECEIVER(JSDate, date, "Date.prototype.toString"); |
| 3370 char buffer[128]; | 3378 char buffer[128]; |
| 3371 Vector<char> str(buffer, arraysize(buffer)); | 3379 Vector<char> str(buffer, arraysize(buffer)); |
| 3372 ToDateString(date->value()->Number(), str, isolate->date_cache()); | 3380 ToDateString(date->value()->Number(), str, isolate->date_cache()); |
| 3373 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 3381 Handle<String> result; |
| 3382 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 3383 isolate, result, |
| 3384 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 3385 return *result; |
| 3374 } | 3386 } |
| 3375 | 3387 |
| 3376 | 3388 |
| 3377 // ES6 section 20.3.4.42 Date.prototype.toTimeString ( ) | 3389 // ES6 section 20.3.4.42 Date.prototype.toTimeString ( ) |
| 3378 BUILTIN(DatePrototypeToTimeString) { | 3390 BUILTIN(DatePrototypeToTimeString) { |
| 3379 HandleScope scope(isolate); | 3391 HandleScope scope(isolate); |
| 3380 CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString"); | 3392 CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString"); |
| 3381 char buffer[128]; | 3393 char buffer[128]; |
| 3382 Vector<char> str(buffer, arraysize(buffer)); | 3394 Vector<char> str(buffer, arraysize(buffer)); |
| 3383 ToDateString(date->value()->Number(), str, isolate->date_cache(), kTimeOnly); | 3395 ToDateString(date->value()->Number(), str, isolate->date_cache(), kTimeOnly); |
| 3384 return *isolate->factory()->NewStringFromAsciiChecked(str.start()); | 3396 Handle<String> result; |
| 3397 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 3398 isolate, result, |
| 3399 isolate->factory()->NewStringFromUtf8(CStrVector(buffer))); |
| 3400 return *result; |
| 3385 } | 3401 } |
| 3386 | 3402 |
| 3387 | 3403 |
| 3388 // ES6 section 20.3.4.43 Date.prototype.toUTCString ( ) | 3404 // ES6 section 20.3.4.43 Date.prototype.toUTCString ( ) |
| 3389 BUILTIN(DatePrototypeToUTCString) { | 3405 BUILTIN(DatePrototypeToUTCString) { |
| 3390 HandleScope scope(isolate); | 3406 HandleScope scope(isolate); |
| 3391 CHECK_RECEIVER(JSDate, date, "Date.prototype.toUTCString"); | 3407 CHECK_RECEIVER(JSDate, date, "Date.prototype.toUTCString"); |
| 3392 double const time_val = date->value()->Number(); | 3408 double const time_val = date->value()->Number(); |
| 3393 if (std::isnan(time_val)) { | 3409 if (std::isnan(time_val)) { |
| 3394 return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date"); | 3410 return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date"); |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4616 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) | 4632 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) |
| 4617 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4633 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 4618 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4634 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4619 #undef DEFINE_BUILTIN_ACCESSOR_C | 4635 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 4620 #undef DEFINE_BUILTIN_ACCESSOR_A | 4636 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 4621 #undef DEFINE_BUILTIN_ACCESSOR_T | 4637 #undef DEFINE_BUILTIN_ACCESSOR_T |
| 4622 #undef DEFINE_BUILTIN_ACCESSOR_H | 4638 #undef DEFINE_BUILTIN_ACCESSOR_H |
| 4623 | 4639 |
| 4624 } // namespace internal | 4640 } // namespace internal |
| 4625 } // namespace v8 | 4641 } // namespace v8 |
| OLD | NEW |