davidot
03c468fb7d
LibJS: Parse date strings like "9/17/2022"
2022-09-17 18:53:14 +02:00
Ben Wiederhake
4cd382c621
LibJS: Break another inclusion cycle by removing unnecessary include
2022-09-17 04:00:54 +00:00
Ben Wiederhake
6a4e2efa65
LibJS: Break inclusion cycle by removing unnecessary include
2022-09-17 04:00:54 +00:00
Tim Schumacher
388dc9cc5f
LibJS: Supress an unused bind when wrapping float atomic operations
2022-09-16 05:39:28 +00:00
Timothy Flynn
85e313077a
LibJS: Do not invoke Cell::vm in constructors before Cell is constructed
...
In a subclass of Cell, we cannot use Cell::vm() before the base Cell
object itself is constructed. Use the Realm's VM instead.
This was caught by UBSAN with vptr sanitation enabled.
2022-09-15 09:45:13 +02:00
Timothy Flynn
3efe611dbf
LibJS: Do not assume that IsArray means the object type is an Array
...
IsArray returns true if the object is an Array *or* if it is a
ProxyObject whose target is an Array. Therefore, we cannot downcast to
an Array based on IsArray.
Luckily, we don't actually need an Array here; SerializeJSONArray only
needs an Object.
This was caught by UBSAN with vptr sanitation enabled.
2022-09-15 09:45:13 +02:00
Timothy Flynn
98a6f962a0
LibJS: Use correct include + object class for Function{Object,Prototype}
...
Not causing any real issue, just noticed while debugging vptr sanitation
errors.
2022-09-15 09:45:13 +02:00
davidot
d4736d17ae
LibJS: Allow negative pointers in Value
...
Also ensure that all a nullptr input gives null object and you don't
accidentally dereference a nullptr.
2022-09-10 00:05:32 +01:00
Andreas Kling
7b0dd98103
LibJS+LibWeb: Spin event loop via VM::CustomData abstraction
...
Instead of calling Core::EventLoop directly, LibJS now has a virtual
function on VM::CustomData for customizing this behavior.
We use this in LibWeb to plumb the spin request through to the
PlatformEventPlugin.
2022-09-08 00:13:39 +02:00
Andreas Kling
00c8f07192
LibJS: Make Script and Module GC-allocated
...
This ensures that code currently in any active or saved execution stack
always stays alive.
2022-09-06 00:27:09 +02:00
Andreas Kling
abfb73f2e7
LibWeb+LibJS: Let JS::Realm::HostDefined objects mark things during GC
...
This allows us to mark the HTML::Window from our window environment
settings object.
2022-09-06 00:27:09 +02:00
Timothy Flynn
43a3471298
LibLocale: Move locale source files to the LibLocale folder
...
These are still included in LibUnicode, but this updates their location
and the include paths of other files which include them.
2022-09-05 14:37:16 -04:00
Timothy Flynn
ff48220dca
Userland: Move files destined for LibLocale to the Locale namespace
2022-09-05 14:37:16 -04:00
Timothy Flynn
6c7b05a0ff
LibUnicode+LibJS: Move Unicode::get_available_currencies() to Locale.h
...
This is generated by GenerateLocaleData, which will soon be in the
Locale namespace. Move it out of CurrencyCode.h, as that will continue
to live in the Unicode namespace.
2022-09-05 14:37:16 -04:00
Timothy Flynn
85994d6115
LibJS: Remove unused include from JS::Temporal::Calendar
2022-09-05 14:37:16 -04:00
Andreas Kling
7fce5f102f
LibJS: Don't use a Handle<Realm> in FinalizationRegistry
...
Instead just treat it like a normal GC cell edge.
2022-09-03 00:36:26 +02:00
Linus Groh
486775f9fe
LibJS: Fix incorrect check in ValidateAndApplyPropertyDescriptor
...
This is an editorial change in the ECMA-262 spec.
See: f0e4ae8
2022-09-02 22:47:28 +01:00
Linus Groh
455537d31d
LibJS: Assert Proxy target is a function in [[Call]] and [[Construct]]
...
As the TODOs suggested for a long time. :^)
2022-09-02 22:44:44 +01:00
davidot
0fc67ffd62
LibJS: Make indirect bindings of module behave like normal bindings
...
Before this we attempted to hack around this by only overriding
has_binding. However this did not cover all cases, for example when
assigning to variables before their declaration it didn't throw.
By using the new find_binding_and_index virtual method we can just
pretend the indirect bindings are real.
Since indirect binding do come from a normal environment we need to
ensure you cannot modify the binding and that properties like mutable
are false as expected by the spec for such an indirect binding.
2022-09-02 02:07:37 +01:00
davidot
2484bbc4e0
LibJS: Make DeclarativeEnvironment based on bindings instead of indices
...
This will allow other environments which extend DeclarativeEnvironment
to provide their own custom bindings.
2022-09-02 02:07:37 +01:00
davidot
3b56043612
LibJS: Put exports before symbols in keys of module namespace object
2022-09-02 02:07:37 +01:00
davidot
fb61e9274a
LibJS: Call resolve instead of reject in AsyncFromSyncIteratorPrototype
2022-09-02 02:07:37 +01:00
Timothy Flynn
c477425b9b
LibJS: Create DurationFormat's ListFormat object with type and style
...
This is a normative change in the Intl.DurationFormat spec. See:
1304e4b
2022-08-30 14:26:11 -04:00
Timothy Flynn
127b28c940
LibJS: Use numeric style if the previous style was numeric or 2-digit
...
This is a normative change in the Intl.DurationFormat proposal. See:
3a46ee3
2022-08-30 14:26:11 -04:00
Timothy Flynn
cab1cce522
LibJS: Update DurationFormat AO text to align with ECMA-402 and Temporal
...
These are editorial changes in the Intl.DurationFormat proposal. See:
71b291b
d0cc6fa
d4b35bb
2022-08-30 14:26:11 -04:00
Timothy Flynn
a86b840c64
LibJS: Rename DurationFormat's DurationSign to DurationRecordSign
...
This is an editorial change in the Intl.DurationFormat proposal. See:
f947239
2022-08-30 14:26:11 -04:00
Timothy Flynn
f8c51fec1d
LibJS: Align ToDurationRecord with ToTemporalDurationRecord
...
This is an editorial change in the Intl.DurationFormat proposal. See:
527ea58
2022-08-30 14:26:11 -04:00
Timothy Flynn
a28ff92106
LibJS: Mark PartitionDurationFormatPattern as infallible
...
This is an editorial change in the Intl.DurationFormat proposal. See:
cea3b68
2022-08-30 14:26:11 -04:00
Timothy Flynn
aabd06722f
LibJS: Change GetDurationUnitOptions to require a string for prevStyle
...
This is an editoral change in the Intl.DurationFormat proposal. See:
62ee645
2022-08-30 14:26:11 -04:00
Timothy Flynn
1778462d97
LibJS: Resolve FIXMEs in DurationFormat's PartitionDurationFormatPattern
...
These are normative changes in the Intl.DurationFormat proposal. See:
e2e18d1
f1e8ed3
2ed31b8
2d51d64
64cc5db
a1d7876
47a3a69
3e9358e
f4ecb46
b454c8c
2022-08-30 14:26:11 -04:00
Timothy Flynn
d57b92da09
LibJS: Default to "short" for DurationFormat's style option
...
This is a normative change in the Intl.DurationFormat proposal. See:
b289494
2022-08-30 14:26:11 -04:00
Timothy Flynn
765d016670
LibJS: Default to 0 for DurationFormat's fractionalDigits option
...
This is a normative change in the Intl.DurationFormat proposal. See:
ac7e184
2022-08-30 14:26:11 -04:00
Timothy Flynn
2fb332da7b
LibJS: Update spec steps to validate DurationFormat's numberingSystem
...
This is a normative change in the Intl.DurationFormat proposal. See:
63a9202
2022-08-30 14:26:11 -04:00
Linus Groh
69415f0608
LibJS: Make string_to_bigint() a standalone function
...
This now matches the newly added string_to_number().
2022-08-30 10:30:54 +01:00
Linus Groh
15e3a99250
LibJS: Trim non-ASCII whitespace as well in StringToBigInt
...
This was never caught since the original implementation AFAICT, and
isn't being covered by test262 either:
https://github.com/tc39/test262/issues/1354
2022-08-30 10:30:43 +01:00
Linus Groh
c88c33dc22
LibJS: Trim non-ASCII whitespace as well in StringToNumber
...
This regressed in f4b3bb5
.
2022-08-30 10:20:45 +01:00
Slappy826
f4b3bb519f
LibJS: Handle non-decimal integer literals in Value::to_number
...
Implements support for parsing binary and octal literals, and fixes
instances where a hex literal is parsed in ways the spec doesn't
allow.
2022-08-30 01:00:48 +01:00
Andreas Kling
35c9aa7c05
LibJS: Hide all the constructors!
...
Now that the GC allocator is able to invoke Cell subclass constructors
directly via friendship, we no longer need to keep them public. :^)
2022-08-29 03:24:54 +02:00
Andreas Kling
49fd92d92a
LibJS: Make JS_OBJECT and JS_ENVIRONMENT forward to JS_CELL
2022-08-29 03:24:54 +02:00
Andreas Kling
6e973ce69b
LibJS: Add JS_CELL macro and use it in all JS::Cell subclasses
...
This is similar to what we already had with JS_OBJECT (and also
JS_ENVIRONMENT) but sits at the top of the Cell inheritance hierarchy.
2022-08-29 03:24:54 +02:00
Linus Groh
d53a369e7f
LibJS: Implement ShadowRealmConstructor::construct() closer to spec
...
Defer creation of the global object to Realm::set_global_object(), and
use the newly added set_default_global_bindings() AO as intended.
2022-08-28 19:34:10 +01:00
Linus Groh
040e3abb1d
LibJS: Implement SetDefaultGlobalBindings as a standalone function
...
Instead of hardcoding all the property definitions in GlobalObject's
initialize() function, make it the standalone AO it is supposed to be
that can then be used by other global objects that don't inherit from
JS::GlobalObject.
2022-08-28 19:34:10 +01:00
Linus Groh
e3804e6426
LibJS: Move construction of GlobalObject native functions to Intrinsics
...
This will later allow global objects not inheriting from the regular
JS::GlobalObject to pull in these functions without having to implement
them from scratch. The primary use case here is, again, a wrapper-less
HTML::Window in LibWeb :^)
Allocating these upfront now allows us to get rid of two hacks:
- The GlobalObject assigning Intrinsics private members after finishing
its initialization
- The GlobalObject defining the parseInt and parseFloat properties of
the NumberConstructor object, as they are supposed to be identical
with the global functions of the same name
2022-08-28 19:34:10 +01:00
Linus Groh
52543fc771
LibJS+LibWeb: Let Realm store a plain Object for [[GlobalObject]]
...
This removes the requirement of having a global object that actually
inherits from JS::GlobalObject, which is now a perfectly valid scenario.
With the upcoming removal of wrapper objects in LibWeb, the HTML::Window
object will inherit from DOM::EventTarget, which means it cannot also
inherit from JS::GlobalObject.
2022-08-28 16:36:56 +01:00
Linus Groh
72730422bb
LibJS: Remove Shape::global_object() and Object::global_object()
...
Same reason as in commit 275dea9
.
2022-08-28 16:36:56 +01:00
Linus Groh
4f436bd323
LibJS: Let NewGlobalEnvironment take a plain Object
...
The object is passed directly to NewObjectEnvironment, which has no
requirement for this being a JS::GlobalObject. This is needed for the
next change, which will make Realm store a plain Object as for the
global object as well.
2022-08-28 16:36:56 +01:00
Linus Groh
cfa5885855
LibJS: Turn initialize_global_object() into a regular initialize()
...
There's nothing special about global object initialization anymore, this
can just work the same way as for any other object now.
2022-08-28 16:36:56 +01:00
Linus Groh
867ad03995
LibJS: Move Console ownership from GlobalObject to ConsoleObject
...
GlobalObject is now a regular object with no special properties :^)
2022-08-28 16:36:56 +01:00
Linus Groh
78eca3ae64
LibJS: Move ConsoleObject construction from GlobalObject to Intrinsics
...
This will allow us to move the underlying console from GlobalObject to
ConsoleObject without still having to do a 'console' property lookup on
the GlobalObject.
2022-08-28 16:36:56 +01:00
Linus Groh
d35f53c344
LibJS: Remove Console's reliance on GlobalObject
...
This was not being used for anything meaningful, just store a reference
to the VM directly.
2022-08-28 16:36:56 +01:00