summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-07-06 02:15:08 +0300
committerLinus Groh <mail@linusgroh.de>2021-07-06 14:20:30 +0100
commita6b8291a9b3f72c6c70141dafb85d380a68ebdd0 (patch)
tree908ed08ffe0d308d926fe0c605983e25148335cf /Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
parente915155ca452bb9c731051030b0cbb6883d4809d (diff)
downloadserenity-a6b8291a9b3f72c6c70141dafb85d380a68ebdd0.zip
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.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/GlobalObject.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
index 4c30e70a1f..30afc5f467 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
@@ -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()