mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:37:34 +00:00
LibJS: Add Object::get_without_side_effects()
Similar to Value::to_string_without_side_effects() this is mostly a regular object property lookup, but with the guarantee that it will be side-effect free, i.e. no accessors or native property functions will be called. This is needed when we want to access user-controlled object properties for debug logging, for example. The specific use case will be error objects which will soon no longer have internal name/message properties, so we need to guarantee that printing an error, which may already be the result of an exception, won't blow up in our face :^)
This commit is contained in:
parent
9ec4defdd2
commit
6e9eb0a284
4 changed files with 23 additions and 11 deletions
|
@ -94,14 +94,15 @@ public:
|
|||
|
||||
GlobalObject& global_object() const { return *shape().global_object(); }
|
||||
|
||||
virtual Value get(const PropertyName&, Value receiver = {}) const;
|
||||
virtual Value get(const PropertyName&, Value receiver = {}, bool without_side_effects = false) const;
|
||||
Value get_without_side_effects(const PropertyName&) const;
|
||||
|
||||
virtual bool has_property(const PropertyName&) const;
|
||||
bool has_own_property(const PropertyName&) const;
|
||||
|
||||
virtual bool put(const PropertyName&, Value, Value receiver = {});
|
||||
|
||||
Value get_own_property(const PropertyName&, Value receiver) const;
|
||||
Value get_own_property(const PropertyName&, Value receiver, bool without_side_effects = false) const;
|
||||
MarkedValueList get_own_properties(PropertyKind, bool only_enumerable_properties = false, GetOwnPropertyReturnType = GetOwnPropertyReturnType::All) const;
|
||||
MarkedValueList get_enumerable_own_property_names(PropertyKind) const;
|
||||
virtual Optional<PropertyDescriptor> get_own_property_descriptor(const PropertyName&) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue