summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp16
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index a640ccc58c..35a1d18a0b 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -789,6 +789,22 @@ double Value::to_integer_or_infinity(GlobalObject& global_object) const
return integer;
}
+// 7.3.3 GetV ( V, P ), https://tc39.es/ecma262/#sec-getv
+Value Value::get(GlobalObject& global_object, PropertyName const& property_name) const
+{
+ auto& vm = global_object.vm();
+
+ // 1. Assert: IsPropertyKey(P) is true.
+
+ // 2. Let O be ? ToObject(V).
+ auto* object = to_object(global_object);
+ if (vm.exception())
+ return {};
+
+ // 3. Return ? O.[[Get]](P, V).
+ return object->get(property_name, *this);
+}
+
// 13.10 Relational Operators, https://tc39.es/ecma262/#sec-relational-operators
Value greater_than(GlobalObject& global_object, Value lhs, Value rhs)
{
diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h
index e178c04e9a..e7217af3ba 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.h
+++ b/Userland/Libraries/LibJS/Runtime/Value.h
@@ -287,6 +287,8 @@ public:
double to_integer_or_infinity(GlobalObject&) const;
bool to_boolean() const;
+ Value get(GlobalObject&, PropertyName const&) const;
+
String to_string_without_side_effects() const;
Value value_or(Value fallback) const