summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-08-28 17:47:16 +0100
committerLinus Groh <mail@linusgroh.de>2021-08-28 23:17:01 +0100
commit47ab84ffd961c407cc4e75d37f44f030ba474d2e (patch)
tree81216b72101930e61d7549b5e6ccf757e4f85cc3
parent222e518a5360d72337961f26dcee07a8fe24e7ea (diff)
downloadserenity-47ab84ffd961c407cc4e75d37f44f030ba474d2e.zip
LibJS: Add define_direct_{property,accessor}_without_transition()
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.cpp13
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.h3
2 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp
index 99fd70f87e..fdb542150c 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Object.cpp
@@ -6,6 +6,7 @@
*/
#include <AK/String.h>
+#include <AK/TemporaryChange.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/Accessor.h>
@@ -1052,6 +1053,18 @@ void Object::define_direct_accessor(PropertyName const& property_name, FunctionO
}
}
+void Object::define_direct_property_without_transition(PropertyName const& property_name, Value value, PropertyAttributes attributes)
+{
+ TemporaryChange disable_transitions(m_transitions_enabled, false);
+ define_direct_property(property_name, value, attributes);
+}
+
+void Object::define_direct_accessor_without_transition(PropertyName const& property_name, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes)
+{
+ TemporaryChange disable_transitions(m_transitions_enabled, false);
+ define_direct_accessor(property_name, getter, setter, attributes);
+}
+
void Object::ensure_shape_is_unique()
{
if (shape().is_unique())
diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h
index bf4b625198..70d3dff18a 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.h
+++ b/Userland/Libraries/LibJS/Runtime/Object.h
@@ -124,6 +124,9 @@ public:
void define_direct_property(PropertyName const& property_name, Value value, PropertyAttributes attributes) { storage_set(property_name, { value, attributes }); };
void define_direct_accessor(PropertyName const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes);
+ void define_direct_property_without_transition(PropertyName const&, Value, PropertyAttributes);
+ void define_direct_accessor_without_transition(PropertyName const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes);
+
void define_native_function(PropertyName const&, Function<Value(VM&, GlobalObject&)>, i32 length, PropertyAttributes attributes);
void define_native_accessor(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attributes);