summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.h
AgeCommit message (Collapse)Author
2022-08-29LibJS: Hide all the constructors!Andreas Kling
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-28LibJS: Let NewGlobalEnvironment take a plain ObjectLinus Groh
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-23LibJS: Replace GlobalObject with VM in Environment AOs [Part 5/19]Linus Groh
2021-12-29LibJS: Convert create_global_function_binding() to ThrowCompletionOrLinus Groh
2021-12-29LibJS: Convert create_global_var_binding() to ThrowCompletionOrLinus Groh
2021-12-29LibJS: Convert can_declare_global_function() to ThrowCompletionOrLinus Groh
2021-12-29LibJS: Convert can_declare_global_var() to ThrowCompletionOrLinus Groh
2021-12-29LibJS: Convert has_restricted_global_property() to ThrowCompletionOrLinus Groh
2021-10-09LibJS: Convert delete_binding() to ThrowCompletionOrLinus Groh
Also add spec step comments to it while we're here.
2021-10-09LibJS: Convert get_binding_value() to ThrowCompletionOrLinus Groh
Also add spec step comments to it while we're here.
2021-10-09LibJS: Convert set_mutable_binding() to ThrowCompletionOrLinus Groh
Also add spec step comments to it while we're here.
2021-10-09LibJS: Convert initialize_binding() to ThrowCompletionOrLinus Groh
Also add spec step comments to it while we're here.
2021-10-09LibJS: Convert create_immutable_binding() to ThrowCompletionOrLinus Groh
Also add spec step comments to it while we're here.
2021-10-09LibJS: Convert create_mutable_binding() to ThrowCompletionOrLinus Groh
Also add spec step comments to it while we're here.
2021-10-09LibJS: Convert has_binding() to ThrowCompletionOrLinus Groh
Also add spec step comments to it while we're here.
2021-10-09LibJS: Convert get_this_binding() to ThrowCompletionOrLinus Groh
Also add spec step comments to it while we're here.
2021-10-07LibJS: Make Environment::has_binding() optionally return binding indexAndreas Kling
If the caller wants to use the binding index for anything, if there is such a thing, it can now be obtained via an optional out-parameter.
2021-09-30LibJS: Make scoping follow the specdavidot
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-12LibJS: Add [[GlobalThisValue]] internal slot to GlobalEnvironmentLinus Groh
Instead of hardcoding the environment's global object as the return value of GlobalEnvironment::global_this_value(), it now stores an Object reference which is passed to the constructor for this purpose. From the spec (https://tc39.es/ecma262/#sec-global-environment-records): [[GlobalThisValue]] | Object | The value returned by this in global scope. Hosts may provide any ECMAScript Object value.
2021-07-02LibJS: Make Environment::put_into_environment() return a success boolAndreas Kling
This code is non-conforming and will eventually get cleaned out once we implement proper variable bindings. However, this will aid us in improving other parts of the code right now.
2021-07-01LibJS: Drop "Record" suffix from all the *Environment record classesAndreas Kling
"Records" in the spec are basically C++ classes, so let's drop this mouthful of a suffix.