From be055b3ddd7fc65702b2938b13fea3ba6a1aba45 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 29 Sep 2020 16:45:24 +0200 Subject: LibJS: Reduce use of Interpreter in Reference --- Libraries/LibJS/AST.cpp | 6 +++--- Libraries/LibJS/Runtime/Reference.cpp | 30 +++++++++++++++--------------- Libraries/LibJS/Runtime/Reference.h | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'Libraries/LibJS') diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index 39485a8203..cedab231cd 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -1286,7 +1286,7 @@ Value AssignmentExpression::execute(Interpreter& interpreter, GlobalObject& glob return {}; } update_function_name(rhs_result, get_function_name(global_object, reference.name().to_value(interpreter.vm()))); - reference.put(interpreter, global_object, rhs_result); + reference.put(global_object, rhs_result); if (interpreter.exception()) return {}; @@ -1298,7 +1298,7 @@ Value UpdateExpression::execute(Interpreter& interpreter, GlobalObject& global_o auto reference = m_argument->to_reference(interpreter, global_object); if (interpreter.exception()) return {}; - auto old_value = reference.get(interpreter, global_object); + auto old_value = reference.get(global_object); if (interpreter.exception()) return {}; old_value = old_value.to_numeric(global_object); @@ -1323,7 +1323,7 @@ Value UpdateExpression::execute(Interpreter& interpreter, GlobalObject& global_o ASSERT_NOT_REACHED(); } - reference.put(interpreter, global_object, new_value); + reference.put(global_object, new_value); if (interpreter.exception()) return {}; return m_prefixed ? new_value : old_value; diff --git a/Libraries/LibJS/Runtime/Reference.cpp b/Libraries/LibJS/Runtime/Reference.cpp index 488e22a966..2f8ae22522 100644 --- a/Libraries/LibJS/Runtime/Reference.cpp +++ b/Libraries/LibJS/Runtime/Reference.cpp @@ -33,25 +33,25 @@ namespace JS { -void Reference::put(Interpreter& interpreter, GlobalObject& global_object, Value value) +void Reference::put(GlobalObject& global_object, Value value) { - // NOTE: The caller is responsible for doing an exception check after assign(). + auto& vm = global_object.vm(); if (is_unresolvable()) { - throw_reference_error(interpreter, global_object); + throw_reference_error(global_object); return; } if (is_local_variable() || is_global_variable()) { if (is_local_variable()) - interpreter.vm().set_variable(m_name.to_string(), value, global_object); + vm.set_variable(m_name.to_string(), value, global_object); else global_object.put(m_name, value); return; } - if (!base().is_object() && interpreter.in_strict_mode()) { - interpreter.vm().throw_exception(global_object, ErrorType::ReferencePrimitiveAssignment, m_name.to_string().characters()); + if (!base().is_object() && vm.interpreter().in_strict_mode()) { + vm.throw_exception(global_object, ErrorType::ReferencePrimitiveAssignment, m_name.to_string().characters()); return; } @@ -62,36 +62,36 @@ void Reference::put(Interpreter& interpreter, GlobalObject& global_object, Value object->put(m_name, value); } -void Reference::throw_reference_error(Interpreter& interpreter, GlobalObject& global_object) +void Reference::throw_reference_error(GlobalObject& global_object) { auto property_name = m_name.to_string(); String message; if (property_name.is_empty()) { - interpreter.vm().throw_exception(global_object, ErrorType::ReferenceUnresolvable); + global_object.vm().throw_exception(global_object, ErrorType::ReferenceUnresolvable); } else { - interpreter.vm().throw_exception(global_object, ErrorType::UnknownIdentifier, property_name.characters()); + global_object.vm().throw_exception(global_object, ErrorType::UnknownIdentifier, property_name.characters()); } } -Value Reference::get(Interpreter& interpreter, GlobalObject& global_object) +Value Reference::get(GlobalObject& global_object) { - // NOTE: The caller is responsible for doing an exception check after fetch(). + auto& vm = global_object.vm(); if (is_unresolvable()) { - throw_reference_error(interpreter, global_object); + throw_reference_error(global_object); return {}; } if (is_local_variable() || is_global_variable()) { Value value; if (is_local_variable()) - value = interpreter.vm().get_variable(m_name.to_string(), global_object); + value = vm.get_variable(m_name.to_string(), global_object); else value = global_object.get(m_name); - if (interpreter.exception()) + if (vm.exception()) return {}; if (value.is_empty()) { - throw_reference_error(interpreter, global_object); + throw_reference_error(global_object); return {}; } return value; diff --git a/Libraries/LibJS/Runtime/Reference.h b/Libraries/LibJS/Runtime/Reference.h index 8c30666d86..149bb31082 100644 --- a/Libraries/LibJS/Runtime/Reference.h +++ b/Libraries/LibJS/Runtime/Reference.h @@ -85,11 +85,11 @@ public: return m_global_variable; } - void put(Interpreter&, GlobalObject&, Value); - Value get(Interpreter&, GlobalObject&); + void put(GlobalObject&, Value); + Value get(GlobalObject&); private: - void throw_reference_error(Interpreter&, GlobalObject&); + void throw_reference_error(GlobalObject&); Value m_base { js_undefined() }; PropertyName m_name; -- cgit v1.2.3