summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-06-25 11:24:47 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-25 16:58:36 +0200
commit07acdc7be28b37193cd992fedd919bcf09413d24 (patch)
tree8c19320cc7624c676981926341168a2502c92d96 /Userland
parent2b4cab284c1231822a361a3141805a0951c743d3 (diff)
downloadserenity-07acdc7be28b37193cd992fedd919bcf09413d24.zip
LibJS: Rename VM::get_reference() => resolve_binding()
This function maps to the ResolveBinding operation from the spec, so let's rename it to match.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/AST.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.cpp5
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.h2
3 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp
index c523381556..b4eac8d457 100644
--- a/Userland/Libraries/LibJS/AST.cpp
+++ b/Userland/Libraries/LibJS/AST.cpp
@@ -669,7 +669,7 @@ Reference Expression::to_reference(Interpreter&, GlobalObject&) const
Reference Identifier::to_reference(Interpreter& interpreter, GlobalObject&) const
{
- return interpreter.vm().get_reference(string());
+ return interpreter.vm().resolve_binding(string());
}
Reference MemberExpression::to_reference(Interpreter& interpreter, GlobalObject& global_object) const
diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp
index 80427df7c0..cd40bd14cc 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.cpp
+++ b/Userland/Libraries/LibJS/Runtime/VM.cpp
@@ -392,8 +392,11 @@ Value VM::get_variable(const FlyString& name, GlobalObject& global_object)
return value;
}
-Reference VM::get_reference(const FlyString& name)
+// 9.4.2 ResolveBinding ( name [ , env ] ), https://tc39.es/ecma262/#sec-resolvebinding
+Reference VM::resolve_binding(FlyString const& name)
{
+ // FIXME: This implementation of ResolveBinding is non-conforming.
+
for (auto* environment_record = lexical_environment(); environment_record && environment_record->outer_environment(); environment_record = environment_record->outer_environment()) {
auto possible_match = environment_record->get_from_environment_record(name);
if (possible_match.has_value())
diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h
index b49d1468aa..1a90766991 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.h
+++ b/Userland/Libraries/LibJS/Runtime/VM.h
@@ -202,7 +202,7 @@ public:
void assign(const FlyString& target, Value, GlobalObject&, bool first_assignment = false, EnvironmentRecord* specific_scope = nullptr);
void assign(const NonnullRefPtr<BindingPattern>& target, Value, GlobalObject&, bool first_assignment = false, EnvironmentRecord* specific_scope = nullptr);
- Reference get_reference(const FlyString& name);
+ Reference resolve_binding(FlyString const&);
template<typename T, typename... Args>
void throw_exception(GlobalObject& global_object, Args&&... args)