Fix coding style of Intl code
authorsukolsak@gmail.com <sukolsak@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Nov 2015 22:21:18 +0000 (22:21 +0000)
committersukolsak@gmail.com <sukolsak@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Nov 2015 22:21:18 +0000 (22:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151491

Reviewed by Darin Adler.

This patch does three things:
1. Rename pointers and references to ExecState from "exec" to "state".
2. Pass parameters by references instead of pointers if the parameters
   are required.
3. Remove the word "get" from the names of functions that don't return
   values through out arguments.

* runtime/IntlCollator.cpp:
(JSC::IntlCollatorFuncCompare):
* runtime/IntlCollatorConstructor.cpp:
(JSC::initializeCollator):
(JSC::constructIntlCollator):
(JSC::callIntlCollator):
(JSC::IntlCollatorConstructor::getOwnPropertySlot):
(JSC::IntlCollatorConstructorFuncSupportedLocalesOf):
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormatFuncFormatDateTime):
* runtime/IntlDateTimeFormatConstructor.cpp:
(JSC::constructIntlDateTimeFormat):
(JSC::callIntlDateTimeFormat):
(JSC::IntlDateTimeFormatConstructor::getOwnPropertySlot):
(JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):
* runtime/IntlDateTimeFormatPrototype.cpp:
(JSC::IntlDateTimeFormatPrototype::getOwnPropertySlot):
(JSC::IntlDateTimeFormatPrototypeGetterFormat):
(JSC::IntlDateTimeFormatPrototypeFuncResolvedOptions):
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormatFuncFormatNumber):
* runtime/IntlNumberFormatConstructor.cpp:
(JSC::constructIntlNumberFormat):
(JSC::callIntlNumberFormat):
(JSC::IntlNumberFormatConstructor::getOwnPropertySlot):
(JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf):
* runtime/IntlNumberFormatPrototype.cpp:
(JSC::IntlNumberFormatPrototype::getOwnPropertySlot):
(JSC::IntlNumberFormatPrototypeGetterFormat):
(JSC::IntlNumberFormatPrototypeFuncResolvedOptions):
* runtime/IntlObject.cpp:
(JSC::intlBooleanOption):
(JSC::intlStringOption):
(JSC::privateUseLangTag):
(JSC::canonicalLangTag):
(JSC::grandfatheredLangTag):
(JSC::canonicalizeLanguageTag):
(JSC::canonicalizeLocaleList):
(JSC::lookupSupportedLocales):
(JSC::bestFitSupportedLocales):
(JSC::supportedLocales):
(JSC::getIntlBooleanOption): Deleted.
(JSC::getIntlStringOption): Deleted.
(JSC::getPrivateUseLangTag): Deleted.
(JSC::getCanonicalLangTag): Deleted.
(JSC::getGrandfatheredLangTag): Deleted.
* runtime/IntlObject.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192831 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/IntlCollator.cpp
Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp
Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp
Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp
Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp
Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp
Source/JavaScriptCore/runtime/IntlObject.cpp
Source/JavaScriptCore/runtime/IntlObject.h

index 62ab7282ce7a382998ad5be2bf5caad9a12006f2..de7b6debb0cc4053be754d61bb2739a2021a99b4 100644 (file)
@@ -1,3 +1,65 @@
+2015-11-30  Sukolsak Sakshuwong  <sukolsak@gmail.com>
+
+        Fix coding style of Intl code
+        https://bugs.webkit.org/show_bug.cgi?id=151491
+
+        Reviewed by Darin Adler.
+
+        This patch does three things:
+        1. Rename pointers and references to ExecState from "exec" to "state".
+        2. Pass parameters by references instead of pointers if the parameters
+           are required.
+        3. Remove the word "get" from the names of functions that don't return
+           values through out arguments.
+
+        * runtime/IntlCollator.cpp:
+        (JSC::IntlCollatorFuncCompare):
+        * runtime/IntlCollatorConstructor.cpp:
+        (JSC::initializeCollator):
+        (JSC::constructIntlCollator):
+        (JSC::callIntlCollator):
+        (JSC::IntlCollatorConstructor::getOwnPropertySlot):
+        (JSC::IntlCollatorConstructorFuncSupportedLocalesOf):
+        * runtime/IntlDateTimeFormat.cpp:
+        (JSC::IntlDateTimeFormatFuncFormatDateTime):
+        * runtime/IntlDateTimeFormatConstructor.cpp:
+        (JSC::constructIntlDateTimeFormat):
+        (JSC::callIntlDateTimeFormat):
+        (JSC::IntlDateTimeFormatConstructor::getOwnPropertySlot):
+        (JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):
+        * runtime/IntlDateTimeFormatPrototype.cpp:
+        (JSC::IntlDateTimeFormatPrototype::getOwnPropertySlot):
+        (JSC::IntlDateTimeFormatPrototypeGetterFormat):
+        (JSC::IntlDateTimeFormatPrototypeFuncResolvedOptions):
+        * runtime/IntlNumberFormat.cpp:
+        (JSC::IntlNumberFormatFuncFormatNumber):
+        * runtime/IntlNumberFormatConstructor.cpp:
+        (JSC::constructIntlNumberFormat):
+        (JSC::callIntlNumberFormat):
+        (JSC::IntlNumberFormatConstructor::getOwnPropertySlot):
+        (JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf):
+        * runtime/IntlNumberFormatPrototype.cpp:
+        (JSC::IntlNumberFormatPrototype::getOwnPropertySlot):
+        (JSC::IntlNumberFormatPrototypeGetterFormat):
+        (JSC::IntlNumberFormatPrototypeFuncResolvedOptions):
+        * runtime/IntlObject.cpp:
+        (JSC::intlBooleanOption):
+        (JSC::intlStringOption):
+        (JSC::privateUseLangTag):
+        (JSC::canonicalLangTag):
+        (JSC::grandfatheredLangTag):
+        (JSC::canonicalizeLanguageTag):
+        (JSC::canonicalizeLocaleList):
+        (JSC::lookupSupportedLocales):
+        (JSC::bestFitSupportedLocales):
+        (JSC::supportedLocales):
+        (JSC::getIntlBooleanOption): Deleted.
+        (JSC::getIntlStringOption): Deleted.
+        (JSC::getPrivateUseLangTag): Deleted.
+        (JSC::getCanonicalLangTag): Deleted.
+        (JSC::getGrandfatheredLangTag): Deleted.
+        * runtime/IntlObject.h:
+
 2015-11-30  Benjamin Poulain  <bpoulain@apple.com>
 
         [JSC] Simplify the loop that remove useless Air instructions
index 98108fc18598d3e2c7ad89e0cf1f88d4e5a11ec9..79c523c65b99a96a93d3c5a62924a1fb50be61a6 100644 (file)
@@ -84,28 +84,28 @@ void IntlCollator::setBoundCompare(VM& vm, JSBoundFunction* format)
     m_boundCompare.set(vm, this, format);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlCollatorFuncCompare(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlCollatorFuncCompare(ExecState* state)
 {
     // 10.3.4 Collator Compare Functions (ECMA-402 2.0)
     // 1. Let collator be the this value.
-    IntlCollator* collator = jsDynamicCast<IntlCollator*>(exec->thisValue());
+    IntlCollator* collator = jsDynamicCast<IntlCollator*>(state->thisValue());
 
     // 2. Assert: Type(collator) is Object and collator has an [[initializedCollator]] internal slot whose value is true.
     if (!collator)
-        return JSValue::encode(throwTypeError(exec));
+        return JSValue::encode(throwTypeError(state));
 
     // 3. If x is not provided, let x be undefined.
     // 4. If y is not provided, let y be undefined.
     // 5. Let X be ToString(x).
-    JSString* a = exec->argument(0).toString(exec);
+    JSString* a = state->argument(0).toString(state);
     // 6. ReturnIfAbrupt(X).
-    if (exec->hadException())
+    if (state->hadException())
         return JSValue::encode(jsUndefined());
 
     // 7. Let Y be ToString(y).
-    JSString* b = exec->argument(1).toString(exec);
+    JSString* b = state->argument(1).toString(state);
     // 8. ReturnIfAbrupt(Y).
-    if (exec->hadException())
+    if (state->hadException())
         return JSValue::encode(jsUndefined());
 
     // 9. Return CompareStrings(collator, X, Y).
@@ -114,7 +114,7 @@ EncodedJSValue JSC_HOST_CALL IntlCollatorFuncCompare(ExecState* exec)
     // FIXME: Implement CompareStrings.
 
     // Return simple check until properly implemented.
-    return JSValue::encode(jsNumber(codePointCompare(a->value(exec).impl(), b->value(exec).impl())));
+    return JSValue::encode(jsNumber(codePointCompare(a->value(state).impl(), b->value(state).impl())));
 }
 
 } // namespace JSC
index 4e2750a3f691244de77e050aad1d7fc2f6162267..15982509507e7a1fdeadb6ff4e404ce47a1754a8 100644 (file)
@@ -120,7 +120,7 @@ static Vector<String> searchLocaleData(const String&, const String& key)
     return keyLocaleData;
 }
 
-static IntlCollator* initializeCollator(ExecState* exec, IntlCollator* collator, JSValue locales, JSValue optionsValue)
+static IntlCollator* initializeCollator(ExecState& state, IntlCollator& collator, JSValue locales, JSValue optionsValue)
 {
     // 10.1.1 InitializeCollator (collator, locales, options) (ECMA-402 2.0)
 
@@ -128,32 +128,32 @@ static IntlCollator* initializeCollator(ExecState* exec, IntlCollator* collator,
     // 2. Set collator.[[initializedIntlObject]] to true.
 
     // 3. Let requestedLocales be CanonicalizeLocaleList(locales).
-    Vector<String> requestedLocales = canonicalizeLocaleList(exec, locales);
+    Vector<String> requestedLocales = canonicalizeLocaleList(state, locales);
     // 4. ReturnIfAbrupt(requestedLocales).
-    if (exec->hadException())
+    if (state.hadException())
         return nullptr;
 
     // 5. If options is undefined, then
     JSObject* options;
     if (optionsValue.isUndefined()) {
         // a. Let options be ObjectCreate(%ObjectPrototype%).
-        options = constructEmptyObject(exec);
+        options = constructEmptyObject(&state);
     } else { // 6. Else
         // a. Let options be ToObject(options).
-        options = optionsValue.toObject(exec);
+        options = optionsValue.toObject(&state);
         // b. ReturnIfAbrupt(options).
-        if (exec->hadException())
+        if (state.hadException())
             return nullptr;
     }
 
     // 7. Let u be GetOption(options, "usage", "string", «"sort", "search"», "sort").
     const HashSet<String> usages({ ASCIILiteral("sort"), ASCIILiteral("search") });
-    String usage = getIntlStringOption(exec, options, exec->vm().propertyNames->usage, usages, "usage must be either \"sort\" or \"search\"", ASCIILiteral("sort"));
+    String usage = intlStringOption(state, options, state.vm().propertyNames->usage, usages, "usage must be either \"sort\" or \"search\"", ASCIILiteral("sort"));
     // 8. ReturnIfAbrupt(u).
-    if (exec->hadException())
+    if (state.hadException())
         return nullptr;
     // 9. Set collator.[[usage]] to u.
-    collator->setUsage(usage);
+    collator.setUsage(usage);
 
     // 10. If u is "sort", then
     // a. Let localeData be the value of %Collator%.[[sortLocaleData]];
@@ -170,9 +170,9 @@ static IntlCollator* initializeCollator(ExecState* exec, IntlCollator* collator,
 
     // 13. Let matcher be GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
     const HashSet<String> matchers({ ASCIILiteral("lookup"), ASCIILiteral("best fit") });
-    String matcher = getIntlStringOption(exec, options, exec->vm().propertyNames->localeMatcher, matchers, "localeMatcher must be either \"lookup\" or \"best fit\"", ASCIILiteral("best fit"));
+    String matcher = intlStringOption(state, options, state.vm().propertyNames->localeMatcher, matchers, "localeMatcher must be either \"lookup\" or \"best fit\"", ASCIILiteral("best fit"));
     // 14. ReturnIfAbrupt(matcher).
-    if (exec->hadException())
+    if (state.hadException())
         return nullptr;
     // 15. Set opt.[[localeMatcher]] to matcher.
     opt.set(ASCIILiteral("localeMatcher"), matcher);
@@ -191,8 +191,8 @@ static IntlCollator* initializeCollator(ExecState* exec, IntlCollator* collator,
     {
         String numericString;
         bool usesFallback;
-        bool numeric = getIntlBooleanOption(exec, options, exec->vm().propertyNames->numeric, usesFallback);
-        if (exec->hadException())
+        bool numeric = intlBooleanOption(state, options, state.vm().propertyNames->numeric, usesFallback);
+        if (state.hadException())
             return nullptr;
         if (!usesFallback)
             numericString = ASCIILiteral(numeric ? "true" : "false");
@@ -200,8 +200,8 @@ static IntlCollator* initializeCollator(ExecState* exec, IntlCollator* collator,
     }
     {
         const HashSet<String> caseFirsts({ ASCIILiteral("upper"), ASCIILiteral("lower"), ASCIILiteral("false") });
-        String caseFirst = getIntlStringOption(exec, options, exec->vm().propertyNames->caseFirst, caseFirsts, "caseFirst must be either \"upper\", \"lower\", or \"false\"", String());
-        if (exec->hadException())
+        String caseFirst = intlStringOption(state, options, state.vm().propertyNames->caseFirst, caseFirsts, "caseFirst must be either \"upper\", \"lower\", or \"false\"", String());
+        if (state.hadException())
             return nullptr;
         opt.set(ASCIILiteral("kf"), caseFirst);
     }
@@ -211,11 +211,11 @@ static IntlCollator* initializeCollator(ExecState* exec, IntlCollator* collator,
     const Vector<String> relevantExtensionKeys { ASCIILiteral("co"), ASCIILiteral("kn") };
 
     // 18. Let r be ResolveLocale(%Collator%.[[availableLocales]], requestedLocales, opt, relevantExtensionKeys, localeData).
-    const HashSet<String>& availableLocales = exec->callee()->globalObject()->intlCollatorAvailableLocales();
+    const HashSet<String>& availableLocales = state.callee()->globalObject()->intlCollatorAvailableLocales();
     HashMap<String, String> result = resolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData);
 
     // 19. Set collator.[[locale]] to the value of r.[[locale]].
-    collator->setLocale(result.get(ASCIILiteral("locale")));
+    collator.setLocale(result.get(ASCIILiteral("locale")));
 
     // 20. Let k be 0.
     // 21. Let lenValue be Get(relevantExtensionKeys, "length").
@@ -238,19 +238,19 @@ static IntlCollator* initializeCollator(ExecState* exec, IntlCollator* collator,
     {
         ASSERT(relevantExtensionKeys[0] == "co");
         const String& value = result.get(ASCIILiteral("co"));
-        collator->setCollation(value.isNull() ? ASCIILiteral("default") : value);
+        collator.setCollation(value.isNull() ? ASCIILiteral("default") : value);
     }
     {
         ASSERT(relevantExtensionKeys[1] == "kn");
         const String& value = result.get(ASCIILiteral("kn"));
-        collator->setNumeric(value == "true");
+        collator.setNumeric(value == "true");
     }
 
     // 24. Let s be GetOption(options, "sensitivity", "string", «"base", "accent", "case", "variant"», undefined).
     const HashSet<String> sensitivities({ ASCIILiteral("base"), ASCIILiteral("accent"), ASCIILiteral("case"), ASCIILiteral("variant") });
-    String sensitivity = getIntlStringOption(exec, options, exec->vm().propertyNames->sensitivity, sensitivities, "sensitivity must be either \"base\", \"accent\", \"case\", or \"variant\"", String());
+    String sensitivity = intlStringOption(state, options, state.vm().propertyNames->sensitivity, sensitivities, "sensitivity must be either \"base\", \"accent\", \"case\", or \"variant\"", String());
     // 25. ReturnIfAbrupt(s).
-    if (exec->hadException())
+    if (state.hadException())
         return nullptr;
     // 26. If s is undefined, then
     if (sensitivity.isNull()) {
@@ -267,23 +267,23 @@ static IntlCollator* initializeCollator(ExecState* exec, IntlCollator* collator,
         }
     }
     // 27. Set collator.[[sensitivity]] to s.
-    collator->setSensitivity(sensitivity);
+    collator.setSensitivity(sensitivity);
 
     // 28. Let ip be GetOption(options, "ignorePunctuation", "boolean", undefined, false).
     bool usesFallback;
-    bool ignorePunctuation = getIntlBooleanOption(exec, options, exec->vm().propertyNames->ignorePunctuation, usesFallback);
+    bool ignorePunctuation = intlBooleanOption(state, options, state.vm().propertyNames->ignorePunctuation, usesFallback);
     if (usesFallback)
         ignorePunctuation = false;
     // 29. ReturnIfAbrupt(ip).
-    if (exec->hadException())
+    if (state.hadException())
         return nullptr;
     // 30. Set collator.[[ignorePunctuation]] to ip.
-    collator->setIgnorePunctuation(ignorePunctuation);
+    collator.setIgnorePunctuation(ignorePunctuation);
 
     // 31. Set collator.[[boundCompare]] to undefined.
     // 32. Set collator.[[initializedCollator]] to true.
     // 33. Return collator.
-    return collator;
+    return &collator;
 }
 
 IntlCollatorConstructor* IntlCollatorConstructor::create(VM& vm, Structure* structure, IntlCollatorPrototype* collatorPrototype, Structure* collatorStructure)
@@ -311,48 +311,48 @@ void IntlCollatorConstructor::finishCreation(VM& vm, IntlCollatorPrototype* coll
     m_collatorStructure.set(vm, this, collatorStructure);
 }
 
-static EncodedJSValue JSC_HOST_CALL constructIntlCollator(ExecState* exec)
+static EncodedJSValue JSC_HOST_CALL constructIntlCollator(ExecState* state)
 {
     // 10.1.2 Intl.Collator ([locales [, options]]) (ECMA-402 2.0)
     // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
-    JSValue newTarget = exec->newTarget();
+    JSValue newTarget = state->newTarget();
     if (newTarget.isUndefined())
-        newTarget = exec->callee();
+        newTarget = state->callee();
 
     // 2. Let collator be OrdinaryCreateFromConstructor(newTarget, %CollatorPrototype%).
-    VM& vm = exec->vm();
-    IntlCollator* collator = IntlCollator::create(vm, jsCast<IntlCollatorConstructor*>(exec->callee()));
+    VM& vm = state->vm();
+    IntlCollator* collator = IntlCollator::create(vm, jsCast<IntlCollatorConstructor*>(state->callee()));
     if (collator && !jsDynamicCast<IntlCollatorConstructor*>(newTarget)) {
         JSValue proto = asObject(newTarget)->getDirect(vm, vm.propertyNames->prototype);
-        asObject(collator)->setPrototypeWithCycleCheck(exec, proto);
+        asObject(collator)->setPrototypeWithCycleCheck(state, proto);
     }
 
     // 3. ReturnIfAbrupt(collator).
     ASSERT(collator);
 
     // 4. Return InitializeCollator(collator, locales, options).
-    JSValue locales = exec->argument(0);
-    JSValue options = exec->argument(1);
-    return JSValue::encode(initializeCollator(exec, collator, locales, options));
+    JSValue locales = state->argument(0);
+    JSValue options = state->argument(1);
+    return JSValue::encode(initializeCollator(*state, *collator, locales, options));
 }
 
-static EncodedJSValue JSC_HOST_CALL callIntlCollator(ExecState* exec)
+static EncodedJSValue JSC_HOST_CALL callIntlCollator(ExecState* state)
 {
     // 10.1.2 Intl.Collator ([locales [, options]]) (ECMA-402 2.0)
     // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
     // NewTarget is always undefined when called as a function.
 
     // 2. Let collator be OrdinaryCreateFromConstructor(newTarget, %CollatorPrototype%).
-    VM& vm = exec->vm();
-    IntlCollator* collator = IntlCollator::create(vm, jsCast<IntlCollatorConstructor*>(exec->callee()));
+    VM& vm = state->vm();
+    IntlCollator* collator = IntlCollator::create(vm, jsCast<IntlCollatorConstructor*>(state->callee()));
 
     // 3. ReturnIfAbrupt(collator).
     ASSERT(collator);
 
     // 4. Return InitializeCollator(collator, locales, options).
-    JSValue locales = exec->argument(0);
-    JSValue options = exec->argument(1);
-    return JSValue::encode(initializeCollator(exec, collator, locales, options));
+    JSValue locales = state->argument(0);
+    JSValue options = state->argument(1);
+    return JSValue::encode(initializeCollator(*state, *collator, locales, options));
 }
 
 ConstructType IntlCollatorConstructor::getConstructData(JSCell*, ConstructData& constructData)
@@ -367,25 +367,25 @@ CallType IntlCollatorConstructor::getCallData(JSCell*, CallData& callData)
     return CallTypeHost;
 }
 
-bool IntlCollatorConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+bool IntlCollatorConstructor::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
 {
-    return getStaticFunctionSlot<InternalFunction>(exec, collatorConstructorTable, jsCast<IntlCollatorConstructor*>(object), propertyName, slot);
+    return getStaticFunctionSlot<InternalFunction>(state, collatorConstructorTable, jsCast<IntlCollatorConstructor*>(object), propertyName, slot);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlCollatorConstructorFuncSupportedLocalesOf(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlCollatorConstructorFuncSupportedLocalesOf(ExecState* state)
 {
     // 10.2.2 Intl.Collator.supportedLocalesOf(locales [, options]) (ECMA-402 2.0)
 
     // 1. Let requestedLocales be CanonicalizeLocaleList(locales).
-    Vector<String> requestedLocales = canonicalizeLocaleList(exec, exec->argument(0));
+    Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
 
     // 2. ReturnIfAbrupt(requestedLocales).
-    if (exec->hadException())
+    if (state->hadException())
         return JSValue::encode(jsUndefined());
 
     // 3. Return SupportedLocales(%Collator%.[[availableLocales]], requestedLocales, options).
-    JSGlobalObject* globalObject = exec->callee()->globalObject();
-    return JSValue::encode(supportedLocales(exec, globalObject->intlCollatorAvailableLocales(), requestedLocales, exec->argument(1)));
+    JSGlobalObject* globalObject = state->callee()->globalObject();
+    return JSValue::encode(supportedLocales(*state, globalObject->intlCollatorAvailableLocales(), requestedLocales, state->argument(1)));
 }
 
 void IntlCollatorConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor)
index 7839badc3ae9039bfafd06fc01dd823cf8dff264..dc5b2ace325b08b6f2f37b231076920e88fcf028 100644 (file)
@@ -86,28 +86,28 @@ void IntlDateTimeFormat::setBoundFormat(VM& vm, JSBoundFunction* format)
     m_boundFormat.set(vm, this, format);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatFuncFormatDateTime(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatFuncFormatDateTime(ExecState* state)
 {
     // 12.3.4 DateTime Format Functions (ECMA-402 2.0)
     // 1. Let dtf be the this value.
-    IntlDateTimeFormat* format = jsDynamicCast<IntlDateTimeFormat*>(exec->thisValue());
+    IntlDateTimeFormat* format = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue());
     // 2. Assert: Type(dtf) is Object and dtf has an [[initializedDateTimeFormat]] internal slot whose value is true.
     if (!format)
-        return JSValue::encode(throwTypeError(exec));
+        return JSValue::encode(throwTypeError(state));
 
-    JSValue date = exec->argument(0);
+    JSValue date = state->argument(0);
     double value;
 
     // 3. If date is not provided or is undefined, then
     if (date.isUndefined()) {
         // a. Let x be %Date_now%().
-        value = JSValue::decode(dateNow(exec)).toNumber(exec);
+        value = JSValue::decode(dateNow(state)).toNumber(state);
     } else {
         // 4. Else
         // a. Let x be ToNumber(date).
-        value = date.toNumber(exec);
+        value = date.toNumber(state);
         // b. ReturnIfAbrupt(x).
-        if (exec->hadException())
+        if (state->hadException())
             return JSValue::encode(jsUndefined());
     }
 
@@ -117,15 +117,15 @@ EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatFuncFormatDateTime(ExecState* exe
 
     // 1. If x is not a finite Number, then throw a RangeError exception.
     if (!std::isfinite(value))
-        return JSValue::encode(throwRangeError(exec, ASCIILiteral("date value is not finite in DateTimeFormat.format()")));
+        return JSValue::encode(throwRangeError(state, ASCIILiteral("date value is not finite in DateTimeFormat.format()")));
 
     // FIXME: implement 2 - 9
 
     // Return new Date(value).toString() until properly implemented.
-    VM& vm = exec->vm();
-    JSGlobalObject* globalObject = exec->callee()->globalObject();
+    VM& vm = state->vm();
+    JSGlobalObject* globalObject = state->callee()->globalObject();
     DateInstance* d = DateInstance::create(vm, globalObject->dateStructure(), value);
-    return JSValue::encode(JSValue(d).toString(exec));
+    return JSValue::encode(JSValue(d).toString(state));
 }
 
 } // namespace JSC
index f2da051754f6d2b27051cea384fe0a7c382df2f3..1e89faaab7eb88c7f864e0f53f255cb8a2c5eecc 100644 (file)
@@ -84,20 +84,20 @@ void IntlDateTimeFormatConstructor::finishCreation(VM& vm, IntlDateTimeFormatPro
     m_dateTimeFormatStructure.set(vm, this, dateTimeFormatStructure);
 }
 
-static EncodedJSValue JSC_HOST_CALL constructIntlDateTimeFormat(ExecState* exec)
+static EncodedJSValue JSC_HOST_CALL constructIntlDateTimeFormat(ExecState* state)
 {
     // 12.1.2 Intl.DateTimeFormat ([locales [, options]]) (ECMA-402 2.0)
     // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
-    JSValue newTarget = exec->newTarget();
+    JSValue newTarget = state->newTarget();
     if (newTarget.isUndefined())
-        newTarget = exec->callee();
+        newTarget = state->callee();
 
     // 2. Let dateTimeFormat be OrdinaryCreateFromConstructor(newTarget, %DateTimeFormatPrototype%).
-    VM& vm = exec->vm();
-    IntlDateTimeFormat* dateTimeFormat = IntlDateTimeFormat::create(vm, jsCast<IntlDateTimeFormatConstructor*>(exec->callee()));
+    VM& vm = state->vm();
+    IntlDateTimeFormat* dateTimeFormat = IntlDateTimeFormat::create(vm, jsCast<IntlDateTimeFormatConstructor*>(state->callee()));
     if (dateTimeFormat && !jsDynamicCast<IntlDateTimeFormatConstructor*>(newTarget)) {
         JSValue proto = asObject(newTarget)->getDirect(vm, vm.propertyNames->prototype);
-        asObject(dateTimeFormat)->setPrototypeWithCycleCheck(exec, proto);
+        asObject(dateTimeFormat)->setPrototypeWithCycleCheck(state, proto);
     }
 
     // 3. ReturnIfAbrupt(dateTimeFormat).
@@ -109,15 +109,15 @@ static EncodedJSValue JSC_HOST_CALL constructIntlDateTimeFormat(ExecState* exec)
     return JSValue::encode(dateTimeFormat);
 }
 
-static EncodedJSValue JSC_HOST_CALL callIntlDateTimeFormat(ExecState* exec)
+static EncodedJSValue JSC_HOST_CALL callIntlDateTimeFormat(ExecState* state)
 {
     // 12.1.2 Intl.DateTimeFormat ([locales [, options]]) (ECMA-402 2.0)
     // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
     // NewTarget is always undefined when called as a function.
 
     // 2. Let dateTimeFormat be OrdinaryCreateFromConstructor(newTarget, %DateTimeFormatPrototype%).
-    VM& vm = exec->vm();
-    IntlDateTimeFormat* dateTimeFormat = IntlDateTimeFormat::create(vm, jsCast<IntlDateTimeFormatConstructor*>(exec->callee()));
+    VM& vm = state->vm();
+    IntlDateTimeFormat* dateTimeFormat = IntlDateTimeFormat::create(vm, jsCast<IntlDateTimeFormatConstructor*>(state->callee()));
 
     // 3. ReturnIfAbrupt(dateTimeFormat).
     ASSERT(dateTimeFormat);
@@ -140,26 +140,26 @@ CallType IntlDateTimeFormatConstructor::getCallData(JSCell*, CallData& callData)
     return CallTypeHost;
 }
 
-bool IntlDateTimeFormatConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+bool IntlDateTimeFormatConstructor::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
 {
-    return getStaticFunctionSlot<InternalFunction>(exec, dateTimeFormatConstructorTable, jsCast<IntlDateTimeFormatConstructor*>(object), propertyName, slot);
+    return getStaticFunctionSlot<InternalFunction>(state, dateTimeFormatConstructorTable, jsCast<IntlDateTimeFormatConstructor*>(object), propertyName, slot);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatConstructorFuncSupportedLocalesOf(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatConstructorFuncSupportedLocalesOf(ExecState* state)
 {
     // 12.2.2 Intl.DateTimeFormat.supportedLocalesOf(locales [, options]) (ECMA-402 2.0)
 
     // 1. Let availableLocales be %DateTimeFormat%.[[availableLocales]].
-    JSGlobalObject* globalObject = exec->callee()->globalObject();
+    JSGlobalObject* globalObject = state->callee()->globalObject();
     const HashSet<String> availableLocales = globalObject->intlDateTimeFormatAvailableLocales();
 
     // 2. Let requestedLocales be CanonicalizeLocaleList(locales).
-    Vector<String> requestedLocales = canonicalizeLocaleList(exec, exec->argument(0));
-    if (exec->hadException())
+    Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
+    if (state->hadException())
         return JSValue::encode(jsUndefined());
 
     // 3. Return SupportedLocales(availableLocales, requestedLocales, options).
-    return JSValue::encode(supportedLocales(exec, availableLocales, requestedLocales, exec->argument(1)));
+    return JSValue::encode(supportedLocales(*state, availableLocales, requestedLocales, state->argument(1)));
 }
     
 void IntlDateTimeFormatConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor)
index 079b9295cdc3699bbe1a94839ded5a8e7bd59019..d5e525982480b1ed491e6b7b8fb12bb8af1aee7d 100644 (file)
@@ -81,31 +81,31 @@ void IntlDateTimeFormatPrototype::finishCreation(VM& vm, Structure*)
     Base::finishCreation(vm);
 }
 
-bool IntlDateTimeFormatPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+bool IntlDateTimeFormatPrototype::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
 {
-    return getStaticFunctionSlot<JSObject>(exec, dateTimeFormatPrototypeTable, jsCast<IntlDateTimeFormatPrototype*>(object), propertyName, slot);
+    return getStaticFunctionSlot<JSObject>(state, dateTimeFormatPrototypeTable, jsCast<IntlDateTimeFormatPrototype*>(object), propertyName, slot);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatPrototypeGetterFormat(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatPrototypeGetterFormat(ExecState* state)
 {
     // 12.3.3 Intl.DateTimeFormat.prototype.format (ECMA-402 2.0)
     // 1. Let dtf be this DateTimeFormat object.
-    IntlDateTimeFormat* dtf = jsDynamicCast<IntlDateTimeFormat*>(exec->thisValue());
+    IntlDateTimeFormat* dtf = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue());
     // 2. ReturnIfAbrupt(dtf).
     if (!dtf)
-        return JSValue::encode(throwTypeError(exec, ASCIILiteral("Intl.DateTimeFormat.prototype.format called on value that's not an object initialized as a DateTimeFormat")));
+        return JSValue::encode(throwTypeError(state, ASCIILiteral("Intl.DateTimeFormat.prototype.format called on value that's not an object initialized as a DateTimeFormat")));
     
     JSBoundFunction* boundFormat = dtf->boundFormat();
     // 3. If the [[boundFormat]] internal slot of this DateTimeFormat object is undefined,
     if (!boundFormat) {
-        VM& vm = exec->vm();
+        VM& vm = state->vm();
         JSGlobalObject* globalObject = dtf->globalObject();
         // a. Let F be a new built-in function object as defined in 12.3.4.
         // b. The value of F’s length property is 1. (Note: F’s length property was 0 in ECMA-402 1.0)
         JSFunction* targetObject = JSFunction::create(vm, globalObject, 1, ASCIILiteral("format"), IntlDateTimeFormatFuncFormatDateTime, NoIntrinsic);
         JSArray* boundArgs = JSArray::tryCreateUninitialized(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), 0);
         if (!boundArgs)
-            return JSValue::encode(throwOutOfMemoryError(exec));
+            return JSValue::encode(throwOutOfMemoryError(state));
         
         // c. Let bf be BoundFunctionCreate(F, «this value»).
         boundFormat = JSBoundFunction::create(vm, globalObject, targetObject, dtf, boundArgs, 1, ASCIILiteral("format"));
@@ -116,17 +116,17 @@ EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatPrototypeGetterFormat(ExecState*
     return JSValue::encode(boundFormat);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatPrototypeFuncResolvedOptions(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatPrototypeFuncResolvedOptions(ExecState* state)
 {
     // 12.3.5 Intl.DateTimeFormat.prototype.resolvedOptions() (ECMA-402 2.0)
-    IntlDateTimeFormat* dtf = jsDynamicCast<IntlDateTimeFormat*>(exec->thisValue());
+    IntlDateTimeFormat* dtf = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue());
     if (!dtf)
-        return JSValue::encode(throwTypeError(exec, ASCIILiteral("Intl.DateTimeFormat.prototype.resolvedOptions called on value that's not an object initialized as a DateTimeFormat")));
+        return JSValue::encode(throwTypeError(state, ASCIILiteral("Intl.DateTimeFormat.prototype.resolvedOptions called on value that's not an object initialized as a DateTimeFormat")));
 
     // The function returns a new object whose properties and attributes are set as if constructed by an object literal assigning to each of the following properties the value of the corresponding internal slot of this DateTimeFormat object (see 12.4): locale, calendar, numberingSystem, timeZone, hour12, weekday, era, year, month, day, hour, minute, second, and timeZoneName. Properties whose corresponding internal slots are not present are not assigned.
     // Note: In this version of the ECMAScript 2015 Internationalization API, the timeZone property will be the name of the default time zone if no timeZone property was provided in the options object provided to the Intl.DateTimeFormat constructor. The previous version left the timeZone property undefined in this case.
 
-    JSObject* options = constructEmptyObject(exec);
+    JSObject* options = constructEmptyObject(state);
 
     // FIXME: Populate object from internal slots.
 
index 139dc5b19ea48ecb4a4ae31790e309eb4ac76ab9..81a0978d1e30f3ccb3fc36dca70034b981d63757 100644 (file)
@@ -84,20 +84,20 @@ void IntlNumberFormat::setBoundFormat(VM& vm, JSBoundFunction* format)
     m_boundFormat.set(vm, this, format);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlNumberFormatFuncFormatNumber(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlNumberFormatFuncFormatNumber(ExecState* state)
 {
     // 11.3.4 Format Number Functions (ECMA-402 2.0)
     // 1. Let nf be the this value.
-    IntlNumberFormat* format = jsDynamicCast<IntlNumberFormat*>(exec->thisValue());
+    IntlNumberFormat* format = jsDynamicCast<IntlNumberFormat*>(state->thisValue());
     // 2. Assert: Type(nf) is Object and nf has an [[initializedNumberFormat]] internal slot whose value is true.
     if (!format)
-        return JSValue::encode(throwTypeError(exec));
+        return JSValue::encode(throwTypeError(state));
 
     // 3. If value is not provided, let value be undefined.
     // 4. Let x be ToNumber(value).
-    double value = exec->argument(0).toNumber(exec);
+    double value = state->argument(0).toNumber(state);
     // 5. ReturnIfAbrupt(x).
-    if (exec->hadException())
+    if (state->hadException())
         return JSValue::encode(jsUndefined());
 
     // 6. Return FormatNumber(nf, x).
@@ -105,7 +105,7 @@ EncodedJSValue JSC_HOST_CALL IntlNumberFormatFuncFormatNumber(ExecState* exec)
     // 11.3.4 FormatNumber abstract operation (ECMA-402 2.0)
     // FIXME: Implement FormatNumber.
 
-    return JSValue::encode(jsNumber(value).toString(exec));
+    return JSValue::encode(jsNumber(value).toString(state));
 }
 
 } // namespace JSC
index 04c50aac8d151824ca9eda036bc2ff7546cf2273..cfe65650b828a577cde2073fd11595c28e8b57ec 100644 (file)
@@ -84,20 +84,20 @@ void IntlNumberFormatConstructor::finishCreation(VM& vm, IntlNumberFormatPrototy
     m_numberFormatStructure.set(vm, this, numberFormatStructure);
 }
 
-static EncodedJSValue JSC_HOST_CALL constructIntlNumberFormat(ExecState* exec)
+static EncodedJSValue JSC_HOST_CALL constructIntlNumberFormat(ExecState* state)
 {
     // 11.1.2 Intl.NumberFormat ([locales [, options]]) (ECMA-402 2.0)
     // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
-    JSValue newTarget = exec->newTarget();
+    JSValue newTarget = state->newTarget();
     if (newTarget.isUndefined())
-        newTarget = exec->callee();
+        newTarget = state->callee();
 
     // 2. Let numberFormat be OrdinaryCreateFromConstructor(newTarget, %NumberFormatPrototype%).
-    VM& vm = exec->vm();
-    IntlNumberFormat* numberFormat = IntlNumberFormat::create(vm, jsCast<IntlNumberFormatConstructor*>(exec->callee()));
+    VM& vm = state->vm();
+    IntlNumberFormat* numberFormat = IntlNumberFormat::create(vm, jsCast<IntlNumberFormatConstructor*>(state->callee()));
     if (numberFormat && !jsDynamicCast<IntlNumberFormatConstructor*>(newTarget)) {
         JSValue proto = asObject(newTarget)->getDirect(vm, vm.propertyNames->prototype);
-        asObject(numberFormat)->setPrototypeWithCycleCheck(exec, proto);
+        asObject(numberFormat)->setPrototypeWithCycleCheck(state, proto);
     }
 
     // 3. ReturnIfAbrupt(numberFormat).
@@ -109,15 +109,15 @@ static EncodedJSValue JSC_HOST_CALL constructIntlNumberFormat(ExecState* exec)
     return JSValue::encode(numberFormat);
 }
 
-static EncodedJSValue JSC_HOST_CALL callIntlNumberFormat(ExecState* exec)
+static EncodedJSValue JSC_HOST_CALL callIntlNumberFormat(ExecState* state)
 {
     // 11.1.2 Intl.NumberFormat ([locales [, options]]) (ECMA-402 2.0)
     // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
     // NewTarget is always undefined when called as a function.
 
     // 2. Let numberFormat be OrdinaryCreateFromConstructor(newTarget, %NumberFormatPrototype%).
-    VM& vm = exec->vm();
-    IntlNumberFormat* numberFormat = IntlNumberFormat::create(vm, jsCast<IntlNumberFormatConstructor*>(exec->callee()));
+    VM& vm = state->vm();
+    IntlNumberFormat* numberFormat = IntlNumberFormat::create(vm, jsCast<IntlNumberFormatConstructor*>(state->callee()));
 
     // 3. ReturnIfAbrupt(numberFormat).
     ASSERT(numberFormat);
@@ -140,26 +140,26 @@ CallType IntlNumberFormatConstructor::getCallData(JSCell*, CallData& callData)
     return CallTypeHost;
 }
 
-bool IntlNumberFormatConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+bool IntlNumberFormatConstructor::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
 {
-    return getStaticFunctionSlot<InternalFunction>(exec, numberFormatConstructorTable, jsCast<IntlNumberFormatConstructor*>(object), propertyName, slot);
+    return getStaticFunctionSlot<InternalFunction>(state, numberFormatConstructorTable, jsCast<IntlNumberFormatConstructor*>(object), propertyName, slot);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlNumberFormatConstructorFuncSupportedLocalesOf(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlNumberFormatConstructorFuncSupportedLocalesOf(ExecState* state)
 {
     // 11.2.2 Intl.NumberFormat.supportedLocalesOf(locales [, options]) (ECMA-402 2.0)
 
     // 1. Let availableLocales be %NumberFormat%.[[availableLocales]].
-    JSGlobalObject* globalObject = exec->callee()->globalObject();
+    JSGlobalObject* globalObject = state->callee()->globalObject();
     const HashSet<String> availableLocales = globalObject->intlNumberFormatAvailableLocales();
 
     // 2. Let requestedLocales be CanonicalizeLocaleList(locales).
-    Vector<String> requestedLocales = canonicalizeLocaleList(exec, exec->argument(0));
-    if (exec->hadException())
+    Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
+    if (state->hadException())
         return JSValue::encode(jsUndefined());
 
     // 3. Return SupportedLocales(availableLocales, requestedLocales, options).
-    return JSValue::encode(supportedLocales(exec, availableLocales, requestedLocales, exec->argument(1)));
+    return JSValue::encode(supportedLocales(*state, availableLocales, requestedLocales, state->argument(1)));
 }
 
 void IntlNumberFormatConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor)
index 8a3492294ec3816b91bb1c004e239f9febbde4f9..fa8a0ea7274586988c62a7aa408f55d45ceacecf 100644 (file)
@@ -81,30 +81,30 @@ void IntlNumberFormatPrototype::finishCreation(VM& vm, Structure*)
     Base::finishCreation(vm);
 }
 
-bool IntlNumberFormatPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+bool IntlNumberFormatPrototype::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
 {
-    return getStaticFunctionSlot<JSObject>(exec, numberFormatPrototypeTable, jsCast<IntlNumberFormatPrototype*>(object), propertyName, slot);
+    return getStaticFunctionSlot<JSObject>(state, numberFormatPrototypeTable, jsCast<IntlNumberFormatPrototype*>(object), propertyName, slot);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlNumberFormatPrototypeGetterFormat(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlNumberFormatPrototypeGetterFormat(ExecState* state)
 {
     // 11.3.3 Intl.NumberFormat.prototype.format (ECMA-402 2.0)
     // 1. Let nf be this NumberFormat object.
-    IntlNumberFormat* nf = jsDynamicCast<IntlNumberFormat*>(exec->thisValue());
+    IntlNumberFormat* nf = jsDynamicCast<IntlNumberFormat*>(state->thisValue());
     if (!nf)
-        return JSValue::encode(throwTypeError(exec, ASCIILiteral("Intl.NumberFormat.prototype.format called on value that's not an object initialized as a NumberFormat")));
+        return JSValue::encode(throwTypeError(state, ASCIILiteral("Intl.NumberFormat.prototype.format called on value that's not an object initialized as a NumberFormat")));
     
     JSBoundFunction* boundFormat = nf->boundFormat();
     // 2. If nf.[[boundFormat]] is undefined,
     if (!boundFormat) {
-        VM& vm = exec->vm();
+        VM& vm = state->vm();
         JSGlobalObject* globalObject = nf->globalObject();
         // a. Let F be a new built-in function object as defined in 11.3.4.
         // b. The value of F’s length property is 1.
         JSFunction* targetObject = JSFunction::create(vm, globalObject, 1, ASCIILiteral("format"), IntlNumberFormatFuncFormatNumber, NoIntrinsic);
         JSArray* boundArgs = JSArray::tryCreateUninitialized(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), 0);
         if (!boundArgs)
-            return JSValue::encode(throwOutOfMemoryError(exec));
+            return JSValue::encode(throwOutOfMemoryError(state));
 
         // c. Let bf be BoundFunctionCreate(F, «this value»).
         boundFormat = JSBoundFunction::create(vm, globalObject, targetObject, nf, boundArgs, 1, ASCIILiteral("format"));
@@ -115,16 +115,16 @@ EncodedJSValue JSC_HOST_CALL IntlNumberFormatPrototypeGetterFormat(ExecState* ex
     return JSValue::encode(boundFormat);
 }
 
-EncodedJSValue JSC_HOST_CALL IntlNumberFormatPrototypeFuncResolvedOptions(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL IntlNumberFormatPrototypeFuncResolvedOptions(ExecState* state)
 {
     // 11.3.5 Intl.NumberFormat.prototype.resolvedOptions() (ECMA-402 2.0)
-    IntlNumberFormat* nf = jsDynamicCast<IntlNumberFormat*>(exec->thisValue());
+    IntlNumberFormat* nf = jsDynamicCast<IntlNumberFormat*>(state->thisValue());
     if (!nf)
-        return JSValue::encode(throwTypeError(exec, ASCIILiteral("Intl.NumberFormat.prototype.resolvedOptions called on value that's not an object initialized as a NumberFormat")));
+        return JSValue::encode(throwTypeError(state, ASCIILiteral("Intl.NumberFormat.prototype.resolvedOptions called on value that's not an object initialized as a NumberFormat")));
 
     // The function returns a new object whose properties and attributes are set as if constructed by an object literal assigning to each of the following properties the value of the corresponding internal slot of this NumberFormat object (see 11.4): locale, numberingSystem, style, currency, currencyDisplay, minimumIntegerDigits, minimumFractionDigits, maximumFractionDigits, minimumSignificantDigits, maximumSignificantDigits, and useGrouping. Properties whose corresponding internal slots are not present are not assigned.
 
-    JSObject* options = constructEmptyObject(exec);
+    JSObject* options = constructEmptyObject(state);
 
     // FIXME: Populate object from internal slots.
 
index 3ec2297b0c9687f339b86daad271cb05eb68e581..38f053154ca4e8f27edec2fe57c18f8239aeb933 100644 (file)
@@ -119,23 +119,23 @@ static String defaultLocale()
     return ASCIILiteral("en");
 }
 
-bool getIntlBooleanOption(ExecState* exec, JSValue options, PropertyName property, bool& usesFallback)
+bool intlBooleanOption(ExecState& state, JSValue options, PropertyName property, bool& usesFallback)
 {
     // 9.2.9 GetOption (options, property, type, values, fallback)
     // For type="boolean". values is always undefined.
 
     // 1. Let opts be ToObject(options).
-    JSObject* opts = options.toObject(exec);
+    JSObject* opts = options.toObject(&state);
 
     // 2. ReturnIfAbrupt(opts).
-    if (exec->hadException())
+    if (state.hadException())
         return false;
 
     // 3. Let value be Get(opts, property).
-    JSValue value = opts->get(exec, property);
+    JSValue value = opts->get(&state, property);
 
     // 4. ReturnIfAbrupt(value).
-    if (exec->hadException())
+    if (state.hadException())
         return false;
 
     // 5. If value is not undefined, then
@@ -145,7 +145,7 @@ bool getIntlBooleanOption(ExecState* exec, JSValue options, PropertyName propert
 
         // b. If type is "boolean", then
         // i. Let value be ToBoolean(value).
-        bool booleanValue = value.toBoolean(exec);
+        bool booleanValue = value.toBoolean(&state);
 
         // e. Return value.
         usesFallback = false;
@@ -158,23 +158,23 @@ bool getIntlBooleanOption(ExecState* exec, JSValue options, PropertyName propert
     return false;
 }
 
-String getIntlStringOption(ExecState* exec, JSValue options, PropertyName property, const HashSet<String>& values, const char* notFound, String fallback)
+String intlStringOption(ExecState& state, JSValue options, PropertyName property, const HashSet<String>& values, const char* notFound, String fallback)
 {
     // 9.2.9 GetOption (options, property, type, values, fallback)
     // For type="string".
 
     // 1. Let opts be ToObject(options).
-    JSObject* opts = options.toObject(exec);
+    JSObject* opts = options.toObject(&state);
 
     // 2. ReturnIfAbrupt(opts).
-    if (exec->hadException())
+    if (state.hadException())
         return String();
 
     // 3. Let value be Get(opts, property).
-    JSValue value = opts->get(exec, property);
+    JSValue value = opts->get(&state, property);
 
     // 4. ReturnIfAbrupt(value).
-    if (exec->hadException())
+    if (state.hadException())
         return String();
 
     // 5. If value is not undefined, then
@@ -184,28 +184,28 @@ String getIntlStringOption(ExecState* exec, JSValue options, PropertyName proper
 
         // c. If type is "string", then
         // i. Let value be ToString(value).
-        JSString* stringValue = value.toString(exec);
+        JSString* stringValue = value.toString(&state);
 
         // ii. ReturnIfAbrupt(value).
-        if (exec->hadException())
+        if (state.hadException())
             return String();
 
         // d. If values is not undefined, then
         // i. If values does not contain an element equal to value, throw a RangeError exception.
-        if (!values.isEmpty() && !values.contains(stringValue->value(exec))) {
-            exec->vm().throwException(exec, createRangeError(exec, String(notFound)));
+        if (!values.isEmpty() && !values.contains(stringValue->value(&state))) {
+            state.vm().throwException(&state, createRangeError(&state, String(notFound)));
             return String();
         }
 
         // e. Return value.
-        return stringValue->value(exec);
+        return stringValue->value(&state);
     }
 
     // 6. Else return fallback.
     return fallback;
 }
 
-static String getPrivateUseLangTag(const Vector<String>& parts, size_t startIndex)
+static String privateUseLangTag(const Vector<String>& parts, size_t startIndex)
 {
     size_t numParts = parts.size();
     size_t currentIndex = startIndex;
@@ -252,7 +252,7 @@ static String getPrivateUseLangTag(const Vector<String>& parts, size_t startInde
     return privateuse.toString();
 }
 
-static String getCanonicalLangTag(const Vector<String>& parts)
+static String canonicalLangTag(const Vector<String>& parts)
 {
     ASSERT(!parts.isEmpty());
 
@@ -401,7 +401,7 @@ static String getCanonicalLangTag(const Vector<String>& parts)
 
     // Check for privateuse.
     if (currentIndex < numParts) {
-        String privateuse = getPrivateUseLangTag(parts, currentIndex);
+        String privateuse = privateUseLangTag(parts, currentIndex);
         if (privateuse.isNull())
             return String();
         canonical.append('-');
@@ -413,7 +413,7 @@ static String getCanonicalLangTag(const Vector<String>& parts)
     return canonical.toString();
 }
 
-static String getGrandfatheredLangTag(const String& locale)
+static String grandfatheredLangTag(const String& locale)
 {
     // grandfathered = irregular / regular
     // FIXME: convert to a compile time hash table if this is causing performance issues.
@@ -459,7 +459,7 @@ static String canonicalizeLanguageTag(const String& locale)
     // https://www.rfc-editor.org/rfc/bcp/bcp47.txt
 
     // Language-Tag = langtag / privateuse / grandfathered
-    String grandfather = getGrandfatheredLangTag(locale);
+    String grandfather = grandfatheredLangTag(locale);
     if (!grandfather.isNull())
         return grandfather;
 
@@ -468,11 +468,11 @@ static String canonicalizeLanguageTag(const String& locale)
     Vector<String> parts;
     locale.split('-', true, parts);
     if (!parts.isEmpty()) {
-        String langtag = getCanonicalLangTag(parts);
+        String langtag = canonicalLangTag(parts);
         if (!langtag.isNull())
             return langtag;
 
-        String privateuse = getPrivateUseLangTag(parts, 0);
+        String privateuse = privateUseLangTag(parts, 0);
         if (!privateuse.isNull())
             return privateuse;
     }
@@ -480,11 +480,11 @@ static String canonicalizeLanguageTag(const String& locale)
     return String();
 }
 
-Vector<String> canonicalizeLocaleList(ExecState* exec, JSValue locales)
+Vector<String> canonicalizeLocaleList(ExecState& state, JSValue locales)
 {
     // 9.2.1 CanonicalizeLocaleList (locales)
-    VM& vm = exec->vm();
-    JSGlobalObject* globalObject = exec->callee()->globalObject();
+    VM& vm = state.vm();
+    JSGlobalObject* globalObject = state.callee()->globalObject();
     Vector<String> seen;
 
     // 1. If locales is undefined, then a. Return a new empty List.
@@ -504,20 +504,20 @@ Vector<String> canonicalizeLocaleList(ExecState* exec, JSValue locales)
         localesObject = localesArray;
     } else {
         // 4. Let O be ToObject(aLocales).
-        localesObject = locales.toObject(exec);
+        localesObject = locales.toObject(&state);
     }
 
     // 5. ReturnIfAbrupt(O).
-    if (exec->hadException())
+    if (state.hadException())
         return Vector<String>();
 
     // 6. Let len be ToLength(Get(O, "length")).
-    JSValue lengthProperty = localesObject->get(exec, vm.propertyNames->length);
-    if (exec->hadException())
+    JSValue lengthProperty = localesObject->get(&state, vm.propertyNames->length);
+    if (state.hadException())
         return Vector<String>();
 
-    double length = lengthProperty.toLength(exec);
-    if (exec->hadException())
+    double length = lengthProperty.toLength(&state);
+    if (state.hadException())
         return Vector<String>();
 
     // Keep track of locales that have been added to the list.
@@ -530,39 +530,39 @@ Vector<String> canonicalizeLocaleList(ExecState* exec, JSValue locales)
         // Not needed because hasProperty and get take an int for numeric key.
 
         // b. Let kPresent be HasProperty(O, Pk).
-        bool kPresent = localesObject->hasProperty(exec, k);
+        bool kPresent = localesObject->hasProperty(&state, k);
 
         // c. ReturnIfAbrupt(kPresent).
-        if (exec->hadException())
+        if (state.hadException())
             return Vector<String>();
 
         // d. If kPresent is true, then
         if (kPresent) {
             // i. Let kValue be Get(O, Pk).
-            JSValue kValue = localesObject->get(exec, k);
+            JSValue kValue = localesObject->get(&state, k);
 
             // ii. ReturnIfAbrupt(kValue).
-            if (exec->hadException())
+            if (state.hadException())
                 return Vector<String>();
 
             // iii. If Type(kValue) is not String or Object, throw a TypeError exception.
             if (!kValue.isString() && !kValue.isObject()) {
-                throwTypeError(exec, ASCIILiteral("locale value must be a string or object"));
+                throwTypeError(&state, ASCIILiteral("locale value must be a string or object"));
                 return Vector<String>();
             }
 
             // iv. Let tag be ToString(kValue).
-            JSString* tag = kValue.toString(exec);
+            JSString* tag = kValue.toString(&state);
 
             // v. ReturnIfAbrupt(tag).
-            if (exec->hadException())
+            if (state.hadException())
                 return Vector<String>();
 
             // vi. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
             // vii. Let canonicalizedTag be CanonicalizeLanguageTag(tag).
-            String canonicalizedTag = canonicalizeLanguageTag(tag->value(exec));
+            String canonicalizedTag = canonicalizeLanguageTag(tag->value(&state));
             if (canonicalizedTag.isNull()) {
-                exec->vm().throwException(exec, createRangeError(exec, String::format("invalid language tag: %s", tag->value(exec).utf8().data())));
+                state.vm().throwException(&state, createRangeError(&state, String::format("invalid language tag: %s", tag->value(&state).utf8().data())));
                 return Vector<String>();
             }
 
@@ -801,7 +801,7 @@ HashMap<String, String> resolveLocale(const HashSet<String>& availableLocales, c
     return result;
 }
 
-static JSArray* lookupSupportedLocales(ExecState* exec, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)
+static JSArray* lookupSupportedLocales(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)
 {
     // 9.2.6 LookupSupportedLocales (availableLocales, requestedLocales)
 
@@ -812,11 +812,11 @@ static JSArray* lookupSupportedLocales(ExecState* exec, const HashSet<String>& a
     size_t len = requestedLocales.size();
 
     // 3. Let subset be an empty List.
-    VM& vm = exec->vm();
-    JSGlobalObject* globalObject = exec->callee()->globalObject();
+    VM& vm = state.vm();
+    JSGlobalObject* globalObject = state.callee()->globalObject();
     JSArray* subset = JSArray::tryCreateUninitialized(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), 0);
     if (!subset) {
-        throwOutOfMemoryError(exec);
+        throwOutOfMemoryError(&state);
         return nullptr;
     }
 
@@ -836,7 +836,7 @@ static JSArray* lookupSupportedLocales(ExecState* exec, const HashSet<String>& a
 
         // f. If availableLocale is not undefined, then append locale to the end of subset.
         if (!availableLocale.isNull())
-            subset->push(exec, jsString(exec, locale));
+            subset->push(&state, jsString(&state, locale));
 
         // g. Increment k by 1.
     }
@@ -845,26 +845,26 @@ static JSArray* lookupSupportedLocales(ExecState* exec, const HashSet<String>& a
     return subset;
 }
 
-static JSArray* bestFitSupportedLocales(ExecState* exec, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)
+static JSArray* bestFitSupportedLocales(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)
 {
     // 9.2.7 BestFitSupportedLocales (availableLocales, requestedLocales)
     // FIXME: Implement something better than lookup.
-    return lookupSupportedLocales(exec, availableLocales, requestedLocales);
+    return lookupSupportedLocales(state, availableLocales, requestedLocales);
 }
 
-JSValue supportedLocales(ExecState* exec, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, JSValue options)
+JSValue supportedLocales(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, JSValue options)
 {
     // 9.2.8 SupportedLocales (availableLocales, requestedLocales, options)
-    VM& vm = exec->vm();
+    VM& vm = state.vm();
     String matcher;
 
     // 1. If options is not undefined, then
     if (!options.isUndefined()) {
         // a. Let matcher be GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
         const HashSet<String> matchers({ ASCIILiteral("lookup"), ASCIILiteral("best fit") });
-        matcher = getIntlStringOption(exec, options, vm.propertyNames->localeMatcher, matchers, "localeMatcher must be either \"lookup\" or \"best fit\"", ASCIILiteral("best fit"));
+        matcher = intlStringOption(state, options, vm.propertyNames->localeMatcher, matchers, "localeMatcher must be either \"lookup\" or \"best fit\"", ASCIILiteral("best fit"));
         // b. ReturnIfAbrupt(matcher).
-        if (exec->hadException())
+        if (state.hadException())
             return jsUndefined();
     } else {
         // 2. Else, let matcher be "best fit".
@@ -876,23 +876,23 @@ JSValue supportedLocales(ExecState* exec, const HashSet<String>& availableLocale
     if (matcher == "best fit") {
         // a. Let MatcherOperation be the abstract operation BestFitSupportedLocales.
         // 5. Let supportedLocales be MatcherOperation(availableLocales, requestedLocales).
-        supportedLocales = bestFitSupportedLocales(exec, availableLocales, requestedLocales);
+        supportedLocales = bestFitSupportedLocales(state, availableLocales, requestedLocales);
     } else {
         // 4. Else
         // a. Let MatcherOperation be the abstract operation LookupSupportedLocales.
         // 5. Let supportedLocales be MatcherOperation(availableLocales, requestedLocales).
-        supportedLocales = lookupSupportedLocales(exec, availableLocales, requestedLocales);
+        supportedLocales = lookupSupportedLocales(state, availableLocales, requestedLocales);
     }
 
-    if (exec->hadException())
+    if (state.hadException())
         return jsUndefined();
 
     // 6. Let subset be CreateArrayFromList(supportedLocales).
     // Already an array.
 
     // 7. Let keys be subset.[[OwnPropertyKeys]]().
-    PropertyNameArray keys(exec, PropertyNameMode::Strings);
-    supportedLocales->getOwnPropertyNames(supportedLocales, exec, keys, EnumerationMode());
+    PropertyNameArray keys(&state, PropertyNameMode::Strings);
+    supportedLocales->getOwnPropertyNames(supportedLocales, &state, keys, EnumerationMode());
 
     PropertyDescriptor desc;
     desc.setConfigurable(false);
@@ -905,10 +905,10 @@ JSValue supportedLocales(ExecState* exec, const HashSet<String>& availableLocale
         // Created above for reuse.
 
         // b. Let status be DefinePropertyOrThrow(subset, P, desc).
-        supportedLocales->defineOwnProperty(supportedLocales, exec, keys[i], desc, true);
+        supportedLocales->defineOwnProperty(supportedLocales, &state, keys[i], desc, true);
 
         // c. Assert: status is not abrupt completion.
-        if (exec->hadException())
+        if (state.hadException())
             return jsUndefined();
     }
 
index fa2a6350eaa54859c9174d7d5ca0cb4a9eb0675a..e5975bf0beb849f52e90de74ee9dcaf9fbbc56c5 100644 (file)
@@ -57,11 +57,11 @@ private:
     IntlObject(VM&, Structure*);
 };
 
-bool getIntlBooleanOption(ExecState*, JSValue options, PropertyName, bool& usesFallback);
-String getIntlStringOption(ExecState*, JSValue options, PropertyName, const HashSet<String>& values, const char* notFound, String fallback);
-Vector<String> canonicalizeLocaleList(ExecState*, JSValue locales);
+bool intlBooleanOption(ExecState&, JSValue options, PropertyName, bool& usesFallback);
+String intlStringOption(ExecState&, JSValue options, PropertyName, const HashSet<String>& values, const char* notFound, String fallback);
+Vector<String> canonicalizeLocaleList(ExecState&, JSValue locales);
 HashMap<String, String> resolveLocale(const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, const HashMap<String, String>& options, const Vector<String>& relevantExtensionKeys, Vector<String> (*localeData)(const String&, const String&));
-JSValue supportedLocales(ExecState*, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, JSValue options);
+JSValue supportedLocales(ExecState&, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, JSValue options);
 
 } // namespace JSC