summaryrefslogtreecommitdiff
path: root/Libraries/LibJS
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-05-29 12:20:14 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-29 15:55:40 +0200
commit688ca7b196d2567f46125e54fa8463327cc798d4 (patch)
tree1f94f7cca7bbd1f5f01e5f57dd3431205801f4b4 /Libraries/LibJS
parent1dd44210b7887373d606863a93ed5e9ede370feb (diff)
downloadserenity-688ca7b196d2567f46125e54fa8463327cc798d4.zip
LibJS: Make Object::invoke() non-const
As suggested in #2431's code review.
Diffstat (limited to 'Libraries/LibJS')
-rw-r--r--Libraries/LibJS/Runtime/Object.cpp6
-rw-r--r--Libraries/LibJS/Runtime/Object.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp
index eff0d31e12..915ce3b251 100644
--- a/Libraries/LibJS/Runtime/Object.cpp
+++ b/Libraries/LibJS/Runtime/Object.cpp
@@ -662,9 +662,9 @@ Value Object::to_string() const
return js_string(heap(), String::format("[object %s]", class_name()));
}
-Value Object::invoke(const FlyString& property_name, Optional<MarkedValueList> arguments) const
+Value Object::invoke(const FlyString& property_name, Optional<MarkedValueList> arguments)
{
- auto& interpreter = const_cast<Object*>(this)->interpreter();
+ auto& interpreter = this->interpreter();
auto property = get(property_name).value_or(js_undefined());
if (interpreter.exception())
return {};
@@ -672,7 +672,7 @@ Value Object::invoke(const FlyString& property_name, Optional<MarkedValueList> a
interpreter.throw_exception<TypeError>(String::format("%s is not a function", property.to_string_without_side_effects().characters()));
return {};
}
- return interpreter.call(property.as_function(), const_cast<Object*>(this), move(arguments));
+ return interpreter.call(property.as_function(), this, move(arguments));
}
}
diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h
index 503ba55857..5abc982154 100644
--- a/Libraries/LibJS/Runtime/Object.h
+++ b/Libraries/LibJS/Runtime/Object.h
@@ -108,7 +108,7 @@ public:
IndexedProperties& indexed_properties() { return m_indexed_properties; }
void set_indexed_property_elements(Vector<Value>&& values) { m_indexed_properties = IndexedProperties(move(values)); }
- Value invoke(const FlyString& property_name, Optional<MarkedValueList> arguments = {}) const;
+ Value invoke(const FlyString& property_name, Optional<MarkedValueList> arguments = {});
private:
virtual Value get_by_index(u32 property_index) const;