Commit Graph

33158 Commits

Author SHA1 Message Date
davidot
91b3e5b31f LibJS: Implement the ImportMeta MetaProperty
This "standard" implementation of this is to do nothing.
2022-01-22 01:21:18 +00:00
davidot
7cbf4b90e8 LibJS: Implement ImportCall and HostImportModuleDynamically
This allows us to load modules from scripts.
This can be dangerous as it can load arbitrary files. Because of that it
fails and throws by default. Currently, only js and JavaScriptTestRunner
enable the default hook.

This also adds tests to test-js which test module code. Because we
form a spec perspective can't "enter" a module this is the easiest way
to run tests without having to modify test-js to have special cases for
modules.
To specify modules in test-js we use the extension '.mjs' this is to
ensure the files are not executed. We do still want to lint these files
so the prettier scripts have changed to look for '.mjs' files as well.
2022-01-22 01:21:18 +00:00
davidot
023968a489 LibJS: Implement evaluation of im- and exports statements 2022-01-22 01:21:18 +00:00
davidot
779e677467 LibJS: Implement HostResolveImportedModule for LibJS
This loads modules with relative paths from the referencing module.
In this commit the only way to run a module is via the interpreter
which can link and evaluate a module (and all its dependencies).
2022-01-22 01:21:18 +00:00
davidot
1b8ccf9a66 LibJS: Implement Module linking and evaluating 2022-01-22 01:21:18 +00:00
davidot
be9d478d92 LibJS: Add host layering point related to modules to VM
Also make HostResolveImportedModule fail on the browser to prevent
module loading for now.
2022-01-22 01:21:18 +00:00
davidot
0b89dbc529 Meta: Add JS_MODULE_DEBUG define flag 2022-01-22 01:21:18 +00:00
davidot
55366703d0 LibJS: Add Module Namespace Exotic Object 2022-01-22 01:21:18 +00:00
davidot
0cdbc03de0 LibJS: Add ModuleEnvironment 2022-01-22 01:21:18 +00:00
davidot
12c2f30c54 LibJS: Add filename tracking to Script and Module
This will allow us to resolve modules dynamically loaded from a script.
2022-01-22 01:21:18 +00:00
davidot
57c5a59cab LibJS: Add ScriptOrModule to execution context and track it everywhere 2022-01-22 01:21:18 +00:00
davidot
99edf5b25a LibJS: Track whether a program has a top level await statement 2022-01-22 01:21:18 +00:00
davidot
aca427fc8c LibJS: Make parsing import and export entries follow the spec
The big changes are:
- Allow strings as Module{Export, Import}Name
- Properly track declarations in default export statements

However, the spec is a little strange in that it allows function and
class declarations without a name in default export statements.
This is quite hard to fully implement without rewriting more of the
parser so for now this behavior is emulated by faking things with
function and class expressions. See the comments in
parse_export_statement for details on the hacks and where it goes wrong.
2022-01-22 01:21:18 +00:00
Luke Wilde
631bbcd00a LibJS: Refactor interpreter to use Script and Source Text Modules
This also refactors interpreter creation to follow
InitializeHostDefinedRealm, but I couldn't fit it in the title :^)

This allows us to follow the spec much more closely rather than being
completely ad-hoc with just the parse node instead of having all the
surrounding data such as the realm of the parse node.

The interpreter creation refactor creates the global execution context
once and doesn't take it off the stack. This allows LibWeb to take the
global execution context and manually handle it, following the HTML
spec. The HTML spec calls this the "realm execution context" of the
environment settings object.

It also allows us to specify the globalThis type, as it can be
different from the global object type. For example, on the web, Window
global objects use a WindowProxy global this value to enforce the same
origin policy on operations like [[GetOwnProperty]].

Finally, it allows us to directly call Program::execute in perform_eval
and perform_shadow_realm_eval as this moves
global_declaration_instantiation into Interpreter::run
(ScriptEvaluation) as per the spec.

Note that this doesn't evalulate Source Text Modules yet or refactor
the bytecode interpreter, that's work for future us :^)

This patch was originally build by Luke for the environment settings
object change but was also needed for modules. So I (davidot) have
modified it with the new completion changes and setup for that.

Co-authored-by: davidot <davidot@serenityos.org>
2022-01-22 01:21:18 +00:00
davidot
232a8432b7 LibJS: Move binding_class_declaration_evaluation out of ClassDeclaration 2022-01-22 01:21:18 +00:00
davidot
39b134e8c1 LibJS: Move async_block_start out of ECMAScriptFunctionObject 2022-01-22 01:21:18 +00:00
Ali Mohammad Pur
cd83325c7c LibRegex: Preserve capture groups and matches across ForkReplace
This makes the (flawed) ForkStay inserted as a loop header unnecessary,
and finally fixes LibRegex rewriting weird loops in weird ways.
2022-01-22 00:35:49 +00:00
Ali Mohammad Pur
bc20e4f71d LibRegex: Add some more information to Compare::Reference debug output 2022-01-22 00:35:49 +00:00
Ali Mohammad Pur
97dde09170 LibRegex: Allow ClearCaptureGroup to create new groups
Instead of leaking all capture groups and selectively clearing some,
simply avoid leaking things and only "define" the ones that need to
exist.
This *actually* implements the capture groups ECMA262 quirk.
Also adds the test removed in the previous commit (to avoid messing up
test runs across bisects).
2022-01-22 00:35:49 +00:00
Ali Mohammad Pur
704e0654b3 Revert "LibRegex: Implement an ECMA262 Regex quirk with negative loo..."
This partially reverts commit c11be92e23.
That commit fixes one thing and breaks many more, a next commit will
implement this quirk in a more sane way.
2022-01-22 00:35:49 +00:00
Maciej
e0d3a8f6ce LibGfx: Fix stylistic issues in BitmapFont
* Apply some clang-tidy suggestions
* Convert to east-const
2022-01-22 00:26:23 +00:00
Maciej
b6d6cc5de4 LibGUI: Use Font::glyph_or_emoji_width() in TextEditor
This fixes selection of text containing emoji when variable-width font
is set.
2022-01-22 00:26:23 +00:00
Maciej
8542d1da5a LibGfx: Always scale emojis to fit font height 2022-01-22 00:26:23 +00:00
kleines Filmröllchen
7a92842017 LibCore: Populate the read buffer of Core::Stream::BufferedHelper
Previously, we weren't ever populating the read buffer in read(), which
was making the BufferedHelper useless, how silly :^). This introduces
a buffer refill when we have run out of buffered samples, restoring
FlacLoader performance from the new low of 200% (directly before this
commit) to the old level of ~1400%.
2022-01-22 01:13:42 +03:30
kleines Filmröllchen
8a92573732 LibAudio: Convert FlacLoader to use new Core::Stream APIs :^)
For this change to work "easily", Loader can't take const ByteBuffer's
anymore, which is fine for now.
2022-01-22 01:13:42 +03:30
kleines Filmröllchen
4f48a086b7 LibAudio: Add LOADER_TRY to auto-convert Error to LoaderError 2022-01-22 01:13:42 +03:30
kleines Filmröllchen
9702f2010f LibAudio: Add Error conversion constructor for LoaderError
This will become necessary shortly when we quickly want to promote an
AK::Error to an Audio::LoaderError.
2022-01-22 01:13:42 +03:30
kleines Filmröllchen
d786142eca LibCore: Introduce MemoryStream
MemoryStream is the Core::Stream API's streamlike access to a chunk of
memory, mimicking AK::DuplexMemoryStream. The implementation is very
similar, except that no APIs except the SeekableStream operations
currently exist. This will be fine for the first users and can be
expanded upon later.
2022-01-22 01:13:42 +03:30
kleines Filmröllchen
caeb8fc691 LibCore: Introduce BigEndianInputBitStream
BigEndianInputBitStream is the Core::Stream API's bitwise input stream
for big endian input data. The functionality and bitwise read API is
almost unchanged from AK::BitStream, except that this bit stream only
supports big endian operations.

As the behavior for mixing big endian and little endian reads on
AK::BitStream is unknown (and untested), it was never done anyways. So
this was a good opportunity to split up big endian and little endian
reading.

Another API improvement from AK::BitStream is the ability to specify
the return type of the bit read function. Always needing to static_cast
the result of BitStream::read_bits_big_endian into the desired type is
adding a lot of avoidable noise to the users (primarily FlacLoader).
2022-01-22 01:13:42 +03:30
Dylan Katz
3919a1dcc0 Browser: Load icons at start of program
Previously, Browser loaded icons from the disk every time an icon
was set. In addition to making more calls to the disk and decoding
more images, this makes error propagation impossible. This change
moves all icon loading to the start of the program.
2022-01-21 22:14:13 +01:00
Dylan Katz
a2a93727db LibGUI: Allow Button::set_icon to accept a bitmap without a move
Previously, Button::set_icon required moving the bitmap into the
button, preventing the same bitmap from being used by multiple
buttons at once. While this works for buttons that are created once,
any button that is dynamically added would require the same bitmap to
be loaded every single time. In addition to being ineffecient, this
also makes error checking more difficult.

With this change, a bitmap can be loaded once, and passed to multiple
buttons.
2022-01-21 22:14:13 +01:00
Jean-Baptiste Boric
12a6ec9292 LibCore: Parse classless symbolic notation 2022-01-21 22:10:23 +01:00
Jean-Baptiste Boric
736af8c7da groups: Do not attempt to open /etc/groups 2022-01-21 22:10:23 +01:00
Jean-Baptiste Boric
7fe7eab308 pwd: Add missing rpath pledge 2022-01-21 22:10:23 +01:00
Timur Sultanov
f3139b100c keymaps: Fix keymap for Russian ЙЦУКЕН keyboard
- Swap captial "Ё" and lowercase "ё"
- Replace "|" with "/" to match the standard ЙЦУКЕН keyboard
2022-01-21 22:07:55 +01:00
Jelle Raaijmakers
f7de7501d4 Ports: Set config.sub path for SDL2_mixer
This path needs to be set, or otherwise SDL2_mixer will not build.
2022-01-21 22:07:25 +01:00
Fragstiller
07faa6f670 Ports: Remove redundant ensure_new_config_sub call 2022-01-22 00:31:57 +03:30
Fragstiller
673e81b90b Ports: Relocate use_fresh_config_sub check to do_configure() 2022-01-22 00:31:57 +03:30
Timothy Flynn
9cd93944b8 LibJS: Change test conditions to pass in all time zones
Mostly slapping "timeZone: UTC" on DateTimeFormat tests (we have other
tests for specific time zones). Also pick dates that are not on DST
boundaries in some time zones where that matters.
2022-01-21 19:14:38 +00:00
Kenneth Myhra
1fb8408aa2 LibCore: Do not leak FILE pointer in Group::add_group()
By using a ScopeGuard we make sure that we always close the FILE, also
on early returns.
2022-01-21 18:34:24 +01:00
Kenneth Myhra
6df3fdd83f LibCore: Use generic AK_OS_BSD_GENERIC to hide Group::add_group()
This hides the method Group::add_group() on both MacOS and OpenBSD since
the function putgrent(), which is essential for add_group() to work, is
not available on these OSes.
2022-01-21 18:34:24 +01:00
Liav A
d67c70d043 Kernel: Ensure that CommandLine is initialized before choosing PanicMode
If the kernel commandline is not initialized, just halt everything.
2022-01-21 19:34:10 +02:00
Idan Horowitz
0adee378fd Kernel: Stop using LibKeyboard's CharacterMap in HIDManagement
This was easily done, as the Kernel and Userland don't actually share
any of the APIs exposed by it, so instead the Kernel APIs were moved to
the Kernel, and the Userland APIs stayed in LibKeyboard.

This has multiple advantages:
 * The non OOM-fallible String is not longer used for storing the
   character map name in the Kernel
 * The kernel no longer has to link to the userland LibKeyboard code
 * A lot of #ifdef KERNEL cruft can be removed from LibKeyboard
2022-01-21 18:25:44 +01:00
Liav A
cecfd42916 Kernel/PCI: Verify Access is not initialized before initializing it
There's no valid case where we should try to initialize the Access
singleton multiple times, therefore just assert if it ever happens.
2022-01-21 19:09:16 +02:00
Ali Mohammad Pur
78d1093dab Shell: Make Juxtaposition autocompletion smarter
Now something like `"$HOME"/` autocompletes correctly.
Note that only the first element of lists is used to autocomplete
things.
2022-01-21 18:58:28 +03:30
Ali Mohammad Pur
2e333b3571 Shell: Make SimpleVariable::hit_test_position not hit irrelevant offsets
Without this, any offset would be accepted as being part of the
SimpleVariable.
Fixes #11976 (by making it no longer crash).
2022-01-21 18:58:28 +03:30
Idan Horowitz
3c1ca61e74 Kernel: Use KString instead of String in InodeWatcher::Event's path 2022-01-21 16:27:21 +01:00
Idan Horowitz
d5189b6677 Kernel: Replace {String => KString}::formatted in ACPISysFSDirectory 2022-01-21 16:27:21 +01:00
Idan Horowitz
77a81f5eed Kernel: Use KString instead of String in Ext2FSInode's lookup cache 2022-01-21 16:27:21 +01:00
Idan Horowitz
7356110033 AK: Support setting with non copyable keys in HashMap 2022-01-21 16:27:21 +01:00