mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
LibJS: Implement the GetV() abstract operation
Like Get(), but with any value instead of an object - it's calling ToObject() for us and passes the value to [[Get]]() as the receiver. This will be used in GetMethod() (and a couple of other places, which can be updated over time). I also tried something new here: adding the three steps from the spec as inline comments :^)
This commit is contained in:
parent
dbda5a9a4c
commit
31f5797e89
2 changed files with 18 additions and 0 deletions
|
@ -789,6 +789,22 @@ double Value::to_integer_or_infinity(GlobalObject& global_object) const
|
||||||
return integer;
|
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
|
// 13.10 Relational Operators, https://tc39.es/ecma262/#sec-relational-operators
|
||||||
Value greater_than(GlobalObject& global_object, Value lhs, Value rhs)
|
Value greater_than(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -287,6 +287,8 @@ public:
|
||||||
double to_integer_or_infinity(GlobalObject&) const;
|
double to_integer_or_infinity(GlobalObject&) const;
|
||||||
bool to_boolean() const;
|
bool to_boolean() const;
|
||||||
|
|
||||||
|
Value get(GlobalObject&, PropertyName const&) const;
|
||||||
|
|
||||||
String to_string_without_side_effects() const;
|
String to_string_without_side_effects() const;
|
||||||
|
|
||||||
Value value_or(Value fallback) const
|
Value value_or(Value fallback) const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue