OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 | 5 |
6 #ifdef V8_I18N_SUPPORT | 6 #ifdef V8_I18N_SUPPORT |
7 #include "src/runtime/runtime-utils.h" | 7 #include "src/runtime/runtime-utils.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 ApiNatives::InstantiateObject(date_format_template)); | 352 ApiNatives::InstantiateObject(date_format_template)); |
353 | 353 |
354 // Set date time formatter as internal field of the resulting JS object. | 354 // Set date time formatter as internal field of the resulting JS object. |
355 icu::SimpleDateFormat* date_format = | 355 icu::SimpleDateFormat* date_format = |
356 DateFormat::InitializeDateTimeFormat(isolate, locale, options, resolved); | 356 DateFormat::InitializeDateTimeFormat(isolate, locale, options, resolved); |
357 | 357 |
358 if (!date_format) return isolate->ThrowIllegalOperation(); | 358 if (!date_format) return isolate->ThrowIllegalOperation(); |
359 | 359 |
360 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); | 360 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); |
361 | 361 |
362 Factory* factory = isolate->factory(); | |
363 Handle<String> key = factory->NewStringFromStaticChars("dateFormat"); | |
364 Handle<String> value = factory->NewStringFromStaticChars("valid"); | |
365 JSObject::AddProperty(local_object, key, value, NONE); | |
366 | |
367 // Make object handle weak so we can delete the data format once GC kicks in. | 362 // Make object handle weak so we can delete the data format once GC kicks in. |
368 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 363 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
369 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), | 364 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), |
370 DateFormat::DeleteDateFormat, | 365 DateFormat::DeleteDateFormat, |
371 WeakCallbackType::kInternalFields); | 366 WeakCallbackType::kInternalFields); |
372 return *local_object; | 367 return *local_object; |
373 } | 368 } |
374 | 369 |
375 | 370 |
376 RUNTIME_FUNCTION(Runtime_InternalDateFormat) { | 371 RUNTIME_FUNCTION(Runtime_InternalDateFormat) { |
377 HandleScope scope(isolate); | 372 HandleScope scope(isolate); |
378 | 373 |
379 DCHECK_EQ(2, args.length()); | 374 DCHECK_EQ(2, args.length()); |
380 | 375 |
381 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 376 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
382 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); | 377 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); |
383 | 378 |
384 Handle<Object> value; | 379 Handle<Object> value; |
385 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(date)); | 380 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(date)); |
386 | 381 |
387 icu::SimpleDateFormat* date_format = | 382 icu::SimpleDateFormat* date_format = |
388 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 383 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
389 if (!date_format) return isolate->ThrowIllegalOperation(); | 384 CHECK_NOT_NULL(date_format); |
390 | 385 |
391 icu::UnicodeString result; | 386 icu::UnicodeString result; |
392 date_format->format(value->Number(), result); | 387 date_format->format(value->Number(), result); |
393 | 388 |
394 RETURN_RESULT_OR_FAILURE( | 389 RETURN_RESULT_OR_FAILURE( |
395 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( | 390 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( |
396 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 391 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
397 result.length()))); | 392 result.length()))); |
398 } | 393 } |
399 | 394 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 DCHECK_EQ(2, args.length()); | 475 DCHECK_EQ(2, args.length()); |
481 | 476 |
482 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 477 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
483 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); | 478 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); |
484 | 479 |
485 Handle<Object> value; | 480 Handle<Object> value; |
486 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(date)); | 481 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(date)); |
487 | 482 |
488 icu::SimpleDateFormat* date_format = | 483 icu::SimpleDateFormat* date_format = |
489 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 484 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
490 if (!date_format) return isolate->ThrowIllegalOperation(); | 485 CHECK_NOT_NULL(date_format); |
491 | 486 |
492 icu::UnicodeString formatted; | 487 icu::UnicodeString formatted; |
493 icu::FieldPositionIterator fp_iter; | 488 icu::FieldPositionIterator fp_iter; |
494 icu::FieldPosition fp; | 489 icu::FieldPosition fp; |
495 UErrorCode status = U_ZERO_ERROR; | 490 UErrorCode status = U_ZERO_ERROR; |
496 date_format->format(value->Number(), formatted, &fp_iter, status); | 491 date_format->format(value->Number(), formatted, &fp_iter, status); |
497 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); | 492 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); |
498 | 493 |
499 Handle<JSArray> result = factory->NewJSArray(0); | 494 Handle<JSArray> result = factory->NewJSArray(0); |
500 int32_t length = formatted.length(); | 495 int32_t length = formatted.length(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 ApiNatives::InstantiateObject(number_format_template)); | 544 ApiNatives::InstantiateObject(number_format_template)); |
550 | 545 |
551 // Set number formatter as internal field of the resulting JS object. | 546 // Set number formatter as internal field of the resulting JS object. |
552 icu::DecimalFormat* number_format = | 547 icu::DecimalFormat* number_format = |
553 NumberFormat::InitializeNumberFormat(isolate, locale, options, resolved); | 548 NumberFormat::InitializeNumberFormat(isolate, locale, options, resolved); |
554 | 549 |
555 if (!number_format) return isolate->ThrowIllegalOperation(); | 550 if (!number_format) return isolate->ThrowIllegalOperation(); |
556 | 551 |
557 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); | 552 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); |
558 | 553 |
559 Factory* factory = isolate->factory(); | |
560 Handle<String> key = factory->NewStringFromStaticChars("numberFormat"); | |
561 Handle<String> value = factory->NewStringFromStaticChars("valid"); | |
562 JSObject::AddProperty(local_object, key, value, NONE); | |
563 | |
564 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 554 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
565 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), | 555 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), |
566 NumberFormat::DeleteNumberFormat, | 556 NumberFormat::DeleteNumberFormat, |
567 WeakCallbackType::kInternalFields); | 557 WeakCallbackType::kInternalFields); |
568 return *local_object; | 558 return *local_object; |
569 } | 559 } |
570 | 560 |
571 | 561 |
572 RUNTIME_FUNCTION(Runtime_InternalNumberFormat) { | 562 RUNTIME_FUNCTION(Runtime_InternalNumberFormat) { |
573 HandleScope scope(isolate); | 563 HandleScope scope(isolate); |
574 | 564 |
575 DCHECK_EQ(2, args.length()); | 565 DCHECK_EQ(2, args.length()); |
576 | 566 |
577 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 567 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
578 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); | 568 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); |
579 | 569 |
580 Handle<Object> value; | 570 Handle<Object> value; |
581 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(number)); | 571 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(number)); |
582 | 572 |
583 icu::DecimalFormat* number_format = | 573 icu::DecimalFormat* number_format = |
584 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); | 574 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); |
585 if (!number_format) return isolate->ThrowIllegalOperation(); | 575 CHECK_NOT_NULL(number_format); |
586 | 576 |
587 icu::UnicodeString result; | 577 icu::UnicodeString result; |
588 number_format->format(value->Number(), result); | 578 number_format->format(value->Number(), result); |
589 | 579 |
590 RETURN_RESULT_OR_FAILURE( | 580 RETURN_RESULT_OR_FAILURE( |
591 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( | 581 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( |
592 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 582 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
593 result.length()))); | 583 result.length()))); |
594 } | 584 } |
595 | 585 |
(...skipping 15 matching lines...) Expand all Loading... |
611 isolate, local_object, ApiNatives::InstantiateObject(collator_template)); | 601 isolate, local_object, ApiNatives::InstantiateObject(collator_template)); |
612 | 602 |
613 // Set collator as internal field of the resulting JS object. | 603 // Set collator as internal field of the resulting JS object. |
614 icu::Collator* collator = | 604 icu::Collator* collator = |
615 Collator::InitializeCollator(isolate, locale, options, resolved); | 605 Collator::InitializeCollator(isolate, locale, options, resolved); |
616 | 606 |
617 if (!collator) return isolate->ThrowIllegalOperation(); | 607 if (!collator) return isolate->ThrowIllegalOperation(); |
618 | 608 |
619 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); | 609 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); |
620 | 610 |
621 Factory* factory = isolate->factory(); | |
622 Handle<String> key = factory->NewStringFromStaticChars("collator"); | |
623 Handle<String> value = factory->NewStringFromStaticChars("valid"); | |
624 JSObject::AddProperty(local_object, key, value, NONE); | |
625 | |
626 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 611 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
627 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), | 612 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), |
628 Collator::DeleteCollator, | 613 Collator::DeleteCollator, |
629 WeakCallbackType::kInternalFields); | 614 WeakCallbackType::kInternalFields); |
630 return *local_object; | 615 return *local_object; |
631 } | 616 } |
632 | 617 |
633 | 618 |
634 RUNTIME_FUNCTION(Runtime_InternalCompare) { | 619 RUNTIME_FUNCTION(Runtime_InternalCompare) { |
635 HandleScope scope(isolate); | 620 HandleScope scope(isolate); |
636 | 621 |
637 DCHECK_EQ(3, args.length()); | 622 DCHECK_EQ(3, args.length()); |
638 | 623 |
639 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); | 624 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); |
640 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); | 625 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); |
641 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); | 626 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); |
642 | 627 |
643 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); | 628 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); |
644 if (!collator) return isolate->ThrowIllegalOperation(); | 629 CHECK_NOT_NULL(collator); |
645 | 630 |
646 string1 = String::Flatten(string1); | 631 string1 = String::Flatten(string1); |
647 string2 = String::Flatten(string2); | 632 string2 = String::Flatten(string2); |
648 | 633 |
649 UCollationResult result; | 634 UCollationResult result; |
650 UErrorCode status = U_ZERO_ERROR; | 635 UErrorCode status = U_ZERO_ERROR; |
651 { | 636 { |
652 DisallowHeapAllocation no_gc; | 637 DisallowHeapAllocation no_gc; |
653 int32_t length1 = string1->length(); | 638 int32_t length1 = string1->length(); |
654 int32_t length2 = string2->length(); | 639 int32_t length2 = string2->length(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 // Set break iterator as internal field of the resulting JS object. | 731 // Set break iterator as internal field of the resulting JS object. |
747 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator( | 732 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator( |
748 isolate, locale, options, resolved); | 733 isolate, locale, options, resolved); |
749 | 734 |
750 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 735 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
751 | 736 |
752 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); | 737 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); |
753 // Make sure that the pointer to adopted text is NULL. | 738 // Make sure that the pointer to adopted text is NULL. |
754 local_object->SetInternalField(1, static_cast<Smi*>(nullptr)); | 739 local_object->SetInternalField(1, static_cast<Smi*>(nullptr)); |
755 | 740 |
756 Factory* factory = isolate->factory(); | |
757 Handle<String> key = factory->NewStringFromStaticChars("breakIterator"); | |
758 Handle<String> value = factory->NewStringFromStaticChars("valid"); | |
759 JSObject::AddProperty(local_object, key, value, NONE); | |
760 | |
761 // Make object handle weak so we can delete the break iterator once GC kicks | 741 // Make object handle weak so we can delete the break iterator once GC kicks |
762 // in. | 742 // in. |
763 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 743 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
764 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), | 744 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), |
765 BreakIterator::DeleteBreakIterator, | 745 BreakIterator::DeleteBreakIterator, |
766 WeakCallbackType::kInternalFields); | 746 WeakCallbackType::kInternalFields); |
767 return *local_object; | 747 return *local_object; |
768 } | 748 } |
769 | 749 |
770 | 750 |
771 RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) { | 751 RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) { |
772 HandleScope scope(isolate); | 752 HandleScope scope(isolate); |
773 | 753 |
774 DCHECK_EQ(2, args.length()); | 754 DCHECK_EQ(2, args.length()); |
775 | 755 |
776 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 756 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
777 CONVERT_ARG_HANDLE_CHECKED(String, text, 1); | 757 CONVERT_ARG_HANDLE_CHECKED(String, text, 1); |
778 | 758 |
779 icu::BreakIterator* break_iterator = | 759 icu::BreakIterator* break_iterator = |
780 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 760 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
781 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 761 CHECK_NOT_NULL(break_iterator); |
782 | 762 |
783 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>( | 763 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>( |
784 break_iterator_holder->GetInternalField(1)); | 764 break_iterator_holder->GetInternalField(1)); |
785 delete u_text; | 765 delete u_text; |
786 | 766 |
787 int length = text->length(); | 767 int length = text->length(); |
788 text = String::Flatten(text); | 768 text = String::Flatten(text); |
789 DisallowHeapAllocation no_gc; | 769 DisallowHeapAllocation no_gc; |
790 String::FlatContent flat = text->GetFlatContent(); | 770 String::FlatContent flat = text->GetFlatContent(); |
791 std::unique_ptr<uc16[]> sap; | 771 std::unique_ptr<uc16[]> sap; |
792 const UChar* text_value = GetUCharBufferFromFlat(flat, &sap, length); | 772 const UChar* text_value = GetUCharBufferFromFlat(flat, &sap, length); |
793 u_text = new icu::UnicodeString(text_value, length); | 773 u_text = new icu::UnicodeString(text_value, length); |
794 break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text)); | 774 break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text)); |
795 | 775 |
796 break_iterator->setText(*u_text); | 776 break_iterator->setText(*u_text); |
797 | 777 |
798 return isolate->heap()->undefined_value(); | 778 return isolate->heap()->undefined_value(); |
799 } | 779 } |
800 | 780 |
801 | 781 |
802 RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) { | 782 RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) { |
803 HandleScope scope(isolate); | 783 HandleScope scope(isolate); |
804 | 784 |
805 DCHECK_EQ(1, args.length()); | 785 DCHECK_EQ(1, args.length()); |
806 | 786 |
807 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 787 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
808 | 788 |
809 icu::BreakIterator* break_iterator = | 789 icu::BreakIterator* break_iterator = |
810 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 790 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
811 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 791 CHECK_NOT_NULL(break_iterator); |
812 | 792 |
813 return *isolate->factory()->NewNumberFromInt(break_iterator->first()); | 793 return *isolate->factory()->NewNumberFromInt(break_iterator->first()); |
814 } | 794 } |
815 | 795 |
816 | 796 |
817 RUNTIME_FUNCTION(Runtime_BreakIteratorNext) { | 797 RUNTIME_FUNCTION(Runtime_BreakIteratorNext) { |
818 HandleScope scope(isolate); | 798 HandleScope scope(isolate); |
819 | 799 |
820 DCHECK_EQ(1, args.length()); | 800 DCHECK_EQ(1, args.length()); |
821 | 801 |
822 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 802 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
823 | 803 |
824 icu::BreakIterator* break_iterator = | 804 icu::BreakIterator* break_iterator = |
825 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 805 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
826 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 806 CHECK_NOT_NULL(break_iterator); |
827 | 807 |
828 return *isolate->factory()->NewNumberFromInt(break_iterator->next()); | 808 return *isolate->factory()->NewNumberFromInt(break_iterator->next()); |
829 } | 809 } |
830 | 810 |
831 | 811 |
832 RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) { | 812 RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) { |
833 HandleScope scope(isolate); | 813 HandleScope scope(isolate); |
834 | 814 |
835 DCHECK_EQ(1, args.length()); | 815 DCHECK_EQ(1, args.length()); |
836 | 816 |
837 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 817 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
838 | 818 |
839 icu::BreakIterator* break_iterator = | 819 icu::BreakIterator* break_iterator = |
840 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 820 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
841 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 821 CHECK_NOT_NULL(break_iterator); |
842 | 822 |
843 return *isolate->factory()->NewNumberFromInt(break_iterator->current()); | 823 return *isolate->factory()->NewNumberFromInt(break_iterator->current()); |
844 } | 824 } |
845 | 825 |
846 | 826 |
847 RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) { | 827 RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) { |
848 HandleScope scope(isolate); | 828 HandleScope scope(isolate); |
849 | 829 |
850 DCHECK_EQ(1, args.length()); | 830 DCHECK_EQ(1, args.length()); |
851 | 831 |
852 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 832 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
853 | 833 |
854 icu::BreakIterator* break_iterator = | 834 icu::BreakIterator* break_iterator = |
855 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 835 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
856 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 836 CHECK_NOT_NULL(break_iterator); |
857 | 837 |
858 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. | 838 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. |
859 icu::RuleBasedBreakIterator* rule_based_iterator = | 839 icu::RuleBasedBreakIterator* rule_based_iterator = |
860 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); | 840 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); |
861 int32_t status = rule_based_iterator->getRuleStatus(); | 841 int32_t status = rule_based_iterator->getRuleStatus(); |
862 // Keep return values in sync with JavaScript BreakType enum. | 842 // Keep return values in sync with JavaScript BreakType enum. |
863 if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) { | 843 if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) { |
864 return *isolate->factory()->NewStringFromStaticChars("none"); | 844 return *isolate->factory()->NewStringFromStaticChars("none"); |
865 } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) { | 845 } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) { |
866 return isolate->heap()->number_string(); | 846 return isolate->heap()->number_string(); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 Handle<FixedArray> date_cache_version = | 1181 Handle<FixedArray> date_cache_version = |
1202 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 1182 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( |
1203 EternalHandles::DATE_CACHE_VERSION)); | 1183 EternalHandles::DATE_CACHE_VERSION)); |
1204 return date_cache_version->get(0); | 1184 return date_cache_version->get(0); |
1205 } | 1185 } |
1206 | 1186 |
1207 } // namespace internal | 1187 } // namespace internal |
1208 } // namespace v8 | 1188 } // namespace v8 |
1209 | 1189 |
1210 #endif // V8_I18N_SUPPORT | 1190 #endif // V8_I18N_SUPPORT |
OLD | NEW |