Ignore:
Timestamp:
Dec 4, 2015, 5:14:03 PM (10 years ago)
Author:
[email protected]
Message:

[INTL] Implement Number.prototype.toLocaleString in ECMA-402
https://bugs.webkit.org/show_bug.cgi?id=147610

Patch by Andy VanWagoner <[email protected]> on 2015-12-04
Reviewed by Benjamin Poulain.

Source/JavaScriptCore:

Add toLocaleString in builtin JavaScript that delegates formatting to Intl.NumberFormat.
Keep exisiting native implementation for use if INTL flag is disabled.

  • CMakeLists.txt: Add NumberPrototype.js.
  • DerivedSources.make: Add NumberPrototype.js.
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • builtins/NumberPrototype.js: Added.

(toLocaleString):

  • runtime/CommonIdentifiers.h: Add private names for Intl constructors.
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init): Expose Intl constructors to builtin js.

  • runtime/NumberPrototype.cpp:

(JSC::NumberPrototype::finishCreation): Replace toLocaleString implementation.

LayoutTests:

Add tests for ECMA-402 Number.prototype.toLocaleString.
Since NumberFormat is not fully implemented, don't test locale-specific behavior yet.

  • js/number-toLocaleString-expected.txt: Added.
  • js/number-toLocaleString.html: Added.
  • js/script-tests/number-toLocaleString.js: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r192937 r193493  
    469469   
    470470#if ENABLE(INTL)
    471     putDirectWithoutTransition(vm, vm.propertyNames->Intl, IntlObject::create(vm, this, IntlObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
     471    IntlObject* intl = IntlObject::create(vm, this, IntlObject::createStructure(vm, this, m_objectPrototype.get()));
     472    putDirectWithoutTransition(vm, vm.propertyNames->Intl, intl, DontEnum);
    472473#endif // ENABLE(INTL)
    473474    putDirectWithoutTransition(vm, vm.propertyNames->JSON, JSONObject::create(vm, JSONObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
     
    568569        GlobalPropertyInfo(vm.propertyNames->MapPrivateName, mapConstructor, DontEnum | DontDelete | ReadOnly),
    569570        GlobalPropertyInfo(vm.propertyNames->builtinNames().generatorResumePrivateName(), JSFunction::createBuiltinFunction(vm, generatorPrototypeGeneratorResumeCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly),
     571#if ENABLE(INTL)
     572        GlobalPropertyInfo(vm.propertyNames->builtinNames().CollatorPrivateName(), intl->getDirect(vm, vm.propertyNames->Collator), DontEnum | DontDelete | ReadOnly),
     573        GlobalPropertyInfo(vm.propertyNames->builtinNames().DateTimeFormatPrivateName(), intl->getDirect(vm, vm.propertyNames->DateTimeFormat), DontEnum | DontDelete | ReadOnly),
     574        GlobalPropertyInfo(vm.propertyNames->builtinNames().NumberFormatPrivateName(), intl->getDirect(vm, vm.propertyNames->NumberFormat), DontEnum | DontDelete | ReadOnly),
     575#endif // ENABLE(INTL)
    570576    };
    571577    addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
Note: See TracChangeset for help on using the changeset viewer.