diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-25 11:40:03 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-25 16:58:36 +0200 |
commit | 6e1932e8b2e5ff10854f08e69b9c5cc7032ae30e (patch) | |
tree | f2ab5f60ea47831f93c052a4d03f3a21498dc3ea | |
parent | 92ce4ac23faff6ceed742447ccec2a1937043c87 (diff) | |
download | serenity-6e1932e8b2e5ff10854f08e69b9c5cc7032ae30e.zip |
LibJS: Evaluate `this` in terms of ResolveThisBinding
-rw-r--r-- | Userland/Libraries/LibJS/AST.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/VM.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/VM.h | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index b4eac8d457..6f6a0a74be 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -1347,7 +1347,7 @@ Value SpreadExpression::execute(Interpreter& interpreter, GlobalObject& global_o Value ThisExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const { InterpreterNodeScope node_scope { interpreter, *this }; - return get_this_environment(interpreter.vm()).get_this_binding(global_object); + return interpreter.vm().resolve_this_binding(global_object); } void ThisExpression::dump(int indent) const diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index cd40bd14cc..1740481d65 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -490,6 +490,13 @@ void VM::throw_exception(Exception& exception) unwind(ScopeType::Try); } +// 9.4.4 ResolveThisBinding ( ), https://tc39.es/ecma262/#sec-resolvethisbinding +Value VM::resolve_this_binding(GlobalObject& global_object) +{ + auto& environment = get_this_environment(*this); + return environment.get_this_binding(global_object); +} + String VM::join_arguments(size_t start_index) const { StringBuilder joined_arguments; diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 1a90766991..3a6173ba9d 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -162,6 +162,8 @@ public: return running_execution_context().this_value; } + Value resolve_this_binding(GlobalObject&); + Value last_value() const { return m_last_value; } void set_last_value(Badge<Bytecode::Interpreter>, Value value) { m_last_value = value; } void set_last_value(Badge<Interpreter>, Value value) { m_last_value = value; } |