diff options
author | Linus Groh <mail@linusgroh.de> | 2021-10-09 16:41:18 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-09 21:53:47 +0100 |
commit | 4f0313897131676b58ff2a5f374b35133e5cbb14 (patch) | |
tree | fb89d86e76935fdcbf9344902c7ef8ef397ac0e3 /Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp | |
parent | a456eae4b109247d7b7ff0ae48ffe38d98d5161d (diff) | |
download | serenity-4f0313897131676b58ff2a5f374b35133e5cbb14.zip |
LibJS: Convert get_super_base() to ThrowCompletionOr
Also add spec step comments to it while we're here.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp index 3ec7edc950..4668640b3c 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp @@ -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 |