summaryrefslogtreecommitdiff
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
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 :^)
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp20
-rw-r--r--Tests/LibWasm/test-wasm.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/JSIntegration.cpp6
-rw-r--r--Userland/Libraries/LibJS/AST.cpp11
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Op.cpp4
-rw-r--r--Userland/Libraries/LibJS/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp4
-rw-r--r--Userland/Libraries/LibJS/CyclicModule.cpp4
-rw-r--r--Userland/Libraries/LibJS/Forward.h22
-rw-r--r--Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp12
-rw-r--r--Userland/Libraries/LibJS/Runtime/AbstractOperations.h4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AggregateError.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Array.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp10
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp10
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/BigIntObject.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/BooleanObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Completion.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/DataView.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Date.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/DateConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/DatePrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp18
-rw-r--r--Userland/Libraries/LibJS/Runtime/Error.cpp38
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp108
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp20
-rw-r--r--Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.cpp309
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.h145
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp22
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp10
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/Segmenter.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intrinsics.cpp368
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intrinsics.h163
-rw-r--r--Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/JSONObject.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/Map.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MapConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/MapIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MapPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MathObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/NativeFunction.cpp10
-rw-r--r--Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp13
-rw-r--r--Userland/Libraries/LibJS/Runtime/NumberObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.cpp12
-rw-r--r--Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp12
-rw-r--r--Userland/Libraries/LibJS/Runtime/Promise.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp12
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ProxyObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Realm.cpp14
-rw-r--r--Userland/Libraries/LibJS/Runtime/Realm.h13
-rw-r--r--Userland/Libraries/LibJS/Runtime/Reference.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/ReflectObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpObject.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp10
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Set.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/SetConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/SetIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SetPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/SymbolObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp24
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.cpp268
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakMap.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakRef.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSet.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp2
-rw-r--r--Userland/Libraries/LibJS/SyntheticModule.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/LocationPrototype.h2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/NavigatorPrototype.h2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModulePrototype.h2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h2
-rw-r--r--Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp2
-rw-r--r--Userland/Utilities/js.cpp11
217 files changed, 1301 insertions, 1035 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
index 6b3ff0fe32..f3470bafc5 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
@@ -1572,7 +1572,7 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va
auto dictionary_generator = scoped_generator.fork();
dictionary_generator.append(R"~~~(
- auto* dictionary_object@recursion_depth@ = JS::Object::create(realm, realm.global_object().object_prototype());
+ auto* dictionary_object@recursion_depth@ = JS::Object::create(realm, realm.intrinsics().object_prototype());
)~~~");
auto* current_dictionary = &interface.dictionaries.find(type.name)->value;
@@ -2933,7 +2933,7 @@ using namespace Web::WebGL;
namespace Web::Bindings {
@constructor_class@::@constructor_class@(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
@@ -3220,7 +3220,7 @@ namespace Web::Bindings {
// https://webidl.spec.whatwg.org/#es-DOMException-specialness
// Object.getPrototypeOf(DOMException.prototype) === Error.prototype
generator.append(R"~~~(
- : Object(*realm.global_object().error_prototype())
+ : Object(*realm.intrinsics().error_prototype())
)~~~");
} else if (!interface.parent_name.is_empty()) {
generator.append(R"~~~(
@@ -3228,7 +3228,7 @@ namespace Web::Bindings {
)~~~");
} else {
generator.append(R"~~~(
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
)~~~");
}
@@ -3324,15 +3324,15 @@ void @prototype_class@::initialize(JS::Realm& realm)
if (interface.indexed_property_getter.has_value()) {
auto iterator_generator = generator.fork();
iterator_generator.append(R"~~~(
- define_direct_property(*vm.well_known_symbol_iterator(), realm.global_object().array_prototype()->get_without_side_effects(vm.names.values), JS::Attribute::Configurable | JS::Attribute::Writable);
+ define_direct_property(*vm.well_known_symbol_iterator(), realm.intrinsics().array_prototype()->get_without_side_effects(vm.names.values), JS::Attribute::Configurable | JS::Attribute::Writable);
)~~~");
if (interface.value_iterator_type.has_value()) {
iterator_generator.append(R"~~~(
- define_direct_property(vm.names.entries, realm.global_object().array_prototype()->get_without_side_effects(vm.names.entries), default_attributes);
- define_direct_property(vm.names.keys, realm.global_object().array_prototype()->get_without_side_effects(vm.names.keys), default_attributes);
- define_direct_property(vm.names.values, realm.global_object().array_prototype()->get_without_side_effects(vm.names.values), default_attributes);
- define_direct_property(vm.names.forEach, realm.global_object().array_prototype()->get_without_side_effects(vm.names.forEach), default_attributes);
+ define_direct_property(vm.names.entries, realm.intrinsics().array_prototype()->get_without_side_effects(vm.names.entries), default_attributes);
+ define_direct_property(vm.names.keys, realm.intrinsics().array_prototype()->get_without_side_effects(vm.names.keys), default_attributes);
+ define_direct_property(vm.names.values, realm.intrinsics().array_prototype()->get_without_side_effects(vm.names.values), default_attributes);
+ define_direct_property(vm.names.forEach, realm.intrinsics().array_prototype()->get_without_side_effects(vm.names.forEach), default_attributes);
)~~~");
}
}
@@ -3789,7 +3789,7 @@ using namespace Web::WebGL;
namespace Web::Bindings {
@prototype_class@::@prototype_class@(JS::Realm& realm)
- : Object(*realm.global_object().iterator_prototype())
+ : Object(*realm.intrinsics().iterator_prototype())
{
}
diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp
index 936f01a406..5bb87724d8 100644
--- a/Tests/LibWasm/test-wasm.cpp
+++ b/Tests/LibWasm/test-wasm.cpp
@@ -50,7 +50,7 @@ public:
static JS::ThrowCompletionOr<WebAssemblyModule*> create(JS::Realm& realm, Wasm::Module module, HashMap<Wasm::Linker::Name, Wasm::ExternValue> const& imports)
{
auto& vm = realm.vm();
- auto* instance = realm.heap().allocate<WebAssemblyModule>(realm, *realm.global_object().object_prototype());
+ auto* instance = realm.heap().allocate<WebAssemblyModule>(realm, *realm.intrinsics().object_prototype());
instance->m_module = move(module);
Wasm::Linker linker(*instance->m_module);
linker.link(imports);
diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp
index cbc4369780..f5e2022fa0 100644
--- a/Userland/Applications/Spreadsheet/JSIntegration.cpp
+++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp
@@ -258,7 +258,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::parse_cell_name)
if (!position.has_value())
return JS::js_undefined();
- auto object = JS::Object::create(realm, realm.global_object().object_prototype());
+ auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
object->define_direct_property("column", JS::js_string(vm, sheet_object->m_sheet.column(position.value().column)), JS::default_attributes);
object->define_direct_property("row", JS::Value((unsigned)position.value().row), JS::default_attributes);
@@ -284,7 +284,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::current_cell_position)
auto position = current_cell->position();
- auto object = JS::Object::create(realm, realm.global_object().object_prototype());
+ auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
object->define_direct_property("column", JS::js_string(vm, sheet_object->m_sheet.column(position.column)), JS::default_attributes);
object->define_direct_property("row", JS::Value((unsigned)position.row), JS::default_attributes);
@@ -370,7 +370,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_column_bound)
}
WorkbookObject::WorkbookObject(JS::Realm& realm, Workbook& workbook)
- : JS::Object(*realm.global_object().object_prototype())
+ : JS::Object(*realm.intrinsics().object_prototype())
, m_workbook(workbook)
{
}
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).
diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp
index 0e08621fd6..6bd57635e0 100644
--- a/Userland/Libraries/LibJS/Bytecode/Op.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp
@@ -240,7 +240,7 @@ ThrowCompletionOr<void> NewObject::execute_impl(Bytecode::Interpreter& interpret
auto& vm = interpreter.vm();
auto& realm = *vm.current_realm();
- interpreter.accumulator() = Object::create(realm, realm.global_object().object_prototype());
+ interpreter.accumulator() = Object::create(realm, realm.intrinsics().object_prototype());
return {};
}
@@ -262,7 +262,7 @@ ThrowCompletionOr<void> CopyObjectExcludingProperties::execute_impl(Bytecode::In
auto* from_object = TRY(interpreter.reg(m_from_object).to_object(vm));
- auto* to_object = Object::create(realm, realm.global_object().object_prototype());
+ auto* to_object = Object::create(realm, realm.intrinsics().object_prototype());
HashTable<Value, ValueTraits> excluded_names;
for (size_t i = 0; i < m_excluded_names_count; ++i)
diff --git a/Userland/Libraries/LibJS/CMakeLists.txt b/Userland/Libraries/LibJS/CMakeLists.txt
index bb5d114535..19f0f28222 100644
--- a/Userland/Libraries/LibJS/CMakeLists.txt
+++ b/Userland/Libraries/LibJS/CMakeLists.txt
@@ -132,6 +132,7 @@ set(SOURCES
Runtime/Intl/SegmentIterator.cpp
Runtime/Intl/SegmentIteratorPrototype.cpp
Runtime/Intl/SegmentsPrototype.cpp
+ Runtime/Intrinsics.cpp
Runtime/IteratorOperations.cpp
Runtime/IteratorPrototype.cpp
Runtime/JSONObject.cpp
diff --git a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp
index 68b6a37398..c7fef16128 100644
--- a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp
+++ b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -11,7 +11,7 @@ namespace JS::Test262 {
IsHTMLDDA::IsHTMLDDA(Realm& realm)
// NativeFunction without prototype is currently not possible (only due to the lack of a ctor that supports it)
- : NativeFunction("IsHTMLDDA", *realm.global_object().function_prototype())
+ : NativeFunction("IsHTMLDDA", *realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/CyclicModule.cpp b/Userland/Libraries/LibJS/CyclicModule.cpp
index 0101873085..61a9e84de3 100644
--- a/Userland/Libraries/LibJS/CyclicModule.cpp
+++ b/Userland/Libraries/LibJS/CyclicModule.cpp
@@ -201,7 +201,7 @@ ThrowCompletionOr<Promise*> CyclicModule::evaluate(VM& vm)
// 6. Let capability be ! NewPromiseCapability(%Promise%).
// 7. Set module.[[TopLevelCapability]] to capability.
- m_top_level_capability = MUST(new_promise_capability(vm, realm.global_object().promise_constructor()));
+ m_top_level_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
// 8. Let result be Completion(InnerModuleEvaluation(module, stack, 0)).
auto result = inner_module_evaluation(vm, stack, 0);
@@ -442,7 +442,7 @@ void CyclicModule::execute_async_module(VM& vm)
VERIFY(m_has_top_level_await);
// 3. Let capability be ! NewPromiseCapability(%Promise%).
- auto capability = MUST(new_promise_capability(vm, realm.global_object().promise_constructor()));
+ auto capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
// 4. Let fulfilledClosure be a new Abstract Closure with no parameters that captures module and performs the following steps when called:
auto fulfilled_closure = [&](VM& vm) -> ThrowCompletionOr<Value> {
diff --git a/Userland/Libraries/LibJS/Forward.h b/Userland/Libraries/LibJS/Forward.h
index 740a978e38..d0e9ff5309 100644
--- a/Userland/Libraries/LibJS/Forward.h
+++ b/Userland/Libraries/LibJS/Forward.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -92,6 +93,14 @@
__JS_ENUMERATE(TimeZone, time_zone, TimeZonePrototype, TimeZoneConstructor) \
__JS_ENUMERATE(ZonedDateTime, zoned_date_time, ZonedDateTimePrototype, ZonedDateTimeConstructor)
+#define JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS \
+ __JS_ENUMERATE(AtomicsObject, atomics) \
+ __JS_ENUMERATE(Intl::Intl, intl) \
+ __JS_ENUMERATE(JSONObject, json) \
+ __JS_ENUMERATE(MathObject, math) \
+ __JS_ENUMERATE(ReflectObject, reflect) \
+ __JS_ENUMERATE(Temporal::Temporal, temporal)
+
#define JS_ENUMERATE_ITERATOR_PROTOTYPES \
__JS_ENUMERATE(Iterator, iterator) \
__JS_ENUMERATE(ArrayIterator, array_iterator) \
@@ -161,6 +170,7 @@ class HandleImpl;
class Heap;
class HeapBlock;
class Interpreter;
+class Intrinsics;
class Module;
class NativeFunction;
class ObjectEnvironment;
@@ -205,6 +215,11 @@ class GeneratorPrototype;
class TypedArrayConstructor;
class TypedArrayPrototype;
+class AtomicsObject;
+class JSONObject;
+class MathObject;
+class ReflectObject;
+
// Tag type used to differentiate between u8 as used by Uint8Array and u8 as used by Uint8ClampedArray.
struct ClampedU8;
@@ -217,6 +232,11 @@ JS_ENUMERATE_NATIVE_ERRORS
JS_ENUMERATE_TYPED_ARRAYS
#undef __JS_ENUMERATE
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ class ClassName; \
+ JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS
+#undef __JS_ENUMERATE
+
namespace Intl {
#define __JS_ENUMERATE(ClassName, snake_name, ConstructorName, PrototypeName) \
class ClassName; \
@@ -225,6 +245,7 @@ namespace Intl {
JS_ENUMERATE_INTL_OBJECTS
#undef __JS_ENUMERATE
+class Intl;
class MathematicalValue;
// Not included in JS_ENUMERATE_INTL_OBJECTS due to missing distinct constructor
@@ -239,6 +260,7 @@ namespace Temporal {
class PrototypeName;
JS_ENUMERATE_TEMPORAL_OBJECTS
#undef __JS_ENUMERATE
+class Temporal;
struct DurationRecord;
struct DateDurationRecord;
struct TimeDurationRecord;
diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
index 96f72f372d..60bbeb9921 100644
--- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
@@ -362,7 +362,7 @@ bool validate_and_apply_property_descriptor(Object* object, PropertyKey const& p
}
// 10.1.14 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ), https://tc39.es/ecma262/#sec-getprototypefromconstructor
-ThrowCompletionOr<Object*> get_prototype_from_constructor(VM& vm, FunctionObject const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)())
+ThrowCompletionOr<Object*> get_prototype_from_constructor(VM& vm, FunctionObject const& constructor, Object* (Intrinsics::*intrinsic_default_prototype)())
{
// 1. Assert: intrinsicDefaultProto is this specification's name of an intrinsic object. The corresponding object must be an intrinsic that is intended to be used as the [[Prototype]] value of an object.
@@ -375,7 +375,7 @@ ThrowCompletionOr<Object*> get_prototype_from_constructor(VM& vm, FunctionObject
auto* realm = TRY(get_function_realm(vm, constructor));
// b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
- prototype = (realm->global_object().*intrinsic_default_prototype)();
+ prototype = (realm->intrinsics().*intrinsic_default_prototype)();
}
// 4. Return proto.
@@ -1029,7 +1029,7 @@ Object* create_unmapped_arguments_object(VM& vm, Span<Value> arguments)
// 2. Let obj be OrdinaryObjectCreate(%Object.prototype%, « [[ParameterMap]] »).
// 3. Set obj.[[ParameterMap]] to undefined.
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
object->set_has_parameter_map();
// 4. Perform ! DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(len), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
@@ -1048,11 +1048,11 @@ Object* create_unmapped_arguments_object(VM& vm, Span<Value> arguments)
}
// 7. Perform ! DefinePropertyOrThrow(obj, @@iterator, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
- auto* array_prototype_values = realm.global_object().array_prototype_values_function();
+ auto* array_prototype_values = realm.intrinsics().array_prototype_values_function();
MUST(object->define_property_or_throw(*vm.well_known_symbol_iterator(), { .value = array_prototype_values, .writable = true, .enumerable = false, .configurable = true }));
// 8. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Get]]: %ThrowTypeError%, [[Set]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]: false }).
- auto* throw_type_error = realm.global_object().throw_type_error_function();
+ auto* throw_type_error = realm.intrinsics().throw_type_error_function();
MUST(object->define_property_or_throw(vm.names.callee, { .get = throw_type_error, .set = throw_type_error, .enumerable = false, .configurable = false }));
// 9. Return obj.
@@ -1131,7 +1131,7 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Vector<
}
// 20. Perform ! DefinePropertyOrThrow(obj, @@iterator, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
- auto* array_prototype_values = realm.global_object().array_prototype_values_function();
+ auto* array_prototype_values = realm.intrinsics().array_prototype_values_function();
MUST(object->define_property_or_throw(*vm.well_known_symbol_iterator(), { .value = array_prototype_values, .writable = true, .enumerable = false, .configurable = true }));
// 21. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Value]]: func, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h
index 8f1257f5bd..a004f1e599 100644
--- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h
+++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h
@@ -38,7 +38,7 @@ ThrowCompletionOr<Realm*> get_function_realm(VM&, FunctionObject const&);
ThrowCompletionOr<void> initialize_bound_name(VM&, FlyString const&, Value, Environment*);
bool is_compatible_property_descriptor(bool extensible, PropertyDescriptor const&, Optional<PropertyDescriptor> const& current);
bool validate_and_apply_property_descriptor(Object*, PropertyKey const&, bool extensible, PropertyDescriptor const&, Optional<PropertyDescriptor> const& current);
-ThrowCompletionOr<Object*> get_prototype_from_constructor(VM&, FunctionObject const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)());
+ThrowCompletionOr<Object*> get_prototype_from_constructor(VM&, FunctionObject const& constructor, Object* (Intrinsics::*intrinsic_default_prototype)());
Object* create_unmapped_arguments_object(VM&, Span<Value> arguments);
Object* create_mapped_arguments_object(VM&, FunctionObject&, Vector<FunctionNode::Parameter> const&, Span<Value> arguments, Environment&);
@@ -131,7 +131,7 @@ ALWAYS_INLINE ThrowCompletionOr<Object*> construct(VM& vm, FunctionObject& funct
// 10.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ), https://tc39.es/ecma262/#sec-ordinarycreatefromconstructor
template<typename T, typename... Args>
-ThrowCompletionOr<T*> ordinary_create_from_constructor(VM& vm, FunctionObject const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)(), Args&&... args)
+ThrowCompletionOr<T*> ordinary_create_from_constructor(VM& vm, FunctionObject const& constructor, Object* (Intrinsics::*intrinsic_default_prototype)(), Args&&... args)
{
auto& realm = *vm.current_realm();
auto* prototype = TRY(get_prototype_from_constructor(vm, constructor, intrinsic_default_prototype));
diff --git a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp
index cfca1966b1..db5a12cf57 100644
--- a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -12,7 +12,7 @@ namespace JS {
AggregateError* AggregateError::create(Realm& realm)
{
- return realm.heap().allocate<AggregateError>(realm, *realm.global_object().aggregate_error_prototype());
+ return realm.heap().allocate<AggregateError>(realm, *realm.intrinsics().aggregate_error_prototype());
}
AggregateError::AggregateError(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp
index 868efa57ba..9230e26c73 100644
--- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp
@@ -15,7 +15,7 @@
namespace JS {
AggregateErrorConstructor::AggregateErrorConstructor(Realm& realm)
- : NativeFunction(static_cast<Object&>(*realm.global_object().error_constructor()))
+ : NativeFunction(static_cast<Object&>(*realm.intrinsics().error_constructor()))
{
}
@@ -25,7 +25,7 @@ void AggregateErrorConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 20.5.7.2.1 AggregateError.prototype, https://tc39.es/ecma262/#sec-aggregate-error.prototype
- define_direct_property(vm.names.prototype, realm.global_object().aggregate_error_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().aggregate_error_prototype(), 0);
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
}
@@ -42,7 +42,7 @@ ThrowCompletionOr<Object*> AggregateErrorConstructor::construct(FunctionObject&
auto& vm = this->vm();
auto& realm = *vm.current_realm();
- auto* aggregate_error = TRY(ordinary_create_from_constructor<AggregateError>(vm, new_target, &GlobalObject::aggregate_error_prototype));
+ auto* aggregate_error = TRY(ordinary_create_from_constructor<AggregateError>(vm, new_target, &Intrinsics::aggregate_error_prototype));
if (!vm.argument(1).is_undefined()) {
auto message = TRY(vm.argument(1).to_string(vm));
diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp
index 797b6a1cab..34302bc3f9 100644
--- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -11,7 +11,7 @@
namespace JS {
AggregateErrorPrototype::AggregateErrorPrototype(Realm& realm)
- : Object(*realm.global_object().error_prototype())
+ : Object(*realm.intrinsics().error_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp
index 924ba893ca..ffc05bf542 100644
--- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp
@@ -11,7 +11,7 @@
namespace JS {
ArgumentsObject::ArgumentsObject(Realm& realm, Environment& environment)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
, m_environment(environment)
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp
index dd91a6444a..8d73220398 100644
--- a/Userland/Libraries/LibJS/Runtime/Array.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Array.cpp
@@ -27,7 +27,7 @@ ThrowCompletionOr<Array*> Array::create(Realm& realm, u64 length, Object* protot
// 2. If proto is not present, set proto to %Array.prototype%.
if (!prototype)
- prototype = realm.global_object().array_prototype();
+ prototype = realm.intrinsics().array_prototype();
// 3. Let A be MakeBasicObject(« [[Prototype]], [[Extensible]] »).
// 4. Set A.[[Prototype]] to proto.
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
index f66b67b744..66d59f844b 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
@@ -17,17 +17,17 @@ ThrowCompletionOr<ArrayBuffer*> ArrayBuffer::create(Realm& realm, size_t byte_le
if (buffer.is_error())
return realm.vm().throw_completion<RangeError>(ErrorType::NotEnoughMemoryToAllocate, byte_length);
- return realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), *realm.global_object().array_buffer_prototype());
+ return realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype());
}
ArrayBuffer* ArrayBuffer::create(Realm& realm, ByteBuffer buffer)
{
- return realm.heap().allocate<ArrayBuffer>(realm, move(buffer), *realm.global_object().array_buffer_prototype());
+ return realm.heap().allocate<ArrayBuffer>(realm, move(buffer), *realm.intrinsics().array_buffer_prototype());
}
ArrayBuffer* ArrayBuffer::create(Realm& realm, ByteBuffer* buffer)
{
- return realm.heap().allocate<ArrayBuffer>(realm, buffer, *realm.global_object().array_buffer_prototype());
+ return realm.heap().allocate<ArrayBuffer>(realm, buffer, *realm.intrinsics().array_buffer_prototype());
}
ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype)
@@ -54,7 +54,7 @@ void ArrayBuffer::visit_edges(Cell::Visitor& visitor)
ThrowCompletionOr<ArrayBuffer*> allocate_array_buffer(VM& vm, FunctionObject& constructor, size_t byte_length)
{
// 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] »).
- auto* obj = TRY(ordinary_create_from_constructor<ArrayBuffer>(vm, constructor, &GlobalObject::array_buffer_prototype, nullptr));
+ auto* obj = TRY(ordinary_create_from_constructor<ArrayBuffer>(vm, constructor, &Intrinsics::array_buffer_prototype, nullptr));
// 2. Let block be ? CreateByteDataBlock(byteLength).
auto block = ByteBuffer::create_zeroed(byte_length);
@@ -101,7 +101,7 @@ ThrowCompletionOr<ArrayBuffer*> clone_array_buffer(VM& vm, ArrayBuffer& source_b
VERIFY(!source_buffer.is_detached());
// 2. Let targetBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, srcLength).
- auto* target_buffer = TRY(allocate_array_buffer(vm, *realm.global_object().array_buffer_constructor(), source_length));
+ auto* target_buffer = TRY(allocate_array_buffer(vm, *realm.intrinsics().array_buffer_constructor(), source_length));
// 3. Let srcBlock be srcBuffer.[[ArrayBufferData]].
auto& source_block = source_buffer.buffer();
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
index 64519d44dd..9472b7f370 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
ArrayBufferConstructor::ArrayBufferConstructor(Realm& realm)
- : NativeFunction(vm().names.ArrayBuffer.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.ArrayBuffer.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -24,7 +24,7 @@ void ArrayBufferConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 25.1.4.2 ArrayBuffer.prototype, https://tc39.es/ecma262/#sec-arraybuffer.prototype
- define_direct_property(vm.names.prototype, realm.global_object().array_buffer_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().array_buffer_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.isView, is_view, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp
index d312b5c5c5..5c53ec60cd 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp
@@ -15,7 +15,7 @@
namespace JS {
ArrayBufferPrototype::ArrayBufferPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -82,7 +82,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice)
auto new_length = max(final - first, 0.0);
// 15. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
- auto* constructor = TRY(species_constructor(vm, *array_buffer_object, *realm.global_object().array_buffer_constructor()));
+ auto* constructor = TRY(species_constructor(vm, *array_buffer_object, *realm.intrinsics().array_buffer_constructor()));
// 16. Let new be ? Construct(ctor, « 𝔽(newLen) »).
auto* new_array_buffer = TRY(construct(vm, *constructor, Value(new_length)));
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
index 562d7126ec..784648874a 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
@@ -17,7 +17,7 @@
namespace JS {
ArrayConstructor::ArrayConstructor(Realm& realm)
- : NativeFunction(vm().names.Array.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Array.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -27,7 +27,7 @@ void ArrayConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 23.1.2.4 Array.prototype, https://tc39.es/ecma262/#sec-array.prototype
- define_direct_property(vm.names.prototype, realm.global_object().array_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().array_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
@@ -52,7 +52,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe
auto& vm = this->vm();
auto& realm = *vm.current_realm();
- auto* proto = TRY(get_prototype_from_constructor(vm, new_target, &GlobalObject::array_prototype));
+ auto* proto = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::array_prototype));
if (vm.argument_count() == 0)
return MUST(Array::create(realm, 0, proto));
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp
index c7dde4fb13..b9e45758ec 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp
@@ -11,7 +11,7 @@ namespace JS {
ArrayIterator* ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind)
{
- return realm.heap().allocate<ArrayIterator>(realm, array, iteration_kind, *realm.global_object().array_iterator_prototype());
+ return realm.heap().allocate<ArrayIterator>(realm, array, iteration_kind, *realm.intrinsics().array_iterator_prototype());
}
ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp
index ce00356f78..259587414c 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp
@@ -15,7 +15,7 @@
namespace JS {
ArrayIteratorPrototype::ArrayIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().iterator_prototype())
+ : PrototypeObject(*realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp
index d34d388260..47fb1de68a 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp
@@ -29,7 +29,7 @@ namespace JS {
static HashTable<Object*> s_array_join_seen_objects;
ArrayPrototype::ArrayPrototype(Realm& realm)
- : Array(*realm.global_object().object_prototype())
+ : Array(*realm.intrinsics().object_prototype())
{
}
@@ -128,7 +128,7 @@ static ThrowCompletionOr<Object*> array_species_create(VM& vm, Object& original_
auto* this_realm = vm.current_realm();
auto* constructor_realm = TRY(get_function_realm(vm, constructor_function));
if (constructor_realm != this_realm) {
- if (&constructor_function == constructor_realm->global_object().array_constructor())
+ if (&constructor_function == constructor_realm->intrinsics().array_constructor())
constructor = js_undefined();
}
}
@@ -1968,7 +1968,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_string)
// 3. If IsCallable(func) is false, set func to the intrinsic function %Object.prototype.toString%.
if (!func.is_function())
- func = realm.global_object().object_prototype_to_string_function();
+ func = realm.intrinsics().object_prototype_to_string_function();
// 4. Return ? Call(func, array).
return TRY(call(vm, func.as_function(), array));
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp
index a31e5e2729..0044677a93 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp
@@ -17,7 +17,7 @@ AsyncFromSyncIterator* AsyncFromSyncIterator::create(Realm& realm, Iterator sync
}
AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record)
- : Object(*realm.global_object().async_from_sync_iterator_prototype())
+ : Object(*realm.intrinsics().async_from_sync_iterator_prototype())
, m_sync_iterator_record(sync_iterator_record)
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp
index 84f09708ad..4e71468cfd 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp
@@ -15,7 +15,7 @@
namespace JS {
AsyncFromSyncIteratorPrototype::AsyncFromSyncIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().async_iterator_prototype())
+ : PrototypeObject(*realm.intrinsics().async_iterator_prototype())
{
}
@@ -46,7 +46,7 @@ static Object* async_from_sync_iterator_continuation(VM& vm, Object& result, Pro
// 6. Let valueWrapper be PromiseResolve(%Promise%, value).
// 7. IfAbruptRejectPromise(valueWrapper, promiseCapability).
- auto value_wrapper = TRY_OR_MUST_REJECT(vm, promise_capability, promise_resolve(vm, *realm.global_object().promise_constructor(), value));
+ auto value_wrapper = TRY_OR_MUST_REJECT(vm, promise_capability, promise_resolve(vm, *realm.intrinsics().promise_constructor(), value));
// 8. Let unwrap be a new Abstract Closure with parameters (value) that captures done and performs the following steps when called:
auto unwrap = [done](VM& vm) -> ThrowCompletionOr<Value> {
@@ -75,7 +75,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::next)
auto* this_object = MUST(typed_this_object(vm));
// 3. 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()));
// 4. Let syncIteratorRecord be O.[[SyncIteratorRecord]].
auto& sync_iterator_record = this_object->sync_iterator_record();
@@ -103,7 +103,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::return_)
auto* this_object = MUST(typed_this_object(vm));
// 3. 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()));
// 4. Let syncIterator be O.[[SyncIteratorRecord]].[[Iterator]].
auto* sync_iterator = this_object->sync_iterator_record().iterator;
@@ -156,7 +156,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::throw_)
auto* this_object = MUST(typed_this_object(vm));
// 3. 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()));
// 4. Let syncIterator be O.[[SyncIteratorRecord]].[[Iterator]].
auto* sync_iterator = this_object->sync_iterator_record().iterator;
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp
index e4778ffaa9..b282e66aea 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp
@@ -13,7 +13,7 @@
namespace JS {
AsyncFunctionConstructor::AsyncFunctionConstructor(Realm& realm)
- : NativeFunction(vm().names.AsyncFunction.as_string(), *realm.global_object().function_constructor())
+ : NativeFunction(vm().names.AsyncFunction.as_string(), *realm.intrinsics().function_constructor())
{
}
@@ -23,7 +23,7 @@ void AsyncFunctionConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 27.7.2.2 AsyncFunction.prototype, https://tc39.es/ecma262/#sec-async-function-constructor-prototype
- define_direct_property(vm.names.prototype, realm.global_object().async_function_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().async_function_prototype(), 0);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp
index f398e8a133..becbb47c87 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp
@@ -19,7 +19,7 @@ ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::create(Realm& realm, Genera
}
AsyncFunctionDriverWrapper::AsyncFunctionDriverWrapper(Realm& realm, GeneratorObject* generator_object)
- : Promise(*realm.global_object().promise_prototype())
+ : Promise(*realm.intrinsics().promise_prototype())
, m_generator_object(generator_object)
, m_on_fulfillment(NativeFunction::create(realm, "async.on_fulfillment"sv, [this](VM& vm) {
return react_to_async_task_completion(vm, vm.argument(0), true);
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp
index 4eb27b1e68..a2149557bf 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp
@@ -10,7 +10,7 @@
namespace JS {
AsyncFunctionPrototype::AsyncFunctionPrototype(Realm& realm)
- : Object(*realm.global_object().function_prototype())
+ : Object(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp
index bb83045693..3df767692a 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp
@@ -13,7 +13,7 @@
namespace JS {
AsyncGeneratorFunctionConstructor::AsyncGeneratorFunctionConstructor(Realm& realm)
- : NativeFunction(vm().names.AsyncGeneratorFunction.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.AsyncGeneratorFunction.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -26,7 +26,7 @@ void AsyncGeneratorFunctionConstructor::initialize(Realm& realm)
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
// 27.4.2.2 AsyncGeneratorFunction.prototype, https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype
- define_direct_property(vm.names.prototype, realm.global_object().async_generator_function_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().async_generator_function_prototype(), 0);
}
// 27.4.1.1 AsyncGeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-asyncgeneratorfunction
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp
index 7fc40459b6..24cd874106 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp
@@ -12,7 +12,7 @@
namespace JS {
AsyncGeneratorFunctionPrototype::AsyncGeneratorFunctionPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().function_prototype())
+ : PrototypeObject(*realm.intrinsics().function_prototype())
{
}
@@ -24,7 +24,7 @@ void AsyncGeneratorFunctionPrototype::initialize(Realm& realm)
// The constructor cannot be set at this point since it has not been initialized.
// 27.4.3.2 AsyncGeneratorFunction.prototype.prototype, https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype-prototype
- define_direct_property(vm.names.prototype, realm.global_object().async_generator_prototype(), Attribute::Configurable);
+ define_direct_property(vm.names.prototype, realm.intrinsics().async_generator_prototype(), Attribute::Configurable);
// 27.4.3.3 AsyncGeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype-tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.AsyncGeneratorFunction.as_string()), Attribute::Configurable);
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp
index 745437a78f..db9f611d71 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp
@@ -10,7 +10,7 @@ namespace JS {
// 27.6.1 Properties of the AsyncGenerator Prototype Object, https://tc39.es/ecma262/#sec-properties-of-asyncgenerator-prototype
AsyncGeneratorPrototype::AsyncGeneratorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().async_iterator_prototype())
+ : PrototypeObject(*realm.intrinsics().async_iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp
index 20a4bc3862..9ec5c2608d 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp
@@ -9,7 +9,7 @@
namespace JS {
AsyncIteratorPrototype::AsyncIteratorPrototype(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp
index 74c5a85561..32bd982fe5 100644
--- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp
@@ -123,7 +123,7 @@ static ThrowCompletionOr<Value> perform_atomic_operation(VM& vm, TypedArrayBase&
}
AtomicsObject::AtomicsObject(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp
index 6564178d65..f737840715 100644
--- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp
@@ -18,7 +18,7 @@ namespace JS {
static const Crypto::SignedBigInteger BIGINT_ONE { 1 };
BigIntConstructor::BigIntConstructor(Realm& realm)
- : NativeFunction(vm().names.BigInt.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.BigInt.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -28,7 +28,7 @@ void BigIntConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 21.2.2.3 BigInt.prototype, https://tc39.es/ecma262/#sec-bigint.prototype
- define_direct_property(vm.names.prototype, realm.global_object().bigint_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().bigint_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.asIntN, as_int_n, 2, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp
index 9187b3eb80..ce05f94968 100644
--- a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -11,7 +11,7 @@ namespace JS {
BigIntObject* BigIntObject::create(Realm& realm, BigInt& bigint)
{
- return realm.heap().allocate<BigIntObject>(realm, bigint, *realm.global_object().bigint_prototype());
+ return realm.heap().allocate<BigIntObject>(realm, bigint, *realm.intrinsics().bigint_prototype());
}
BigIntObject::BigIntObject(BigInt& bigint, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp
index 1f8e9963eb..d98ea5cba2 100644
--- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp
@@ -18,7 +18,7 @@
namespace JS {
BigIntPrototype::BigIntPrototype(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
@@ -71,7 +71,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_locale_string)
auto* bigint = TRY(this_bigint_value(vm, vm.this_value()));
// 2. Let numberFormat be ? Construct(%NumberFormat%, « locales, options »).
- auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, *realm.global_object().intl_number_format_constructor(), locales, options)));
+ auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), locales, options)));
// 3. Return ? FormatNumeric(numberFormat, x).
auto formatted = Intl::format_numeric(vm, *number_format, Value(bigint));
diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp
index 14d8adba33..075a997af9 100644
--- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp
@@ -12,7 +12,7 @@
namespace JS {
BooleanConstructor::BooleanConstructor(Realm& realm)
- : NativeFunction(vm().names.Boolean.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Boolean.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -22,7 +22,7 @@ void BooleanConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 20.3.2.1 Boolean.prototype, https://tc39.es/ecma262/#sec-boolean.prototype
- define_direct_property(vm.names.prototype, realm.global_object().boolean_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().boolean_prototype(), 0);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
}
@@ -42,7 +42,7 @@ ThrowCompletionOr<Object*> BooleanConstructor::construct(FunctionObject& new_tar
auto& vm = this->vm();
auto b = vm.argument(0).to_boolean();
- return TRY(ordinary_create_from_constructor<BooleanObject>(vm, new_target, &GlobalObject::boolean_prototype, b));
+ return TRY(ordinary_create_from_constructor<BooleanObject>(vm, new_target, &Intrinsics::boolean_prototype, b));
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp
index 5a79c32fb2..fff4d481f5 100644
--- a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp
@@ -11,7 +11,7 @@ namespace JS {
BooleanObject* BooleanObject::create(Realm& realm, bool value)
{
- return realm.heap().allocate<BooleanObject>(realm, value, *realm.global_object().boolean_prototype());
+ return realm.heap().allocate<BooleanObject>(realm, value, *realm.intrinsics().boolean_prototype());
}
BooleanObject::BooleanObject(bool value, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp
index 836cd6e0f9..d3dc7036cc 100644
--- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp
@@ -13,7 +13,7 @@
namespace JS {
BooleanPrototype::BooleanPrototype(Realm& realm)
- : BooleanObject(false, *realm.global_object().object_prototype())
+ : BooleanObject(false, *realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Completion.cpp b/Userland/Libraries/LibJS/Runtime/Completion.cpp
index eaa75d2110..bcf39d8f50 100644
--- a/Userland/Libraries/LibJS/Runtime/Completion.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Completion.cpp
@@ -37,7 +37,7 @@ ThrowCompletionOr<Value> await(VM& vm, Value value)
// NOTE: This is not needed, as we don't suspend anything.
// 2. Let promise be ? PromiseResolve(%Promise%, value).
- auto* promise_object = TRY(promise_resolve(vm, *realm.global_object().promise_constructor(), value));
+ auto* promise_object = TRY(promise_resolve(vm, *realm.intrinsics().promise_constructor(), value));
Optional<bool> success;
Value result;
diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
index b44eb60fe3..184b66b0a0 100644
--- a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
@@ -13,7 +13,7 @@
namespace JS {
ConsoleObject::ConsoleObject(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/DataView.cpp b/Userland/Libraries/LibJS/Runtime/DataView.cpp
index bb3909b47b..1068ae6fe2 100644
--- a/Userland/Libraries/LibJS/Runtime/DataView.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DataView.cpp
@@ -10,7 +10,7 @@ namespace JS {
DataView* DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset)
{
- return realm.heap().allocate<DataView>(realm, viewed_buffer, byte_length, byte_offset, *realm.global_object().data_view_prototype());
+ return realm.heap().allocate<DataView>(realm, viewed_buffer, byte_length, byte_offset, *realm.intrinsics().data_view_prototype());
}
DataView::DataView(ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp
index d56b01a12b..2b44ddfdaf 100644
--- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
DataViewConstructor::DataViewConstructor(Realm& realm)
- : NativeFunction(vm().names.DataView.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.DataView.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -24,7 +24,7 @@ void DataViewConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 25.3.3.1 DataView.prototype, https://tc39.es/ecma262/#sec-dataview.prototype
- define_direct_property(vm.names.prototype, realm.global_object().data_view_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().data_view_prototype(), 0);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
}
@@ -66,7 +66,7 @@ ThrowCompletionOr<Object*> DataViewConstructor::construct(FunctionObject& new_ta
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, vm.names.DataView);
}
- auto* data_view = TRY(ordinary_create_from_constructor<DataView>(vm, new_target, &GlobalObject::data_view_prototype, &array_buffer, view_byte_length, offset));
+ auto* data_view = TRY(ordinary_create_from_constructor<DataView>(vm, new_target, &Intrinsics::data_view_prototype, &array_buffer, view_byte_length, offset));
if (array_buffer.is_detached())
return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer);
diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp
index 16fadda126..a9363d40c3 100644
--- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp
@@ -11,7 +11,7 @@
namespace JS {
DataViewPrototype::DataViewPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp
index 83af042624..2896cb83ea 100644
--- a/Userland/Libraries/LibJS/Runtime/Date.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Date.cpp
@@ -18,7 +18,7 @@ namespace JS {
Date* Date::create(Realm& realm, double date_value)
{
- return realm.heap().allocate<Date>(realm, date_value, *realm.global_object().date_prototype());
+ return realm.heap().allocate<Date>(realm, date_value, *realm.intrinsics().date_prototype());
}
Date::Date(double date_value, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
index 1c7e80ae28..18830dc5d0 100644
--- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
@@ -163,7 +163,7 @@ static double parse_date_string(String const& date_string)
}
DateConstructor::DateConstructor(Realm& realm)
- : NativeFunction(vm().names.Date.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Date.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -173,7 +173,7 @@ void DateConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 21.4.3.3 Date.prototype, https://tc39.es/ecma262/#sec-date.prototype
- define_direct_property(vm.names.prototype, realm.global_object().date_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().date_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.now, now, 0, attr);
@@ -286,7 +286,7 @@ ThrowCompletionOr<Object*> DateConstructor::construct(FunctionObject& new_target
// 6. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Date.prototype%", « [[DateValue]] »).
// 7. Set O.[[DateValue]] to dv.
// 8. Return O.
- return TRY(ordinary_create_from_constructor<Date>(vm, new_target, &GlobalObject::date_prototype, date_value));
+ return TRY(ordinary_create_from_constructor<Date>(vm, new_target, &Intrinsics::date_prototype, date_value));
}
// 21.4.3.1 Date.now ( ), https://tc39.es/ecma262/#sec-date.now
diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp
index 7ab96f1f37..bbc540fedc 100644
--- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp
@@ -31,7 +31,7 @@
namespace JS {
DatePrototype::DatePrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -986,7 +986,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_json)
static ThrowCompletionOr<Intl::DateTimeFormat*> construct_date_time_format(VM& vm, Value locales, Value options)
{
auto& realm = *vm.current_realm();
- auto* date_time_format = TRY(construct(vm, *realm.global_object().intl_date_time_format_constructor(), locales, options));
+ auto* date_time_format = TRY(construct(vm, *realm.intrinsics().intl_date_time_format_constructor(), locales, options));
return static_cast<Intl::DateTimeFormat*>(date_time_format);
}
diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
index 4385719a43..0ea85b9cd7 100644
--- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
@@ -33,16 +33,16 @@ ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyStri
Object* prototype = nullptr;
switch (kind) {
case FunctionKind::Normal:
- prototype = realm.global_object().function_prototype();
+ prototype = realm.intrinsics().function_prototype();
break;
case FunctionKind::Generator:
- prototype = realm.global_object().generator_function_prototype();
+ prototype = realm.intrinsics().generator_function_prototype();
break;
case FunctionKind::Async:
- prototype = realm.global_object().async_function_prototype();
+ prototype = realm.intrinsics().async_function_prototype();
break;
case FunctionKind::AsyncGenerator:
- prototype = realm.global_object().async_generator_function_prototype();
+ prototype = realm.intrinsics().async_generator_function_prototype();
break;
}
return realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name));
@@ -114,17 +114,17 @@ void ECMAScriptFunctionObject::initialize(Realm& realm)
Object* prototype = nullptr;
switch (m_kind) {
case FunctionKind::Normal:
- prototype = vm.heap().allocate<Object>(realm, *realm.global_object().new_ordinary_function_prototype_object_shape());
+ prototype = vm.heap().allocate<Object>(realm, *realm.intrinsics().new_ordinary_function_prototype_object_shape());
MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true }));
break;
case FunctionKind::Generator:
// prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
- prototype = Object::create(realm, realm.global_object().generator_function_prototype_prototype());
+ prototype = Object::create(realm, realm.intrinsics().generator_function_prototype_prototype());
break;
case FunctionKind::Async:
break;
case FunctionKind::AsyncGenerator:
- prototype = Object::create(realm, realm.global_object().async_generator_function_prototype_prototype());
+ prototype = Object::create(realm, realm.intrinsics().async_generator_function_prototype_prototype());
break;
}
// 27.7.4 AsyncFunction Instances, https://tc39.es/ecma262/#sec-async-function-instances
@@ -208,7 +208,7 @@ ThrowCompletionOr<Object*> ECMAScriptFunctionObject::internal_construct(MarkedVe
// 3. If kind is base, then
if (kind == ConstructorKind::Base) {
// a. Let thisArgument be ? OrdinaryCreateFromConstructor(newTarget, "%Object.prototype%").
- this_argument = TRY(ordinary_create_from_constructor<Object>(vm, new_target, &GlobalObject::object_prototype));
+ this_argument = TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype));
}
ExecutionContext callee_context(heap());
@@ -863,7 +863,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
// AsyncFunctionBody : FunctionBody
else if (m_kind == FunctionKind::Async) {
// 1. 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()));
// 2. Let declResult be Completion(FunctionDeclarationInstantiation(functionObject, argumentsList)).
auto declaration_result = function_declaration_instantiation(ast_interpreter);
diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp
index 780aa8b137..25642c4564 100644
--- a/Userland/Libraries/LibJS/Runtime/Error.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Error.cpp
@@ -16,7 +16,7 @@ namespace JS {
Error* Error::create(Realm& realm)
{
- return realm.heap().allocate<Error>(realm, *realm.global_object().error_prototype());
+ return realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype());
}
Error* Error::create(Realm& realm, String const& message)
@@ -96,24 +96,24 @@ String Error::stack_string() const
return stack_string_builder.build();
}
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- ClassName* ClassName::create(Realm& realm) \
- { \
- return realm.heap().allocate<ClassName>(realm, *realm.global_object().snake_name##_prototype()); /* */ \
- } \
- \
- ClassName* ClassName::create(Realm& realm, String const& message) \
- { \
- auto& vm = realm.vm(); \
- auto* error = ClassName::create(realm); \
- u8 attr = Attribute::Writable | Attribute::Configurable; \
- error->define_direct_property(vm.names.message, js_string(vm, message), attr); \
- return error; \
- } \
- \
- ClassName::ClassName(Object& prototype) \
- : Error(prototype) \
- { \
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ ClassName* ClassName::create(Realm& realm) \
+ { \
+ return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()); \
+ } \
+ \
+ ClassName* ClassName::create(Realm& realm, String const& message) \
+ { \
+ auto& vm = realm.vm(); \
+ auto* error = ClassName::create(realm); \
+ u8 attr = Attribute::Writable | Attribute::Configurable; \
+ error->define_direct_property(vm.names.message, js_string(vm, message), attr); \
+ return error; \
+ } \
+ \
+ ClassName::ClassName(Object& prototype) \
+ : Error(prototype) \
+ { \
}
JS_ENUMERATE_NATIVE_ERRORS
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
index 6839ace3fb..4ee0af6586 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
@@ -12,7 +12,7 @@
namespace JS {
ErrorConstructor::ErrorConstructor(Realm& realm)
- : NativeFunction(vm().names.Error.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Error.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -22,7 +22,7 @@ void ErrorConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 20.5.2.1 Error.prototype, https://tc39.es/ecma262/#sec-error.prototype
- define_direct_property(vm.names.prototype, realm.global_object().error_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().error_prototype(), 0);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
}
@@ -43,7 +43,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
auto options = vm.argument(1);
// 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%Error.prototype%", « [[ErrorData]] »).
- auto* error = TRY(ordinary_create_from_constructor<Error>(vm, new_target, &GlobalObject::error_prototype));
+ auto* error = TRY(ordinary_create_from_constructor<Error>(vm, new_target, &Intrinsics::error_prototype));
// 3. If message is not undefined, then
if (!message.is_undefined()) {
@@ -61,57 +61,57 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
return error;
}
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- ConstructorName::ConstructorName(Realm& realm) \
- : NativeFunction(vm().names.ClassName.as_string(), *static_cast<Object*>(realm.global_object().error_constructor())) \
- { \
- } \
- \
- void ConstructorName::initialize(Realm& realm) \
- { \
- auto& vm = this->vm(); \
- NativeFunction::initialize(realm); \
- \
- /* 20.5.6.2.1 NativeError.prototype, https://tc39.es/ecma262/#sec-nativeerror.prototype */ \
- define_direct_property(vm.names.prototype, realm.global_object().snake_name##_prototype(), 0); \
- \
- define_direct_property(vm.names.length, Value(1), Attribute::Configurable); \
- } \
- \
- ConstructorName::~ConstructorName() = default; \
- \
- /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \
- ThrowCompletionOr<Value> ConstructorName::call() \
- { \
- /* 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. */ \
- return TRY(construct(*this)); \
- } \
- \
- /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \
- ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target) \
- { \
- auto& vm = this->vm(); \
- \
- auto message = vm.argument(0); \
- auto options = vm.argument(1); \
- \
- /* 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeError.prototype%", « [[ErrorData]] »). */ \
- auto* error = TRY(ordinary_create_from_constructor<ClassName>(vm, new_target, &GlobalObject::snake_name##_prototype)); \
- \
- /* 3. If message is not undefined, then */ \
- if (!message.is_undefined()) { \
- /* a. Let msg be ? ToString(message). */ \
- auto msg = TRY(message.to_string(vm)); \
- \
- /* b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg). */ \
- error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, move(msg))); \
- } \
- \
- /* 4. Perform ? InstallErrorCause(O, options). */ \
- TRY(error->install_error_cause(options)); \
- \
- /* 5. Return O. */ \
- return error; \
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ ConstructorName::ConstructorName(Realm& realm) \
+ : NativeFunction(vm().names.ClassName.as_string(), *static_cast<Object*>(realm.intrinsics().error_constructor())) \
+ { \
+ } \
+ \
+ void ConstructorName::initialize(Realm& realm) \
+ { \
+ auto& vm = this->vm(); \
+ NativeFunction::initialize(realm); \
+ \
+ /* 20.5.6.2.1 NativeError.prototype, https://tc39.es/ecma262/#sec-nativeerror.prototype */ \
+ define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \
+ \
+ define_direct_property(vm.names.length, Value(1), Attribute::Configurable); \
+ } \
+ \
+ ConstructorName::~ConstructorName() = default; \
+ \
+ /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \
+ ThrowCompletionOr<Value> ConstructorName::call() \
+ { \
+ /* 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. */ \
+ return TRY(construct(*this)); \
+ } \
+ \
+ /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \
+ ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target) \
+ { \
+ auto& vm = this->vm(); \
+ \
+ auto message = vm.argument(0); \
+ auto options = vm.argument(1); \
+ \
+ /* 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeError.prototype%", « [[ErrorData]] »). */ \
+ auto* error = TRY(ordinary_create_from_constructor<ClassName>(vm, new_target, &Intrinsics::snake_name##_prototype)); \
+ \
+ /* 3. If message is not undefined, then */ \
+ if (!message.is_undefined()) { \
+ /* a. Let msg be ? ToString(message). */ \
+ auto msg = TRY(message.to_string(vm)); \
+ \
+ /* b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg). */ \
+ error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, move(msg))); \
+ } \
+ \
+ /* 4. Perform ? InstallErrorCause(O, options). */ \
+ TRY(error->install_error_cause(options)); \
+ \
+ /* 5. Return O. */ \
+ return error; \
}
JS_ENUMERATE_NATIVE_ERRORS
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
index ec00be85fd..fd00dd0adb 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
@@ -16,7 +16,7 @@
namespace JS {
ErrorPrototype::ErrorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -125,7 +125,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter)
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
PrototypeName::PrototypeName(Realm& realm) \
- : PrototypeObject(*realm.global_object().error_prototype()) \
+ : PrototypeObject(*realm.intrinsics().error_prototype()) \
{ \
} \
\
diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp
index 22e5bb8444..02cb4e25a6 100644
--- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
FinalizationRegistryConstructor::FinalizationRegistryConstructor(Realm& realm)
- : NativeFunction(vm().names.FinalizationRegistry.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.FinalizationRegistry.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -24,7 +24,7 @@ void FinalizationRegistryConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 26.2.2.1 FinalizationRegistry.prototype, https://tc39.es/ecma262/#sec-finalization-registry.prototype
- define_direct_property(vm.names.prototype, realm.global_object().finalization_registry_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().finalization_registry_prototype(), 0);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
}
@@ -56,7 +56,7 @@ ThrowCompletionOr<Object*> FinalizationRegistryConstructor::construct(FunctionOb
// 7. Set finalizationRegistry.[[Cells]] to a new empty List.
// NOTE: This is done inside FinalizationRegistry instead of here.
// 8. Return finalizationRegistry.
- return TRY(ordinary_create_from_constructor<FinalizationRegistry>(vm, new_target, &GlobalObject::finalization_registry_prototype, *realm(), vm.host_make_job_callback(cleanup_callback.as_function())));
+ return TRY(ordinary_create_from_constructor<FinalizationRegistry>(vm, new_target, &Intrinsics::finalization_registry_prototype, *realm(), vm.host_make_job_callback(cleanup_callback.as_function())));
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp
index 029a2f80a4..b10684992e 100644
--- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp
@@ -10,7 +10,7 @@
namespace JS {
FinalizationRegistryPrototype::FinalizationRegistryPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp
index 8fde5b20f8..a6d470fbe1 100644
--- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp
@@ -20,7 +20,7 @@
namespace JS {
FunctionConstructor::FunctionConstructor(Realm& realm)
- : NativeFunction(vm().names.Function.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Function.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -30,7 +30,7 @@ void FunctionConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 20.2.2.2 Function.prototype, https://tc39.es/ecma262/#sec-function.prototype
- define_direct_property(vm.names.prototype, realm.global_object().function_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().function_prototype(), 0);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
}
@@ -49,7 +49,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
new_target = &constructor;
StringView prefix;
- Object* (GlobalObject::*fallback_prototype)() = nullptr;
+ Object* (Intrinsics::*fallback_prototype)() = nullptr;
switch (kind) {
// 4. If kind is normal, then
@@ -62,7 +62,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
// d. Let parameterSym be the grammar symbol FormalParameters[~Yield, ~Await].
// e. Let fallbackProto be "%Function.prototype%".
- fallback_prototype = &GlobalObject::function_prototype;
+ fallback_prototype = &Intrinsics::function_prototype;
break;
// 5. Else if kind is generator, then
@@ -75,7 +75,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
// d. Let parameterSym be the grammar symbol FormalParameters[+Yield, ~Await].
// e. Let fallbackProto be "%GeneratorFunction.prototype%".
- fallback_prototype = &GlobalObject::generator_function_prototype;
+ fallback_prototype = &Intrinsics::generator_function_prototype;
break;
// 6. Else if kind is async, then
@@ -88,7 +88,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
// d. Let parameterSym be the grammar symbol FormalParameters[~Yield, +Await].
// e. Let fallbackProto be "%AsyncFunction.prototype%".
- fallback_prototype = &GlobalObject::async_function_prototype;
+ fallback_prototype = &Intrinsics::async_function_prototype;
break;
// 7. Else,
@@ -103,7 +103,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
// e. Let parameterSym be the grammar symbol FormalParameters[+Yield, +Await].
// f. Let fallbackProto be "%AsyncGeneratorFunction.prototype%".
- fallback_prototype = &GlobalObject::async_generator_function_prototype;
+ fallback_prototype = &Intrinsics::async_generator_function_prototype;
break;
default:
@@ -232,7 +232,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
// 30. If kind is generator, then
if (kind == FunctionKind::Generator) {
// a. Let prototype be OrdinaryObjectCreate(%GeneratorFunction.prototype.prototype%).
- prototype = Object::create(realm, realm.global_object().generator_function_prototype_prototype());
+ prototype = Object::create(realm, realm.intrinsics().generator_function_prototype_prototype());
// b. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }).
function->define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
@@ -240,7 +240,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
// 31. Else if kind is asyncGenerator, then
else if (kind == FunctionKind::AsyncGenerator) {
// a. Let prototype be OrdinaryObjectCreate(%AsyncGeneratorFunction.prototype.prototype%).
- prototype = Object::create(realm, realm.global_object().async_generator_function_prototype_prototype());
+ prototype = Object::create(realm, realm.intrinsics().async_generator_function_prototype_prototype());
// b. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }).
function->define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
@@ -248,7 +248,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
// 32. Else if kind is normal, perform MakeConstructor(F).
else if (kind == FunctionKind::Normal) {
// FIXME: Implement MakeConstructor
- prototype = Object::create(realm, realm.global_object().object_prototype());
+ prototype = Object::create(realm, realm.intrinsics().object_prototype());
prototype->define_direct_property(vm.names.constructor, function, Attribute::Writable | Attribute::Configurable);
function->define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
}
diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp
index d9f7b40a13..379f1b8ea5 100644
--- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp
@@ -21,7 +21,7 @@
namespace JS {
FunctionPrototype::FunctionPrototype(Realm& realm)
- : FunctionObject(*realm.global_object().object_prototype())
+ : FunctionObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp
index 5c73f3e394..0faac0dbf2 100644
--- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp
@@ -12,7 +12,7 @@
namespace JS {
GeneratorFunctionConstructor::GeneratorFunctionConstructor(Realm& realm)
- : NativeFunction(static_cast<Object&>(*realm.global_object().function_constructor()))
+ : NativeFunction(static_cast<Object&>(*realm.intrinsics().function_constructor()))
{
}
@@ -24,7 +24,7 @@ void GeneratorFunctionConstructor::initialize(Realm& realm)
// 27.3.2.1 GeneratorFunction.length, https://tc39.es/ecma262/#sec-generatorfunction.length
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
// 27.3.2.2 GeneratorFunction.prototype, https://tc39.es/ecma262/#sec-generatorfunction.length
- define_direct_property(vm.names.prototype, realm.global_object().generator_function_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().generator_function_prototype(), 0);
}
// 27.3.1.1 GeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-generatorfunction
diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp
index ab6d51e6f4..62e39cbf08 100644
--- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp
@@ -11,7 +11,7 @@
namespace JS {
GeneratorFunctionPrototype::GeneratorFunctionPrototype(Realm& realm)
- : Object(*realm.global_object().function_prototype())
+ : Object(*realm.intrinsics().function_prototype())
{
}
@@ -21,7 +21,7 @@ void GeneratorFunctionPrototype::initialize(Realm& realm)
Object::initialize(realm);
// 27.3.3.2 GeneratorFunction.prototype.prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype
- define_direct_property(vm.names.prototype, realm.global_object().generator_prototype(), Attribute::Configurable);
+ define_direct_property(vm.names.prototype, realm.intrinsics().generator_prototype(), Attribute::Configurable);
// 27.3.3.3 GeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "GeneratorFunction"), Attribute::Configurable);
}
diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp
index 80712ab0c7..5eee673cfe 100644
--- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp
@@ -22,7 +22,7 @@ ThrowCompletionOr<GeneratorObject*> GeneratorObject::create(Realm& realm, Value
// We implement async functions by transforming them to generator function in the bytecode
// interpreter. However an async function does not have a prototype and should not be
// changed thus we hardcode the prototype.
- generating_function_prototype = realm.global_object().generator_prototype();
+ generating_function_prototype = realm.intrinsics().generator_prototype();
} else {
generating_function_prototype = TRY(generating_function->get(vm.names.prototype));
}
@@ -73,7 +73,7 @@ ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, Optional<Value> next
auto previous_generated_value = TRY(generated_value(m_previous_value));
- auto result = Object::create(realm, realm.global_object().object_prototype());
+ auto result = Object::create(realm, realm.intrinsics().object_prototype());
result->define_direct_property("value", previous_generated_value, default_attributes);
if (m_done) {
diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp
index 49c452e24c..d6040de060 100644
--- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp
@@ -10,7 +10,7 @@
namespace JS {
GeneratorPrototype::GeneratorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().iterator_prototype())
+ : PrototypeObject(*realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
index 4f0b65b597..2a5fdd3446 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
@@ -8,7 +8,6 @@
#include <AK/BuiltinWrappers.h>
#include <AK/CharacterTypes.h>
#include <AK/Hex.h>
-#include <AK/Platform.h>
#include <AK/UnicodeUtils.h>
#include <AK/Utf16View.h>
#include <AK/Utf8View.h>
@@ -17,125 +16,70 @@
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/AggregateErrorConstructor.h>
-#include <LibJS/Runtime/AggregateErrorPrototype.h>
#include <LibJS/Runtime/ArrayBufferConstructor.h>
-#include <LibJS/Runtime/ArrayBufferPrototype.h>
#include <LibJS/Runtime/ArrayConstructor.h>
-#include <LibJS/Runtime/ArrayIteratorPrototype.h>
#include <LibJS/Runtime/ArrayPrototype.h>
-#include <LibJS/Runtime/AsyncFromSyncIteratorPrototype.h>
#include <LibJS/Runtime/AsyncFunctionConstructor.h>
-#include <LibJS/Runtime/AsyncFunctionPrototype.h>
#include <LibJS/Runtime/AsyncGeneratorFunctionConstructor.h>
-#include <LibJS/Runtime/AsyncGeneratorFunctionPrototype.h>
#include <LibJS/Runtime/AsyncGeneratorPrototype.h>
-#include <LibJS/Runtime/AsyncIteratorPrototype.h>
#include <LibJS/Runtime/AtomicsObject.h>
#include <LibJS/Runtime/BigIntConstructor.h>
-#include <LibJS/Runtime/BigIntPrototype.h>
#include <LibJS/Runtime/BooleanConstructor.h>
-#include <LibJS/Runtime/BooleanPrototype.h>
#include <LibJS/Runtime/ConsoleObject.h>
#include <LibJS/Runtime/DataViewConstructor.h>
-#include <LibJS/Runtime/DataViewPrototype.h>
#include <LibJS/Runtime/DateConstructor.h>
-#include <LibJS/Runtime/DatePrototype.h>
#include <LibJS/Runtime/ErrorConstructor.h>
-#include <LibJS/Runtime/ErrorPrototype.h>
#include <LibJS/Runtime/FinalizationRegistryConstructor.h>
#include <LibJS/Runtime/FinalizationRegistryPrototype.h>
#include <LibJS/Runtime/FunctionConstructor.h>
-#include <LibJS/Runtime/FunctionPrototype.h>
#include <LibJS/Runtime/GeneratorFunctionConstructor.h>
-#include <LibJS/Runtime/GeneratorFunctionPrototype.h>
#include <LibJS/Runtime/GeneratorPrototype.h>
#include <LibJS/Runtime/GlobalEnvironment.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/Intl/CollatorConstructor.h>
-#include <LibJS/Runtime/Intl/CollatorPrototype.h>
#include <LibJS/Runtime/Intl/DateTimeFormatConstructor.h>
-#include <LibJS/Runtime/Intl/DateTimeFormatPrototype.h>
#include <LibJS/Runtime/Intl/DisplayNamesConstructor.h>
-#include <LibJS/Runtime/Intl/DisplayNamesPrototype.h>
#include <LibJS/Runtime/Intl/DurationFormatConstructor.h>
-#include <LibJS/Runtime/Intl/DurationFormatPrototype.h>
#include <LibJS/Runtime/Intl/Intl.h>
#include <LibJS/Runtime/Intl/ListFormatConstructor.h>
-#include <LibJS/Runtime/Intl/ListFormatPrototype.h>
#include <LibJS/Runtime/Intl/LocaleConstructor.h>
-#include <LibJS/Runtime/Intl/LocalePrototype.h>
#include <LibJS/Runtime/Intl/NumberFormatConstructor.h>
-#include <LibJS/Runtime/Intl/NumberFormatPrototype.h>
#include <LibJS/Runtime/Intl/PluralRulesConstructor.h>
-#include <LibJS/Runtime/Intl/PluralRulesPrototype.h>
#include <LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h>
-#include <LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h>
-#include <LibJS/Runtime/Intl/SegmentIteratorPrototype.h>
#include <LibJS/Runtime/Intl/SegmenterConstructor.h>
-#include <LibJS/Runtime/Intl/SegmenterPrototype.h>
-#include <LibJS/Runtime/Intl/SegmentsPrototype.h>
-#include <LibJS/Runtime/IteratorPrototype.h>
#include <LibJS/Runtime/JSONObject.h>
#include <LibJS/Runtime/MapConstructor.h>
-#include <LibJS/Runtime/MapIteratorPrototype.h>
-#include <LibJS/Runtime/MapPrototype.h>
#include <LibJS/Runtime/MathObject.h>
-#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/NumberConstructor.h>
-#include <LibJS/Runtime/NumberPrototype.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/ObjectConstructor.h>
-#include <LibJS/Runtime/ObjectPrototype.h>
#include <LibJS/Runtime/PromiseConstructor.h>
-#include <LibJS/Runtime/PromisePrototype.h>
#include <LibJS/Runtime/ProxyConstructor.h>
#include <LibJS/Runtime/Realm.h>
#include <LibJS/Runtime/ReflectObject.h>
#include <LibJS/Runtime/RegExpConstructor.h>
-#include <LibJS/Runtime/RegExpPrototype.h>
-#include <LibJS/Runtime/RegExpStringIteratorPrototype.h>
#include <LibJS/Runtime/SetConstructor.h>
-#include <LibJS/Runtime/SetIteratorPrototype.h>
-#include <LibJS/Runtime/SetPrototype.h>
#include <LibJS/Runtime/ShadowRealmConstructor.h>
-#include <LibJS/Runtime/ShadowRealmPrototype.h>
#include <LibJS/Runtime/Shape.h>
#include <LibJS/Runtime/StringConstructor.h>
-#include <LibJS/Runtime/StringIteratorPrototype.h>
#include <LibJS/Runtime/StringPrototype.h>
#include <LibJS/Runtime/SymbolConstructor.h>
-#include <LibJS/Runtime/SymbolPrototype.h>
#include <LibJS/Runtime/Temporal/CalendarConstructor.h>
-#include <LibJS/Runtime/Temporal/CalendarPrototype.h>
#include <LibJS/Runtime/Temporal/DurationConstructor.h>
-#include <LibJS/Runtime/Temporal/DurationPrototype.h>
#include <LibJS/Runtime/Temporal/InstantConstructor.h>
-#include <LibJS/Runtime/Temporal/InstantPrototype.h>
#include <LibJS/Runtime/Temporal/PlainDateConstructor.h>
-#include <LibJS/Runtime/Temporal/PlainDatePrototype.h>
#include <LibJS/Runtime/Temporal/PlainDateTimeConstructor.h>
-#include <LibJS/Runtime/Temporal/PlainDateTimePrototype.h>
#include <LibJS/Runtime/Temporal/PlainMonthDayConstructor.h>
-#include <LibJS/Runtime/Temporal/PlainMonthDayPrototype.h>
#include <LibJS/Runtime/Temporal/PlainTimeConstructor.h>
-#include <LibJS/Runtime/Temporal/PlainTimePrototype.h>
#include <LibJS/Runtime/Temporal/PlainYearMonthConstructor.h>
-#include <LibJS/Runtime/Temporal/PlainYearMonthPrototype.h>
#include <LibJS/Runtime/Temporal/Temporal.h>
#include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
-#include <LibJS/Runtime/Temporal/TimeZonePrototype.h>
#include <LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h>
-#include <LibJS/Runtime/Temporal/ZonedDateTimePrototype.h>
#include <LibJS/Runtime/TypedArray.h>
-#include <LibJS/Runtime/TypedArrayConstructor.h>
-#include <LibJS/Runtime/TypedArrayPrototype.h>
#include <LibJS/Runtime/Value.h>
#include <LibJS/Runtime/WeakMapConstructor.h>
-#include <LibJS/Runtime/WeakMapPrototype.h>
#include <LibJS/Runtime/WeakRefConstructor.h>
-#include <LibJS/Runtime/WeakRefPrototype.h>
#include <LibJS/Runtime/WeakSetConstructor.h>
-#include <LibJS/Runtime/WeakSetPrototype.h>
namespace JS {
@@ -145,215 +89,100 @@ GlobalObject::GlobalObject(Realm& realm)
{
}
+// 9.3.4 SetDefaultGlobalBindings ( realmRec ), https://tc39.es/ecma262/#sec-setdefaultglobalbindings
void GlobalObject::initialize_global_object(Realm& realm)
{
auto& vm = this->vm();
ensure_shape_is_unique();
-
- // These are done first since other prototypes depend on their presence.
- m_empty_object_shape = heap().allocate_without_realm<Shape>(realm);
- m_object_prototype = heap().allocate_without_realm<ObjectPrototype>(realm);
- m_function_prototype = heap().allocate_without_realm<FunctionPrototype>(realm);
-
- m_new_object_shape = vm.heap().allocate_without_realm<Shape>(realm);
- m_new_object_shape->set_prototype_without_transition(m_object_prototype);
-
- m_new_ordinary_function_prototype_object_shape = vm.heap().allocate_without_realm<Shape>(realm);
- m_new_ordinary_function_prototype_object_shape->set_prototype_without_transition(m_object_prototype);
- m_new_ordinary_function_prototype_object_shape->add_property_without_transition(vm.names.constructor, Attribute::Writable | Attribute::Configurable);
-
- // Normally Heap::allocate() takes care of this, but these are allocated via allocate_without_realm().
- static_cast<FunctionPrototype*>(m_function_prototype)->initialize(realm);
- static_cast<ObjectPrototype*>(m_object_prototype)->initialize(realm);
-
- Object::set_prototype(m_object_prototype);
-
- // This must be initialized before allocating AggregateErrorPrototype, which uses ErrorPrototype as its prototype.
- m_error_prototype = heap().allocate<ErrorPrototype>(realm, realm);
-
-#define __JS_ENUMERATE(ClassName, snake_name) \
- if (!m_##snake_name##_prototype) \
- m_##snake_name##_prototype = heap().allocate<ClassName##Prototype>(realm, realm);
- JS_ENUMERATE_ITERATOR_PROTOTYPES
-#undef __JS_ENUMERATE
-
- // These must be initialized separately as they have no companion constructor
- m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(realm, realm);
- m_async_generator_prototype = heap().allocate<AsyncGeneratorPrototype>(realm, realm);
- m_generator_prototype = heap().allocate<GeneratorPrototype>(realm, realm);
- m_intl_segments_prototype = heap().allocate<Intl::SegmentsPrototype>(realm, realm);
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- if (!m_##snake_name##_prototype) \
- m_##snake_name##_prototype = heap().allocate<PrototypeName>(realm, realm);
- JS_ENUMERATE_BUILTIN_TYPES
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- if (!m_intl_##snake_name##_prototype) \
- m_intl_##snake_name##_prototype = heap().allocate<Intl::PrototypeName>(realm, realm);
- JS_ENUMERATE_INTL_OBJECTS
-#undef __JS_ENUMERATE
-
- // Must be allocated before `Intl::Intl` below.
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- initialize_constructor(realm, vm.names.ClassName, m_intl_##snake_name##_constructor, m_intl_##snake_name##_prototype);
- JS_ENUMERATE_INTL_OBJECTS
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- if (!m_temporal_##snake_name##_prototype) \
- m_temporal_##snake_name##_prototype = heap().allocate<Temporal::PrototypeName>(realm, realm);
- JS_ENUMERATE_TEMPORAL_OBJECTS
-#undef __JS_ENUMERATE
-
- // Must be allocated before `Temporal::Temporal` below.
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- initialize_constructor(realm, vm.names.ClassName, m_temporal_##snake_name##_constructor, m_temporal_##snake_name##_prototype);
- JS_ENUMERATE_TEMPORAL_OBJECTS
-#undef __JS_ENUMERATE
+ Object::set_prototype(realm.intrinsics().object_prototype());
u8 attr = Attribute::Writable | Attribute::Configurable;
- define_native_function(realm, vm.names.gc, gc, 0, attr);
- define_native_function(realm, vm.names.isNaN, is_nan, 1, attr);
+
+ // 19.2 Function Properties of the Global Object, https://tc39.es/ecma262/#sec-function-properties-of-the-global-object
+ define_native_function(realm, vm.names.eval, eval, 1, attr);
define_native_function(realm, vm.names.isFinite, is_finite, 1, attr);
+ define_native_function(realm, vm.names.isNaN, is_nan, 1, attr);
define_native_function(realm, vm.names.parseFloat, parse_float, 1, attr);
define_native_function(realm, vm.names.parseInt, parse_int, 2, attr);
- define_native_function(realm, vm.names.eval, eval, 1, attr);
-
- // 10.2.4.1 %ThrowTypeError% ( ), https://tc39.es/ecma262/#sec-%throwtypeerror%
- m_throw_type_error_function = NativeFunction::create(
- realm, [](VM& vm) {
- return vm.throw_completion<TypeError>(ErrorType::RestrictedFunctionPropertiesAccess);
- },
- 0, "", &realm);
- m_throw_type_error_function->define_direct_property(vm.names.length, Value(0), 0);
- m_throw_type_error_function->define_direct_property(vm.names.name, js_string(vm, ""), 0);
- MUST(m_throw_type_error_function->internal_prevent_extensions());
-
- // 10.2.4 AddRestrictedFunctionProperties ( F, realm ), https://tc39.es/ecma262/#sec-addrestrictedfunctionproperties
- m_function_prototype->define_direct_accessor(vm.names.caller, m_throw_type_error_function, m_throw_type_error_function, Attribute::Configurable);
- m_function_prototype->define_direct_accessor(vm.names.arguments, m_throw_type_error_function, m_throw_type_error_function, Attribute::Configurable);
-
- define_native_function(realm, vm.names.encodeURI, encode_uri, 1, attr);
define_native_function(realm, vm.names.decodeURI, decode_uri, 1, attr);
- define_native_function(realm, vm.names.encodeURIComponent, encode_uri_component, 1, attr);
define_native_function(realm, vm.names.decodeURIComponent, decode_uri_component, 1, attr);
- define_native_function(realm, vm.names.escape, escape, 1, attr);
- define_native_function(realm, vm.names.unescape, unescape, 1, attr);
+ define_native_function(realm, vm.names.encodeURI, encode_uri, 1, attr);
+ define_native_function(realm, vm.names.encodeURIComponent, encode_uri_component, 1, attr);
- define_direct_property(vm.names.NaN, js_nan(), 0);
+ // 19.1 Value Properties of the Global Object, https://tc39.es/ecma262/#sec-value-properties-of-the-global-object
+ define_direct_property(vm.names.globalThis, this, attr);
define_direct_property(vm.names.Infinity, js_infinity(), 0);
+ define_direct_property(vm.names.NaN, js_nan(), 0);
define_direct_property(vm.names.undefined, js_undefined(), 0);
- define_direct_property(vm.names.globalThis, this, attr);
- define_direct_property(vm.names.console, heap().allocate<ConsoleObject>(realm, realm), attr);
+ // 19.3 Constructor Properties of the Global Object, https://tc39.es/ecma262/#sec-constructor-properties-of-the-global-object
+ define_direct_property(vm.names.AggregateError, realm.intrinsics().aggregate_error_constructor(), attr);
+ define_direct_property(vm.names.Array, realm.intrinsics().array_constructor(), attr);
+ define_direct_property(vm.names.ArrayBuffer, realm.intrinsics().array_buffer_constructor(), attr);
+ define_direct_property(vm.names.BigInt, realm.intrinsics().bigint_constructor(), attr);
+ define_direct_property(vm.names.BigInt64Array, realm.intrinsics().big_int64_array_constructor(), attr);
+ define_direct_property(vm.names.BigUint64Array, realm.intrinsics().big_uint64_array_constructor(), attr);
+ define_direct_property(vm.names.Boolean, realm.intrinsics().boolean_constructor(), attr);
+ define_direct_property(vm.names.DataView, realm.intrinsics().data_view_constructor(), attr);
+ define_direct_property(vm.names.Date, realm.intrinsics().date_constructor(), attr);
+ define_direct_property(vm.names.Error, realm.intrinsics().error_constructor(), attr);
+ define_direct_property(vm.names.EvalError, realm.intrinsics().eval_error_constructor(), attr);
+ define_direct_property(vm.names.FinalizationRegistry, realm.intrinsics().finalization_registry_constructor(), attr);
+ define_direct_property(vm.names.Float32Array, realm.intrinsics().float32_array_constructor(), attr);
+ define_direct_property(vm.names.Float64Array, realm.intrinsics().float64_array_constructor(), attr);
+ define_direct_property(vm.names.Function, realm.intrinsics().function_constructor(), attr);
+ define_direct_property(vm.names.Int8Array, realm.intrinsics().int8_array_constructor(), attr);
+ define_direct_property(vm.names.Int16Array, realm.intrinsics().int16_array_constructor(), attr);
+ define_direct_property(vm.names.Int32Array, realm.intrinsics().int32_array_constructor(), attr);
+ define_direct_property(vm.names.Map, realm.intrinsics().map_constructor(), attr);
+ define_direct_property(vm.names.Number, realm.intrinsics().number_constructor(), attr);
+ define_direct_property(vm.names.Object, realm.intrinsics().object_constructor(), attr);
+ define_direct_property(vm.names.Promise, realm.intrinsics().promise_constructor(), attr);
+ define_direct_property(vm.names.Proxy, realm.intrinsics().proxy_constructor(), attr);
+ define_direct_property(vm.names.RangeError, realm.intrinsics().range_error_constructor(), attr);
+ define_direct_property(vm.names.ReferenceError, realm.intrinsics().reference_error_constructor(), attr);
+ define_direct_property(vm.names.RegExp, realm.intrinsics().regexp_constructor(), attr);
+ define_direct_property(vm.names.Set, realm.intrinsics().set_constructor(), attr);
+ define_direct_property(vm.names.ShadowRealm, realm.intrinsics().shadow_realm_constructor(), attr);
+ define_direct_property(vm.names.String, realm.intrinsics().string_constructor(), attr);
+ define_direct_property(vm.names.Symbol, realm.intrinsics().symbol_constructor(), attr);
+ define_direct_property(vm.names.SyntaxError, realm.intrinsics().syntax_error_constructor(), attr);
+ define_direct_property(vm.names.TypeError, realm.intrinsics().type_error_constructor(), attr);
+ define_direct_property(vm.names.Uint8Array, realm.intrinsics().uint8_array_constructor(), attr);
+ define_direct_property(vm.names.Uint8ClampedArray, realm.intrinsics().uint8_clamped_array_constructor(), attr);
+ define_direct_property(vm.names.Uint16Array, realm.intrinsics().uint16_array_constructor(), attr);
+ define_direct_property(vm.names.Uint32Array, realm.intrinsics().uint32_array_constructor(), attr);
+ define_direct_property(vm.names.URIError, realm.intrinsics().uri_error_constructor(), attr);
+ define_direct_property(vm.names.WeakMap, realm.intrinsics().weak_map_constructor(), attr);
+ define_direct_property(vm.names.WeakRef, realm.intrinsics().weak_ref_constructor(), attr);
+ define_direct_property(vm.names.WeakSet, realm.intrinsics().weak_set_constructor(), attr);
+
+ // 19.4 Other Properties of the Global Object, https://tc39.es/ecma262/#sec-other-properties-of-the-global-object
define_direct_property(vm.names.Atomics, heap().allocate<AtomicsObject>(realm, realm), attr);
- define_direct_property(vm.names.Math, heap().allocate<MathObject>(realm, realm), attr);
+ define_direct_property(vm.names.Intl, heap().allocate<Intl::Intl>(realm, realm), attr);
define_direct_property(vm.names.JSON, heap().allocate<JSONObject>(realm, realm), attr);
+ define_direct_property(vm.names.Math, heap().allocate<MathObject>(realm, realm), attr);
define_direct_property(vm.names.Reflect, heap().allocate<ReflectObject>(realm, realm), attr);
- define_direct_property(vm.names.Intl, heap().allocate<Intl::Intl>(realm, realm), attr);
define_direct_property(vm.names.Temporal, heap().allocate<Temporal::Temporal>(realm, realm), attr);
- // This must be initialized before allocating AggregateErrorConstructor, which uses ErrorConstructor as its prototype.
- initialize_constructor(realm, vm.names.Error, m_error_constructor, m_error_prototype);
-
- add_constructor(realm, vm.names.AggregateError, m_aggregate_error_constructor, m_aggregate_error_prototype);
- add_constructor(realm, vm.names.Array, m_array_constructor, m_array_prototype);
- add_constructor(realm, vm.names.ArrayBuffer, m_array_buffer_constructor, m_array_buffer_prototype);
- add_constructor(realm, vm.names.BigInt, m_bigint_constructor, m_bigint_prototype);
- add_constructor(realm, vm.names.Boolean, m_boolean_constructor, m_boolean_prototype);
- add_constructor(realm, vm.names.DataView, m_data_view_constructor, m_data_view_prototype);
- add_constructor(realm, vm.names.Date, m_date_constructor, m_date_prototype);
- add_constructor(realm, vm.names.Error, m_error_constructor, m_error_prototype);
- add_constructor(realm, vm.names.FinalizationRegistry, m_finalization_registry_constructor, m_finalization_registry_prototype);
- add_constructor(realm, vm.names.Function, m_function_constructor, m_function_prototype);
- add_constructor(realm, vm.names.Map, m_map_constructor, m_map_prototype);
- add_constructor(realm, vm.names.Number, m_number_constructor, m_number_prototype);
- add_constructor(realm, vm.names.Object, m_object_constructor, m_object_prototype);
- add_constructor(realm, vm.names.Promise, m_promise_constructor, m_promise_prototype);
- add_constructor(realm, vm.names.Proxy, m_proxy_constructor, nullptr);
- add_constructor(realm, vm.names.RegExp, m_regexp_constructor, m_regexp_prototype);
- add_constructor(realm, vm.names.Set, m_set_constructor, m_set_prototype);
- add_constructor(realm, vm.names.ShadowRealm, m_shadow_realm_constructor, m_shadow_realm_prototype);
- add_constructor(realm, vm.names.String, m_string_constructor, m_string_prototype);
- add_constructor(realm, vm.names.Symbol, m_symbol_constructor, m_symbol_prototype);
- add_constructor(realm, vm.names.WeakMap, m_weak_map_constructor, m_weak_map_prototype);
- add_constructor(realm, vm.names.WeakRef, m_weak_ref_constructor, m_weak_ref_prototype);
- add_constructor(realm, vm.names.WeakSet, m_weak_set_constructor, m_weak_set_prototype);
-
- initialize_constructor(realm, vm.names.TypedArray, m_typed_array_constructor, m_typed_array_prototype);
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- add_constructor(realm, vm.names.ClassName, m_##snake_name##_constructor, m_##snake_name##_prototype);
- JS_ENUMERATE_NATIVE_ERRORS
- JS_ENUMERATE_TYPED_ARRAYS
-#undef __JS_ENUMERATE
-
- // NOTE: These constructors cannot be initialized with add_constructor as they have no global binding.
- initialize_constructor(realm, vm.names.GeneratorFunction, m_generator_function_constructor, m_generator_function_prototype, Attribute::Configurable);
- initialize_constructor(realm, vm.names.AsyncGeneratorFunction, m_async_generator_function_constructor, m_async_generator_function_prototype, Attribute::Configurable);
- initialize_constructor(realm, vm.names.AsyncFunction, m_async_function_constructor, m_async_function_prototype, Attribute::Configurable);
-
- // 27.5.1.1 Generator.prototype.constructor, https://tc39.es/ecma262/#sec-generator.prototype.constructor
- m_generator_prototype->define_direct_property(vm.names.constructor, m_generator_function_prototype, Attribute::Configurable);
-
- // 27.6.1.1 AsyncGenerator.prototype.constructor, https://tc39.es/ecma262/#sec-asyncgenerator-prototype-constructor
- m_async_generator_prototype->define_direct_property(vm.names.constructor, m_async_generator_function_prototype, Attribute::Configurable);
-
- m_array_prototype_values_function = &m_array_prototype->get_without_side_effects(vm.names.values).as_function();
- m_date_constructor_now_function = &m_date_constructor->get_without_side_effects(vm.names.now).as_function();
- m_eval_function = &get_without_side_effects(vm.names.eval).as_function();
- m_json_parse_function = &get_without_side_effects(vm.names.JSON).as_object().get_without_side_effects(vm.names.parse).as_function();
- m_object_prototype_to_string_function = &m_object_prototype->get_without_side_effects(vm.names.toString).as_function();
-}
+ // B.2.1 Additional Properties of the Global Object, https://tc39.es/ecma262/#sec-additional-properties-of-the-global-object
+ define_native_function(realm, vm.names.escape, escape, 1, attr);
+ define_native_function(realm, vm.names.unescape, unescape, 1, attr);
-GlobalObject::~GlobalObject() = default;
+ // Non-standard
+ define_direct_property(vm.names.InternalError, realm.intrinsics().internal_error_constructor(), attr);
+ define_direct_property(vm.names.console, heap().allocate<ConsoleObject>(realm, realm), attr);
+ define_native_function(realm, vm.names.gc, gc, 0, attr);
-void GlobalObject::visit_edges(Visitor& visitor)
-{
- Base::visit_edges(visitor);
-
- visitor.visit(m_empty_object_shape);
- visitor.visit(m_new_object_shape);
- visitor.visit(m_new_ordinary_function_prototype_object_shape);
- visitor.visit(m_proxy_constructor);
- visitor.visit(m_async_from_sync_iterator_prototype);
- visitor.visit(m_async_generator_prototype);
- visitor.visit(m_generator_prototype);
- visitor.visit(m_intl_segments_prototype);
- visitor.visit(m_array_prototype_values_function);
- visitor.visit(m_date_constructor_now_function);
- visitor.visit(m_eval_function);
- visitor.visit(m_json_parse_function);
- visitor.visit(m_object_prototype_to_string_function);
- visitor.visit(m_throw_type_error_function);
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- visitor.visit(m_##snake_name##_constructor); \
- visitor.visit(m_##snake_name##_prototype);
- JS_ENUMERATE_BUILTIN_TYPES
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- visitor.visit(m_intl_##snake_name##_constructor); \
- visitor.visit(m_intl_##snake_name##_prototype);
- JS_ENUMERATE_INTL_OBJECTS
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- visitor.visit(m_temporal_##snake_name##_constructor); \
- visitor.visit(m_temporal_##snake_name##_prototype);
- JS_ENUMERATE_TEMPORAL_OBJECTS
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name) \
- visitor.visit(m_##snake_name##_prototype);
- JS_ENUMERATE_ITERATOR_PROTOTYPES
-#undef __JS_ENUMERATE
+ // Assign intrinsics and functions that depend on the GlobalObject's native functions
+ realm.intrinsics().m_eval_function = &get_without_side_effects(vm.names.eval).as_function();
+ realm.intrinsics().m_number_constructor->define_direct_property(vm.names.parseInt, get_without_side_effects(vm.names.parseInt), attr);
+ realm.intrinsics().m_number_constructor->define_direct_property(vm.names.parseFloat, get_without_side_effects(vm.names.parseFloat), attr);
}
+GlobalObject::~GlobalObject() = default;
+
Realm* GlobalObject::associated_realm()
{
return m_associated_realm;
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.h b/Userland/Libraries/LibJS/Runtime/GlobalObject.h
index ef9a2ae1c2..6222fcba75 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h
@@ -27,86 +27,6 @@ public:
Realm* associated_realm();
void set_associated_realm(Realm&);
- Shape* empty_object_shape() { return m_empty_object_shape; }
-
- Shape* new_object_shape() { return m_new_object_shape; }
- Shape* new_ordinary_function_prototype_object_shape() { return m_new_ordinary_function_prototype_object_shape; }
-
- // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
- ProxyConstructor* proxy_constructor() { return m_proxy_constructor; }
-
- // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
- Object* async_from_sync_iterator_prototype() { return m_async_from_sync_iterator_prototype; }
- Object* async_generator_prototype() { return m_async_generator_prototype; }
- Object* generator_prototype() { return m_generator_prototype; }
-
- // Alias for the AsyncGenerator Prototype Object used by the spec (%AsyncGeneratorFunction.prototype.prototype%)
- Object* async_generator_function_prototype_prototype() { return m_async_generator_prototype; }
- // Alias for the Generator Prototype Object used by the spec (%GeneratorFunction.prototype.prototype%)
- Object* generator_function_prototype_prototype() { return m_generator_prototype; }
-
- // Not included in JS_ENUMERATE_INTL_OBJECTS due to missing distinct constructor
- Object* intl_segments_prototype() { return m_intl_segments_prototype; }
-
- FunctionObject* array_prototype_values_function() const { return m_array_prototype_values_function; }
- FunctionObject* date_constructor_now_function() const { return m_date_constructor_now_function; }
- FunctionObject* eval_function() const { return m_eval_function; }
- FunctionObject* json_parse_function() const { return m_json_parse_function; }
- FunctionObject* object_prototype_to_string_function() const { return m_object_prototype_to_string_function; }
- FunctionObject* throw_type_error_function() const { return m_throw_type_error_function; }
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- ConstructorName* snake_name##_constructor() \
- { \
- return m_##snake_name##_constructor; \
- } \
- Object* snake_name##_prototype() \
- { \
- return m_##snake_name##_prototype; \
- }
- JS_ENUMERATE_BUILTIN_TYPES
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- Intl::ConstructorName* intl_##snake_name##_constructor() \
- { \
- return m_intl_##snake_name##_constructor; \
- } \
- Object* intl_##snake_name##_prototype() \
- { \
- return m_intl_##snake_name##_prototype; \
- }
- JS_ENUMERATE_INTL_OBJECTS
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- Temporal::ConstructorName* temporal_##snake_name##_constructor() \
- { \
- return m_temporal_##snake_name##_constructor; \
- } \
- Object* temporal_##snake_name##_prototype() \
- { \
- return m_temporal_##snake_name##_prototype; \
- }
- JS_ENUMERATE_TEMPORAL_OBJECTS
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name) \
- Object* snake_name##_prototype() \
- { \
- return m_##snake_name##_prototype; \
- }
- JS_ENUMERATE_ITERATOR_PROTOTYPES
-#undef __JS_ENUMERATE
-
-protected:
- virtual void visit_edges(Visitor&) override;
-
- template<typename ConstructorType>
- void initialize_constructor(Realm&, PropertyKey const&, ConstructorType*&, Object* prototype, PropertyAttributes = Attribute::Writable | Attribute::Configurable);
- template<typename ConstructorType>
- void add_constructor(Realm&, PropertyKey const&, ConstructorType*&, Object* prototype);
-
private:
virtual bool is_global_object() const final { return true; }
@@ -124,74 +44,9 @@ private:
JS_DECLARE_NATIVE_FUNCTION(unescape);
NonnullOwnPtr<Console> m_console;
-
WeakPtr<Realm> m_associated_realm;
-
- Shape* m_empty_object_shape { nullptr };
- Shape* m_new_object_shape { nullptr };
- Shape* m_new_ordinary_function_prototype_object_shape { nullptr };
-
- // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
- ProxyConstructor* m_proxy_constructor { nullptr };
-
- // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
- Object* m_async_from_sync_iterator_prototype { nullptr };
- Object* m_async_generator_prototype { nullptr };
- Object* m_generator_prototype { nullptr };
-
- // Not included in JS_ENUMERATE_INTL_OBJECTS due to missing distinct constructor
- Object* m_intl_segments_prototype { nullptr };
-
- FunctionObject* m_array_prototype_values_function { nullptr };
- FunctionObject* m_date_constructor_now_function { nullptr };
- FunctionObject* m_eval_function { nullptr };
- FunctionObject* m_json_parse_function { nullptr };
- FunctionObject* m_object_prototype_to_string_function { nullptr };
- FunctionObject* m_throw_type_error_function { nullptr };
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- ConstructorName* m_##snake_name##_constructor { nullptr }; \
- Object* m_##snake_name##_prototype { nullptr };
- JS_ENUMERATE_BUILTIN_TYPES
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- Intl::ConstructorName* m_intl_##snake_name##_constructor { nullptr }; \
- Object* m_intl_##snake_name##_prototype { nullptr };
- JS_ENUMERATE_INTL_OBJECTS
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- Temporal::ConstructorName* m_temporal_##snake_name##_constructor { nullptr }; \
- Object* m_temporal_##snake_name##_prototype { nullptr };
- JS_ENUMERATE_TEMPORAL_OBJECTS
-#undef __JS_ENUMERATE
-
-#define __JS_ENUMERATE(ClassName, snake_name) \
- Object* m_##snake_name##_prototype { nullptr };
- JS_ENUMERATE_ITERATOR_PROTOTYPES
-#undef __JS_ENUMERATE
};
-template<typename ConstructorType>
-inline void GlobalObject::initialize_constructor(Realm& realm, PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype, PropertyAttributes attributes)
-{
- auto& vm = this->vm();
- constructor = heap().allocate<ConstructorType>(realm, realm);
- constructor->define_direct_property(vm.names.name, js_string(heap(), property_key.as_string()), Attribute::Configurable);
- if (prototype)
- prototype->define_direct_property(vm.names.constructor, constructor, attributes);
-}
-
-template<typename ConstructorType>
-inline void GlobalObject::add_constructor(Realm& realm, PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype)
-{
- // Some constructors are pre-initialized separately.
- if (!constructor)
- initialize_constructor(realm, property_key, constructor, prototype);
- define_direct_property(property_key, constructor, Attribute::Writable | Attribute::Configurable);
-}
-
inline GlobalObject* Shape::global_object() const
{
return &static_cast<GlobalObject&>(m_realm.global_object());
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp
index 18b2eff6da..4f1cb868a2 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp
@@ -17,7 +17,7 @@ CollatorCompareFunction* CollatorCompareFunction::create(Realm& realm, Collator&
}
CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
, m_collator(collator)
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
index 3e0078f861..d6574943e7 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
@@ -131,7 +131,7 @@ static ThrowCompletionOr<Collator*> initialize_collator(VM& vm, Collator& collat
// 10.1 The Intl.Collator Constructor, https://tc39.es/ecma402/#sec-the-intl-collator-constructor
CollatorConstructor::CollatorConstructor(Realm& realm)
- : NativeFunction(vm().names.Collator.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Collator.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -142,7 +142,7 @@ void CollatorConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 10.2.1 Intl.Collator.prototype, https://tc39.es/ecma402/#sec-intl.collator.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_collator_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_collator_prototype(), 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
@@ -171,7 +171,7 @@ ThrowCompletionOr<Object*> CollatorConstructor::construct(FunctionObject& new_ta
// a. Append [[CaseFirst]] as the last element of internalSlotsList.
// 5. Let collator be ? OrdinaryCreateFromConstructor(newTarget, "%Collator.prototype%", internalSlotsList).
- auto* collator = TRY(ordinary_create_from_constructor<Collator>(vm, new_target, &GlobalObject::intl_collator_prototype));
+ auto* collator = TRY(ordinary_create_from_constructor<Collator>(vm, new_target, &Intrinsics::intl_collator_prototype));
// 6. Return ? InitializeCollator(collator, locales, options).
return TRY(initialize_collator(vm, *collator, locales, options));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp
index 467e185c65..78c65fd1f9 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp
@@ -13,7 +13,7 @@ namespace JS::Intl {
// 10.3 Properties of the Intl.Collator Prototype Object, https://tc39.es/ecma402/#sec-properties-of-the-intl-collator-prototype-object
CollatorPrototype::CollatorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -64,7 +64,7 @@ JS_DEFINE_NATIVE_FUNCTION(CollatorPrototype::resolved_options)
auto* collator = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
- auto* options = Object::create(realm, realm.global_object().object_prototype());
+ auto* options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 3, except the header row, in table order, do
// a. Let p be the Property value of the current row.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp
index b5ebf23dca..9737c4d4f3 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp
@@ -545,7 +545,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
auto const& data_locale = date_time_format.data_locale();
auto construct_number_format = [&](auto* options) -> ThrowCompletionOr<NumberFormat*> {
- auto* number_format = TRY(construct(vm, *realm.global_object().intl_number_format_constructor(), js_string(vm, locale), options));
+ auto* number_format = TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, locale), options));
return static_cast<NumberFormat*>(number_format);
};
@@ -861,7 +861,7 @@ ThrowCompletionOr<Array*> format_date_time_to_parts(VM& vm, DateTimeFormat& date
// 4. For each Record { [[Type]], [[Value]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
@@ -1175,7 +1175,7 @@ ThrowCompletionOr<Array*> format_date_time_range_to_parts(VM& vm, DateTimeFormat
// 4. For each Record { [[Type]], [[Value]], [[Source]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%ObjectPrototype%).
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
index cba490fe7e..c514140f41 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
@@ -18,7 +18,7 @@ namespace JS::Intl {
// 11.1 The Intl.DateTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-datetimeformat-constructor
DateTimeFormatConstructor::DateTimeFormatConstructor(Realm& realm)
- : NativeFunction(vm().names.DateTimeFormat.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.DateTimeFormat.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -29,7 +29,7 @@ void DateTimeFormatConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 11.2.1 Intl.DateTimeFormat.prototype, https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_date_time_format_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_date_time_format_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
@@ -53,7 +53,7 @@ ThrowCompletionOr<Object*> DateTimeFormatConstructor::construct(FunctionObject&
auto options = vm.argument(1);
// 2. Let dateTimeFormat be ? OrdinaryCreateFromConstructor(newTarget, "%DateTimeFormat.prototype%", « [[InitializedDateTimeFormat]], [[Locale]], [[Calendar]], [[NumberingSystem]], [[TimeZone]], [[Weekday]], [[Era]], [[Year]], [[Month]], [[Day]], [[DayPeriod]], [[Hour]], [[Minute]], [[Second]], [[FractionalSecondDigits]], [[TimeZoneName]], [[HourCycle]], [[Pattern]], [[BoundFormat]] »).
- auto* date_time_format = TRY(ordinary_create_from_constructor<DateTimeFormat>(vm, new_target, &GlobalObject::intl_date_time_format_prototype));
+ auto* date_time_format = TRY(ordinary_create_from_constructor<DateTimeFormat>(vm, new_target, &Intrinsics::intl_date_time_format_prototype));
// 3. Perform ? InitializeDateTimeFormat(dateTimeFormat, locales, options).
TRY(initialize_date_time_format(vm, *date_time_format, locales, options));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp
index e796859c76..86acca212c 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp
@@ -16,7 +16,7 @@ namespace JS::Intl {
// 11.5.5 DateTime Format Functions, https://tc39.es/ecma402/#sec-datetime-format-functions
DateTimeFormatFunction* DateTimeFormatFunction::create(Realm& realm, DateTimeFormat& date_time_format)
{
- return realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, *realm.global_object().function_prototype());
+ return realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, *realm.intrinsics().function_prototype());
}
DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype)
@@ -49,7 +49,7 @@ ThrowCompletionOr<Value> DateTimeFormatFunction::call()
// 3. If date is not provided or is undefined, then
if (date.is_undefined()) {
// a. Let x be ! Call(%Date.now%, undefined).
- date_value = MUST(JS::call(vm, realm.global_object().date_constructor_now_function(), js_undefined())).as_double();
+ date_value = MUST(JS::call(vm, realm.intrinsics().date_constructor_now_function(), js_undefined())).as_double();
}
// 4. Else,
else {
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp
index 19818edda7..a1edbedcff 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 11.3 Properties of the Intl.DateTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-datetimeformat-prototype-object
DateTimeFormatPrototype::DateTimeFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -78,7 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_to_parts)
// 3. If date is undefined, then
if (date.is_undefined()) {
// a. Let x be ! Call(%Date.now%, undefined).
- date_value = MUST(call(vm, realm.global_object().date_constructor_now_function(), js_undefined())).as_double();
+ date_value = MUST(call(vm, realm.intrinsics().date_constructor_now_function(), js_undefined())).as_double();
}
// 4. Else,
else {
@@ -155,7 +155,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options)
auto* date_time_format = TRY(typed_this_object(vm));
// 4. Let options be OrdinaryObjectCreate(%Object.prototype%).
- auto* options = Object::create(realm, realm.global_object().object_prototype());
+ auto* options = Object::create(realm, realm.intrinsics().object_prototype());
// 5. For each row of Table 5, except the header row, in table order, do
// a. Let p be the Property value of the current row.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp
index 27ab0c78b5..7eb1d42759 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp
@@ -115,7 +115,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(VM& vm, DisplayNames::
return vm.throw_completion<RangeError>(ErrorType::IntlInvalidLanguageTag, code);
// c. Return ! CanonicalizeUnicodeLocaleId(code).
- auto canonicalized_tag = Intl::canonicalize_unicode_locale_id(*locale_id);
+ auto canonicalized_tag = JS::Intl::canonicalize_unicode_locale_id(*locale_id);
return js_string(vm, move(canonicalized_tag));
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
index 23639a2748..1e8d0d508c 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
@@ -17,7 +17,7 @@ namespace JS::Intl {
// 12.1 The Intl.DisplayNames Constructor, https://tc39.es/ecma402/#sec-intl-displaynames-constructor
DisplayNamesConstructor::DisplayNamesConstructor(Realm& realm)
- : NativeFunction(vm().names.DisplayNames.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.DisplayNames.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -28,7 +28,7 @@ void DisplayNamesConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 12.2.1 Intl.DisplayNames.prototype, https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_display_names_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_display_names_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
@@ -52,7 +52,7 @@ ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& ne
auto options_value = vm.argument(1);
// 2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNames.prototype%", « [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[LanguageDisplay]], [[Fields]] »).
- auto* display_names = TRY(ordinary_create_from_constructor<DisplayNames>(vm, new_target, &GlobalObject::intl_display_names_prototype));
+ auto* display_names = TRY(ordinary_create_from_constructor<DisplayNames>(vm, new_target, &Intrinsics::intl_display_names_prototype));
// 3. Let requestedLocales be ? CanonicalizeLocaleList(locales).
auto requested_locales = TRY(canonicalize_locale_list(vm, locale_value));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
index e1a695c32c..3d8bf33511 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 12.3 Properties of the Intl.DisplayNames Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-displaynames-prototype-object
DisplayNamesPrototype::DisplayNamesPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -131,7 +131,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
auto* display_names = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
- auto* options = Object::create(realm, realm.global_object().object_prototype());
+ auto* options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 8, except the header row, in table order, do
// a. Let p be the Property value of the current row.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
index aa87496f48..83d3aa1a0e 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
@@ -402,7 +402,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(VM
}
// o. Let nf be ? Construct(%NumberFormat%, « durationFormat.[[Locale]], nfOpts »).
- auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, *realm.global_object().intl_number_format_constructor(), js_string(vm, duration_format.locale()), number_format_options)));
+ auto* number_format = static_cast<NumberFormat*>(TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, duration_format.locale()), number_format_options)));
// FIXME: durationFormat.[[NumberFormat]] is not a thing, the spec likely means 'nf' in this case
// p. Let num be ! FormatNumeric(durationFormat.[[NumberFormat]], value).
@@ -431,7 +431,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(VM
// t. Else,
else {
// i. Let pr be ? Construct(%PluralRules%, « durationFormat.[[Locale]] »).
- auto* plural_rules = TRY(construct(vm, *realm.global_object().intl_plural_rules_constructor(), js_string(vm, duration_format.locale())));
+ auto* plural_rules = TRY(construct(vm, *realm.intrinsics().intl_plural_rules_constructor(), js_string(vm, duration_format.locale())));
// ii. Let prv be ! ResolvePlural(pr, value).
auto plurality = resolve_plural(static_cast<PluralRules&>(*plural_rules), value);
@@ -479,7 +479,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(VM
}
// 3. Let lf be ? Construct(%ListFormat%, « durationFormat.[[Locale]] »).
- auto* list_format = static_cast<Intl::ListFormat*>(TRY(construct(vm, *realm.global_object().intl_list_format_constructor(), js_string(vm, duration_format.locale()))));
+ auto* list_format = static_cast<ListFormat*>(TRY(construct(vm, *realm.intrinsics().intl_list_format_constructor(), js_string(vm, duration_format.locale()))));
// FIXME: CreatePartsFromList expects a list of strings and creates a list of Pattern Partition records, but we already created a list of Pattern Partition records
// so we try to hack something together from it that looks mostly right
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
index 25ad59d859..435159b43b 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 1.2 The Intl.DurationFormat Constructor, https://tc39.es/proposal-intl-duration-format/#sec-intl-durationformat-constructor
DurationFormatConstructor::DurationFormatConstructor(Realm& realm)
- : NativeFunction(vm().names.DurationFormat.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.DurationFormat.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -26,7 +26,7 @@ void DurationFormatConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 1.3.1 Intl.DurationFormat.prototype, https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_duration_format_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_duration_format_prototype(), 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
@@ -49,7 +49,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
auto options_value = vm.argument(1);
// 2. Let durationFormat be ? OrdinaryCreateFromConstructor(NewTarget, "%DurationFormatPrototype%", « [[InitializedDurationFormat]], [[Locale]], [[DataLocale]], [[NumberingSystem]], [[Style]], [[YearsStyle]], [[YearsDisplay]], [[MonthsStyle]], [[MonthsDisplay]] , [[WeeksStyle]], [[WeeksDisplay]] , [[DaysStyle]], [[DaysDisplay]] , [[HoursStyle]], [[HoursDisplay]] , [[MinutesStyle]], [[MinutesDisplay]] , [[SecondsStyle]], [[SecondsDisplay]] , [[MillisecondsStyle]], [[MillisecondsDisplay]] , [[MicrosecondsStyle]], [[MicrosecondsDisplay]] , [[NanosecondsStyle]], [[NanosecondsDisplay]], [[FractionalDigits]] »).
- auto* duration_format = TRY(ordinary_create_from_constructor<DurationFormat>(vm, new_target, &GlobalObject::intl_duration_format_prototype));
+ auto* duration_format = TRY(ordinary_create_from_constructor<DurationFormat>(vm, new_target, &Intrinsics::intl_duration_format_prototype));
// 3. Let requestedLocales be ? CanonicalizeLocaleList(locales).
auto requested_locales = TRY(canonicalize_locale_list(vm, locales));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp
index 620e632920..2ebb5f178d 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp
@@ -12,7 +12,7 @@ namespace JS::Intl {
// 1.4 Properties of the Intl.DurationFormat Prototype Object, https://tc39.es/proposal-intl-duration-format/#sec-properties-of-intl-durationformat-prototype-object
DurationFormatPrototype::DurationFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -89,7 +89,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format_to_parts)
auto const& part = formatted[n];
// a. Let obj be ! OrdinaryObjectCreate(%ObjectPrototype%).
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(obj, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
@@ -117,7 +117,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::resolved_options)
auto* duration_format = TRY(typed_this_object(vm));
// 3. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
- auto* options = Object::create(realm, realm.global_object().object_prototype());
+ auto* options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 2, except the header row, in table order, do
// a. Let p be the Property value of the current row.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp
index 23db1e7bd0..776da44fc4 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp
@@ -29,7 +29,7 @@ namespace JS::Intl {
// 8 The Intl Object, https://tc39.es/ecma402/#intl-object
Intl::Intl(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
@@ -43,16 +43,16 @@ void Intl::initialize(Realm& realm)
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl"), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
- define_direct_property(vm.names.Collator, realm.global_object().intl_collator_constructor(), attr);
- define_direct_property(vm.names.DateTimeFormat, realm.global_object().intl_date_time_format_constructor(), attr);
- define_direct_property(vm.names.DisplayNames, realm.global_object().intl_display_names_constructor(), attr);
- define_direct_property(vm.names.DurationFormat, realm.global_object().intl_duration_format_constructor(), attr);
- define_direct_property(vm.names.ListFormat, realm.global_object().intl_list_format_constructor(), attr);
- define_direct_property(vm.names.Locale, realm.global_object().intl_locale_constructor(), attr);
- define_direct_property(vm.names.NumberFormat, realm.global_object().intl_number_format_constructor(), attr);
- define_direct_property(vm.names.PluralRules, realm.global_object().intl_plural_rules_constructor(), attr);
- define_direct_property(vm.names.RelativeTimeFormat, realm.global_object().intl_relative_time_format_constructor(), attr);
- define_direct_property(vm.names.Segmenter, realm.global_object().intl_segmenter_constructor(), attr);
+ define_direct_property(vm.names.Collator, realm.intrinsics().intl_collator_constructor(), attr);
+ define_direct_property(vm.names.DateTimeFormat, realm.intrinsics().intl_date_time_format_constructor(), attr);
+ define_direct_property(vm.names.DisplayNames, realm.intrinsics().intl_display_names_constructor(), attr);
+ define_direct_property(vm.names.DurationFormat, realm.intrinsics().intl_duration_format_constructor(), attr);
+ define_direct_property(vm.names.ListFormat, realm.intrinsics().intl_list_format_constructor(), attr);
+ define_direct_property(vm.names.Locale, realm.intrinsics().intl_locale_constructor(), attr);
+ define_direct_property(vm.names.NumberFormat, realm.intrinsics().intl_number_format_constructor(), attr);
+ define_direct_property(vm.names.PluralRules, realm.intrinsics().intl_plural_rules_constructor(), attr);
+ define_direct_property(vm.names.RelativeTimeFormat, realm.intrinsics().intl_relative_time_format_constructor(), attr);
+ define_direct_property(vm.names.Segmenter, realm.intrinsics().intl_segmenter_constructor(), attr);
define_native_function(realm, vm.names.getCanonicalLocales, get_canonical_locales, 1, attr);
define_native_function(realm, vm.names.supportedValuesOf, supported_values_of, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp
index 5401ebd3fc..1a9d309168 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp
@@ -217,7 +217,7 @@ Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<String
// 4. For each Record { [[Type]], [[Value]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
index 4fff63e226..736db6606d 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
@@ -16,7 +16,7 @@ namespace JS::Intl {
// 13.1 The Intl.ListFormat Constructor, https://tc39.es/ecma402/#sec-intl-listformat-constructor
ListFormatConstructor::ListFormatConstructor(Realm& realm)
- : NativeFunction(vm().names.ListFormat.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.ListFormat.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -27,7 +27,7 @@ void ListFormatConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 13.2.1 Intl.ListFormat.prototype, https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_list_format_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_list_format_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
@@ -51,7 +51,7 @@ ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_
auto options_value = vm.argument(1);
// 2. Let listFormat be ? OrdinaryCreateFromConstructor(NewTarget, "%ListFormat.prototype%", « [[InitializedListFormat]], [[Locale]], [[Type]], [[Style]], [[Templates]] »).
- auto* list_format = TRY(ordinary_create_from_constructor<ListFormat>(vm, new_target, &GlobalObject::intl_list_format_prototype));
+ auto* list_format = TRY(ordinary_create_from_constructor<ListFormat>(vm, new_target, &Intrinsics::intl_list_format_prototype));
// 3. Let requestedLocales be ? CanonicalizeLocaleList(locales).
auto requested_locales = TRY(canonicalize_locale_list(vm, locale_value));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp
index 5368c75a42..0e9a563c22 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp
@@ -14,7 +14,7 @@ namespace JS::Intl {
// 13.3 Properties of the Intl.ListFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object
ListFormatPrototype::ListFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -76,7 +76,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
auto* list_format = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
- auto* options = Object::create(realm, realm.global_object().object_prototype());
+ auto* options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 10, except the header row, in table order, do
// a. Let p be the Property value of the current row.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp
index c3ebe6d052..19aef1ed8c 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp
@@ -16,7 +16,7 @@ namespace JS::Intl {
Locale* Locale::create(Realm& realm, Unicode::LocaleID const& locale_id)
{
- return realm.heap().allocate<Locale>(realm, locale_id, *realm.global_object().intl_locale_prototype());
+ return realm.heap().allocate<Locale>(realm, locale_id, *realm.intrinsics().intl_locale_prototype());
}
// 14 Locale Objects, https://tc39.es/ecma402/#locale-objects
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
index 4af821bdbc..c754f6a426 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
@@ -65,7 +65,7 @@ static ThrowCompletionOr<String> apply_options_to_tag(VM& vm, StringView tag, Ob
auto region = TRY(get_string_option(vm, options, vm.names.region, Unicode::is_unicode_region_subtag));
// 10. Set tag to ! CanonicalizeUnicodeLocaleId(tag).
- auto canonicalized_tag = Intl::canonicalize_unicode_locale_id(*locale_id);
+ auto canonicalized_tag = JS::Intl::canonicalize_unicode_locale_id(*locale_id);
// 11. Assert: tag matches the unicode_locale_id production.
locale_id = Unicode::parse_unicode_locale_id(canonicalized_tag);
@@ -217,7 +217,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
// 14.1 The Intl.Locale Constructor, https://tc39.es/ecma402/#sec-intl-locale-constructor
LocaleConstructor::LocaleConstructor(Realm& realm)
- : NativeFunction(vm().names.Locale.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Locale.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -228,7 +228,7 @@ void LocaleConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 14.2.1 Intl.Locale.prototype, https://tc39.es/ecma402/#sec-Intl.Locale.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_locale_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_locale_prototype(), 0);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
}
@@ -257,7 +257,7 @@ ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_targ
// a. Append [[Numeric]] as the last element of internalSlotsList.
// 6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, "%Locale.prototype%", internalSlotsList).
- auto* locale = TRY(ordinary_create_from_constructor<Locale>(vm, new_target, &GlobalObject::intl_locale_prototype));
+ auto* locale = TRY(ordinary_create_from_constructor<Locale>(vm, new_target, &Intrinsics::intl_locale_prototype));
String tag;
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
index 4408032d8c..0a48452eb7 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 14.3 Properties of the Intl.Locale Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-locale-prototype-object
LocalePrototype::LocalePrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -258,7 +258,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::text_info)
auto* locale_object = TRY(typed_this_object(vm));
// 3. Let info be ! ObjectCreate(%Object.prototype%).
- auto* info = Object::create(realm, realm.global_object().object_prototype());
+ auto* info = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Let dir be ! CharacterDirectionOfLocale(loc).
auto direction = character_direction_of_locale(*locale_object);
@@ -280,7 +280,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::week_info)
[[maybe_unused]] auto* locale_object = TRY(typed_this_object(vm));
// 3. Let info be ! ObjectCreate(%Object.prototype%).
- auto* info = Object::create(realm, realm.global_object().object_prototype());
+ auto* info = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Let wi be ! WeekInfoOfLocale(loc).
auto week_info = week_info_of_locale(*locale_object);
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp
index 23ad1c2be2..ec1bd9e182 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp
@@ -922,7 +922,7 @@ Array* format_numeric_to_parts(VM& vm, NumberFormat& number_format, Mathematical
// 4. For each Record { [[Type]], [[Value]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
@@ -1837,7 +1837,7 @@ ThrowCompletionOr<Array*> format_numeric_range_to_parts(VM& vm, NumberFormat& nu
// 4. For each Record { [[Type]], [[Value]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
index 9c4df7ca91..92323acc1f 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 15.1 The Intl.NumberFormat Constructor, https://tc39.es/ecma402/#sec-intl-numberformat-constructor
NumberFormatConstructor::NumberFormatConstructor(Realm& realm)
- : NativeFunction(vm().names.NumberFormat.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.NumberFormat.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -26,7 +26,7 @@ void NumberFormatConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 15.2.1 Intl.NumberFormat.prototype, https://tc39.es/ecma402/#sec-intl.numberformat.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_number_format_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_number_format_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
@@ -50,7 +50,7 @@ ThrowCompletionOr<Object*> NumberFormatConstructor::construct(FunctionObject& ne
auto options = vm.argument(1);
// 2. Let numberFormat be ? OrdinaryCreateFromConstructor(newTarget, "%NumberFormat.prototype%", « [[InitializedNumberFormat]], [[Locale]], [[DataLocale]], [[NumberingSystem]], [[Style]], [[Unit]], [[UnitDisplay]], [[Currency]], [[CurrencyDisplay]], [[CurrencySign]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[Notation]], [[CompactDisplay]], [[UseGrouping]], [[SignDisplay]], [[BoundFormat]] »).
- auto* number_format = TRY(ordinary_create_from_constructor<NumberFormat>(vm, new_target, &GlobalObject::intl_number_format_prototype));
+ auto* number_format = TRY(ordinary_create_from_constructor<NumberFormat>(vm, new_target, &Intrinsics::intl_number_format_prototype));
// 3. Perform ? InitializeNumberFormat(numberFormat, locales, options).
TRY(initialize_number_format(vm, *number_format, locales, options));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp
index 2bd13528d5..2d434de3a9 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp
@@ -14,7 +14,7 @@ namespace JS::Intl {
// 1.1.4 Number Format Functions, https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-number-format-functions
NumberFormatFunction* NumberFormatFunction::create(Realm& realm, NumberFormat& number_format)
{
- return realm.heap().allocate<NumberFormatFunction>(realm, number_format, *realm.global_object().function_prototype());
+ return realm.heap().allocate<NumberFormatFunction>(realm, number_format, *realm.intrinsics().function_prototype());
}
NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp
index f3fafaf2a0..403d8b5f53 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 15.3 Properties of the Intl.NumberFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-prototype-object
NumberFormatPrototype::NumberFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -145,7 +145,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
auto* number_format = TRY(typed_this_object(vm));
// 4. Let options be OrdinaryObjectCreate(%Object.prototype%).
- auto* options = Object::create(realm, realm.global_object().object_prototype());
+ auto* options = Object::create(realm, realm.intrinsics().object_prototype());
// 5. For each row of Table 11, except the header row, in table order, do
// a. Let p be the Property value of the current row.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
index aa301d0788..b0dec35b96 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
@@ -17,7 +17,7 @@ namespace JS::Intl {
// 16.1 The Intl.PluralRules Constructor, https://tc39.es/ecma402/#sec-intl-pluralrules-constructor
PluralRulesConstructor::PluralRulesConstructor(Realm& realm)
- : NativeFunction(vm().names.PluralRules.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.PluralRules.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -28,7 +28,7 @@ void PluralRulesConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 16.2.1 Intl.PluralRules.prototype, https://tc39.es/ecma402/#sec-intl.pluralrules.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_plural_rules_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_plural_rules_prototype(), 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
@@ -51,7 +51,7 @@ ThrowCompletionOr<Object*> PluralRulesConstructor::construct(FunctionObject& new
auto options = vm.argument(1);
// 2. Let pluralRules be ? OrdinaryCreateFromConstructor(NewTarget, "%PluralRules.prototype%", « [[InitializedPluralRules]], [[Locale]], [[Type]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]] »).
- auto* plural_rules = TRY(ordinary_create_from_constructor<PluralRules>(vm, new_target, &GlobalObject::intl_plural_rules_prototype));
+ auto* plural_rules = TRY(ordinary_create_from_constructor<PluralRules>(vm, new_target, &Intrinsics::intl_plural_rules_prototype));
// 3. Return ? InitializePluralRules(pluralRules, locales, options).
return TRY(initialize_plural_rules(vm, *plural_rules, locales, options));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp
index 5245d708a5..66f51d233a 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp
@@ -14,7 +14,7 @@ namespace JS::Intl {
// 16.3 Properties of the Intl.PluralRules Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-pluralrules-prototype-object
PluralRulesPrototype::PluralRulesPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -86,7 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options)
auto* plural_rules = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
- auto* options = Object::create(realm, realm.global_object().object_prototype());
+ auto* options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 13, except the header row, in table order, do
// a. Let p be the Property value of the current row.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp
index 96fac8169a..3781b84ccd 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp
@@ -257,7 +257,7 @@ ThrowCompletionOr<Array*> format_relative_time_to_parts(VM& vm, RelativeTimeForm
// 4. For each Record { [[Type]], [[Value]], [[Unit]] } part in parts, do
for (auto& part : parts) {
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
index 9896a1b62a..4308395f2a 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
@@ -20,7 +20,7 @@ namespace JS::Intl {
// 17.1 The Intl.RelativeTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor
RelativeTimeFormatConstructor::RelativeTimeFormatConstructor(Realm& realm)
- : NativeFunction(vm().names.RelativeTimeFormat.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.RelativeTimeFormat.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -31,7 +31,7 @@ void RelativeTimeFormatConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 17.2.1 Intl.RelativeTimeFormat.prototype, https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_relative_time_format_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_relative_time_format_prototype(), 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
@@ -54,7 +54,7 @@ ThrowCompletionOr<Object*> RelativeTimeFormatConstructor::construct(FunctionObje
auto options = vm.argument(1);
// 2. Let relativeTimeFormat be ? OrdinaryCreateFromConstructor(NewTarget, "%RelativeTimeFormat.prototype%", « [[InitializedRelativeTimeFormat]], [[Locale]], [[DataLocale]], [[Style]], [[Numeric]], [[NumberFormat]], [[NumberingSystem]], [[PluralRules]] »).
- auto* relative_time_format = TRY(ordinary_create_from_constructor<RelativeTimeFormat>(vm, new_target, &GlobalObject::intl_relative_time_format_prototype));
+ auto* relative_time_format = TRY(ordinary_create_from_constructor<RelativeTimeFormat>(vm, new_target, &Intrinsics::intl_relative_time_format_prototype));
// 3. Return ? InitializeRelativeTimeFormat(relativeTimeFormat, locales, options).
return TRY(initialize_relative_time_format(vm, *relative_time_format, locales, options));
@@ -138,11 +138,11 @@ ThrowCompletionOr<RelativeTimeFormat*> initialize_relative_time_format(VM& vm, R
relative_time_format.set_numeric(numeric.as_string().string());
// 19. Let relativeTimeFormat.[[NumberFormat]] be ! Construct(%NumberFormat%, « locale »).
- auto* number_format = MUST(construct(vm, *realm.global_object().intl_number_format_constructor(), js_string(vm, locale)));
+ auto* number_format = MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, locale)));
relative_time_format.set_number_format(static_cast<NumberFormat*>(number_format));
// 20. Let relativeTimeFormat.[[PluralRules]] be ! Construct(%PluralRules%, « locale »).
- auto* plural_rules = MUST(construct(vm, *realm.global_object().intl_plural_rules_constructor(), js_string(vm, locale)));
+ auto* plural_rules = MUST(construct(vm, *realm.intrinsics().intl_plural_rules_constructor(), js_string(vm, locale)));
relative_time_format.set_plural_rules(static_cast<PluralRules*>(plural_rules));
// 21. Return relativeTimeFormat.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp
index 583d011513..21ab4500e8 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp
@@ -12,7 +12,7 @@ namespace JS::Intl {
// 17.3 Properties of the Intl.RelativeTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-relativetimeformat-prototype-object
RelativeTimeFormatPrototype::RelativeTimeFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -76,7 +76,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::resolved_options)
auto* relative_time_format = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
- auto* options = Object::create(realm, realm.global_object().object_prototype());
+ auto* options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 15, except the header row, in table order, do
// a. Let p be the Property value of the current row.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp
index a24ce1a082..ecba77b752 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp
@@ -24,7 +24,7 @@ SegmentIterator* SegmentIterator::create(Realm& realm, Segmenter& segmenter, Utf
// 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects
SegmentIterator::SegmentIterator(Realm& realm, Segmenter& segmenter, Utf16View const& string, Segments const& segments)
- : Object(*realm.global_object().intl_segment_iterator_prototype())
+ : Object(*realm.intrinsics().intl_segment_iterator_prototype())
, m_iterating_segmenter(segmenter)
, m_iterated_string(string)
, m_segments(segments)
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp
index cdafeeb66e..9854ee7314 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp
@@ -14,7 +14,7 @@ namespace JS::Intl {
// 18.6.2 The %SegmentIteratorPrototype% Object, https://tc39.es/ecma402/#sec-%segmentiteratorprototype%-object
SegmentIteratorPrototype::SegmentIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().iterator_prototype())
+ : PrototypeObject(*realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.cpp
index 6bfaa33655..0323aceb6c 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.cpp
@@ -62,7 +62,7 @@ Object* create_segment_data_object(VM& vm, Segmenter const& segmenter, Utf16View
VERIFY(start_index < end_index);
// 5. Let result be OrdinaryObjectCreate(%Object.prototype%).
- auto* result = Object::create(realm, realm.global_object().object_prototype());
+ auto* result = Object::create(realm, realm.intrinsics().object_prototype());
// 6. Let segment be the substring of string from startIndex to endIndex.
auto segment = string.substring_view(start_index, end_index - start_index);
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
index e10e8760d0..1fe7d8b8fa 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
@@ -16,7 +16,7 @@ namespace JS::Intl {
// 18.1 The Intl.Segmenter Constructor, https://tc39.es/ecma402/#sec-intl-segmenter-constructor
SegmenterConstructor::SegmenterConstructor(Realm& realm)
- : NativeFunction(vm().names.Segmenter.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Segmenter.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -27,7 +27,7 @@ void SegmenterConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 18.2.1 Intl.Segmenter.prototype, https://tc39.es/ecma402/#sec-intl.segmenter.prototype
- define_direct_property(vm.names.prototype, realm.global_object().intl_segmenter_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().intl_segmenter_prototype(), 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
@@ -51,7 +51,7 @@ ThrowCompletionOr<Object*> SegmenterConstructor::construct(FunctionObject& new_t
// 2. Let internalSlotsList be « [[InitializedSegmenter]], [[Locale]], [[SegmenterGranularity]] ».
// 3. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%Segmenter.prototype%", internalSlotsList).
- auto* segmenter = TRY(ordinary_create_from_constructor<Segmenter>(vm, new_target, &GlobalObject::intl_segmenter_prototype));
+ auto* segmenter = TRY(ordinary_create_from_constructor<Segmenter>(vm, new_target, &Intrinsics::intl_segmenter_prototype));
// 4. Let requestedLocales be ? CanonicalizeLocaleList(locales).
auto requested_locales = TRY(canonicalize_locale_list(vm, locales));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp
index a883115b6b..a0fd1e7bce 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp
@@ -13,7 +13,7 @@ namespace JS::Intl {
// 18.3 Properties of the Intl.Segmenter Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-segmenter-prototype-object
SegmenterPrototype::SegmenterPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -41,7 +41,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::resolved_options)
auto* segmenter = TRY(typed_this_object(vm));
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
- auto* options = Object::create(realm, realm.global_object().object_prototype());
+ auto* options = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each row of Table 16, except the header row, in table order, do
// a. Let p be the Property value of the current row.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp
index 4ea60d6565..e3bc76f843 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp
@@ -23,7 +23,7 @@ Segments* Segments::create(Realm& realm, Segmenter& segmenter, Utf16String strin
// 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects
Segments::Segments(Realm& realm, Segmenter& segmenter, Utf16String string)
- : Object(*realm.global_object().intl_segments_prototype())
+ : Object(*realm.intrinsics().intl_segments_prototype())
, m_segments_segmenter(segmenter)
, m_segments_string(move(string))
{
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp
index aa59db6850..aba326ecfb 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp
@@ -13,7 +13,7 @@ namespace JS::Intl {
// 18.5.2 The %SegmentsPrototype% Object, https://tc39.es/ecma402/#sec-%segmentsprototype%-object
SegmentsPrototype::SegmentsPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
new file mode 100644
index 0000000000..c7ae6642ac
--- /dev/null
+++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibJS/Runtime/AggregateErrorConstructor.h>
+#include <LibJS/Runtime/AggregateErrorPrototype.h>
+#include <LibJS/Runtime/ArrayBufferConstructor.h>
+#include <LibJS/Runtime/ArrayBufferPrototype.h>
+#include <LibJS/Runtime/ArrayConstructor.h>
+#include <LibJS/Runtime/ArrayIteratorPrototype.h>
+#include <LibJS/Runtime/ArrayPrototype.h>
+#include <LibJS/Runtime/AsyncFromSyncIteratorPrototype.h>
+#include <LibJS/Runtime/AsyncFunctionConstructor.h>
+#include <LibJS/Runtime/AsyncFunctionPrototype.h>
+#include <LibJS/Runtime/AsyncGeneratorFunctionConstructor.h>
+#include <LibJS/Runtime/AsyncGeneratorFunctionPrototype.h>
+#include <LibJS/Runtime/AsyncGeneratorPrototype.h>
+#include <LibJS/Runtime/AsyncIteratorPrototype.h>
+#include <LibJS/Runtime/AtomicsObject.h>
+#include <LibJS/Runtime/BigIntConstructor.h>
+#include <LibJS/Runtime/BigIntPrototype.h>
+#include <LibJS/Runtime/BooleanConstructor.h>
+#include <LibJS/Runtime/BooleanPrototype.h>
+#include <LibJS/Runtime/DataViewConstructor.h>
+#include <LibJS/Runtime/DataViewPrototype.h>
+#include <LibJS/Runtime/DateConstructor.h>
+#include <LibJS/Runtime/DatePrototype.h>
+#include <LibJS/Runtime/ErrorConstructor.h>
+#include <LibJS/Runtime/ErrorPrototype.h>
+#include <LibJS/Runtime/FinalizationRegistryConstructor.h>
+#include <LibJS/Runtime/FinalizationRegistryPrototype.h>
+#include <LibJS/Runtime/FunctionConstructor.h>
+#include <LibJS/Runtime/FunctionPrototype.h>
+#include <LibJS/Runtime/GeneratorFunctionConstructor.h>
+#include <LibJS/Runtime/GeneratorFunctionPrototype.h>
+#include <LibJS/Runtime/GeneratorPrototype.h>
+#include <LibJS/Runtime/Intl/CollatorConstructor.h>
+#include <LibJS/Runtime/Intl/CollatorPrototype.h>
+#include <LibJS/Runtime/Intl/DateTimeFormatConstructor.h>
+#include <LibJS/Runtime/Intl/DateTimeFormatPrototype.h>
+#include <LibJS/Runtime/Intl/DisplayNamesConstructor.h>
+#include <LibJS/Runtime/Intl/DisplayNamesPrototype.h>
+#include <LibJS/Runtime/Intl/DurationFormatConstructor.h>
+#include <LibJS/Runtime/Intl/DurationFormatPrototype.h>
+#include <LibJS/Runtime/Intl/Intl.h>
+#include <LibJS/Runtime/Intl/ListFormatConstructor.h>
+#include <LibJS/Runtime/Intl/ListFormatPrototype.h>
+#include <LibJS/Runtime/Intl/LocaleConstructor.h>
+#include <LibJS/Runtime/Intl/LocalePrototype.h>
+#include <LibJS/Runtime/Intl/NumberFormatConstructor.h>
+#include <LibJS/Runtime/Intl/NumberFormatPrototype.h>
+#include <LibJS/Runtime/Intl/PluralRulesConstructor.h>
+#include <LibJS/Runtime/Intl/PluralRulesPrototype.h>
+#include <LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h>
+#include <LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h>
+#include <LibJS/Runtime/Intl/SegmentIteratorPrototype.h>
+#include <LibJS/Runtime/Intl/SegmenterConstructor.h>
+#include <LibJS/Runtime/Intl/SegmenterPrototype.h>
+#include <LibJS/Runtime/Intl/SegmentsPrototype.h>
+#include <LibJS/Runtime/Intrinsics.h>
+#include <LibJS/Runtime/IteratorPrototype.h>
+#include <LibJS/Runtime/JSONObject.h>
+#include <LibJS/Runtime/MapConstructor.h>
+#include <LibJS/Runtime/MapIteratorPrototype.h>
+#include <LibJS/Runtime/MapPrototype.h>
+#include <LibJS/Runtime/MathObject.h>
+#include <LibJS/Runtime/NativeFunction.h>
+#include <LibJS/Runtime/NumberConstructor.h>
+#include <LibJS/Runtime/NumberPrototype.h>
+#include <LibJS/Runtime/ObjectConstructor.h>
+#include <LibJS/Runtime/ObjectPrototype.h>
+#include <LibJS/Runtime/PromiseConstructor.h>
+#include <LibJS/Runtime/PromisePrototype.h>
+#include <LibJS/Runtime/ProxyConstructor.h>
+#include <LibJS/Runtime/Realm.h>
+#include <LibJS/Runtime/ReflectObject.h>
+#include <LibJS/Runtime/RegExpConstructor.h>
+#include <LibJS/Runtime/RegExpPrototype.h>
+#include <LibJS/Runtime/RegExpStringIteratorPrototype.h>
+#include <LibJS/Runtime/SetConstructor.h>
+#include <LibJS/Runtime/SetIteratorPrototype.h>
+#include <LibJS/Runtime/SetPrototype.h>
+#include <LibJS/Runtime/ShadowRealmConstructor.h>
+#include <LibJS/Runtime/ShadowRealmPrototype.h>
+#include <LibJS/Runtime/Shape.h>
+#include <LibJS/Runtime/StringConstructor.h>
+#include <LibJS/Runtime/StringIteratorPrototype.h>
+#include <LibJS/Runtime/StringPrototype.h>
+#include <LibJS/Runtime/SymbolConstructor.h>
+#include <LibJS/Runtime/SymbolPrototype.h>
+#include <LibJS/Runtime/Temporal/CalendarConstructor.h>
+#include <LibJS/Runtime/Temporal/CalendarPrototype.h>
+#include <LibJS/Runtime/Temporal/DurationConstructor.h>
+#include <LibJS/Runtime/Temporal/DurationPrototype.h>
+#include <LibJS/Runtime/Temporal/InstantConstructor.h>
+#include <LibJS/Runtime/Temporal/InstantPrototype.h>
+#include <LibJS/Runtime/Temporal/PlainDateConstructor.h>
+#include <LibJS/Runtime/Temporal/PlainDatePrototype.h>
+#include <LibJS/Runtime/Temporal/PlainDateTimeConstructor.h>
+#include <LibJS/Runtime/Temporal/PlainDateTimePrototype.h>
+#include <LibJS/Runtime/Temporal/PlainMonthDayConstructor.h>
+#include <LibJS/Runtime/Temporal/PlainMonthDayPrototype.h>
+#include <LibJS/Runtime/Temporal/PlainTimeConstructor.h>
+#include <LibJS/Runtime/Temporal/PlainTimePrototype.h>
+#include <LibJS/Runtime/Temporal/PlainYearMonthConstructor.h>
+#include <LibJS/Runtime/Temporal/PlainYearMonthPrototype.h>
+#include <LibJS/Runtime/Temporal/Temporal.h>
+#include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
+#include <LibJS/Runtime/Temporal/TimeZonePrototype.h>
+#include <LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h>
+#include <LibJS/Runtime/Temporal/ZonedDateTimePrototype.h>
+#include <LibJS/Runtime/TypedArray.h>
+#include <LibJS/Runtime/TypedArrayConstructor.h>
+#include <LibJS/Runtime/TypedArrayPrototype.h>
+#include <LibJS/Runtime/WeakMapConstructor.h>
+#include <LibJS/Runtime/WeakMapPrototype.h>
+#include <LibJS/Runtime/WeakRefConstructor.h>
+#include <LibJS/Runtime/WeakRefPrototype.h>
+#include <LibJS/Runtime/WeakSetConstructor.h>
+#include <LibJS/Runtime/WeakSetPrototype.h>
+
+namespace JS {
+
+static void initialize_constructor(VM& vm, PropertyKey const& property_key, Object& constructor, Object* prototype, PropertyAttributes constructor_property_attributes = Attribute::Writable | Attribute::Configurable)
+{
+ constructor.define_direct_property(vm.names.name, js_string(vm, property_key.as_string()), Attribute::Configurable);
+ if (prototype)
+ prototype->define_direct_property(vm.names.constructor, &constructor, constructor_property_attributes);
+}
+
+// 9.3.2 CreateIntrinsics ( realmRec ), https://tc39.es/ecma262/#sec-createintrinsics
+Intrinsics* Intrinsics::create(Realm& realm)
+{
+ auto& vm = realm.vm();
+
+ // 1. Set realmRec.[[Intrinsics]] to a new Record.
+ auto* intrinsics = vm.heap().allocate_without_realm<Intrinsics>();
+ realm.set_intrinsics({}, *intrinsics);
+
+ // 2. Set fields of realmRec.[[Intrinsics]] with the values listed in Table 6.
+ // The field names are the names listed in column one of the table.
+ // The value of each field is a new object value fully and recursively populated
+ // with property values as defined by the specification of each object in
+ // clauses 19 through 28. All object property values are newly created object
+ // values. All values that are built-in function objects are created by performing
+ // CreateBuiltinFunction(steps, length, name, slots, realmRec, prototype)
+ // where steps is the definition of that function provided by this specification,
+ // name is the initial value of the function's "name" property, length is the
+ // initial value of the function's "length" property, slots is a list of the
+ // names, if any, of the function's specified internal slots, and prototype
+ // is the specified value of the function's [[Prototype]] internal slot. The
+ // creation of the intrinsics and their properties must be ordered to avoid
+ // any dependencies upon objects that have not yet been created.
+ intrinsics->initialize_intrinsics(realm);
+
+ // 3. Perform AddRestrictedFunctionProperties(realmRec.[[Intrinsics]].[[%Function.prototype%]], realmRec).
+ add_restricted_function_properties(static_cast<FunctionObject&>(*realm.intrinsics().function_prototype()), realm);
+
+ // 4. Return unused.
+ return intrinsics;
+}
+
+void Intrinsics::initialize_intrinsics(Realm& realm)
+{
+ auto& vm = this->vm();
+
+ // These are done first since other prototypes depend on their presence.
+ m_empty_object_shape = heap().allocate_without_realm<Shape>(realm);
+ m_object_prototype = heap().allocate_without_realm<ObjectPrototype>(realm);
+ m_function_prototype = heap().allocate_without_realm<FunctionPrototype>(realm);
+
+ m_new_object_shape = heap().allocate_without_realm<Shape>(realm);
+ m_new_object_shape->set_prototype_without_transition(m_object_prototype);
+
+ m_new_ordinary_function_prototype_object_shape = heap().allocate_without_realm<Shape>(realm);
+ m_new_ordinary_function_prototype_object_shape->set_prototype_without_transition(m_object_prototype);
+ m_new_ordinary_function_prototype_object_shape->add_property_without_transition(vm.names.constructor, Attribute::Writable | Attribute::Configurable);
+
+ // Normally Heap::allocate() takes care of this, but these are allocated via allocate_without_realm().
+ static_cast<FunctionPrototype*>(m_function_prototype)->initialize(realm);
+ static_cast<ObjectPrototype*>(m_object_prototype)->initialize(realm);
+
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ VERIFY(!m_##snake_name##_prototype); \
+ m_##snake_name##_prototype = heap().allocate<ClassName##Prototype>(realm, realm);
+ JS_ENUMERATE_ITERATOR_PROTOTYPES
+#undef __JS_ENUMERATE
+
+ // These must be initialized separately as they have no companion constructor
+ m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(realm, realm);
+ m_async_generator_prototype = heap().allocate<AsyncGeneratorPrototype>(realm, realm);
+ m_generator_prototype = heap().allocate<GeneratorPrototype>(realm, realm);
+ m_intl_segments_prototype = heap().allocate<Intl::SegmentsPrototype>(realm, realm);
+
+ // These must be initialized before allocating...
+ // - AggregateErrorPrototype, which uses ErrorPrototype as its prototype
+ // - AggregateErrorConstructor, which uses ErrorConstructor as its prototype
+ // - AsyncFunctionConstructor, which uses FunctionConstructor as its prototype
+ m_error_prototype = heap().allocate<ErrorPrototype>(realm, realm);
+ m_error_constructor = heap().allocate<ErrorConstructor>(realm, realm);
+ m_function_constructor = heap().allocate<FunctionConstructor>(realm, realm);
+
+ // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
+ m_proxy_constructor = heap().allocate<ProxyConstructor>(realm, realm);
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ /* These are the prototypes allocated earlier, everything else must not yet exist.*/ \
+ if constexpr (!IsOneOf<PrototypeName, ErrorPrototype, FunctionPrototype, ObjectPrototype>) { \
+ VERIFY(!m_##snake_name##_prototype); \
+ m_##snake_name##_prototype = heap().allocate<PrototypeName>(realm, realm); \
+ } \
+ if constexpr (!IsOneOf<ConstructorName, ErrorConstructor, FunctionConstructor>) { \
+ VERIFY(!m_##snake_name##_constructor); \
+ m_##snake_name##_constructor = heap().allocate<ConstructorName>(realm, realm); \
+ }
+ JS_ENUMERATE_BUILTIN_TYPES
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ VERIFY(!m_intl_##snake_name##_constructor); \
+ VERIFY(!m_intl_##snake_name##_prototype); \
+ m_intl_##snake_name##_prototype = heap().allocate<Intl::PrototypeName>(realm, realm); \
+ m_intl_##snake_name##_constructor = heap().allocate<Intl::ConstructorName>(realm, realm); \
+ initialize_constructor(vm, vm.names.ClassName, *m_intl_##snake_name##_constructor, m_intl_##snake_name##_prototype);
+ JS_ENUMERATE_INTL_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ VERIFY(!m_temporal_##snake_name##_constructor); \
+ VERIFY(!m_temporal_##snake_name##_prototype); \
+ m_temporal_##snake_name##_prototype = heap().allocate<Temporal::PrototypeName>(realm, realm); \
+ m_temporal_##snake_name##_constructor = heap().allocate<Temporal::ConstructorName>(realm, realm); \
+ initialize_constructor(vm, vm.names.ClassName, *m_temporal_##snake_name##_constructor, m_temporal_##snake_name##_prototype);
+ JS_ENUMERATE_TEMPORAL_OBJECTS
+#undef __JS_ENUMERATE
+
+ // 10.2.4.1 %ThrowTypeError% ( ), https://tc39.es/ecma262/#sec-%throwtypeerror%
+ m_throw_type_error_function = NativeFunction::create(
+ realm, [](VM& vm) {
+ return vm.throw_completion<TypeError>(ErrorType::RestrictedFunctionPropertiesAccess);
+ },
+ 0, "", &realm);
+ m_throw_type_error_function->define_direct_property(vm.names.length, Value(0), 0);
+ m_throw_type_error_function->define_direct_property(vm.names.name, js_string(vm, ""), 0);
+ MUST(m_throw_type_error_function->internal_prevent_extensions());
+
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ VERIFY(!m_##snake_name##_object); \
+ m_##snake_name##_object = heap().allocate<ClassName>(realm, realm);
+ JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS
+#undef __JS_ENUMERATE
+
+ initialize_constructor(vm, vm.names.AggregateError, *m_aggregate_error_constructor, m_aggregate_error_prototype);
+ initialize_constructor(vm, vm.names.Array, *m_array_constructor, m_array_prototype);
+ initialize_constructor(vm, vm.names.ArrayBuffer, *m_array_buffer_constructor, m_array_buffer_prototype);
+ initialize_constructor(vm, vm.names.BigInt, *m_bigint_constructor, m_bigint_prototype);
+ initialize_constructor(vm, vm.names.Boolean, *m_boolean_constructor, m_boolean_prototype);
+ initialize_constructor(vm, vm.names.DataView, *m_data_view_constructor, m_data_view_prototype);
+ initialize_constructor(vm, vm.names.Date, *m_date_constructor, m_date_prototype);
+ initialize_constructor(vm, vm.names.Error, *m_error_constructor, m_error_prototype);
+ initialize_constructor(vm, vm.names.FinalizationRegistry, *m_finalization_registry_constructor, m_finalization_registry_prototype);
+ initialize_constructor(vm, vm.names.Function, *m_function_constructor, m_function_prototype);
+ initialize_constructor(vm, vm.names.Map, *m_map_constructor, m_map_prototype);
+ initialize_constructor(vm, vm.names.Number, *m_number_constructor, m_number_prototype);
+ initialize_constructor(vm, vm.names.Object, *m_object_constructor, m_object_prototype);
+ initialize_constructor(vm, vm.names.Promise, *m_promise_constructor, m_promise_prototype);
+ initialize_constructor(vm, vm.names.Proxy, *m_proxy_constructor, nullptr);
+ initialize_constructor(vm, vm.names.RegExp, *m_regexp_constructor, m_regexp_prototype);
+ initialize_constructor(vm, vm.names.Set, *m_set_constructor, m_set_prototype);
+ initialize_constructor(vm, vm.names.ShadowRealm, *m_shadow_realm_constructor, m_shadow_realm_prototype);
+ initialize_constructor(vm, vm.names.String, *m_string_constructor, m_string_prototype);
+ initialize_constructor(vm, vm.names.Symbol, *m_symbol_constructor, m_symbol_prototype);
+ initialize_constructor(vm, vm.names.TypedArray, *m_typed_array_constructor, m_typed_array_prototype);
+ initialize_constructor(vm, vm.names.WeakMap, *m_weak_map_constructor, m_weak_map_prototype);
+ initialize_constructor(vm, vm.names.WeakRef, *m_weak_ref_constructor, m_weak_ref_prototype);
+ initialize_constructor(vm, vm.names.WeakSet, *m_weak_set_constructor, m_weak_set_prototype);
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ initialize_constructor(vm, vm.names.ClassName, *m_##snake_name##_constructor, m_##snake_name##_prototype);
+ JS_ENUMERATE_NATIVE_ERRORS
+ JS_ENUMERATE_TYPED_ARRAYS
+#undef __JS_ENUMERATE
+
+ initialize_constructor(vm, vm.names.GeneratorFunction, *m_generator_function_constructor, m_generator_function_prototype, Attribute::Configurable);
+ initialize_constructor(vm, vm.names.AsyncGeneratorFunction, *m_async_generator_function_constructor, m_async_generator_function_prototype, Attribute::Configurable);
+ initialize_constructor(vm, vm.names.AsyncFunction, *m_async_function_constructor, m_async_function_prototype, Attribute::Configurable);
+
+ // 27.5.1.1 Generator.prototype.constructor, https://tc39.es/ecma262/#sec-generator.prototype.constructor
+ m_generator_prototype->define_direct_property(vm.names.constructor, m_generator_function_prototype, Attribute::Configurable);
+
+ // 27.6.1.1 AsyncGenerator.prototype.constructor, https://tc39.es/ecma262/#sec-asyncgenerator-prototype-constructor
+ m_async_generator_prototype->define_direct_property(vm.names.constructor, m_async_generator_function_prototype, Attribute::Configurable);
+
+ m_array_prototype_values_function = &m_array_prototype->get_without_side_effects(vm.names.values).as_function();
+ m_date_constructor_now_function = &m_date_constructor->get_without_side_effects(vm.names.now).as_function();
+ m_json_parse_function = &m_json_object->get_without_side_effects(vm.names.parse).as_function();
+ m_object_prototype_to_string_function = &m_object_prototype->get_without_side_effects(vm.names.toString).as_function();
+}
+
+void Intrinsics::visit_edges(Visitor& visitor)
+{
+ visitor.visit(m_empty_object_shape);
+ visitor.visit(m_new_object_shape);
+ visitor.visit(m_new_ordinary_function_prototype_object_shape);
+ visitor.visit(m_proxy_constructor);
+ visitor.visit(m_async_from_sync_iterator_prototype);
+ visitor.visit(m_async_generator_prototype);
+ visitor.visit(m_generator_prototype);
+ visitor.visit(m_intl_segments_prototype);
+ visitor.visit(m_array_prototype_values_function);
+ visitor.visit(m_date_constructor_now_function);
+ visitor.visit(m_eval_function);
+ visitor.visit(m_json_parse_function);
+ visitor.visit(m_object_prototype_to_string_function);
+ visitor.visit(m_throw_type_error_function);
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ visitor.visit(m_##snake_name##_constructor); \
+ visitor.visit(m_##snake_name##_prototype);
+ JS_ENUMERATE_BUILTIN_TYPES
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ visitor.visit(m_intl_##snake_name##_constructor); \
+ visitor.visit(m_intl_##snake_name##_prototype);
+ JS_ENUMERATE_INTL_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ visitor.visit(m_temporal_##snake_name##_constructor); \
+ visitor.visit(m_temporal_##snake_name##_prototype);
+ JS_ENUMERATE_TEMPORAL_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ visitor.visit(m_##snake_name##_object);
+ JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ visitor.visit(m_##snake_name##_prototype);
+ JS_ENUMERATE_ITERATOR_PROTOTYPES
+#undef __JS_ENUMERATE
+}
+
+// 10.2.4 AddRestrictedFunctionProperties ( F, realm ), https://tc39.es/ecma262/#sec-addrestrictedfunctionproperties
+void add_restricted_function_properties(FunctionObject& function, Realm& realm)
+{
+ auto& vm = realm.vm();
+
+ // 1. Assert: realm.[[Intrinsics]].[[%ThrowTypeError%]] exists and has been initialized.
+ VERIFY(realm.intrinsics().throw_type_error_function());
+
+ // 2. Let thrower be realm.[[Intrinsics]].[[%ThrowTypeError%]].
+ auto* thrower = realm.intrinsics().throw_type_error_function();
+
+ // 3. Perform ! DefinePropertyOrThrow(F, "caller", PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: true }).
+ function.define_direct_accessor(vm.names.caller, thrower, thrower, Attribute::Configurable);
+
+ // 4. Perform ! DefinePropertyOrThrow(F, "arguments", PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: true }).
+ function.define_direct_accessor(vm.names.arguments, thrower, thrower, Attribute::Configurable);
+
+ // 5. Return unused.
+}
+
+}
diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.h b/Userland/Libraries/LibJS/Runtime/Intrinsics.h
new file mode 100644
index 0000000000..2ddaa566d8
--- /dev/null
+++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.h
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibJS/Forward.h>
+#include <LibJS/Heap/Cell.h>
+#include <LibJS/Runtime/Realm.h>
+
+namespace JS {
+
+class Intrinsics final : public Cell {
+public:
+ // Allow the global object to set intrinsics, ugly but needed for now.
+ friend class GlobalObject;
+
+ static Intrinsics* create(Realm&);
+
+ Intrinsics() = default;
+
+ Shape* empty_object_shape() { return m_empty_object_shape; }
+
+ Shape* new_object_shape() { return m_new_object_shape; }
+ Shape* new_ordinary_function_prototype_object_shape() { return m_new_ordinary_function_prototype_object_shape; }
+
+ // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
+ ProxyConstructor* proxy_constructor() { return m_proxy_constructor; }
+
+ // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
+ Object* async_from_sync_iterator_prototype() { return m_async_from_sync_iterator_prototype; }
+ Object* async_generator_prototype() { return m_async_generator_prototype; }
+ Object* generator_prototype() { return m_generator_prototype; }
+
+ // Alias for the AsyncGenerator Prototype Object used by the spec (%AsyncGeneratorFunction.prototype.prototype%)
+ Object* async_generator_function_prototype_prototype() { return m_async_generator_prototype; }
+ // Alias for the Generator Prototype Object used by the spec (%GeneratorFunction.prototype.prototype%)
+ Object* generator_function_prototype_prototype() { return m_generator_prototype; }
+
+ // Not included in JS_ENUMERATE_INTL_OBJECTS due to missing distinct constructor
+ Object* intl_segments_prototype() { return m_intl_segments_prototype; }
+
+ FunctionObject* array_prototype_values_function() const { return m_array_prototype_values_function; }
+ FunctionObject* date_constructor_now_function() const { return m_date_constructor_now_function; }
+ FunctionObject* eval_function() const { return m_eval_function; }
+ FunctionObject* json_parse_function() const { return m_json_parse_function; }
+ FunctionObject* object_prototype_to_string_function() const { return m_object_prototype_to_string_function; }
+ FunctionObject* throw_type_error_function() const { return m_throw_type_error_function; }
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ ConstructorName* snake_name##_constructor() \
+ { \
+ return m_##snake_name##_constructor; \
+ } \
+ Object* snake_name##_prototype() \
+ { \
+ return m_##snake_name##_prototype; \
+ }
+ JS_ENUMERATE_BUILTIN_TYPES
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ Intl::ConstructorName* intl_##snake_name##_constructor() \
+ { \
+ return m_intl_##snake_name##_constructor; \
+ } \
+ Object* intl_##snake_name##_prototype() \
+ { \
+ return m_intl_##snake_name##_prototype; \
+ }
+ JS_ENUMERATE_INTL_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ Temporal::ConstructorName* temporal_##snake_name##_constructor() \
+ { \
+ return m_temporal_##snake_name##_constructor; \
+ } \
+ Object* temporal_##snake_name##_prototype() \
+ { \
+ return m_temporal_##snake_name##_prototype; \
+ }
+ JS_ENUMERATE_TEMPORAL_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ ClassName* snake_name##_object() \
+ { \
+ return m_##snake_name##_object; \
+ }
+ JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ Object* snake_name##_prototype() \
+ { \
+ return m_##snake_name##_prototype; \
+ }
+ JS_ENUMERATE_ITERATOR_PROTOTYPES
+#undef __JS_ENUMERATE
+
+private:
+ virtual StringView class_name() const override { return "Intrinsics"sv; }
+ virtual void visit_edges(Visitor&) override;
+
+ void initialize_intrinsics(Realm&);
+
+ Shape* m_empty_object_shape { nullptr };
+ Shape* m_new_object_shape { nullptr };
+ Shape* m_new_ordinary_function_prototype_object_shape { nullptr };
+
+ // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
+ ProxyConstructor* m_proxy_constructor { nullptr };
+
+ // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
+ Object* m_async_from_sync_iterator_prototype { nullptr };
+ Object* m_async_generator_prototype { nullptr };
+ Object* m_generator_prototype { nullptr };
+
+ // Not included in JS_ENUMERATE_INTL_OBJECTS due to missing distinct constructor
+ Object* m_intl_segments_prototype { nullptr };
+
+ FunctionObject* m_array_prototype_values_function { nullptr };
+ FunctionObject* m_date_constructor_now_function { nullptr };
+ FunctionObject* m_eval_function { nullptr };
+ FunctionObject* m_json_parse_function { nullptr };
+ FunctionObject* m_object_prototype_to_string_function { nullptr };
+ FunctionObject* m_throw_type_error_function { nullptr };
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ ConstructorName* m_##snake_name##_constructor { nullptr }; \
+ Object* m_##snake_name##_prototype { nullptr };
+ JS_ENUMERATE_BUILTIN_TYPES
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ Intl::ConstructorName* m_intl_##snake_name##_constructor { nullptr }; \
+ Object* m_intl_##snake_name##_prototype { nullptr };
+ JS_ENUMERATE_INTL_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ Temporal::ConstructorName* m_temporal_##snake_name##_constructor { nullptr }; \
+ Object* m_temporal_##snake_name##_prototype { nullptr };
+ JS_ENUMERATE_TEMPORAL_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ ClassName* m_##snake_name##_object { nullptr };
+ JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ Object* m_##snake_name##_prototype { nullptr };
+ JS_ENUMERATE_ITERATOR_PROTOTYPES
+#undef __JS_ENUMERATE
+};
+
+void add_restricted_function_properties(FunctionObject&, Realm&);
+
+}
diff --git a/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp b/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp
index c57de9bd7a..2bdbc5406e 100644
--- a/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp
@@ -189,7 +189,7 @@ Object* create_iterator_result_object(VM& vm, Value value, bool done)
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 ! CreateDataPropertyOrThrow(obj, "value", value).
MUST(object->create_data_property_or_throw(vm.names.value, value));
diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp
index 8c8eef569e..177c714961 100644
--- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp
@@ -12,7 +12,7 @@ namespace JS {
// 27.1.2 The %IteratorPrototype% Object, https://tc39.es/ecma262/#sec-%iteratorprototype%-object
IteratorPrototype::IteratorPrototype(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp
index 7f5991ddd3..d4f97646dd 100644
--- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp
@@ -26,7 +26,7 @@
namespace JS {
JSONObject::JSONObject(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
@@ -101,7 +101,7 @@ ThrowCompletionOr<String> JSONObject::stringify_impl(VM& vm, Value value, Value
state.gap = String::empty();
}
- auto* wrapper = Object::create(realm, realm.global_object().object_prototype());
+ auto* wrapper = Object::create(realm, realm.intrinsics().object_prototype());
MUST(wrapper->create_data_property_or_throw(String::empty(), value));
return serialize_json_property(vm, state, String::empty(), wrapper);
}
@@ -400,7 +400,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
return vm.throw_completion<SyntaxError>(ErrorType::JsonMalformed);
Value unfiltered = parse_json_value(vm, json.value());
if (reviver.is_function()) {
- auto* root = Object::create(realm, realm.global_object().object_prototype());
+ auto* root = Object::create(realm, realm.intrinsics().object_prototype());
auto root_name = String::empty();
MUST(root->create_data_property_or_throw(root_name, unfiltered));
return internalize_json_property(vm, root, root_name, reviver.as_function());
@@ -430,7 +430,7 @@ Value JSONObject::parse_json_value(VM& vm, JsonValue const& value)
Object* JSONObject::parse_json_object(VM& vm, JsonObject const& json_object)
{
auto& realm = *vm.current_realm();
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
json_object.for_each_member([&](auto& key, auto& value) {
object->define_direct_property(key, parse_json_value(vm, value), default_attributes);
});
diff --git a/Userland/Libraries/LibJS/Runtime/Map.cpp b/Userland/Libraries/LibJS/Runtime/Map.cpp
index 6c8824bd59..076d963a97 100644
--- a/Userland/Libraries/LibJS/Runtime/Map.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Map.cpp
@@ -10,7 +10,7 @@ namespace JS {
Map* Map::create(Realm& realm)
{
- return realm.heap().allocate<Map>(realm, *realm.global_object().map_prototype());
+ return realm.heap().allocate<Map>(realm, *realm.intrinsics().map_prototype());
}
Map::Map(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp
index bc61a2ff9d..952aee361f 100644
--- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
MapConstructor::MapConstructor(Realm& realm)
- : NativeFunction(vm().names.Map.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Map.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -24,7 +24,7 @@ void MapConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 24.1.2.1 Map.prototype, https://tc39.es/ecma262/#sec-map.prototype
- define_direct_property(vm.names.prototype, realm.global_object().map_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().map_prototype(), 0);
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
@@ -43,7 +43,7 @@ ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
- auto* map = TRY(ordinary_create_from_constructor<Map>(vm, new_target, &GlobalObject::map_prototype));
+ auto* map = TRY(ordinary_create_from_constructor<Map>(vm, new_target, &Intrinsics::map_prototype));
if (vm.argument(0).is_nullish())
return map;
diff --git a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp
index 52cee6fad5..33fb1357ad 100644
--- a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp
@@ -11,7 +11,7 @@ namespace JS {
MapIterator* MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind)
{
- return realm.heap().allocate<MapIterator>(realm, map, iteration_kind, *realm.global_object().map_iterator_prototype());
+ return realm.heap().allocate<MapIterator>(realm, map, iteration_kind, *realm.intrinsics().map_iterator_prototype());
}
MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp
index d45810aac7..88800c8d03 100644
--- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp
@@ -14,7 +14,7 @@
namespace JS {
MapIteratorPrototype::MapIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().iterator_prototype())
+ : PrototypeObject(*realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp
index 19dcf8e2f3..0321086adc 100644
--- a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp
@@ -13,7 +13,7 @@
namespace JS {
MapPrototype::MapPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.cpp b/Userland/Libraries/LibJS/Runtime/MathObject.cpp
index bf212c4b5f..fef6df733f 100644
--- a/Userland/Libraries/LibJS/Runtime/MathObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MathObject.cpp
@@ -16,7 +16,7 @@
namespace JS {
MathObject::MathObject(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp
index efab770e2f..2fda0b0e9c 100644
--- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp
@@ -11,7 +11,7 @@
namespace JS {
ModuleNamespaceObject::ModuleNamespaceObject(Realm& realm, Module* module, Vector<FlyString> exports)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
, m_module(module)
, m_exports(move(exports))
{
diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp
index 4f9578c7a6..a8ee8e7883 100644
--- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp
@@ -26,7 +26,7 @@ NativeFunction* NativeFunction::create(Realm& allocating_realm, Function<ThrowCo
// 2. If prototype is not present, set prototype to realm.[[Intrinsics]].[[%Function.prototype%]].
if (!prototype.has_value())
- prototype = realm.value()->global_object().function_prototype();
+ prototype = realm.value()->intrinsics().function_prototype();
// 3. Let internalSlotsList be a List containing the names of all the internal slots that 10.3 requires for the built-in function object that is about to be created.
// 4. Append to internalSlotsList the elements of additionalInternalSlotsList.
@@ -53,7 +53,7 @@ NativeFunction* NativeFunction::create(Realm& allocating_realm, Function<ThrowCo
NativeFunction* NativeFunction::create(Realm& realm, FlyString const& name, Function<ThrowCompletionOr<Value>(VM&)> function)
{
- return realm.heap().allocate<NativeFunction>(realm, name, move(function), *realm.global_object().function_prototype());
+ return realm.heap().allocate<NativeFunction>(realm, name, move(function), *realm.intrinsics().function_prototype());
}
NativeFunction::NativeFunction(Function<ThrowCompletionOr<Value>(VM&)> native_function, Object* prototype, Realm& realm)
@@ -69,7 +69,7 @@ NativeFunction::NativeFunction(Function<ThrowCompletionOr<Value>(VM&)> native_fu
NativeFunction::NativeFunction(Object& prototype)
: FunctionObject(prototype)
- , m_realm(global_object().associated_realm())
+ , m_realm(&prototype.shape().realm())
{
}
@@ -77,14 +77,14 @@ NativeFunction::NativeFunction(FlyString name, Function<ThrowCompletionOr<Value>
: FunctionObject(prototype)
, m_name(move(name))
, m_native_function(move(native_function))
- , m_realm(global_object().associated_realm())
+ , m_realm(&prototype.shape().realm())
{
}
NativeFunction::NativeFunction(FlyString name, Object& prototype)
: FunctionObject(prototype)
, m_name(move(name))
- , m_realm(global_object().associated_realm())
+ , m_realm(&prototype.shape().realm())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
index b1f6ed14f7..6e61b56c6a 100644
--- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
@@ -24,7 +24,7 @@ constexpr double const MIN_SAFE_INTEGER_VALUE { -(__builtin_exp2(53) - 1) };
namespace JS {
NumberConstructor::NumberConstructor(Realm& realm)
- : NativeFunction(vm().names.Number.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Number.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -34,16 +34,17 @@ void NumberConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 21.1.2.15 Number.prototype, https://tc39.es/ecma262/#sec-number.prototype
- define_direct_property(vm.names.prototype, realm.global_object().number_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().number_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.isFinite, is_finite, 1, attr);
define_native_function(realm, vm.names.isInteger, is_integer, 1, attr);
define_native_function(realm, vm.names.isNaN, is_nan, 1, attr);
define_native_function(realm, vm.names.isSafeInteger, is_safe_integer, 1, attr);
- // FIXME: Store these as intrinsics (`parse_int_function()`) instead of getting them from the global object
- define_direct_property(vm.names.parseInt, realm.global_object().get_without_side_effects(vm.names.parseInt), attr);
- define_direct_property(vm.names.parseFloat, realm.global_object().get_without_side_effects(vm.names.parseFloat), attr);
+ // NOTE: These are set from the global object as at this point we don't have them allocated yet;
+ // The native functions are part of the global object itself.
+ define_direct_property(vm.names.parseInt, js_undefined(), attr);
+ define_direct_property(vm.names.parseFloat, js_undefined(), attr);
define_direct_property(vm.names.EPSILON, Value(EPSILON_VALUE), 0);
define_direct_property(vm.names.MAX_VALUE, Value(NumericLimits<double>::max()), 0);
define_direct_property(vm.names.MIN_VALUE, Value(NumericLimits<double>::min()), 0);
@@ -100,7 +101,7 @@ ThrowCompletionOr<Object*> NumberConstructor::construct(FunctionObject& new_targ
// 4. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Number.prototype%", « [[NumberData]] »).
// 5. Set O.[[NumberData]] to n.
// 6. Return O.
- return TRY(ordinary_create_from_constructor<NumberObject>(vm, new_target, &GlobalObject::number_prototype, number.as_double()));
+ return TRY(ordinary_create_from_constructor<NumberObject>(vm, new_target, &Intrinsics::number_prototype, number.as_double()));
}
// 21.1.2.2 Number.isFinite ( number ), https://tc39.es/ecma262/#sec-number.isfinite
diff --git a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp
index 750d9a4bad..8284f91cad 100644
--- a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp
@@ -11,7 +11,7 @@ namespace JS {
NumberObject* NumberObject::create(Realm& realm, double value)
{
- return realm.heap().allocate<NumberObject>(realm, value, *realm.global_object().number_prototype());
+ return realm.heap().allocate<NumberObject>(realm, value, *realm.intrinsics().number_prototype());
}
NumberObject::NumberObject(double value, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp
index 1a6b02cf5a..1e0a8b5212 100644
--- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp
@@ -84,7 +84,7 @@ static size_t compute_fraction_digits(double number, int exponent)
}
NumberPrototype::NumberPrototype(Realm& realm)
- : NumberObject(0, *realm.global_object().object_prototype())
+ : NumberObject(0, *realm.intrinsics().object_prototype())
{
}
@@ -327,7 +327,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_locale_string)
auto number_value = TRY(this_number_value(vm, vm.this_value()));
// 2. Let numberFormat be ? Construct(%NumberFormat%, « locales, options »).
- auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, *realm.global_object().intl_number_format_constructor(), locales, options)));
+ auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), locales, options)));
// 3. Return ? FormatNumeric(numberFormat, x).
// Note: Our implementation of FormatNumeric does not throw.
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp
index 7eeefde661..7c1daa32b0 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Object.cpp
@@ -27,9 +27,9 @@ namespace JS {
Object* Object::create(Realm& realm, Object* prototype)
{
if (!prototype)
- return realm.heap().allocate<Object>(realm, *realm.global_object().empty_object_shape());
- else if (prototype == realm.global_object().object_prototype())
- return realm.heap().allocate<Object>(realm, *realm.global_object().new_object_shape());
+ return realm.heap().allocate<Object>(realm, *realm.intrinsics().empty_object_shape());
+ else if (prototype == realm.intrinsics().object_prototype())
+ return realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape());
else
return realm.heap().allocate<Object>(realm, *prototype);
}
@@ -52,14 +52,16 @@ Object::Object(ConstructWithoutPrototypeTag, Realm& realm)
Object::Object(Realm& realm, Object* prototype)
{
- m_shape = realm.global_object().empty_object_shape();
+ m_shape = realm.intrinsics().empty_object_shape();
+ VERIFY(m_shape);
if (prototype != nullptr)
set_prototype(prototype);
}
Object::Object(Object& prototype)
{
- m_shape = prototype.global_object().empty_object_shape();
+ m_shape = prototype.shape().realm().intrinsics().empty_object_shape();
+ VERIFY(m_shape);
set_prototype(&prototype);
}
diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
index 9f3ccf6ec5..ad58242b7a 100644
--- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
@@ -18,7 +18,7 @@
namespace JS {
ObjectConstructor::ObjectConstructor(Realm& realm)
- : NativeFunction(vm().names.Object.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Object.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -28,7 +28,7 @@ void ObjectConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 20.1.2.19 Object.prototype, https://tc39.es/ecma262/#sec-object.prototype
- define_direct_property(vm.names.prototype, realm.global_object().object_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().object_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.defineProperty, define_property, 3, attr);
@@ -70,10 +70,10 @@ ThrowCompletionOr<Object*> ObjectConstructor::construct(FunctionObject& new_targ
auto& realm = *vm.current_realm();
if (&new_target != this)
- return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &GlobalObject::object_prototype));
+ return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype));
auto value = vm.argument(0);
if (value.is_nullish())
- return Object::create(realm, realm.global_object().object_prototype());
+ return Object::create(realm, realm.intrinsics().object_prototype());
return value.to_object(vm);
}
@@ -223,7 +223,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries)
auto& realm = *vm.current_realm();
auto iterable = TRY(require_object_coercible(vm, vm.argument(0)));
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
(void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> {
if (!iterator_value.is_object())
@@ -274,7 +274,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_descriptors)
auto own_keys = TRY(object->internal_own_property_keys());
// 3. Let descriptors be OrdinaryObjectCreate(%Object.prototype%).
- auto* descriptors = Object::create(realm, realm.global_object().object_prototype());
+ auto* descriptors = Object::create(realm, realm.intrinsics().object_prototype());
// 4. For each element key of ownKeys, do
for (auto& key : own_keys) {
diff --git a/Userland/Libraries/LibJS/Runtime/Promise.cpp b/Userland/Libraries/LibJS/Runtime/Promise.cpp
index e36b9195eb..d114b094d7 100644
--- a/Userland/Libraries/LibJS/Runtime/Promise.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Promise.cpp
@@ -43,7 +43,7 @@ ThrowCompletionOr<Object*> promise_resolve(VM& vm, Object& constructor, Value va
Promise* Promise::create(Realm& realm)
{
- return realm.heap().allocate<Promise>(realm, *realm.global_object().promise_prototype());
+ return realm.heap().allocate<Promise>(realm, *realm.intrinsics().promise_prototype());
}
// 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
index a2ae7a4511..1737852101 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
@@ -240,7 +240,7 @@ static ThrowCompletionOr<Value> perform_promise_race(VM& vm, Iterator& iterator_
}
PromiseConstructor::PromiseConstructor(Realm& realm)
- : NativeFunction(vm().names.Promise.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Promise.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -250,7 +250,7 @@ void PromiseConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 27.2.4.4 Promise.prototype, https://tc39.es/ecma262/#sec-promise.prototype
- define_direct_property(vm.names.prototype, realm.global_object().promise_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().promise_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.all, all, 1, attr);
@@ -290,7 +290,7 @@ ThrowCompletionOr<Object*> PromiseConstructor::construct(FunctionObject& new_tar
// 5. Set promise.[[PromiseFulfillReactions]] to a new empty List.
// 6. Set promise.[[PromiseRejectReactions]] to a new empty List.
// 7. Set promise.[[PromiseIsHandled]] to false.
- auto* promise = TRY(ordinary_create_from_constructor<Promise>(vm, new_target, &GlobalObject::promise_prototype));
+ auto* promise = TRY(ordinary_create_from_constructor<Promise>(vm, new_target, &Intrinsics::promise_prototype));
// 8. Let resolvingFunctions be CreateResolvingFunctions(promise).
auto [resolve_function, reject_function] = promise->create_resolving_functions();
diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp
index 3a28aa5821..04fb7e4530 100644
--- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp
@@ -17,7 +17,7 @@
namespace JS {
PromisePrototype::PromisePrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -48,7 +48,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::then)
auto* promise = TRY(typed_this_object(vm));
// 3. Let C be ? SpeciesConstructor(promise, %Promise%).
- auto* constructor = TRY(species_constructor(vm, *promise, *realm.global_object().promise_constructor()));
+ auto* constructor = TRY(species_constructor(vm, *promise, *realm.intrinsics().promise_constructor()));
// 4. Let resultCapability be ? NewPromiseCapability(C).
auto result_capability = TRY(new_promise_capability(vm, constructor));
@@ -84,7 +84,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, promise.to_string_without_side_effects());
// 3. Let C be ? SpeciesConstructor(promise, %Promise%).
- auto* constructor = TRY(species_constructor(vm, promise.as_object(), *realm.global_object().promise_constructor()));
+ auto* constructor = TRY(species_constructor(vm, promise.as_object(), *realm.intrinsics().promise_constructor()));
// 4. Assert: IsConstructor(C) is true.
VERIFY(constructor);
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp
index c80b9d7cd6..2a47562949 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp
@@ -57,7 +57,7 @@ void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor)
PromiseAllResolveElementFunction* PromiseAllResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements)
{
- return realm.heap().allocate<PromiseAllResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.global_object().function_prototype());
+ return realm.heap().allocate<PromiseAllResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
}
PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements, Object& prototype)
@@ -89,7 +89,7 @@ ThrowCompletionOr<Value> PromiseAllResolveElementFunction::resolve_element()
PromiseAllSettledResolveElementFunction* PromiseAllSettledResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements)
{
- return realm.heap().allocate<PromiseAllSettledResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.global_object().function_prototype());
+ return realm.heap().allocate<PromiseAllSettledResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
}
PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements, Object& prototype)
@@ -103,7 +103,7 @@ ThrowCompletionOr<Value> PromiseAllSettledResolveElementFunction::resolve_elemen
auto& realm = *vm.current_realm();
// 9. 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());
// 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "fulfilled").
MUST(object->create_data_property_or_throw(vm.names.status, js_string(vm, "fulfilled"sv)));
@@ -130,7 +130,7 @@ ThrowCompletionOr<Value> PromiseAllSettledResolveElementFunction::resolve_elemen
PromiseAllSettledRejectElementFunction* PromiseAllSettledRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements)
{
- return realm.heap().allocate<PromiseAllSettledRejectElementFunction>(realm, index, values, capability, remaining_elements, *realm.global_object().function_prototype());
+ return realm.heap().allocate<PromiseAllSettledRejectElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
}
PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements, Object& prototype)
@@ -144,7 +144,7 @@ ThrowCompletionOr<Value> PromiseAllSettledRejectElementFunction::resolve_element
auto& realm = *vm.current_realm();
// 9. 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());
// 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "rejected").
MUST(object->create_data_property_or_throw(vm.names.status, js_string(vm, "rejected"sv)));
@@ -171,7 +171,7 @@ ThrowCompletionOr<Value> PromiseAllSettledRejectElementFunction::resolve_element
PromiseAnyRejectElementFunction* PromiseAnyRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& errors, PromiseCapability capability, RemainingElements& remaining_elements)
{
- return realm.heap().allocate<PromiseAnyRejectElementFunction>(realm, index, errors, capability, remaining_elements, *realm.global_object().function_prototype());
+ return realm.heap().allocate<PromiseAnyRejectElementFunction>(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype());
}
PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, PromiseCapability capability, RemainingElements& remaining_elements, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp
index 31ee4835e5..935be968c0 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp
@@ -13,7 +13,7 @@ namespace JS {
PromiseResolvingFunction* PromiseResolvingFunction::create(Realm& realm, Promise& promise, AlreadyResolved& already_resolved, FunctionType function)
{
- return realm.heap().allocate<PromiseResolvingFunction>(realm, promise, already_resolved, move(function), *realm.global_object().function_prototype());
+ return realm.heap().allocate<PromiseResolvingFunction>(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype());
}
PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp
index 74bb413b76..ab958b26f3 100644
--- a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp
@@ -71,7 +71,7 @@ Value from_property_descriptor(VM& vm, Optional<PropertyDescriptor> const& prope
if (!property_descriptor.has_value())
return js_undefined();
- auto* object = Object::create(realm, realm.global_object().object_prototype());
+ auto* object = Object::create(realm, realm.intrinsics().object_prototype());
if (property_descriptor->value.has_value())
MUST(object->create_data_property_or_throw(vm.names.value, *property_descriptor->value));
if (property_descriptor->writable.has_value())
diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp
index 81926730ab..6a68131f04 100644
--- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp
@@ -25,7 +25,7 @@ static ThrowCompletionOr<ProxyObject*> proxy_create(VM& vm, Value target, Value
}
ProxyConstructor::ProxyConstructor(Realm& realm)
- : NativeFunction(vm().names.Proxy.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Proxy.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -87,7 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(ProxyConstructor::revocable)
auto* revoker = NativeFunction::create(realm, move(revoker_closure), 0, "");
// 5. Let result be OrdinaryObjectCreate(%Object.prototype%).
- auto* result = Object::create(realm, realm.global_object().object_prototype());
+ auto* result = Object::create(realm, realm.intrinsics().object_prototype());
// 6. Perform ! CreateDataPropertyOrThrow(result, "proxy", p).
MUST(result->create_data_property_or_throw(vm.names.proxy, proxy));
diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
index 648e00c526..eef9c96ba4 100644
--- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
@@ -17,7 +17,7 @@ namespace JS {
ProxyObject* ProxyObject::create(Realm& realm, Object& target, Object& handler)
{
- return realm.heap().allocate<ProxyObject>(realm, target, handler, *realm.global_object().object_prototype());
+ return realm.heap().allocate<ProxyObject>(realm, target, handler, *realm.intrinsics().object_prototype());
}
ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/Realm.cpp b/Userland/Libraries/LibJS/Runtime/Realm.cpp
index ca9e09b449..03038f3127 100644
--- a/Userland/Libraries/LibJS/Runtime/Realm.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Realm.cpp
@@ -17,7 +17,18 @@ namespace JS {
// 9.3.1 CreateRealm ( ), https://tc39.es/ecma262/#sec-createrealm
Realm* Realm::create(VM& vm)
{
- return vm.heap().allocate_without_realm<Realm>();
+ // 1. Let realmRec be a new Realm Record.
+ auto* realm = vm.heap().allocate_without_realm<Realm>();
+
+ // 2. Perform CreateIntrinsics(realmRec).
+ Intrinsics::create(*realm);
+
+ // 3. Set realmRec.[[GlobalObject]] to undefined.
+ // 4. Set realmRec.[[GlobalEnv]] to undefined.
+ // 5. Set realmRec.[[TemplateMap]] to a new empty List.
+
+ // 6. Return realmRec.
+ return realm;
}
// 9.6 InitializeHostDefinedRealm ( ), https://tc39.es/ecma262/#sec-initializehostdefinedrealm
@@ -107,6 +118,7 @@ void Realm::set_global_object(GlobalObject* global_object, GlobalObject* this_va
void Realm::visit_edges(Visitor& visitor)
{
+ visitor.visit(m_intrinsics);
visitor.visit(m_global_object);
visitor.visit(m_global_environment);
}
diff --git a/Userland/Libraries/LibJS/Runtime/Realm.h b/Userland/Libraries/LibJS/Runtime/Realm.h
index 9739a09641..8a3a043d0b 100644
--- a/Userland/Libraries/LibJS/Runtime/Realm.h
+++ b/Userland/Libraries/LibJS/Runtime/Realm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -7,10 +7,12 @@
#pragma once
+#include <AK/Badge.h>
#include <AK/OwnPtr.h>
#include <AK/StringView.h>
#include <AK/Weakable.h>
#include <LibJS/Heap/Cell.h>
+#include <LibJS/Runtime/Intrinsics.h>
namespace JS {
@@ -33,6 +35,14 @@ public:
[[nodiscard]] GlobalObject& global_object() const { return *m_global_object; }
[[nodiscard]] GlobalEnvironment& global_environment() const { return *m_global_environment; }
+ [[nodiscard]] Intrinsics const& intrinsics() const { return *m_intrinsics; }
+ [[nodiscard]] Intrinsics& intrinsics() { return *m_intrinsics; }
+ void set_intrinsics(Badge<Intrinsics>, Intrinsics& intrinsics)
+ {
+ VERIFY(!m_intrinsics);
+ m_intrinsics = &intrinsics;
+ }
+
HostDefined* host_defined() { return m_host_defined; }
void set_host_defined(OwnPtr<HostDefined> host_defined) { m_host_defined = move(host_defined); }
@@ -40,6 +50,7 @@ private:
virtual StringView class_name() const override { return "Realm"sv; }
virtual void visit_edges(Visitor&) override;
+ Intrinsics* m_intrinsics { nullptr }; // [[Intrinsics]]
GlobalObject* m_global_object { nullptr }; // [[GlobalObject]]
GlobalEnvironment* m_global_environment { nullptr }; // [[GlobalEnv]]
OwnPtr<HostDefined> m_host_defined; // [[HostDefined]]
diff --git a/Userland/Libraries/LibJS/Runtime/Reference.cpp b/Userland/Libraries/LibJS/Runtime/Reference.cpp
index dbf23f5419..c6bff072ec 100644
--- a/Userland/Libraries/LibJS/Runtime/Reference.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Reference.cpp
@@ -118,11 +118,11 @@ ThrowCompletionOr<Value> Reference::get_value(VM& vm) const
auto string_value = m_base_value.as_string().get(vm, m_name);
if (string_value.has_value())
return *string_value;
- base_obj = realm.global_object().string_prototype();
+ base_obj = realm.intrinsics().string_prototype();
} else if (m_base_value.is_number())
- base_obj = realm.global_object().number_prototype();
+ base_obj = realm.intrinsics().number_prototype();
else if (m_base_value.is_boolean())
- base_obj = realm.global_object().boolean_prototype();
+ base_obj = realm.intrinsics().boolean_prototype();
else
base_obj = TRY(m_base_value.to_object(vm));
diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
index 8c74732106..7ac1d6ecc9 100644
--- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
@@ -16,7 +16,7 @@
namespace JS {
ReflectObject::ReflectObject(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
index b40387d28d..3acbb1d2b2 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
@@ -12,7 +12,7 @@
namespace JS {
RegExpConstructor::RegExpConstructor(Realm& realm)
- : NativeFunction(vm().names.RegExp.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.RegExp.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -22,7 +22,7 @@ void RegExpConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 22.2.4.1 RegExp.prototype, https://tc39.es/ecma262/#sec-regexp.prototype
- define_direct_property(vm.names.prototype, realm.global_object().regexp_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().regexp_prototype(), 0);
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp
index 1af4e908c0..192b682dce 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp
@@ -124,12 +124,12 @@ ThrowCompletionOr<String> parse_regex_pattern(VM& vm, StringView pattern, bool u
RegExpObject* RegExpObject::create(Realm& realm)
{
- return realm.heap().allocate<RegExpObject>(realm, *realm.global_object().regexp_prototype());
+ return realm.heap().allocate<RegExpObject>(realm, *realm.intrinsics().regexp_prototype());
}
RegExpObject* RegExpObject::create(Realm& realm, Regex<ECMA262> regex, String pattern, String flags)
{
- return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), *realm.global_object().regexp_prototype());
+ return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype());
}
RegExpObject::RegExpObject(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
index 7d1353ba87..781c64ec42 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
@@ -22,7 +22,7 @@
namespace JS {
RegExpPrototype::RegExpPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -418,7 +418,7 @@ size_t advance_string_index(Utf16View const& string, size_t index, bool unicode)
/* 2. If R does not have an [[OriginalFlags]] internal slot, then */ \
if (!is<RegExpObject>(regexp_object)) { \
/* a. If SameValue(R, %RegExp.prototype%) is true, return undefined. */ \
- if (same_value(regexp_object, realm.global_object().regexp_prototype())) \
+ if (same_value(regexp_object, realm.intrinsics().regexp_prototype())) \
return js_undefined(); \
/* b. Otherwise, throw a TypeError exception. */ \
return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "RegExp"); \
@@ -574,7 +574,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match_all)
auto string = TRY(vm.argument(0).to_utf16_string(vm));
// 4. Let C be ? SpeciesConstructor(R, %RegExp%).
- auto* constructor = TRY(species_constructor(vm, *regexp_object, *realm.global_object().regexp_constructor()));
+ auto* constructor = TRY(species_constructor(vm, *regexp_object, *realm.intrinsics().regexp_constructor()));
// 5. Let flags be ? ToString(? Get(R, "flags")).
auto flags_value = TRY(regexp_object->get(vm.names.flags));
@@ -851,7 +851,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::source)
// 3. If R does not have an [[OriginalSource]] internal slot, then
if (!is<RegExpObject>(regexp_object)) {
// a. If SameValue(R, %RegExp.prototype%) is true, return "(?:)".
- if (same_value(regexp_object, realm.global_object().regexp_prototype()))
+ if (same_value(regexp_object, realm.intrinsics().regexp_prototype()))
return js_string(vm, "(?:)");
// b. Otherwise, throw a TypeError exception.
@@ -879,7 +879,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split)
auto string = TRY(vm.argument(0).to_utf16_string(vm));
// 4. Let C be ? SpeciesConstructor(rx, %RegExp%).
- auto* constructor = TRY(species_constructor(vm, *regexp_object, *realm.global_object().regexp_constructor()));
+ auto* constructor = TRY(species_constructor(vm, *regexp_object, *realm.intrinsics().regexp_constructor()));
// 5. Let flags be ? ToString(? Get(rx, "flags")).
auto flags_value = TRY(regexp_object->get(vm.names.flags));
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp
index a79b2350b2..68436ef091 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp
@@ -12,7 +12,7 @@ namespace JS {
// 22.2.7.1 CreateRegExpStringIterator ( R, S, global, fullUnicode ), https://tc39.es/ecma262/#sec-createregexpstringiterator
RegExpStringIterator* RegExpStringIterator::create(Realm& realm, Object& regexp_object, Utf16String string, bool global, bool unicode)
{
- return realm.heap().allocate<RegExpStringIterator>(realm, *realm.global_object().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode);
+ return realm.heap().allocate<RegExpStringIterator>(realm, *realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode);
}
RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode)
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp
index bc76b94ec5..f202b759e9 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp
@@ -13,7 +13,7 @@
namespace JS {
RegExpStringIteratorPrototype::RegExpStringIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().iterator_prototype())
+ : PrototypeObject(*realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp
index 9f3b940655..618d95b6f8 100644
--- a/Userland/Libraries/LibJS/Runtime/Set.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Set.cpp
@@ -10,12 +10,12 @@ namespace JS {
Set* Set::create(Realm& realm)
{
- return realm.heap().allocate<Set>(realm, *realm.global_object().set_prototype());
+ return realm.heap().allocate<Set>(realm, *realm.intrinsics().set_prototype());
}
Set::Set(Object& prototype)
: Object(prototype)
- , m_values(*prototype.global_object().map_prototype())
+ , m_values(*prototype.shape().realm().intrinsics().map_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp
index 4754c4fc54..b3c4d36bbc 100644
--- a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
SetConstructor::SetConstructor(Realm& realm)
- : NativeFunction(vm().names.Set.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Set.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -24,7 +24,7 @@ void SetConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 24.2.2.1 Set.prototype, https://tc39.es/ecma262/#sec-set.prototype
- define_direct_property(vm.names.prototype, realm.global_object().set_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().set_prototype(), 0);
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
@@ -43,7 +43,7 @@ ThrowCompletionOr<Object*> SetConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
- auto* set = TRY(ordinary_create_from_constructor<Set>(vm, new_target, &GlobalObject::set_prototype));
+ auto* set = TRY(ordinary_create_from_constructor<Set>(vm, new_target, &Intrinsics::set_prototype));
if (vm.argument(0).is_nullish())
return set;
diff --git a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp
index 2797ee1833..5fcdb86f8b 100644
--- a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp
@@ -11,7 +11,7 @@ namespace JS {
SetIterator* SetIterator::create(Realm& realm, Set& set, Object::PropertyKind iteration_kind)
{
- return realm.heap().allocate<SetIterator>(realm, set, iteration_kind, *realm.global_object().set_iterator_prototype());
+ return realm.heap().allocate<SetIterator>(realm, set, iteration_kind, *realm.intrinsics().set_iterator_prototype());
}
SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp
index 2f976e1a5f..d93db45b96 100644
--- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp
@@ -14,7 +14,7 @@
namespace JS {
SetIteratorPrototype::SetIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().iterator_prototype())
+ : PrototypeObject(*realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp
index 0a9bea3abf..f1ec8b21a8 100644
--- a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp
@@ -13,7 +13,7 @@
namespace JS {
SetPrototype::SetPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp
index 0ed2d9a99a..ff7e6dd6d5 100644
--- a/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp
@@ -212,7 +212,7 @@ ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, String specifier_stri
// 1. Assert: evalContext is an execution context associated to a ShadowRealm instance's [[ExecutionContext]].
// 2. Let innerCapability be ! NewPromiseCapability(%Promise%).
- auto inner_capability = MUST(new_promise_capability(vm, realm.global_object().promise_constructor()));
+ auto inner_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
// 3. Let runningContext be the running execution context.
// 4. If runningContext is not already suspended, suspend runningContext.
@@ -267,7 +267,7 @@ ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, String specifier_stri
auto* on_fulfilled = NativeFunction::create(realm, move(steps), 1, "", &caller_realm);
// 12. 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()));
// NOTE: Even though the spec tells us to use %ThrowTypeError%, it's not observable if we actually do.
// Throw a nicer TypeError forwarding the import error message instead (we know the argument is an Error object).
diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
index 82e7f86259..d0a384ddf0 100644
--- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
@@ -12,7 +12,7 @@ namespace JS {
// 3.2 The ShadowRealm Constructor, https://tc39.es/proposal-shadowrealm/#sec-shadowrealm-constructor
ShadowRealmConstructor::ShadowRealmConstructor(Realm& realm)
- : NativeFunction(vm().names.ShadowRealm.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.ShadowRealm.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -22,7 +22,7 @@ void ShadowRealmConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 3.3.1 ShadowRealm.prototype, https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype
- define_direct_property(vm.names.prototype, realm.global_object().shadow_realm_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().shadow_realm_prototype(), 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
}
@@ -59,7 +59,7 @@ ThrowCompletionOr<Object*> ShadowRealmConstructor::construct(FunctionObject& new
// 2. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%ShadowRealm.prototype%", « [[ShadowRealm]], [[ExecutionContext]] »).
// 4. Set O.[[ShadowRealm]] to realmRec.
// 9. Set O.[[ExecutionContext]] to context.
- auto* object = TRY(ordinary_create_from_constructor<ShadowRealm>(vm, new_target, &GlobalObject::shadow_realm_prototype, *realm, move(context)));
+ auto* object = TRY(ordinary_create_from_constructor<ShadowRealm>(vm, new_target, &Intrinsics::shadow_realm_prototype, *realm, move(context)));
// 10. Perform ? SetRealmGlobalObject(realmRec, undefined, undefined).
auto* new_global_object = vm.heap().allocate_without_realm<GlobalObject>(*realm);
diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp
index ca96c2f721..7a510e9a71 100644
--- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp
@@ -12,7 +12,7 @@ namespace JS {
// 3.4 Properties of the ShadowRealm Prototype Object, https://tc39.es/proposal-shadowrealm/#sec-properties-of-the-shadowrealm-prototype-object
ShadowRealmPrototype::ShadowRealmPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
index fa07dcd9cd..ab4f1982cb 100644
--- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
@@ -18,7 +18,7 @@
namespace JS {
StringConstructor::StringConstructor(Realm& realm)
- : NativeFunction(vm().names.String.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.String.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -28,7 +28,7 @@ void StringConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 22.1.2.3 String.prototype, https://tc39.es/ecma262/#sec-string.prototype
- define_direct_property(vm.names.prototype, realm.global_object().string_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().string_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.raw, raw, 1, attr);
@@ -60,7 +60,7 @@ ThrowCompletionOr<Object*> StringConstructor::construct(FunctionObject& new_targ
primitive_string = js_string(vm, "");
else
primitive_string = TRY(vm.argument(0).to_primitive_string(vm));
- auto* prototype = TRY(get_prototype_from_constructor(vm, new_target, &GlobalObject::string_prototype));
+ auto* prototype = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::string_prototype));
return StringObject::create(realm, *primitive_string, *prototype);
}
diff --git a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp
index 0a72b029e6..abd8e8f62f 100644
--- a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp
@@ -12,7 +12,7 @@ namespace JS {
StringIterator* StringIterator::create(Realm& realm, String string)
{
- return realm.heap().allocate<StringIterator>(realm, move(string), *realm.global_object().string_iterator_prototype());
+ return realm.heap().allocate<StringIterator>(realm, move(string), *realm.intrinsics().string_iterator_prototype());
}
StringIterator::StringIterator(String string, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp
index 71e056bacb..72386b1015 100644
--- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp
@@ -14,7 +14,7 @@
namespace JS {
StringIteratorPrototype::StringIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().iterator_prototype())
+ : PrototypeObject(*realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp
index ce10ba34fa..1d1be6b03a 100644
--- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp
@@ -103,7 +103,7 @@ static Optional<size_t> string_index_of(Utf16View const& string, Utf16View const
}
StringPrototype::StringPrototype(Realm& realm)
- : StringObject(*js_string(realm.vm(), String::empty()), *realm.global_object().object_prototype())
+ : StringObject(*js_string(realm.vm(), String::empty()), *realm.intrinsics().object_prototype())
{
}
@@ -1088,7 +1088,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::locale_compare)
auto that_value = TRY(vm.argument(0).to_string(vm));
// 4. Let collator be ? Construct(%Collator%, « locales, options »).
- auto* collator = TRY(construct(vm, *realm.global_object().intl_collator_constructor(), vm.argument(1), vm.argument(2)));
+ auto* collator = TRY(construct(vm, *realm.intrinsics().intl_collator_constructor(), vm.argument(1), vm.argument(2)));
// 5. Return CompareStrings(collator, S, thatValue).
return Intl::compare_strings(static_cast<Intl::Collator&>(*collator), Utf8View(string), Utf8View(that_value));
diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp
index 13847b1cb9..8d266a49c8 100644
--- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp
@@ -11,7 +11,7 @@
namespace JS {
SymbolConstructor::SymbolConstructor(Realm& realm)
- : NativeFunction(vm().names.Symbol.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Symbol.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -21,7 +21,7 @@ void SymbolConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 20.4.2.9 Symbol.prototype, https://tc39.es/ecma262/#sec-symbol.prototype
- define_direct_property(vm.names.prototype, realm.global_object().symbol_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().symbol_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.for_, for_, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp
index 61344a3b13..5163d3487f 100644
--- a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp
@@ -12,7 +12,7 @@ namespace JS {
SymbolObject* SymbolObject::create(Realm& realm, Symbol& primitive_symbol)
{
- return realm.heap().allocate<SymbolObject>(realm, primitive_symbol, *realm.global_object().symbol_prototype());
+ return realm.heap().allocate<SymbolObject>(realm, primitive_symbol, *realm.intrinsics().symbol_prototype());
}
SymbolObject::SymbolObject(Symbol& symbol, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp
index bc7981e1a8..7e9b574813 100644
--- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp
@@ -19,7 +19,7 @@
namespace JS {
SymbolPrototype::SymbolPrototype(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp
index c398769976..02229cb06b 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp
@@ -70,11 +70,11 @@ ThrowCompletionOr<Calendar*> create_temporal_calendar(VM& vm, String const& iden
// 2. If newTarget is not provided, set newTarget to %Temporal.Calendar%.
if (!new_target)
- new_target = realm.global_object().temporal_calendar_constructor();
+ new_target = realm.intrinsics().temporal_calendar_constructor();
// 3. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.Calendar.prototype%", « [[InitializedTemporalCalendar]], [[Identifier]] »).
// 4. Set object.[[Identifier]] to identifier.
- auto* object = TRY(ordinary_create_from_constructor<Calendar>(vm, *new_target, &GlobalObject::temporal_calendar_prototype, identifier));
+ auto* object = TRY(ordinary_create_from_constructor<Calendar>(vm, *new_target, &Intrinsics::temporal_calendar_prototype, identifier));
// 5. Return object.
return object;
@@ -947,7 +947,7 @@ ThrowCompletionOr<Object*> default_merge_calendar_fields(VM& vm, Object const& f
auto& realm = *vm.current_realm();
// 1. Let merged be OrdinaryObjectCreate(%Object.prototype%).
- auto* merged = Object::create(realm, realm.global_object().object_prototype());
+ auto* merged = Object::create(realm, realm.intrinsics().object_prototype());
// 2. Let fieldsKeys be ? EnumerableOwnPropertyNames(fields, key).
auto fields_keys = TRY(fields.enumerable_own_property_names(Object::PropertyKind::Key));
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp
index 4f3da005bf..6dfe194894 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp
@@ -12,7 +12,7 @@ namespace JS::Temporal {
// 12.2 The Temporal.Calendar Constructor, https://tc39.es/proposal-temporal/#sec-temporal-calendar-constructor
CalendarConstructor::CalendarConstructor(Realm& realm)
- : NativeFunction(vm().names.Calendar.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Calendar.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -23,7 +23,7 @@ void CalendarConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 12.3.1 Temporal.Calendar.prototype, https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_calendar_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_calendar_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp
index 6e33204687..422bb7e3b6 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp
@@ -21,7 +21,7 @@ namespace JS::Temporal {
// 12.4 Properties of the Temporal.Calendar Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-calendar-prototype-object
CalendarPrototype::CalendarPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp
index 99eaff7f98..e1b89a8a7f 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp
@@ -334,7 +334,7 @@ ThrowCompletionOr<Duration*> create_temporal_duration(VM& vm, double years, doub
// 2. If newTarget is not present, set newTarget to %Temporal.Duration%.
if (!new_target)
- new_target = realm.global_object().temporal_duration_constructor();
+ new_target = realm.intrinsics().temporal_duration_constructor();
// 3. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.Duration.prototype%", « [[InitializedTemporalDuration]], [[Years]], [[Months]], [[Weeks]], [[Days]], [[Hours]], [[Minutes]], [[Seconds]], [[Milliseconds]], [[Microseconds]], [[Nanoseconds]] »).
// 4. Set object.[[Years]] to ℝ(𝔽(years)).
@@ -347,7 +347,7 @@ ThrowCompletionOr<Duration*> create_temporal_duration(VM& vm, double years, doub
// 11. Set object.[[Milliseconds]] to ℝ(𝔽(milliseconds)).
// 12. Set object.[[Microseconds]] to ℝ(𝔽(microseconds)).
// 13. Set object.[[Nanoseconds]] to ℝ(𝔽(nanoseconds)).
- auto* object = TRY(ordinary_create_from_constructor<Duration>(vm, *new_target, &GlobalObject::temporal_duration_prototype, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds));
+ auto* object = TRY(ordinary_create_from_constructor<Duration>(vm, *new_target, &Intrinsics::temporal_duration_prototype, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds));
// 14. Return object.
return object;
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp
index 0bf97db585..9604a6eb28 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp
@@ -15,7 +15,7 @@ namespace JS::Temporal {
// 7.1 The Temporal.Duration Constructor, https://tc39.es/proposal-temporal/#sec-temporal-duration-constructor
DurationConstructor::DurationConstructor(Realm& realm)
- : NativeFunction(vm().names.Duration.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Duration.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -26,7 +26,7 @@ void DurationConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 7.2.1 Temporal.Duration.prototype, https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_duration_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_duration_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp
index f23fc5dae1..f7c91f6c5a 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 7.3 Properties of the Temporal.Duration Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-duration-prototype-object
DurationPrototype::DurationPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp
index dbe4eab60a..48a12782eb 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp
@@ -61,11 +61,11 @@ ThrowCompletionOr<Instant*> create_temporal_instant(VM& vm, BigInt const& epoch_
// 3. If newTarget is not present, set newTarget to %Temporal.Instant%.
if (!new_target)
- new_target = realm.global_object().temporal_instant_constructor();
+ new_target = realm.intrinsics().temporal_instant_constructor();
// 4. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.Instant.prototype%", « [[InitializedTemporalInstant]], [[Nanoseconds]] »).
// 5. Set object.[[Nanoseconds]] to epochNanoseconds.
- auto* object = TRY(ordinary_create_from_constructor<Instant>(vm, *new_target, &GlobalObject::temporal_instant_prototype, epoch_nanoseconds));
+ auto* object = TRY(ordinary_create_from_constructor<Instant>(vm, *new_target, &Intrinsics::temporal_instant_prototype, epoch_nanoseconds));
// 6. Return object.
return object;
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp
index f0d9ba895a..152ef332e7 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp
@@ -14,7 +14,7 @@ namespace JS::Temporal {
// 8.1 The Temporal.Instant Constructor, https://tc39.es/proposal-temporal/#sec-temporal-instant-constructor
InstantConstructor::InstantConstructor(Realm& realm)
- : NativeFunction(vm().names.Instant.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.Instant.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -25,7 +25,7 @@ void InstantConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 8.2.1 Temporal.Instant.prototype, https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_instant_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_instant_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp
index 6325b02421..6b382757bc 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp
@@ -20,7 +20,7 @@ namespace JS::Temporal {
// 8.3 Properties of the Temporal.Instant Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-instant-prototype-object
InstantPrototype::InstantPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
index bac128c0b7..e31a88dc41 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
@@ -21,7 +21,7 @@ namespace JS::Temporal {
// 2 The Temporal.Now Object, https://tc39.es/proposal-temporal/#sec-temporal-now-object
Now::Now(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp
index b54133dd20..a3e0f96008 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp
@@ -67,14 +67,14 @@ ThrowCompletionOr<PlainDate*> create_temporal_date(VM& vm, i32 iso_year, u8 iso_
// 7. If newTarget is not present, set newTarget to %Temporal.PlainDate%.
if (!new_target)
- new_target = realm.global_object().temporal_plain_date_constructor();
+ new_target = realm.intrinsics().temporal_plain_date_constructor();
// 8. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainDate.prototype%", « [[InitializedTemporalDate]], [[ISOYear]], [[ISOMonth]], [[ISODay]], [[Calendar]] »).
// 9. Set object.[[ISOYear]] to isoYear.
// 10. Set object.[[ISOMonth]] to isoMonth.
// 11. Set object.[[ISODay]] to isoDay.
// 12. Set object.[[Calendar]] to calendar.
- auto* object = TRY(ordinary_create_from_constructor<PlainDate>(vm, *new_target, &GlobalObject::temporal_plain_date_prototype, iso_year, iso_month, iso_day, calendar));
+ auto* object = TRY(ordinary_create_from_constructor<PlainDate>(vm, *new_target, &Intrinsics::temporal_plain_date_prototype, iso_year, iso_month, iso_day, calendar));
return object;
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
index 29153665de..f4b9c81166 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 3.1 The Temporal.PlainDate Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaindate-constructor
PlainDateConstructor::PlainDateConstructor(Realm& realm)
- : NativeFunction(vm().names.PlainDate.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.PlainDate.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -27,7 +27,7 @@ void PlainDateConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 3.2.1 Temporal.PlainDate.prototype, https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_plain_date_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_plain_date_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp
index 9ba70eaa67..e2cbd780bf 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp
@@ -21,7 +21,7 @@ namespace JS::Temporal {
// 3.3 Properties of the Temporal.PlainDate Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaindate-prototype-object
PlainDatePrototype::PlainDatePrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -326,7 +326,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::get_iso_fields)
auto* temporal_date = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
- auto* fields = Object::create(realm, realm.global_object().object_prototype());
+ auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalDate.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_date->calendar())));
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp
index b3d611c60a..173cb5874b 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp
@@ -249,7 +249,7 @@ ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(VM& vm, i32 iso_year
// 6. If newTarget is not present, set newTarget to %Temporal.PlainDateTime%.
if (!new_target)
- new_target = realm.global_object().temporal_plain_date_time_constructor();
+ new_target = realm.intrinsics().temporal_plain_date_time_constructor();
// 7. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainDateTime.prototype%", « [[InitializedTemporalDateTime]], [[ISOYear]], [[ISOMonth]], [[ISODay]], [[ISOHour]], [[ISOMinute]], [[ISOSecond]], [[ISOMillisecond]], [[ISOMicrosecond]], [[ISONanosecond]], [[Calendar]] »).
// 8. Set object.[[ISOYear]] to isoYear.
@@ -262,7 +262,7 @@ ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(VM& vm, i32 iso_year
// 15. Set object.[[ISOMicrosecond]] to microsecond.
// 16. Set object.[[ISONanosecond]] to nanosecond.
// 17. Set object.[[Calendar]] to calendar.
- auto* object = TRY(ordinary_create_from_constructor<PlainDateTime>(vm, *new_target, &GlobalObject::temporal_plain_date_prototype, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, calendar));
+ auto* object = TRY(ordinary_create_from_constructor<PlainDateTime>(vm, *new_target, &Intrinsics::temporal_plain_date_prototype, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, calendar));
// 18. Return object.
return object;
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp
index 0ce85372d5..0a3f8c16a5 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 5.1 The Temporal.PlainDateTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaindatetime-constructor
PlainDateTimeConstructor::PlainDateTimeConstructor(Realm& realm)
- : NativeFunction(vm().names.PlainDateTime.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.PlainDateTime.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -27,7 +27,7 @@ void PlainDateTimeConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 5.2.1 Temporal.PlainDateTime.prototype, https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_plain_date_time_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_plain_date_time_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp
index 25cac88f60..93a4a36a90 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp
@@ -22,7 +22,7 @@ namespace JS::Temporal {
// 5.3 Properties of the Temporal.PlainDateTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaindatetime-prototype-object
PlainDateTimePrototype::PlainDateTimePrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -735,7 +735,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::get_iso_fields)
auto* date_time = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
- auto* fields = Object::create(realm, realm.global_object().object_prototype());
+ auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", dateTime.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&date_time->calendar())));
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp
index ecbc433553..fa3d6dc632 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp
@@ -159,14 +159,14 @@ ThrowCompletionOr<PlainMonthDay*> create_temporal_month_day(VM& vm, u8 iso_month
// 5. If newTarget is not present, set newTarget to %Temporal.PlainMonthDay%.
if (!new_target)
- new_target = realm.global_object().temporal_plain_month_day_constructor();
+ new_target = realm.intrinsics().temporal_plain_month_day_constructor();
// 6. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainMonthDay.prototype%", « [[InitializedTemporalMonthDay]], [[ISOMonth]], [[ISODay]], [[ISOYear]], [[Calendar]] »).
// 7. Set object.[[ISOMonth]] to isoMonth.
// 8. Set object.[[ISODay]] to isoDay.
// 9. Set object.[[Calendar]] to calendar.
// 10. Set object.[[ISOYear]] to referenceISOYear.
- auto* object = TRY(ordinary_create_from_constructor<PlainMonthDay>(vm, *new_target, &GlobalObject::temporal_plain_month_day_prototype, iso_month, iso_day, reference_iso_year, calendar));
+ auto* object = TRY(ordinary_create_from_constructor<PlainMonthDay>(vm, *new_target, &Intrinsics::temporal_plain_month_day_prototype, iso_month, iso_day, reference_iso_year, calendar));
// 11. Return object.
return object;
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp
index 4cc51a6aa9..125b233d79 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp
@@ -15,7 +15,7 @@ namespace JS::Temporal {
// 10.1 The Temporal.PlainMonthDay Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plainmonthday-constructor
PlainMonthDayConstructor::PlainMonthDayConstructor(Realm& realm)
- : NativeFunction(vm().names.PlainMonthDay.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.PlainMonthDay.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -26,7 +26,7 @@ void PlainMonthDayConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 10.2.1 Temporal.PlainMonthDay.prototype, https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_plain_month_day_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_plain_month_day_prototype(), 0);
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp
index 2c31946da7..816bf4998e 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 10.3 Properties of the Temporal.PlainMonthDay Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plainmonthday-prototype-object
PlainMonthDayPrototype::PlainMonthDayPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -260,7 +260,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::get_iso_fields)
auto* month_day = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
- auto* fields = Object::create(realm, realm.global_object().object_prototype());
+ auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", monthDay.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&month_day->calendar())));
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp
index 78a29922c2..d2f91c3406 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp
@@ -320,7 +320,7 @@ ThrowCompletionOr<PlainTime*> create_temporal_time(VM& vm, u8 hour, u8 minute, u
// 3. If newTarget is not present, set newTarget to %Temporal.PlainTime%.
if (!new_target)
- new_target = realm.global_object().temporal_plain_time_constructor();
+ new_target = realm.intrinsics().temporal_plain_time_constructor();
// 4. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainTime.prototype%", « [[InitializedTemporalTime]], [[ISOHour]], [[ISOMinute]], [[ISOSecond]], [[ISOMillisecond]], [[ISOMicrosecond]], [[ISONanosecond]], [[Calendar]] »).
// 5. Set object.[[ISOHour]] to hour.
@@ -330,7 +330,7 @@ ThrowCompletionOr<PlainTime*> create_temporal_time(VM& vm, u8 hour, u8 minute, u
// 9. Set object.[[ISOMicrosecond]] to microsecond.
// 10. Set object.[[ISONanosecond]] to nanosecond.
// 11. Set object.[[Calendar]] to ! GetISO8601Calendar().
- auto* object = TRY(ordinary_create_from_constructor<PlainTime>(vm, *new_target, &GlobalObject::temporal_plain_time_prototype, hour, minute, second, millisecond, microsecond, nanosecond, *get_iso8601_calendar(vm)));
+ auto* object = TRY(ordinary_create_from_constructor<PlainTime>(vm, *new_target, &Intrinsics::temporal_plain_time_prototype, hour, minute, second, millisecond, microsecond, nanosecond, *get_iso8601_calendar(vm)));
// 12. Return object.
return object;
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp
index 6d156a43a3..01e3c56704 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp
@@ -14,7 +14,7 @@ namespace JS::Temporal {
// 4.1 The Temporal.PlainTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaintime-constructor
PlainTimeConstructor::PlainTimeConstructor(Realm& realm)
- : NativeFunction(vm().names.PlainTime.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.PlainTime.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -25,7 +25,7 @@ void PlainTimeConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 4.2.1 Temporal.PlainTime.prototype, https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_plain_time_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_plain_time_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp
index 7d5f42e237..215b27c59f 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp
@@ -21,7 +21,7 @@ namespace JS::Temporal {
// 4.3 Properties of the Temporal.PlainTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaintime-prototype-object
PlainTimePrototype::PlainTimePrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -425,7 +425,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields)
auto* temporal_time = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
- auto* fields = Object::create(realm, realm.global_object().object_prototype());
+ auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalTime.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_time->calendar())));
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp
index 82272ceb4e..c744de030e 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp
@@ -200,14 +200,14 @@ ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(VM& vm, i32 iso_ye
// 5. If newTarget is not present, set newTarget to %Temporal.PlainYearMonth%.
if (!new_target)
- new_target = realm.global_object().temporal_plain_year_month_constructor();
+ new_target = realm.intrinsics().temporal_plain_year_month_constructor();
// 6. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainYearMonth.prototype%", « [[InitializedTemporalYearMonth]], [[ISOYear]], [[ISOMonth]], [[ISODay]], [[Calendar]] »).
// 7. Set object.[[ISOYear]] to isoYear.
// 8. Set object.[[ISOMonth]] to isoMonth.
// 9. Set object.[[Calendar]] to calendar.
// 10. Set object.[[ISODay]] to referenceISODay.
- auto* object = TRY(ordinary_create_from_constructor<PlainYearMonth>(vm, *new_target, &GlobalObject::temporal_plain_year_month_prototype, iso_year, iso_month, reference_iso_day, calendar));
+ auto* object = TRY(ordinary_create_from_constructor<PlainYearMonth>(vm, *new_target, &Intrinsics::temporal_plain_year_month_prototype, iso_year, iso_month, reference_iso_day, calendar));
// 11. Return object.
return object;
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp
index 72f43002da..f79f20a9d3 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 9.1 The Temporal.PlainYearMonth Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plainyearmonth-constructor
PlainYearMonthConstructor::PlainYearMonthConstructor(Realm& realm)
- : NativeFunction(vm().names.PlainYearMonth.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.PlainYearMonth.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -27,7 +27,7 @@ void PlainYearMonthConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 9.2.1 Temporal.PlainYearMonth.prototype, https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_plain_year_month_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_plain_year_month_prototype(), 0);
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp
index 0f49d70672..9c12558557 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp
@@ -18,7 +18,7 @@ namespace JS::Temporal {
// 9.3 Properties of the Temporal.PlainYearMonth Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plainyearmonth-prototype-object
PlainYearMonthPrototype::PlainYearMonthPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -427,7 +427,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::get_iso_fields)
auto* year_month = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
- auto* fields = Object::create(realm, realm.global_object().object_prototype());
+ auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", yearMonth.[[Calendar]]).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&year_month->calendar())));
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
index 7cfb762247..d7a8b6cc18 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -22,7 +22,7 @@ namespace JS::Temporal {
// 1 The Temporal Object, https://tc39.es/proposal-temporal/#sec-temporal-objects
Temporal::Temporal(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
@@ -37,16 +37,16 @@ void Temporal::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_direct_property(vm.names.Now, heap().allocate<Now>(realm, realm), attr);
- define_direct_property(vm.names.Calendar, realm.global_object().temporal_calendar_constructor(), attr);
- define_direct_property(vm.names.Duration, realm.global_object().temporal_duration_constructor(), attr);
- define_direct_property(vm.names.Instant, realm.global_object().temporal_instant_constructor(), attr);
- define_direct_property(vm.names.PlainDate, realm.global_object().temporal_plain_date_constructor(), attr);
- define_direct_property(vm.names.PlainDateTime, realm.global_object().temporal_plain_date_time_constructor(), attr);
- define_direct_property(vm.names.PlainMonthDay, realm.global_object().temporal_plain_month_day_constructor(), attr);
- define_direct_property(vm.names.PlainTime, realm.global_object().temporal_plain_time_constructor(), attr);
- define_direct_property(vm.names.PlainYearMonth, realm.global_object().temporal_plain_year_month_constructor(), attr);
- define_direct_property(vm.names.TimeZone, realm.global_object().temporal_time_zone_constructor(), attr);
- define_direct_property(vm.names.ZonedDateTime, realm.global_object().temporal_zoned_date_time_constructor(), attr);
+ define_direct_property(vm.names.Calendar, realm.intrinsics().temporal_calendar_constructor(), attr);
+ define_direct_property(vm.names.Duration, realm.intrinsics().temporal_duration_constructor(), attr);
+ define_direct_property(vm.names.Instant, realm.intrinsics().temporal_instant_constructor(), attr);
+ define_direct_property(vm.names.PlainDate, realm.intrinsics().temporal_plain_date_constructor(), attr);
+ define_direct_property(vm.names.PlainDateTime, realm.intrinsics().temporal_plain_date_time_constructor(), attr);
+ define_direct_property(vm.names.PlainMonthDay, realm.intrinsics().temporal_plain_month_day_constructor(), attr);
+ define_direct_property(vm.names.PlainTime, realm.intrinsics().temporal_plain_time_constructor(), attr);
+ define_direct_property(vm.names.PlainYearMonth, realm.intrinsics().temporal_plain_year_month_constructor(), attr);
+ define_direct_property(vm.names.TimeZone, realm.intrinsics().temporal_time_zone_constructor(), attr);
+ define_direct_property(vm.names.ZonedDateTime, realm.intrinsics().temporal_zoned_date_time_constructor(), attr);
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
index 3b7936858a..1bc1faa152 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
@@ -69,10 +69,10 @@ ThrowCompletionOr<TimeZone*> create_temporal_time_zone(VM& vm, String const& ide
// 1. If newTarget is not present, set newTarget to %Temporal.TimeZone%.
if (!new_target)
- new_target = realm.global_object().temporal_time_zone_constructor();
+ new_target = realm.intrinsics().temporal_time_zone_constructor();
// 2. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.TimeZone.prototype%", « [[InitializedTemporalTimeZone]], [[Identifier]], [[OffsetNanoseconds]] »).
- auto* object = TRY(ordinary_create_from_constructor<TimeZone>(vm, *new_target, &GlobalObject::temporal_time_zone_prototype));
+ auto* object = TRY(ordinary_create_from_constructor<TimeZone>(vm, *new_target, &Intrinsics::temporal_time_zone_prototype));
// 3. Let offsetNanosecondsResult be Completion(ParseTimeZoneOffsetString(identifier)).
auto offset_nanoseconds_result = parse_time_zone_offset_string(vm, identifier);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp
index 9ee77b5887..8ea721b368 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp
@@ -12,7 +12,7 @@ namespace JS::Temporal {
// 11.2 The Temporal.TimeZone Constructor, https://tc39.es/proposal-temporal/#sec-temporal-timezone-constructor
TimeZoneConstructor::TimeZoneConstructor(Realm& realm)
- : NativeFunction(vm().names.TimeZone.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.TimeZone.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -23,7 +23,7 @@ void TimeZoneConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 11.3.1 Temporal.TimeZone.prototype, https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_time_zone_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_time_zone_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp
index c65254bce2..fc463bfbda 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp
@@ -18,7 +18,7 @@ namespace JS::Temporal {
// 11.4 Properties of the Temporal.TimeZone Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-timezone-prototype-object
TimeZonePrototype::TimeZonePrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp
index eb824f38fe..1d9efe8b36 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp
@@ -273,13 +273,13 @@ ThrowCompletionOr<ZonedDateTime*> create_temporal_zoned_date_time(VM& vm, BigInt
// 2. If newTarget is not present, set newTarget to %Temporal.ZonedDateTime%.
if (!new_target)
- new_target = realm.global_object().temporal_zoned_date_time_constructor();
+ new_target = realm.intrinsics().temporal_zoned_date_time_constructor();
// 3. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.ZonedDateTime.prototype%", « [[InitializedTemporalZonedDateTime]], [[Nanoseconds]], [[TimeZone]], [[Calendar]] »).
// 4. Set object.[[Nanoseconds]] to epochNanoseconds.
// 5. Set object.[[TimeZone]] to timeZone.
// 6. Set object.[[Calendar]] to calendar.
- auto* object = TRY(ordinary_create_from_constructor<ZonedDateTime>(vm, *new_target, &GlobalObject::temporal_time_zone_prototype, epoch_nanoseconds, time_zone, calendar));
+ auto* object = TRY(ordinary_create_from_constructor<ZonedDateTime>(vm, *new_target, &Intrinsics::temporal_time_zone_prototype, epoch_nanoseconds, time_zone, calendar));
// 7. Return object.
return object;
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp
index d695455c51..cd1ce2ab5c 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp
@@ -17,7 +17,7 @@ namespace JS::Temporal {
// 6.1 The Temporal.ZonedDateTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-zoneddatetime-constructor
ZonedDateTimeConstructor::ZonedDateTimeConstructor(Realm& realm)
- : NativeFunction(vm().names.ZonedDateTime.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.ZonedDateTime.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -28,7 +28,7 @@ void ZonedDateTimeConstructor::initialize(Realm& realm)
auto& vm = this->vm();
// 6.2.1 Temporal.ZonedDateTime.prototype, https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype
- define_direct_property(vm.names.prototype, realm.global_object().temporal_zoned_date_time_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().temporal_zoned_date_time_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp
index e0e8660802..8cb5157afe 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp
@@ -21,7 +21,7 @@ namespace JS::Temporal {
// 6.3 Properties of the Temporal.ZonedDateTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-zoneddatetime-prototype-object
ZonedDateTimePrototype::ZonedDateTimePrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
@@ -1291,7 +1291,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
auto* zoned_date_time = TRY(typed_this_object(vm));
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
- auto* fields = Object::create(realm, realm.global_object().object_prototype());
+ auto* fields = Object::create(realm, realm.intrinsics().object_prototype());
// 4. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone();
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
index 35e20e2007..5ea98f0fdc 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
@@ -168,7 +168,7 @@ static ThrowCompletionOr<void> initialize_typed_array_from_typed_array(VM& vm, T
// 11. Else,
else {
// a. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength).
- data = TRY(allocate_array_buffer(vm, *realm.global_object().array_buffer_constructor(), byte_length.value()));
+ data = TRY(allocate_array_buffer(vm, *realm.intrinsics().array_buffer_constructor(), byte_length.value()));
// b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception.
if (src_data->is_detached())
@@ -240,7 +240,7 @@ static ThrowCompletionOr<void> allocate_typed_array_buffer(VM& vm, TypedArray<T>
auto byte_length = element_size * length;
// 4. Let data be ? AllocateArrayBuffer(%ArrayBuffer%, byteLength).
- auto* data = TRY(allocate_array_buffer(vm, *realm.global_object().array_buffer_constructor(), byte_length));
+ auto* data = TRY(allocate_array_buffer(vm, *realm.intrinsics().array_buffer_constructor(), byte_length));
// 5. Set O.[[ViewedArrayBuffer]] to data.
typed_array.set_viewed_array_buffer(data);
@@ -346,7 +346,7 @@ ThrowCompletionOr<TypedArrayBase*> typed_array_create_same_type(VM& vm, TypedArr
// 1. Assert: exemplar is an Object that has [[TypedArrayName]] and [[ContentType]] internal slots.
// 2. Let constructor be the intrinsic object listed in column one of Table 63 (points to Table 72) for exemplar.[[TypedArrayName]].
- auto* constructor = (realm.global_object().*exemplar.intrinsic_constructor())();
+ auto* constructor = (realm.intrinsics().*exemplar.intrinsic_constructor())();
// 3. Let result be ? TypedArrayCreate(constructor, argumentList).
auto* result = TRY(typed_array_create(vm, *constructor, move(arguments)));
@@ -423,137 +423,137 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
visitor.visit(m_viewed_array_buffer);
}
-#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
- ThrowCompletionOr<ClassName*> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \
- { \
- auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &GlobalObject::snake_name##_prototype)); \
- auto* array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
- return realm.heap().allocate<ClassName>(realm, *prototype, length, *array_buffer); \
- } \
- \
- ThrowCompletionOr<ClassName*> ClassName::create(Realm& realm, u32 length) \
- { \
- auto* array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
- return create(realm, length, *array_buffer); \
- } \
- \
- ClassName* ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \
- { \
- return realm.heap().allocate<ClassName>(realm, *realm.global_object().snake_name##_prototype(), length, array_buffer); /* */ \
- } \
- \
- ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \
- : TypedArray(prototype, \
- reinterpret_cast<TypedArrayBase::IntrinsicConstructor>(&GlobalObject::snake_name##_constructor), length, array_buffer) \
- { \
- if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \
- m_content_type = ContentType::BigInt; \
- else \
- m_content_type = ContentType::Number; \
- } \
- \
- ClassName::~ClassName() \
- { \
- } \
- \
- FlyString const& ClassName::element_name() const \
- { \
- return vm().names.ClassName.as_string(); \
- } \
- \
- PrototypeName::PrototypeName(Realm& realm) \
- : Object(*realm.global_object().typed_array_prototype()) \
- { \
- } \
- \
- PrototypeName::~PrototypeName() \
- { \
- } \
- \
- void PrototypeName::initialize(Realm& realm) \
- { \
- auto& vm = this->vm(); \
- Object::initialize(realm); \
- define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
- } \
- \
- ConstructorName::ConstructorName(Realm& realm) \
- : TypedArrayConstructor(vm().names.ClassName.as_string(), *realm.global_object().typed_array_constructor()) \
- { \
- } \
- \
- ConstructorName::~ConstructorName() \
- { \
- } \
- \
- void ConstructorName::initialize(Realm& realm) \
- { \
- auto& vm = this->vm(); \
- NativeFunction::initialize(realm); \
- \
- /* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \
- define_direct_property(vm.names.prototype, realm.global_object().snake_name##_prototype(), 0); \
- \
- /* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \
- define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
- \
- define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \
- } \
- \
- /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
- ThrowCompletionOr<Value> ConstructorName::call() \
- { \
- auto& vm = this->vm(); \
- return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \
- } \
- \
- /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
- ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target) \
- { \
- auto& vm = this->vm(); \
- auto& realm = *vm.current_realm(); \
- \
- if (vm.argument_count() == 0) \
- return TRY(ClassName::create(realm, 0, new_target)); \
- \
- auto first_argument = vm.argument(0); \
- if (first_argument.is_object()) { \
- auto* typed_array = TRY(ClassName::create(realm, 0, new_target)); \
- if (first_argument.as_object().is_typed_array()) { \
- auto& arg_typed_array = static_cast<TypedArrayBase&>(first_argument.as_object()); \
- TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \
- } else if (is<ArrayBuffer>(first_argument.as_object())) { \
- auto& array_buffer = static_cast<ArrayBuffer&>(first_argument.as_object()); \
- TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \
- vm.argument(1), vm.argument(2))); \
- } else { \
- auto iterator = TRY(first_argument.get_method(vm, *vm.well_known_symbol_iterator())); \
- if (iterator) { \
- auto values = TRY(iterable_to_list(vm, first_argument, iterator)); \
- TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \
- } else { \
- TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \
- } \
- } \
- return typed_array; \
- } \
- \
- auto array_length_or_error = first_argument.to_index(vm); \
- if (array_length_or_error.is_error()) { \
- auto error = array_length_or_error.release_error(); \
- if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) { \
- /* Re-throw more specific RangeError */ \
- return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
- } \
- return error; \
- } \
- auto array_length = array_length_or_error.release_value(); \
- if (array_length > NumericLimits<i32>::max() / sizeof(Type)) \
- return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
- /* FIXME: What is the best/correct behavior here? */ \
- if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type))) \
- return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
- return TRY(ClassName::create(realm, array_length, new_target)); \
+#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
+ ThrowCompletionOr<ClassName*> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \
+ { \
+ auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &Intrinsics::snake_name##_prototype)); \
+ auto* array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
+ return realm.heap().allocate<ClassName>(realm, *prototype, length, *array_buffer); \
+ } \
+ \
+ ThrowCompletionOr<ClassName*> ClassName::create(Realm& realm, u32 length) \
+ { \
+ auto* array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
+ return create(realm, length, *array_buffer); \
+ } \
+ \
+ ClassName* ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \
+ { \
+ return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype(), length, array_buffer); \
+ } \
+ \
+ ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \
+ : TypedArray(prototype, \
+ reinterpret_cast<TypedArrayBase::IntrinsicConstructor>(&Intrinsics::snake_name##_constructor), length, array_buffer) \
+ { \
+ if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \
+ m_content_type = ContentType::BigInt; \
+ else \
+ m_content_type = ContentType::Number; \
+ } \
+ \
+ ClassName::~ClassName() \
+ { \
+ } \
+ \
+ FlyString const& ClassName::element_name() const \
+ { \
+ return vm().names.ClassName.as_string(); \
+ } \
+ \
+ PrototypeName::PrototypeName(Realm& realm) \
+ : Object(*realm.intrinsics().typed_array_prototype()) \
+ { \
+ } \
+ \
+ PrototypeName::~PrototypeName() \
+ { \
+ } \
+ \
+ void PrototypeName::initialize(Realm& realm) \
+ { \
+ auto& vm = this->vm(); \
+ Object::initialize(realm); \
+ define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
+ } \
+ \
+ ConstructorName::ConstructorName(Realm& realm) \
+ : TypedArrayConstructor(vm().names.ClassName.as_string(), *realm.intrinsics().typed_array_constructor()) \
+ { \
+ } \
+ \
+ ConstructorName::~ConstructorName() \
+ { \
+ } \
+ \
+ void ConstructorName::initialize(Realm& realm) \
+ { \
+ auto& vm = this->vm(); \
+ NativeFunction::initialize(realm); \
+ \
+ /* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \
+ define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \
+ \
+ /* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \
+ define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
+ \
+ define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \
+ } \
+ \
+ /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
+ ThrowCompletionOr<Value> ConstructorName::call() \
+ { \
+ auto& vm = this->vm(); \
+ return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \
+ } \
+ \
+ /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
+ ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target) \
+ { \
+ auto& vm = this->vm(); \
+ auto& realm = *vm.current_realm(); \
+ \
+ if (vm.argument_count() == 0) \
+ return TRY(ClassName::create(realm, 0, new_target)); \
+ \
+ auto first_argument = vm.argument(0); \
+ if (first_argument.is_object()) { \
+ auto* typed_array = TRY(ClassName::create(realm, 0, new_target)); \
+ if (first_argument.as_object().is_typed_array()) { \
+ auto& arg_typed_array = static_cast<TypedArrayBase&>(first_argument.as_object()); \
+ TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \
+ } else if (is<ArrayBuffer>(first_argument.as_object())) { \
+ auto& array_buffer = static_cast<ArrayBuffer&>(first_argument.as_object()); \
+ TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \
+ vm.argument(1), vm.argument(2))); \
+ } else { \
+ auto iterator = TRY(first_argument.get_method(vm, *vm.well_known_symbol_iterator())); \
+ if (iterator) { \
+ auto values = TRY(iterable_to_list(vm, first_argument, iterator)); \
+ TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \
+ } else { \
+ TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \
+ } \
+ } \
+ return typed_array; \
+ } \
+ \
+ auto array_length_or_error = first_argument.to_index(vm); \
+ if (array_length_or_error.is_error()) { \
+ auto error = array_length_or_error.release_error(); \
+ if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) { \
+ /* Re-throw more specific RangeError */ \
+ return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
+ } \
+ return error; \
+ } \
+ auto array_length = array_length_or_error.release_value(); \
+ if (array_length > NumericLimits<i32>::max() / sizeof(Type)) \
+ return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
+ /* FIXME: What is the best/correct behavior here? */ \
+ if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type))) \
+ return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
+ return TRY(ClassName::create(realm, array_length, new_target)); \
}
#undef __JS_ENUMERATE
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h
index 6d7da88854..403c809a51 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.h
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h
@@ -32,7 +32,7 @@ public:
Number,
};
- using IntrinsicConstructor = TypedArrayConstructor* (GlobalObject::*)();
+ using IntrinsicConstructor = TypedArrayConstructor* (Intrinsics::*)();
u32 array_length() const { return m_array_length; }
u32 byte_length() const { return m_byte_length; }
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
index 2282b0f3b8..ab711200de 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
@@ -17,7 +17,7 @@ TypedArrayConstructor::TypedArrayConstructor(FlyString const& name, Object& prot
}
TypedArrayConstructor::TypedArrayConstructor(Realm& realm)
- : NativeFunction(vm().names.TypedArray.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.TypedArray.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -27,7 +27,7 @@ void TypedArrayConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 23.2.2.3 %TypedArray%.prototype, https://tc39.es/ecma262/#sec-%typedarray%.prototype
- define_direct_property(vm.names.prototype, realm.global_object().typed_array_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().typed_array_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.from, from, 1, attr);
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp
index a391a9f45b..e9b83e07f9 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp
@@ -16,7 +16,7 @@
namespace JS {
TypedArrayPrototype::TypedArrayPrototype(Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
}
@@ -65,7 +65,7 @@ void TypedArrayPrototype::initialize(Realm& realm)
define_native_accessor(realm, *vm.well_known_symbol_to_string_tag(), to_string_tag_getter, nullptr, Attribute::Configurable);
// 23.2.3.32 %TypedArray%.prototype.toString ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring
- define_direct_property(vm.names.toString, realm.global_object().array_prototype()->get_without_side_effects(vm.names.toString), attr);
+ define_direct_property(vm.names.toString, realm.intrinsics().array_prototype()->get_without_side_effects(vm.names.toString), attr);
// 23.2.3.34 %TypedArray%.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype-@@iterator
define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr);
@@ -146,7 +146,7 @@ static ThrowCompletionOr<TypedArrayBase*> typed_array_species_create(VM& vm, Typ
auto& realm = *vm.current_realm();
// 1. Let defaultConstructor be the intrinsic object listed in column one of Table 72 for exemplar.[[TypedArrayName]].
- auto* default_constructor = (realm.global_object().*exemplar.intrinsic_constructor())();
+ auto* default_constructor = (realm.intrinsics().*exemplar.intrinsic_constructor())();
// 2. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
auto* constructor = TRY(species_constructor(vm, exemplar, *default_constructor));
diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp
index bcc591c993..8a1c09e906 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.cpp
+++ b/Userland/Libraries/LibJS/Runtime/VM.cpp
@@ -336,7 +336,7 @@ ThrowCompletionOr<void> VM::property_binding_initialization(BindingPattern const
VERIFY_NOT_REACHED();
}
- auto* rest_object = Object::create(realm, realm.global_object().object_prototype());
+ auto* rest_object = Object::create(realm, realm.intrinsics().object_prototype());
VERIFY(rest_object);
TRY(rest_object->copy_data_properties(vm, object, seen_names));
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index cb5650540f..a4997dc5ad 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -450,7 +450,7 @@ ThrowCompletionOr<Object*> Value::to_object(VM& vm) const
case BOOLEAN_TAG:
return BooleanObject::create(realm, as_bool());
case STRING_TAG:
- return StringObject::create(realm, const_cast<JS::PrimitiveString&>(as_string()), *realm.global_object().string_prototype());
+ return StringObject::create(realm, const_cast<JS::PrimitiveString&>(as_string()), *realm.intrinsics().string_prototype());
case SYMBOL_TAG:
return SymbolObject::create(realm, const_cast<JS::Symbol&>(as_symbol()));
case BIGINT_TAG:
diff --git a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
index 2da2b3f40e..0169bdf1c1 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
@@ -10,7 +10,7 @@ namespace JS {
WeakMap* WeakMap::create(Realm& realm)
{
- return realm.heap().allocate<WeakMap>(realm, *realm.global_object().weak_map_prototype());
+ return realm.heap().allocate<WeakMap>(realm, *realm.intrinsics().weak_map_prototype());
}
WeakMap::WeakMap(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp
index 2ffda9bdc5..73667d24f5 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
WeakMapConstructor::WeakMapConstructor(Realm& realm)
- : NativeFunction(vm().names.WeakMap.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.WeakMap.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -24,7 +24,7 @@ void WeakMapConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 24.3.2.1 WeakMap.prototype, https://tc39.es/ecma262/#sec-weakmap.prototype
- define_direct_property(vm.names.prototype, realm.global_object().weak_map_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().weak_map_prototype(), 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
}
@@ -41,7 +41,7 @@ ThrowCompletionOr<Object*> WeakMapConstructor::construct(FunctionObject& new_tar
{
auto& vm = this->vm();
- auto* weak_map = TRY(ordinary_create_from_constructor<WeakMap>(vm, new_target, &GlobalObject::weak_map_prototype));
+ auto* weak_map = TRY(ordinary_create_from_constructor<WeakMap>(vm, new_target, &Intrinsics::weak_map_prototype));
if (vm.argument(0).is_nullish())
return weak_map;
diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp
index 8f311fcb2d..08538e9d53 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp
@@ -12,7 +12,7 @@
namespace JS {
WeakMapPrototype::WeakMapPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp
index d3d10a2cb9..023ccbcbd4 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp
@@ -10,12 +10,12 @@ namespace JS {
WeakRef* WeakRef::create(Realm& realm, Object& value)
{
- return realm.heap().allocate<WeakRef>(realm, value, *realm.global_object().weak_ref_prototype());
+ return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype());
}
WeakRef* WeakRef::create(Realm& realm, Symbol& value)
{
- return realm.heap().allocate<WeakRef>(realm, value, *realm.global_object().weak_ref_prototype());
+ return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype());
}
WeakRef::WeakRef(Object& value, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp
index e4769ab867..302f291f7a 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp
@@ -13,7 +13,7 @@
namespace JS {
WeakRefConstructor::WeakRefConstructor(Realm& realm)
- : NativeFunction(vm().names.WeakRef.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.WeakRef.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -23,7 +23,7 @@ void WeakRefConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 26.1.2.1 WeakRef.prototype, https://tc39.es/ecma262/#sec-weak-ref.prototype
- define_direct_property(vm.names.prototype, realm.global_object().weak_ref_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().weak_ref_prototype(), 0);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
}
@@ -45,9 +45,9 @@ ThrowCompletionOr<Object*> WeakRefConstructor::construct(FunctionObject& new_tar
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, target.to_string_without_side_effects());
if (target.is_object())
- return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &GlobalObject::weak_ref_prototype, target.as_object()));
+ return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_object()));
VERIFY(target.is_symbol());
- return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &GlobalObject::weak_ref_prototype, target.as_symbol()));
+ return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_symbol()));
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp
index bd90ec7865..5b7b818407 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp
@@ -10,7 +10,7 @@
namespace JS {
WeakRefPrototype::WeakRefPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
index afa0f30a8b..336a3d1501 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
@@ -10,7 +10,7 @@ namespace JS {
WeakSet* WeakSet::create(Realm& realm)
{
- return realm.heap().allocate<WeakSet>(realm, *realm.global_object().weak_set_prototype());
+ return realm.heap().allocate<WeakSet>(realm, *realm.intrinsics().weak_set_prototype());
}
WeakSet::WeakSet(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp
index 493e0b2756..146d022228 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
WeakSetConstructor::WeakSetConstructor(Realm& realm)
- : NativeFunction(vm().names.WeakSet.as_string(), *realm.global_object().function_prototype())
+ : NativeFunction(vm().names.WeakSet.as_string(), *realm.intrinsics().function_prototype())
{
}
@@ -24,7 +24,7 @@ void WeakSetConstructor::initialize(Realm& realm)
NativeFunction::initialize(realm);
// 24.4.2.1 WeakSet.prototype, https://tc39.es/ecma262/#sec-weakset.prototype
- define_direct_property(vm.names.prototype, realm.global_object().weak_set_prototype(), 0);
+ define_direct_property(vm.names.prototype, realm.intrinsics().weak_set_prototype(), 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
}
@@ -41,7 +41,7 @@ ThrowCompletionOr<Object*> WeakSetConstructor::construct(FunctionObject& new_tar
{
auto& vm = this->vm();
- auto* weak_set = TRY(ordinary_create_from_constructor<WeakSet>(vm, new_target, &GlobalObject::weak_set_prototype));
+ auto* weak_set = TRY(ordinary_create_from_constructor<WeakSet>(vm, new_target, &Intrinsics::weak_set_prototype));
if (vm.argument(0).is_nullish())
return weak_set;
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp
index f1c0833b75..1d536fcb3e 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp
@@ -12,7 +12,7 @@
namespace JS {
WeakSetPrototype::WeakSetPrototype(Realm& realm)
- : PrototypeObject(*realm.global_object().object_prototype())
+ : PrototypeObject(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp
index 65356ba0a5..31d020511d 100644
--- a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp
@@ -21,7 +21,7 @@ ThrowCompletionOr<WrappedFunction*> WrappedFunction::create(Realm& realm, Realm&
// 4. Set wrapped.[[Call]] as described in 2.1.
// 5. Set wrapped.[[WrappedTargetFunction]] to Target.
// 6. Set wrapped.[[Realm]] to callerRealm.
- auto& prototype = *caller_realm.global_object().function_prototype();
+ auto& prototype = *caller_realm.intrinsics().function_prototype();
auto* wrapped = vm.heap().allocate<WrappedFunction>(realm, caller_realm, target, prototype);
// 7. Let result be CopyNameAndLength(wrapped, Target).
diff --git a/Userland/Libraries/LibJS/SyntheticModule.cpp b/Userland/Libraries/LibJS/SyntheticModule.cpp
index 709de2869c..bf76e76106 100644
--- a/Userland/Libraries/LibJS/SyntheticModule.cpp
+++ b/Userland/Libraries/LibJS/SyntheticModule.cpp
@@ -148,7 +148,7 @@ ThrowCompletionOr<NonnullRefPtr<Module>> parse_json_module(StringView source_tex
auto& vm = realm.vm();
// 1. Let jsonParse be realm's intrinsic object named "%JSON.parse%".
- auto* json_parse = realm.global_object().json_parse_function();
+ auto* json_parse = realm.intrinsics().json_parse_function();
// 2. Let json be ? Call(jsonParse, undefined, « sourceText »).
auto json = TRY(call(vm, *json_parse, js_undefined(), js_string(realm.vm(), source_text)));
diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp
index 54ef788791..775ff6d773 100644
--- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp
@@ -15,7 +15,7 @@
namespace Web::Bindings {
AudioConstructor::AudioConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp
index 55a3955265..97f9c4b8b5 100644
--- a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp
@@ -14,7 +14,7 @@
namespace Web::Bindings {
CSSNamespace::CSSNamespace(JS::Realm& realm)
- : JS::Object(*realm.global_object().object_prototype())
+ : JS::Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp b/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp
index c161fea585..ebcc9a890f 100644
--- a/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp
@@ -13,7 +13,7 @@ namespace Web {
namespace Bindings {
EventListenerWrapper::EventListenerWrapper(JS::Realm& realm, DOM::IDLEventListener& impl)
- : Wrapper(*realm.global_object().object_prototype())
+ : Wrapper(*realm.intrinsics().object_prototype())
, m_impl(impl)
{
}
diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
index 7c2810aff6..772daf0f24 100644
--- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
@@ -15,7 +15,7 @@
namespace Web::Bindings {
ImageConstructor::ImageConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp
index 94aa81905f..774fbfed70 100644
--- a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp
@@ -12,7 +12,7 @@
namespace Web::Bindings {
LocationConstructor::LocationConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/Bindings/LocationPrototype.h b/Userland/Libraries/LibWeb/Bindings/LocationPrototype.h
index cc597d0ac4..52ed45fe8d 100644
--- a/Userland/Libraries/LibWeb/Bindings/LocationPrototype.h
+++ b/Userland/Libraries/LibWeb/Bindings/LocationPrototype.h
@@ -19,7 +19,7 @@ class LocationPrototype final : public JS::Object {
public:
explicit LocationPrototype(JS::Realm& realm)
- : JS::Object(*realm.global_object().object_prototype())
+ : JS::Object(*realm.intrinsics().object_prototype())
{
}
};
diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp
index 92b897893e..8a1b13e22f 100644
--- a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp
@@ -12,7 +12,7 @@
namespace Web::Bindings {
NavigatorConstructor::NavigatorConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorPrototype.h b/Userland/Libraries/LibWeb/Bindings/NavigatorPrototype.h
index c94aa13e60..32eb17d619 100644
--- a/Userland/Libraries/LibWeb/Bindings/NavigatorPrototype.h
+++ b/Userland/Libraries/LibWeb/Bindings/NavigatorPrototype.h
@@ -19,7 +19,7 @@ class NavigatorPrototype final : public JS::Object {
public:
explicit NavigatorPrototype(JS::Realm& realm)
- : JS::Object(*realm.global_object().object_prototype())
+ : JS::Object(*realm.intrinsics().object_prototype())
{
}
};
diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp
index 8f72bab816..c4b7930f13 100644
--- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp
@@ -16,7 +16,7 @@
namespace Web::Bindings {
OptionConstructor::OptionConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp
index 946aff9007..ef33827f17 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp
@@ -12,7 +12,7 @@
namespace Web::Bindings {
WindowConstructor::WindowConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp
index ca6a07d917..bcb42d8a04 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp
@@ -15,7 +15,7 @@
namespace Web::Bindings {
WebAssemblyInstanceConstructor::WebAssemblyInstanceConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h
index 8f409538a3..36ba30e1d1 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h
@@ -18,7 +18,7 @@ class WebAssemblyInstancePrototype final : public JS::Object {
public:
explicit WebAssemblyInstancePrototype(JS::Realm& realm)
- : JS::Object(*realm.global_object().object_prototype())
+ : JS::Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp
index ea23f37cbe..35f38465ea 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp
@@ -13,7 +13,7 @@
namespace Web::Bindings {
WebAssemblyMemoryConstructor::WebAssemblyMemoryConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h
index ac68af75fd..c9b8aa03e3 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h
@@ -20,7 +20,7 @@ class WebAssemblyMemoryPrototype final : public JS::Object {
public:
explicit WebAssemblyMemoryPrototype(JS::Realm& realm)
- : JS::Object(*realm.global_object().object_prototype())
+ : JS::Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp
index 06969b48a6..71a24e7694 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp
@@ -15,7 +15,7 @@
namespace Web::Bindings {
WebAssemblyModuleConstructor::WebAssemblyModuleConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModulePrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModulePrototype.h
index b2177e2e98..33890534c7 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModulePrototype.h
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModulePrototype.h
@@ -20,7 +20,7 @@ class WebAssemblyModulePrototype final : public JS::Object {
public:
explicit WebAssemblyModulePrototype(JS::Realm& realm)
- : JS::Object(*realm.global_object().object_prototype())
+ : JS::Object(*realm.intrinsics().object_prototype())
{
}
};
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp
index a5d2ad63b8..5be142435f 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp
@@ -26,7 +26,7 @@
namespace Web::Bindings {
WebAssemblyObject::WebAssemblyObject(JS::Realm& realm)
- : Object(*realm.global_object().object_prototype())
+ : Object(*realm.intrinsics().object_prototype())
{
s_abstract_machine.enable_instruction_count_limit();
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp
index a9a7bef0fe..0698f06be5 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp
@@ -15,7 +15,7 @@
namespace Web::Bindings {
WebAssemblyTableConstructor::WebAssemblyTableConstructor(JS::Realm& realm)
- : NativeFunction(*realm.global_object().function_prototype())
+ : NativeFunction(*realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h
index c3d576f0a9..d5616de191 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h
@@ -20,7 +20,7 @@ class WebAssemblyTablePrototype final : public JS::Object {
public:
explicit WebAssemblyTablePrototype(JS::Realm& realm)
- : JS::Object(*realm.global_object().object_prototype())
+ : JS::Object(*realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
index b08020d917..260eab4e84 100644
--- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
+++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
@@ -143,7 +143,7 @@ DOM::ExceptionOr<JS::Value> XMLHttpRequest::response()
// 3. Let jsonObject be the result of running parse JSON from bytes on this’s received bytes. If that threw an exception, then return null.
TextCodec::UTF8Decoder decoder;
- auto json_object_result = JS::call(vm, realm.global_object().json_parse_function(), JS::js_undefined(), JS::js_string(vm, decoder.to_utf8({ m_received_bytes.data(), m_received_bytes.size() })));
+ auto json_object_result = JS::call(vm, realm.intrinsics().json_parse_function(), JS::js_undefined(), JS::js_string(vm, decoder.to_utf8({ m_received_bytes.data(), m_received_bytes.size() })));
if (json_object_result.is_error())
return JS::Value(JS::js_null());
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index b9f4c187e3..4d51a76b7c 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -1003,8 +1003,11 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
return print_error(object, seen_objects);
auto prototype_or_error = object.internal_get_prototype_of();
- if (prototype_or_error.has_value() && prototype_or_error.value() == object.global_object().error_prototype())
- return print_error(object, seen_objects);
+ if (prototype_or_error.has_value() && prototype_or_error.value() != nullptr) {
+ auto& prototype = *prototype_or_error.value();
+ if (&prototype == prototype.shape().realm().intrinsics().error_prototype())
+ return print_error(object, seen_objects);
+ }
if (is<JS::RegExpObject>(object))
return print_regexp_object(static_cast<JS::RegExpObject&>(object), seen_objects);
@@ -1272,9 +1275,9 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
return vm.throw_completion<JS::Error>(String::formatted("Failed to open '{}': {}", filename, file->error_string()));
auto config_file = MUST(Core::ConfigFile::open(filename, file->fd()));
- auto* object = JS::Object::create(realm, realm.global_object().object_prototype());
+ auto* object = JS::Object::create(realm, realm.intrinsics().object_prototype());
for (auto const& group : config_file->groups()) {
- auto* group_object = JS::Object::create(realm, realm.global_object().object_prototype());
+ auto* group_object = JS::Object::create(realm, realm.intrinsics().object_prototype());
for (auto const& key : config_file->keys(group)) {
auto entry = config_file->read_entry(group, key);
group_object->define_direct_property(key, js_string(vm, move(entry)), JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable);