mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
LibJS: Convert get_super_base() to ThrowCompletionOr
Also add spec step comments to it while we're here.
This commit is contained in:
parent
a456eae4b1
commit
4f03138971
3 changed files with 14 additions and 5 deletions
|
@ -458,7 +458,7 @@ ThrowCompletionOr<Reference> make_super_property_reference(GlobalObject& global_
|
|||
// 2. Assert: env.HasSuperBinding() is true.
|
||||
VERIFY(env.has_super_binding());
|
||||
// 3. Let baseValue be ? env.GetSuperBase().
|
||||
auto base_value = env.get_super_base();
|
||||
auto base_value = TRY(env.get_super_base());
|
||||
// 4. Let bv be ? RequireObjectCoercible(baseValue).
|
||||
auto bv = TRY(require_object_coercible(global_object, base_value));
|
||||
// 5. Return the Reference Record { [[Base]]: bv, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]: actualThis }.
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/FunctionEnvironment.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -29,13 +29,21 @@ void FunctionEnvironment::visit_edges(Visitor& visitor)
|
|||
}
|
||||
|
||||
// 9.1.1.3.5 GetSuperBase ( ), https://tc39.es/ecma262/#sec-getsuperbase
|
||||
Value FunctionEnvironment::get_super_base() const
|
||||
ThrowCompletionOr<Value> FunctionEnvironment::get_super_base() const
|
||||
{
|
||||
VERIFY(m_function_object);
|
||||
|
||||
// 1. Let home be envRec.[[FunctionObject]].[[HomeObject]].
|
||||
auto home_object = m_function_object->home_object();
|
||||
|
||||
// 2. If home has the value undefined, return undefined.
|
||||
if (!home_object)
|
||||
return js_undefined();
|
||||
return TRY_OR_DISCARD(home_object->internal_get_prototype_of());
|
||||
|
||||
// 3. Assert: Type(home) is Object.
|
||||
|
||||
// 4. Return ? home.[[GetPrototypeOf]]().
|
||||
return { TRY(home_object->internal_get_prototype_of()) };
|
||||
}
|
||||
|
||||
// 9.1.1.3.2 HasThisBinding ( ), https://tc39.es/ecma262/#sec-function-environment-records-hasthisbinding
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/DeclarativeEnvironment.h>
|
||||
#include <LibJS/Runtime/ECMAScriptFunctionObject.h>
|
||||
|
||||
|
@ -42,7 +43,7 @@ public:
|
|||
void set_new_target(Value new_target) { m_new_target = new_target; }
|
||||
|
||||
// Abstract operations
|
||||
Value get_super_base() const;
|
||||
ThrowCompletionOr<Value> get_super_base() const;
|
||||
bool has_super_binding() const;
|
||||
virtual bool has_this_binding() const override;
|
||||
virtual Value get_this_binding(GlobalObject&) const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue