Commit graph

14 commits

Author SHA1 Message Date
Linus Groh
f9705eb2f4 LibJS: Replace GlobalObject with VM in Intl AOs [Part 1/19]
Instead of passing a GlobalObject everywhere, we will simply pass a VM,
from which we can get everything we need: common names, the current
realm, symbols, arguments, the heap, and a few other things.

In some places we already don't actually need a global object and just
do it for consistency - no more `auto& vm = global_object.vm();`!

This will eventually automatically fix the "wrong realm" issue we have
in some places where we (incorrectly) use the global object from the
allocating object, e.g. in call() / construct() implementations. When
only ever a VM is passed around, this issue can't happen :^)

I've decided to split this change into a series of patches that should
keep each commit down do a somewhat manageable size.
2022-08-23 13:58:30 +01:00
Linus Groh
f3117d46dc LibJS: Remove GlobalObject from VM::throw_completion()
This is a continuation of the previous five commits.

A first big step into the direction of no longer having to pass a realm
(or currently, a global object) trough layers upon layers of AOs!
Unlike the create() APIs we can safely assume that this is only ever
called when a running execution context and therefore current realm
exists. If not, you can always manually allocate the Error and put it in
a Completion :^)

In the spec, throw exceptions implicitly use the current realm's
intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
2022-08-23 13:58:30 +01:00
Timothy Flynn
417a385db1 LibJS: Allow out-of-order plural ranges to be formatted
This is a normative change to the Intl NumberFormat V3 spec:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/0c3d849
2022-07-26 10:46:08 -07:00
Timothy Flynn
292b8908b5 LibJS: Hook the Intl mathematical value into Intl.NumberFormat 2022-07-20 18:21:24 +01:00
Timothy Flynn
f089c11b5b LibJS: Implement Intl.PluralRules.prototype.selectRange 2022-07-12 00:43:34 +01:00
Timothy Flynn
6d9b779757 LibJS: Add an overload of ResolvePlural for use without PluralRules
The NumberFormat spec casually indicates the need for a PluralRules
object without explicity saying so, with text such as:

"which may depend on x in languages having different plural forms."

Other implementations actually do create a PluralRules object to resolve
those cases with ResolvePlural. However, ResolvePlural doesn't need much
from PluralRules to operate, so this can be abstracted out for use in
NumberFormat without the need to allocate a PluralRules instance.
2022-07-08 20:33:52 +02:00
Timothy Flynn
cc5c707649 LibJS+LibUnicode: Do not generate the PluralCategory enum
The PluralCategory enum is currently generated for plural rules. Instead
of generating it, this moves the enum to the public LibUnicode header.
While it was nice to auto-discover these values, they are well defined
by TR-35, and we will need their values from within the number format
code generator (which can't rely on the plural rules generator having
run yet). Further, number format will require additional values in the
enum that plural rules doesn't know about.
2022-07-08 20:33:52 +02:00
Timothy Flynn
36abcd820d LibJS: Implement Intl.PluralRules.prototype.select 2022-07-08 11:51:54 +02:00
Timothy Flynn
670bd066a5 LibJS: Replace JS::Intl::PluralRules::Type with Unicode::PluralForm
The JS::Intl enum was added when implementing the PluralRules
constructor. Now that LibUnicode has a plural rules implementation,
replace the JS::Intl enum with the analagous Unicode enum.
2022-07-08 11:51:54 +02:00
Timothy Flynn
8941d0b49e LibJS: Reorganize spec steps for Intl.PluralRules
This is an editorial change in the Intl spec:
https://github.com/tc39/ecma402/commit/d7c7157
2022-03-15 17:30:58 +01:00
Timothy Flynn
812d3a7ef8 LibJS: Reorganize spec steps for Intl.NumberFormat
This is an editorial change in the Intl spec:
https://github.com/tc39/ecma402/commit/110cb1f
2022-03-15 17:30:58 +01:00
Timothy Flynn
6efbafa6e0 Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2022-01-31 18:23:22 +00:00
Timothy Flynn
348059bffd LibJS: Implement the Intl.PluralRules constructor 2022-01-28 19:38:47 +00:00
Timothy Flynn
0087804d10 LibJS: Implement a nearly empty Intl.PluralRules object
This adds plumbing for the Intl.PluralRules object, constructor, and
prototype.
2022-01-28 19:38:47 +00:00