OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 // ECMAScript 402 API implementation. | 5 // ECMAScript 402 API implementation. |
6 | 6 |
7 /** | 7 /** |
8 * Intl object is a single object that has some named properties, | 8 * Intl object is a single object that has some named properties, |
9 * all of which are constructors. | 9 * all of which are constructors. |
10 */ | 10 */ |
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 // Default (created with undefined locales and options parameters) collator, | 1982 // Default (created with undefined locales and options parameters) collator, |
1983 // number and date format instances. They'll be created as needed. | 1983 // number and date format instances. They'll be created as needed. |
1984 var defaultObjects = { | 1984 var defaultObjects = { |
1985 'collator': UNDEFINED, | 1985 'collator': UNDEFINED, |
1986 'numberformat': UNDEFINED, | 1986 'numberformat': UNDEFINED, |
1987 'dateformatall': UNDEFINED, | 1987 'dateformatall': UNDEFINED, |
1988 'dateformatdate': UNDEFINED, | 1988 'dateformatdate': UNDEFINED, |
1989 'dateformattime': UNDEFINED, | 1989 'dateformattime': UNDEFINED, |
1990 }; | 1990 }; |
1991 | 1991 |
| 1992 function clearDefaultObjects() { |
| 1993 defaultObjects['dateformatall'] = UNDEFINED; |
| 1994 defaultObjects['dateformatdate'] = UNDEFINED; |
| 1995 defaultObjects['dateformattime'] = UNDEFINED; |
| 1996 } |
| 1997 |
| 1998 var date_cache_version_holder; |
| 1999 var date_cache_version; |
| 2000 |
| 2001 function checkDateCacheCurrent() { |
| 2002 if (!date_cache_version_holder) { |
| 2003 date_cache_version_holder = %DateCacheVersion(); |
| 2004 if (!date_cache_version_holder) return; |
| 2005 } |
| 2006 if (date_cache_version_holder[0] == date_cache_version) { |
| 2007 return; |
| 2008 } |
| 2009 date_cache_version = date_cache_version_holder[0]; |
| 2010 |
| 2011 clearDefaultObjects(); |
| 2012 } |
1992 | 2013 |
1993 /** | 2014 /** |
1994 * Returns cached or newly created instance of a given service. | 2015 * Returns cached or newly created instance of a given service. |
1995 * We cache only default instances (where no locales or options are provided). | 2016 * We cache only default instances (where no locales or options are provided). |
1996 */ | 2017 */ |
1997 function cachedOrNewService(service, locales, options, defaults) { | 2018 function cachedOrNewService(service, locales, options, defaults) { |
1998 var useOptions = (IS_UNDEFINED(defaults)) ? options : defaults; | 2019 var useOptions = (IS_UNDEFINED(defaults)) ? options : defaults; |
1999 if (IS_UNDEFINED(locales) && IS_UNDEFINED(options)) { | 2020 if (IS_UNDEFINED(locales) && IS_UNDEFINED(options)) { |
| 2021 checkDateCacheCurrent(); |
2000 if (IS_UNDEFINED(defaultObjects[service])) { | 2022 if (IS_UNDEFINED(defaultObjects[service])) { |
2001 defaultObjects[service] = new savedObjects[service](locales, useOptions); | 2023 defaultObjects[service] = new savedObjects[service](locales, useOptions); |
2002 } | 2024 } |
2003 return defaultObjects[service]; | 2025 return defaultObjects[service]; |
2004 } | 2026 } |
2005 return new savedObjects[service](locales, useOptions); | 2027 return new savedObjects[service](locales, useOptions); |
2006 } | 2028 } |
2007 | 2029 |
2008 function LocaleConvertCase(s, locales, isToUpper) { | 2030 function LocaleConvertCase(s, locales, isToUpper) { |
2009 // ECMA 402 section 13.1.2 steps 1 through 12. | 2031 // ECMA 402 section 13.1.2 steps 1 through 12. |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 } | 2254 } |
2233 ); | 2255 ); |
2234 | 2256 |
2235 utils.Export(function(to) { | 2257 utils.Export(function(to) { |
2236 to.AddBoundMethod = AddBoundMethod; | 2258 to.AddBoundMethod = AddBoundMethod; |
2237 to.IntlParseDate = IntlParseDate; | 2259 to.IntlParseDate = IntlParseDate; |
2238 to.IntlParseNumber = IntlParseNumber; | 2260 to.IntlParseNumber = IntlParseNumber; |
2239 }); | 2261 }); |
2240 | 2262 |
2241 }) | 2263 }) |
OLD | NEW |