summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/AST.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-08-27 00:54:55 +0100
committerLinus Groh <mail@linusgroh.de>2022-08-27 11:29:10 +0100
commit50428ea8d21045bbc3c5584a16496cff4a38fdc5 (patch)
treef56dee290ed47d0d796d51cdcb41e02c22ae40a6 /Userland/Libraries/LibJS/AST.cpp
parent84c4b66721c893775938e40808486e1ce506732e (diff)
downloadserenity-50428ea8d21045bbc3c5584a16496cff4a38fdc5.zip
LibJS: Move intrinsics to the realm
Intrinsics, i.e. mostly constructor and prototype objects, but also things like empty and new object shape now live on a new heap-allocated JS::Intrinsics object, thus completing the long journey of taking all the magic away from the global object. This represents the Realm's [[Intrinsics]] slot in the spec and matches its existing [[GlobalObject]] / [[GlobalEnv]] slots in terms of architecture. In the majority of cases it should now be possibly to fully allocate a regular object without the global object existing, and in fact that's what we do now - the realm is allocated before the global object, and the intrinsics between both :^)
Diffstat (limited to 'Userland/Libraries/LibJS/AST.cpp')
-rw-r--r--Userland/Libraries/LibJS/AST.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp
index ee6e5f07ae..734eea302a 100644
--- a/Userland/Libraries/LibJS/AST.cpp
+++ b/Userland/Libraries/LibJS/AST.cpp
@@ -442,7 +442,7 @@ Completion CallExpression::execute(Interpreter& interpreter) const
auto& function = callee.as_function();
- if (&function == realm.global_object().eval_function()
+ if (&function == realm.intrinsics().eval_function()
&& callee_reference.is_environment_reference()
&& callee_reference.name().is_string()
&& callee_reference.name().as_string() == vm.names.eval.as_string()) {
@@ -1829,9 +1829,8 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
class_private_environment->add_private_name({}, opt_private_name.release_value());
}
- auto* proto_parent = vm.current_realm()->global_object().object_prototype();
-
- auto* constructor_parent = vm.current_realm()->global_object().function_prototype();
+ auto* proto_parent = realm.intrinsics().object_prototype();
+ auto* constructor_parent = realm.intrinsics().function_prototype();
if (!m_super_class.is_null()) {
vm.running_execution_context().lexical_environment = class_environment;
@@ -3036,7 +3035,7 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
auto& realm = *vm.current_realm();
// 1. Let obj be OrdinaryObjectCreate(%Object.prototype%).
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
// 2. Perform ? PropertyDefinitionEvaluation of PropertyDefinitionList with argument obj.
for (auto& property : m_properties) {
@@ -3347,7 +3346,7 @@ Completion ImportCall::execute(Interpreter& interpreter) const
// Note: options_value is undefined by default.
// 6. Let promiseCapability be ! NewPromiseCapability(%Promise%).
- auto promise_capability = MUST(new_promise_capability(vm, realm.global_object().promise_constructor()));
+ auto promise_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
// 7. Let specifierString be Completion(ToString(specifier)).
// 8. IfAbruptRejectPromise(specifierString, promiseCapability).