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 = 0; | |
1999 | |
2000 function checkDateCacheCurrent() { | |
2001 var date_cache_version_holder = %DateCacheVersion(); | |
jungshik at Google
2016/05/19 23:11:58
nit: What's returned by DateCacheVersion is not a
pgorszkowski
2016/05/20 13:14:56
Done.
| |
2002 if (date_cache_version_holder == date_cache_version) { | |
2003 return; | |
2004 } | |
2005 date_cache_version = date_cache_version_holder; | |
2006 | |
2007 clearDefaultObjects(); | |
2008 } | |
1992 | 2009 |
1993 /** | 2010 /** |
1994 * Returns cached or newly created instance of a given service. | 2011 * Returns cached or newly created instance of a given service. |
1995 * We cache only default instances (where no locales or options are provided). | 2012 * We cache only default instances (where no locales or options are provided). |
1996 */ | 2013 */ |
1997 function cachedOrNewService(service, locales, options, defaults) { | 2014 function cachedOrNewService(service, locales, options, defaults) { |
1998 var useOptions = (IS_UNDEFINED(defaults)) ? options : defaults; | 2015 var useOptions = (IS_UNDEFINED(defaults)) ? options : defaults; |
1999 if (IS_UNDEFINED(locales) && IS_UNDEFINED(options)) { | 2016 if (IS_UNDEFINED(locales) && IS_UNDEFINED(options)) { |
2017 checkDateCacheCurrent(); | |
2000 if (IS_UNDEFINED(defaultObjects[service])) { | 2018 if (IS_UNDEFINED(defaultObjects[service])) { |
2001 defaultObjects[service] = new savedObjects[service](locales, useOptions); | 2019 defaultObjects[service] = new savedObjects[service](locales, useOptions); |
2002 } | 2020 } |
2003 return defaultObjects[service]; | 2021 return defaultObjects[service]; |
2004 } | 2022 } |
2005 return new savedObjects[service](locales, useOptions); | 2023 return new savedObjects[service](locales, useOptions); |
2006 } | 2024 } |
2007 | 2025 |
2008 function LocaleConvertCase(s, locales, isToUpper) { | 2026 function LocaleConvertCase(s, locales, isToUpper) { |
2009 // ECMA 402 section 13.1.2 steps 1 through 12. | 2027 // ECMA 402 section 13.1.2 steps 1 through 12. |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2232 } | 2250 } |
2233 ); | 2251 ); |
2234 | 2252 |
2235 utils.Export(function(to) { | 2253 utils.Export(function(to) { |
2236 to.AddBoundMethod = AddBoundMethod; | 2254 to.AddBoundMethod = AddBoundMethod; |
2237 to.IntlParseDate = IntlParseDate; | 2255 to.IntlParseDate = IntlParseDate; |
2238 to.IntlParseNumber = IntlParseNumber; | 2256 to.IntlParseNumber = IntlParseNumber; |
2239 }); | 2257 }); |
2240 | 2258 |
2241 }) | 2259 }) |
OLD | NEW |