Changeset 197261 in webkit for trunk/Source/JavaScriptCore/runtime
- Timestamp:
- Feb 27, 2016, 4:36:01 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore/runtime
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/IntlCollator.cpp
r196887 r197261 251 251 // 18. Let r be ResolveLocale(%Collator%.[[availableLocales]], requestedLocales, opt, relevantExtensionKeys, localeData). 252 252 auto& availableLocales = state.callee()->globalObject()->intlCollatorAvailableLocales(); 253 auto result = resolveLocale( availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);253 auto result = resolveLocale(state, availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData); 254 254 255 255 // 19. Set collator.[[locale]] to the value of r.[[locale]]. -
trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
r196887 r197261 450 450 // 11. Let localeData be the value of %DateTimeFormat%.[[localeData]]. 451 451 // 12. Let r be ResolveLocale( %DateTimeFormat%.[[availableLocales]], requestedLocales, opt, %DateTimeFormat%.[[relevantExtensionKeys]], localeData). 452 const HashSet<String> availableLocales = exec. lexicalGlobalObject()->intlDateTimeFormatAvailableLocales();453 HashMap<String, String> resolved = resolveLocale( availableLocales, requestedLocales, localeOpt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);452 const HashSet<String> availableLocales = exec.callee()->globalObject()->intlDateTimeFormatAvailableLocales(); 453 HashMap<String, String> resolved = resolveLocale(exec, availableLocales, requestedLocales, localeOpt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData); 454 454 455 455 // 13. Set dateTimeFormat.[[locale]] to the value of r.[[locale]]. -
trunk/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
r196850 r197261 197 197 // 12. Let r be ResolveLocale(%NumberFormat%.[[availableLocales]], requestedLocales, opt, %NumberFormat%.[[relevantExtensionKeys]], localeData). 198 198 auto& availableLocales = state.callee()->globalObject()->intlNumberFormatAvailableLocales(); 199 auto result = resolveLocale( availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);199 auto result = resolveLocale(state, availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData); 200 200 201 201 // 13. Set numberFormat.[[locale]] to the value of r.[[locale]]. -
trunk/Source/JavaScriptCore/runtime/IntlObject.cpp
r196887 r197261 113 113 { 114 114 return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); 115 }116 117 String defaultLocale()118 {119 // 6.2.4 DefaultLocale ()120 String locale = uloc_getDefault();121 convertICULocaleToBCP47LanguageTag(locale);122 return locale;123 115 } 124 116 … … 651 643 } 652 644 645 String defaultLocale(ExecState& state) 646 { 647 // 6.2.4 DefaultLocale () 648 if (auto defaultLanguage = state.callee()->globalObject()->globalObjectMethodTable()->defaultLanguage) { 649 String locale = defaultLanguage(); 650 if (!locale.isEmpty()) 651 return canonicalizeLanguageTag(locale); 652 } 653 String locale = uloc_getDefault(); 654 convertICULocaleToBCP47LanguageTag(locale); 655 return locale; 656 } 657 653 658 String removeUnicodeLocaleExtension(const String& locale) 654 659 { … … 673 678 } 674 679 675 static MatcherResult lookupMatcher( const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)680 static MatcherResult lookupMatcher(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales) 676 681 { 677 682 // 9.2.3 LookupMatcher (availableLocales, requestedLocales) (ECMA-402 2.0) … … 710 715 } 711 716 } else 712 result.locale = defaultLocale( );717 result.locale = defaultLocale(state); 713 718 return result; 714 719 } 715 720 716 static MatcherResult bestFitMatcher( const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)721 static MatcherResult bestFitMatcher(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales) 717 722 { 718 723 // 9.2.4 BestFitMatcher (availableLocales, requestedLocales) (ECMA-402 2.0) 719 724 // FIXME: Implement something better than lookup. 720 return lookupMatcher( availableLocales, requestedLocales);721 } 722 723 HashMap<String, String> resolveLocale( const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, const HashMap<String, String>& options, const char* const relevantExtensionKeys[], size_t relevantExtensionKeyCount, Vector<String> (*localeData)(const String&, size_t))725 return lookupMatcher(state, availableLocales, requestedLocales); 726 } 727 728 HashMap<String, String> resolveLocale(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, const HashMap<String, String>& options, const char* const relevantExtensionKeys[], size_t relevantExtensionKeyCount, Vector<String> (*localeData)(const String&, size_t)) 724 729 { 725 730 // 9.2.5 ResolveLocale (availableLocales, requestedLocales, options, relevantExtensionKeys, localeData) (ECMA-402 2.0) … … 728 733 729 734 // 2. If matcher is "lookup", then 730 MatcherResult (*matcherOperation)( const HashSet<String>&, const Vector<String>&);735 MatcherResult (*matcherOperation)(ExecState&, const HashSet<String>&, const Vector<String>&); 731 736 if (matcher == "lookup") { 732 737 // a. Let MatcherOperation be the abstract operation LookupMatcher. … … 738 743 739 744 // 4. Let r be MatcherOperation(availableLocales, requestedLocales). 740 MatcherResult matcherResult = matcherOperation( availableLocales, requestedLocales);745 MatcherResult matcherResult = matcherOperation(state, availableLocales, requestedLocales); 741 746 742 747 // 5. Let foundLocale be the value of r.[[locale]]. -
trunk/Source/JavaScriptCore/runtime/IntlObject.h
r196434 r197261 58 58 }; 59 59 60 String defaultLocale( );60 String defaultLocale(ExecState&); 61 61 void convertICULocaleToBCP47LanguageTag(String& locale); 62 62 bool intlBooleanOption(ExecState&, JSValue options, PropertyName, bool& usesFallback); … … 64 64 unsigned intlNumberOption(ExecState&, JSValue options, PropertyName, unsigned minimum, unsigned maximum, unsigned fallback); 65 65 Vector<String> canonicalizeLocaleList(ExecState&, JSValue locales); 66 HashMap<String, String> resolveLocale( const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, const HashMap<String, String>& options, const char* const relevantExtensionKeys[], size_t relevantExtensionKeyCount, Vector<String> (*localeData)(const String&, size_t));66 HashMap<String, String> resolveLocale(ExecState&, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, const HashMap<String, String>& options, const char* const relevantExtensionKeys[], size_t relevantExtensionKeyCount, Vector<String> (*localeData)(const String&, size_t)); 67 67 JSValue supportedLocales(ExecState&, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, JSValue options); 68 68 String removeUnicodeLocaleExtension(const String& locale); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r196967 r197261 177 177 const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, &globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) }; 178 178 179 const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr };179 const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; 180 180 181 181 /* Source for JSGlobalObject.lut.h -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r196966 r197261 174 174 typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue); 175 175 ModuleLoaderEvaluatePtr moduleLoaderEvaluate; 176 177 typedef String (*DefaultLanguageFunctionPtr)(); 178 DefaultLanguageFunctionPtr defaultLanguage; 176 179 }; 177 180 -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r196721 r197261 1501 1501 // 8. Else 1502 1502 // a. Let requestedLocale be DefaultLocale(). 1503 String requestedLocale = len > 0 ? requestedLocales.first() : defaultLocale( );1503 String requestedLocale = len > 0 ? requestedLocales.first() : defaultLocale(*state); 1504 1504 1505 1505 // 9. Let noExtensionsLocale be the String value that is requestedLocale with all Unicode locale extension sequences (6.2.1) removed.
Note:
See TracChangeset
for help on using the changeset viewer.