static EncodedJSValue JSC_HOST_CALL constructIntlCollator(ExecState* state) { VM& vm = state->vm(); auto scope = DECLARE_THROW_SCOPE(vm); // 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. // 2. Let collator be OrdinaryCreateFromConstructor(newTarget, %CollatorPrototype%). // 3. ReturnIfAbrupt(collator). Structure* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), jsCast<IntlCollatorConstructor*>(state->jsCallee())->collatorStructure(vm)); RETURN_IF_EXCEPTION(scope, encodedJSValue()); IntlCollator* collator = IntlCollator::create(vm, structure); ASSERT(collator); // 4. Return InitializeCollator(collator, locales, options). scope.release(); collator->initializeCollator(*state, state->argument(0), state->argument(1)); return JSValue::encode(collator); }
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. VM& vm = state->vm(); IntlCollatorConstructor* callee = jsCast<IntlCollatorConstructor*>(state->jsCallee()); // FIXME: Collator does not get the workaround for ECMA-402 1.0 compatibility. // https://bugs.webkit.org/show_bug.cgi?id=153679 // 2. Let collator be OrdinaryCreateFromConstructor(newTarget, %CollatorPrototype%). // 3. ReturnIfAbrupt(collator). IntlCollator* collator = IntlCollator::create(vm, callee->collatorStructure(vm)); ASSERT(collator); // 4. Return InitializeCollator(collator, locales, options). collator->initializeCollator(*state, state->argument(0), state->argument(1)); return JSValue::encode(collator); }