summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-20 16:47:31 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-20 17:50:48 +0200
commit32c121a8f7e1f0ef0bb5f744a6836a9e4b2e6bef (patch)
tree47d047d99316b118ab73d113559fbd3cabf73355
parent8d56e6103e3e0a461e69dcb36aecb19f75731a5f (diff)
downloadserenity-32c121a8f7e1f0ef0bb5f744a6836a9e4b2e6bef.zip
LibJS: Pass GlobalObject& to Reference get/put
-rw-r--r--Libraries/LibJS/AST.cpp6
-rw-r--r--Libraries/LibJS/Runtime/Reference.cpp24
-rw-r--r--Libraries/LibJS/Runtime/Reference.h8
3 files changed, 19 insertions, 19 deletions
diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp
index 27d3c8cb9d..308c951914 100644
--- a/Libraries/LibJS/AST.cpp
+++ b/Libraries/LibJS/AST.cpp
@@ -1110,7 +1110,7 @@ Value AssignmentExpression::execute(Interpreter& interpreter, GlobalObject& glob
return interpreter.throw_exception<ReferenceError>(ErrorType::InvalidLeftHandAssignment);
update_function_name(rhs_result, reference.name().as_string());
- reference.put(interpreter, rhs_result);
+ reference.put(interpreter, global_object, rhs_result);
if (interpreter.exception())
return {};
@@ -1122,7 +1122,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);
+ auto old_value = reference.get(interpreter, global_object);
if (interpreter.exception())
return {};
old_value = old_value.to_numeric(interpreter);
@@ -1147,7 +1147,7 @@ Value UpdateExpression::execute(Interpreter& interpreter, GlobalObject& global_o
ASSERT_NOT_REACHED();
}
- reference.put(interpreter, new_value);
+ reference.put(interpreter, 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 992cdbedd3..e670a02370 100644
--- a/Libraries/LibJS/Runtime/Reference.cpp
+++ b/Libraries/LibJS/Runtime/Reference.cpp
@@ -33,20 +33,20 @@
namespace JS {
-void Reference::put(Interpreter& interpreter, Value value)
+void Reference::put(Interpreter& interpreter, GlobalObject& global_object, Value value)
{
// NOTE: The caller is responsible for doing an exception check after assign().
if (is_unresolvable()) {
- throw_reference_error(interpreter);
+ throw_reference_error(interpreter, global_object);
return;
}
if (is_local_variable() || is_global_variable()) {
if (is_local_variable())
- interpreter.set_variable(m_name.to_string(), value, interpreter.global_object());
+ interpreter.set_variable(m_name.to_string(), value, global_object);
else
- interpreter.global_object().put(m_name, value);
+ global_object.put(m_name, value);
return;
}
@@ -55,14 +55,14 @@ void Reference::put(Interpreter& interpreter, Value value)
return;
}
- auto* object = base().to_object(interpreter, interpreter.global_object());
+ auto* object = base().to_object(interpreter, global_object);
if (!object)
return;
object->put(m_name, value);
}
-void Reference::throw_reference_error(Interpreter& interpreter)
+void Reference::throw_reference_error(Interpreter& interpreter, GlobalObject&)
{
auto property_name = m_name.to_string();
String message;
@@ -73,31 +73,31 @@ void Reference::throw_reference_error(Interpreter& interpreter)
}
}
-Value Reference::get(Interpreter& interpreter)
+Value Reference::get(Interpreter& interpreter, GlobalObject& global_object)
{
// NOTE: The caller is responsible for doing an exception check after fetch().
if (is_unresolvable()) {
- throw_reference_error(interpreter);
+ throw_reference_error(interpreter, global_object);
return {};
}
if (is_local_variable() || is_global_variable()) {
Value value;
if (is_local_variable())
- value = interpreter.get_variable(m_name.to_string(), interpreter.global_object());
+ value = interpreter.get_variable(m_name.to_string(), global_object);
else
- value = interpreter.global_object().get(m_name);
+ value = global_object.get(m_name);
if (interpreter.exception())
return {};
if (value.is_empty()) {
- throw_reference_error(interpreter);
+ throw_reference_error(interpreter, global_object);
return {};
}
return value;
}
- auto* object = base().to_object(interpreter, interpreter.global_object());
+ auto* object = base().to_object(interpreter, global_object);
if (!object)
return {};
diff --git a/Libraries/LibJS/Runtime/Reference.h b/Libraries/LibJS/Runtime/Reference.h
index 870a4e8f8f..8c30666d86 100644
--- a/Libraries/LibJS/Runtime/Reference.h
+++ b/Libraries/LibJS/Runtime/Reference.h
@@ -34,7 +34,7 @@ namespace JS {
class Reference {
public:
- Reference() {}
+ Reference() { }
Reference(Value base, const PropertyName& name, bool strict = false)
: m_base(base)
, m_name(name)
@@ -85,11 +85,11 @@ public:
return m_global_variable;
}
- void put(Interpreter&, Value);
- Value get(Interpreter&);
+ void put(Interpreter&, GlobalObject&, Value);
+ Value get(Interpreter&, GlobalObject&);
private:
- void throw_reference_error(Interpreter&);
+ void throw_reference_error(Interpreter&, GlobalObject&);
Value m_base { js_undefined() };
PropertyName m_name;