mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
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 :^)
This commit is contained in:
parent
84c4b66721
commit
50428ea8d2
Notes:
sideshowbarker
2024-07-17 07:41:37 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/50428ea8d2 Pull-request: https://github.com/SerenityOS/serenity/pull/15035 Reviewed-by: https://github.com/davidot
217 changed files with 1305 additions and 1039 deletions
|
@ -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())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 }).
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace JS {
|
||||
|
||||
ArrayIteratorPrototype::ArrayIteratorPrototype(Realm& realm)
|
||||
: PrototypeObject(*realm.global_object().iterator_prototype())
|
||||
: PrototypeObject(*realm.intrinsics().iterator_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
namespace JS {
|
||||
|
||||
AsyncFunctionPrototype::AsyncFunctionPrototype(Realm& realm)
|
||||
: Object(*realm.global_object().function_prototype())
|
||||
: Object(*realm.intrinsics().function_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
namespace JS {
|
||||
|
||||
AsyncIteratorPrototype::AsyncIteratorPrototype(Realm& realm)
|
||||
: Object(*realm.global_object().object_prototype())
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace JS {
|
||||
|
||||
BooleanPrototype::BooleanPrototype(Realm& realm)
|
||||
: BooleanObject(false, *realm.global_object().object_prototype())
|
||||
: BooleanObject(false, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace JS {
|
||||
|
||||
ConsoleObject::ConsoleObject(Realm& realm)
|
||||
: Object(*realm.global_object().object_prototype())
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace JS {
|
||||
|
||||
DataViewPrototype::DataViewPrototype(Realm& realm)
|
||||
: PrototypeObject(*realm.global_object().object_prototype())
|
||||
: PrototypeObject(*realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
@ -99,7 +99,7 @@ String Error::stack_string() const
|
|||
#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()); /* */ \
|
||||
return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()); \
|
||||
} \
|
||||
\
|
||||
ClassName* ClassName::create(Realm& realm, String const& message) \
|
||||
|
|
|
@ -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()) {
|
||||
|
@ -63,7 +63,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
|
|||
|
||||
#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())) \
|
||||
: NativeFunction(vm().names.ClassName.as_string(), *static_cast<Object*>(realm.intrinsics().error_constructor())) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
|
@ -73,7 +73,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
|
|||
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.prototype, realm.intrinsics().snake_name##_prototype(), 0); \
|
||||
\
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable); \
|
||||
} \
|
||||
|
@ -96,7 +96,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
|
|||
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)); \
|
||||
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()) { \
|
||||
|
|
|
@ -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()) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
|
|
|
@ -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())));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
namespace JS {
|
||||
|
||||
FinalizationRegistryPrototype::FinalizationRegistryPrototype(Realm& realm)
|
||||
: PrototypeObject(*realm.global_object().object_prototype())
|
||||
: PrototypeObject(*realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
namespace JS {
|
||||
|
||||
FunctionPrototype::FunctionPrototype(Realm& realm)
|
||||
: FunctionObject(*realm.global_object().object_prototype())
|
||||
: FunctionObject(*realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
namespace JS {
|
||||
|
||||
GeneratorPrototype::GeneratorPrototype(Realm& realm)
|
||||
: PrototypeObject(*realm.global_object().iterator_prototype())
|
||||
: PrototypeObject(*realm.intrinsics().iterator_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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.encodeURI, encode_uri, 1, attr);
|
||||
define_native_function(realm, vm.names.encodeURIComponent, encode_uri_component, 1, attr);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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.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.Temporal, heap().allocate<Temporal::Temporal>(realm, realm), attr);
|
||||
|
||||
// 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);
|
||||
|
||||
define_direct_property(vm.names.NaN, js_nan(), 0);
|
||||
define_direct_property(vm.names.Infinity, js_infinity(), 0);
|
||||
define_direct_property(vm.names.undefined, js_undefined(), 0);
|
||||
|
||||
define_direct_property(vm.names.globalThis, this, attr);
|
||||
// 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_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.JSON, heap().allocate<JSONObject>(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);
|
||||
define_native_function(realm, vm.names.gc, gc, 0, 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();
|
||||
// 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;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Realm* GlobalObject::associated_realm()
|
||||
{
|
||||
return m_associated_realm;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
368
Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
Normal file
368
Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
Normal file
|
@ -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.
|
||||
}
|
||||
|
||||
}
|
163
Userland/Libraries/LibJS/Runtime/Intrinsics.h
Normal file
163
Userland/Libraries/LibJS/Runtime/Intrinsics.h
Normal file
|
@ -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&);
|
||||
|
||||
}
|
|
@ -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));
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue