mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibJS: Add define_direct_property and remove the define_property helper
This removes all usages of the non-standard define_property helper method and replaces all it's usages with the specification required alternative or with define_direct_property where appropriate.
This commit is contained in:
parent
e915155ca4
commit
a6b8291a9b
81 changed files with 246 additions and 275 deletions
|
@ -126,7 +126,7 @@ void GlobalObject::initialize_global_object()
|
|||
// %GeneratorFunction.prototype.prototype% must be initialized separately as it has no
|
||||
// companion constructor
|
||||
m_generator_object_prototype = heap().allocate<GeneratorObjectPrototype>(*this, *this);
|
||||
m_generator_object_prototype->define_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
m_generator_object_prototype->define_direct_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
if (!m_##snake_name##_prototype) \
|
||||
|
@ -148,13 +148,13 @@ void GlobalObject::initialize_global_object()
|
|||
vm.throw_exception<TypeError>(global_object, ErrorType::RestrictedFunctionPropertiesAccess);
|
||||
return Value();
|
||||
});
|
||||
m_throw_type_error_function->define_property_without_transition(vm.names.length, Value(0), 0, false);
|
||||
m_throw_type_error_function->define_property_without_transition(vm.names.name, js_string(vm, ""), 0, false);
|
||||
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);
|
||||
m_throw_type_error_function->internal_prevent_extensions();
|
||||
|
||||
// 10.2.4 AddRestrictedFunctionProperties ( F, realm ), https://tc39.es/ecma262/#sec-addrestrictedfunctionproperties
|
||||
m_function_prototype->define_accessor(vm.names.caller, throw_type_error_function(), throw_type_error_function(), Attribute::Configurable);
|
||||
m_function_prototype->define_accessor(vm.names.arguments, throw_type_error_function(), throw_type_error_function(), Attribute::Configurable);
|
||||
m_function_prototype->define_direct_accessor(vm.names.caller, throw_type_error_function(), throw_type_error_function(), Attribute::Configurable);
|
||||
m_function_prototype->define_direct_accessor(vm.names.arguments, throw_type_error_function(), throw_type_error_function(), Attribute::Configurable);
|
||||
|
||||
define_native_function(vm.names.encodeURI, encode_uri, 1, attr);
|
||||
define_native_function(vm.names.decodeURI, decode_uri, 1, attr);
|
||||
|
@ -163,15 +163,15 @@ void GlobalObject::initialize_global_object()
|
|||
define_native_function(vm.names.escape, escape, 1, attr);
|
||||
define_native_function(vm.names.unescape, unescape, 1, attr);
|
||||
|
||||
define_property(vm.names.NaN, js_nan(), 0);
|
||||
define_property(vm.names.Infinity, js_infinity(), 0);
|
||||
define_property(vm.names.undefined, js_undefined(), 0);
|
||||
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_property(vm.names.globalThis, this, attr);
|
||||
define_property(vm.names.console, heap().allocate<ConsoleObject>(*this, *this), attr);
|
||||
define_property(vm.names.Math, heap().allocate<MathObject>(*this, *this), attr);
|
||||
define_property(vm.names.JSON, heap().allocate<JSONObject>(*this, *this), attr);
|
||||
define_property(vm.names.Reflect, heap().allocate<ReflectObject>(*this, *this), attr);
|
||||
define_direct_property(vm.names.globalThis, this, attr);
|
||||
define_direct_property(vm.names.console, heap().allocate<ConsoleObject>(*this, *this), attr);
|
||||
define_direct_property(vm.names.Math, heap().allocate<MathObject>(*this, *this), attr);
|
||||
define_direct_property(vm.names.JSON, heap().allocate<JSONObject>(*this, *this), attr);
|
||||
define_direct_property(vm.names.Reflect, heap().allocate<ReflectObject>(*this, *this), attr);
|
||||
|
||||
// This must be initialized before allocating AggregateErrorConstructor, which uses ErrorConstructor as its prototype.
|
||||
initialize_constructor(vm.names.Error, m_error_constructor, m_error_prototype);
|
||||
|
@ -210,7 +210,7 @@ void GlobalObject::initialize_global_object()
|
|||
// The generator constructor cannot be initialized with add_constructor as it has no global binding
|
||||
m_generator_function_constructor = heap().allocate<GeneratorFunctionConstructor>(*this, *this);
|
||||
// 27.3.3.1 GeneratorFunction.prototype.constructor, https://tc39.es/ecma262/#sec-generatorfunction.prototype.constructor
|
||||
m_generator_function_prototype->define_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
m_generator_function_prototype->define_direct_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
}
|
||||
|
||||
GlobalObject::~GlobalObject()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue