1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 03:18:11 +00:00
serenity/Userland/Libraries
davidot 830ea0414c LibJS: Make scoping follow the spec
Before this we used an ad-hoc combination of references and 'variables'
stored in a hashmap. This worked in most cases but is not spec like.
Additionally hoisting, dynamically naming functions and scope analysis
was not done properly.

This patch fixes all of that by:
  - Implement BindingInitialization for destructuring assignment.
  - Implementing a new ScopePusher which tracks the lexical and var
    scoped declarations. This hoists functions to the top level if no
    lexical declaration name overlaps. Furthermore we do checking of
    redeclarations in the ScopePusher now requiring less checks all over
    the place.
  - Add methods for parsing the directives and statement lists instead
    of having that code duplicated in multiple places. This allows
    declarations to pushed to the appropriate scope more easily.
  - Remove the non spec way of storing 'variables' in
    DeclarativeEnvironment and make Reference follow the spec instead of
    checking both the bindings and 'variables'.
  - Remove all scoping related things from the Interpreter. And instead
    use environments as specified by the spec. This also includes fixing
    that NativeFunctions did not produce a valid FunctionEnvironment
    which could cause issues with callbacks and eval. All
    FunctionObjects now have a valid NewFunctionEnvironment
    implementation.
  - Remove execute_statements from Interpreter and instead use
    ASTNode::execute everywhere this simplifies AST.cpp as you no longer
    need to worry about which method to call.
  - Make ScopeNodes setup their own environment. This uses four
    different methods specified by the spec
    {Block, Function, Eval, Global}DeclarationInstantiation with the
    annexB extensions.
  - Implement and use NamedEvaluation where specified.

Additionally there are fixes to things exposed by these changes to eval,
{for, for-in, for-of} loops and assignment.

Finally it also fixes some tests in test-js which where passing before
but not now that we have correct behavior :^).
2021-09-30 08:16:32 +01:00
..
LibArchive Everywhere: Use my cool new @serenityos.org email address 2021-09-01 11:37:25 +04:30
LibAudio Audio: Add per-client volume 2021-09-12 23:38:57 +02:00
LibC LibC+LibELF: Add definitions for extra dtags 2021-09-26 12:45:55 +02:00
LibCards LibGfx: Use "try_" prefix for static factory functions 2021-07-21 18:02:15 +02:00
LibChess LibChess: Fix hashing of the chess board 2021-07-30 20:49:18 +02:00
LibCompress LibCompress: Discard GZip NAME & COMMENT optional strings 2021-05-18 08:09:21 +02:00
LibConfig ConfigServer+LibConfig: Add way for clients to listen for config changes 2021-08-26 23:41:38 +02:00
LibCore LibCore: Buffer small byte reads 2021-09-27 16:31:28 +02:00
LibCoredump LibCoredump: Don't copy uncompressed coredumps into a ByteBuffer 2021-09-22 00:40:07 +02:00
LibCpp LibCpp: Remove redundant comparison to Token::Type::PipePipe 2021-09-28 10:58:09 +02:00
LibCrypt Everywhere: Use my cool new @serenityos.org email address 2021-09-01 11:37:25 +04:30
LibCrypto Libraries: Use AK::Variant default initialization where appropriate 2021-09-21 04:22:52 +04:30
LibDebug LibDebug: Add missing break in AddressRanges::for_each_range() 2021-09-28 18:05:42 +02:00
LibDesktop Userland: Use Core::Process::spawn() instead of posix_spawn() in places 2021-08-06 01:06:42 +02:00
LibDiff LibDiff: Coalesce adjacent changes into the same Hunk 2021-09-24 14:32:52 +02:00
LibDl Toolchain+Userland: Enable TLS for x86_64 2021-07-04 01:07:28 +02:00
LibDSP LibDSP: Remove unused Effects::Delay::m_old_delay_size member 2021-09-28 10:58:09 +02:00
LibELF LibELF: Indicate value of unimplemented dtag 2021-09-26 12:45:55 +02:00
LibFileSystemAccessClient LibFileSystemAccessClient: Convert request paths to absolute if needed 2021-09-10 20:46:50 +04:30
LibGemini LibTLS: Use a setter for on_tls_ready_to_write with some more smarts 2021-09-19 21:10:23 +04:30
LibGfx LibGfx: Forward declare Gfx::FontMetrics as a struct 2021-09-24 19:03:46 +02:00
LibGL Everywhere: Behaviour => Behavior 2021-09-07 13:53:14 +02:00
LibGUI LibGUI: Implement automatic scrolling in AbstractView 2021-09-29 23:58:55 +02:00
LibHTTP LibTLS: Use a setter for on_tls_ready_to_write with some more smarts 2021-09-19 21:10:23 +04:30
LibImageDecoderClient Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
LibIMAP LibIMAP: Remove unused Variant option 2021-09-21 04:22:52 +04:30
LibIPC LibIPC: Use default instead of an empty constructor/destructor 2021-09-16 17:17:13 +02:00
LibJS LibJS: Make scoping follow the spec 2021-09-30 08:16:32 +01:00
LibKeyboard AK: Make Utf8View constructors inline and remove C string constructor 2021-09-18 19:54:24 +02:00
LibLine Everywhere: Behaviour => Behavior 2021-09-07 13:53:14 +02:00
LibM AK: Introduce Math.h 2021-07-19 16:34:21 +04:30
LibMarkdown LibMarkdown: Re-add support for Serenity's style code blocks extension 2021-09-12 12:17:16 +02:00
LibPCIDB Everywhere: "file name" => "filename" 2021-04-29 22:16:18 +02:00
LibPDF LibPDF: Rely on default-constructor of Variant 2021-09-21 04:22:52 +04:30
LibProtocol RequestServer+LibProtocol: Add an 'EnsureConnection' IPC endpoint 2021-09-28 22:32:31 +02:00
LibPthread LibPthread: Correct nonsensical loop exit condition in RWLock unlock 2021-09-28 12:34:51 +03:30
LibRegex LibRegex: Flatten bytecode before performing optimizations 2021-09-29 18:45:26 +02:00
LibSanitizer LibSanitizer+AK: Add float cast overflow handler 2021-08-08 10:55:36 +02:00
LibSQL Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
LibSymbolication LibSymbolication+SystemMonitor: Show ELF object in stack 2021-09-30 00:51:08 +02:00
LibSyntax LibSyntax: Fix bug in matching cursor highlighting 2021-09-03 11:45:50 +02:00
LibSystem Kernel+LibSystem: Add a 4th syscall argument 2021-07-25 14:08:50 +02:00
LibTest LibJS + test-js: Get results from the global object directly 2021-09-30 08:16:32 +01:00
LibTextCodec LibTextCodec: Ignore BYTE ORDER MARK at the start of utf8/16 strings 2021-09-15 17:00:18 +02:00
LibThreading LibThreading: Use default instead of an empty constructor/destructor 2021-09-16 17:17:13 +02:00
LibTLS LibTLS: Mark the connection as finished and disconnected on TLS error 2021-09-28 22:32:31 +02:00
LibUnicode LibUnicode: Add some data related to currency codes 2021-09-11 11:05:50 +01:00
LibUSBDB LibUSBDB: Fix vendor id decoding 2021-06-18 19:41:25 +04:30
LibVideo Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
LibVT LibVT: Add movemouse support for triple click 2021-09-19 20:28:09 +04:30
LibWasm Libraries: Use AK::Variant default initialization where appropriate 2021-09-21 04:22:52 +04:30
LibWeb LibWeb: Fix null dereference when assigning an ImageStyleValue via JS 2021-09-30 02:18:30 +02:00
LibWebSocket LibTLS: Use a setter for on_tls_ready_to_write with some more smarts 2021-09-19 21:10:23 +04:30
LibX86 LibX86: Use default instead of an empty constructor/destructor 2021-09-16 17:17:13 +02:00
CMakeLists.txt Libraries: Add LibDSP 2021-08-31 17:03:55 +04:30