summaryrefslogtreecommitdiff
path: root/Libraries/LibJS
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-27 18:45:21 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-27 20:26:58 +0200
commitf79d4c7347c1d5a9ca4dbc8fb4b1bfeb74c1d3a3 (patch)
treefb92b1a87707275b031ee2bcbf62f28a53b3d2c8 /Libraries/LibJS
parent340a115dfe9518eae3d76154fba9092c36526430 (diff)
downloadserenity-f79d4c7347c1d5a9ca4dbc8fb4b1bfeb74c1d3a3.zip
LibJS: Remove Interpreter& argument to Function::construct()
This is no longer needed, we can get everything we need from the VM.
Diffstat (limited to 'Libraries/LibJS')
-rw-r--r--Libraries/LibJS/Runtime/ArrayConstructor.cpp2
-rw-r--r--Libraries/LibJS/Runtime/ArrayConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/BigIntConstructor.cpp4
-rw-r--r--Libraries/LibJS/Runtime/BigIntConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/BooleanConstructor.cpp4
-rw-r--r--Libraries/LibJS/Runtime/BooleanConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/BoundFunction.cpp6
-rw-r--r--Libraries/LibJS/Runtime/BoundFunction.h2
-rw-r--r--Libraries/LibJS/Runtime/DateConstructor.cpp4
-rw-r--r--Libraries/LibJS/Runtime/DateConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/ErrorConstructor.cpp15
-rw-r--r--Libraries/LibJS/Runtime/ErrorConstructor.h4
-rw-r--r--Libraries/LibJS/Runtime/Function.h2
-rw-r--r--Libraries/LibJS/Runtime/FunctionConstructor.cpp16
-rw-r--r--Libraries/LibJS/Runtime/FunctionConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/NativeFunction.cpp2
-rw-r--r--Libraries/LibJS/Runtime/NativeFunction.h2
-rw-r--r--Libraries/LibJS/Runtime/NumberConstructor.cpp2
-rw-r--r--Libraries/LibJS/Runtime/NumberConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/ObjectConstructor.cpp2
-rw-r--r--Libraries/LibJS/Runtime/ObjectConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/ProxyConstructor.cpp15
-rw-r--r--Libraries/LibJS/Runtime/ProxyConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/ProxyObject.cpp4
-rw-r--r--Libraries/LibJS/Runtime/ProxyObject.h2
-rw-r--r--Libraries/LibJS/Runtime/RegExpConstructor.cpp4
-rw-r--r--Libraries/LibJS/Runtime/RegExpConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/ScriptFunction.cpp2
-rw-r--r--Libraries/LibJS/Runtime/ScriptFunction.h2
-rw-r--r--Libraries/LibJS/Runtime/StringConstructor.cpp2
-rw-r--r--Libraries/LibJS/Runtime/StringConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/SymbolConstructor.cpp4
-rw-r--r--Libraries/LibJS/Runtime/SymbolConstructor.h2
-rw-r--r--Libraries/LibJS/Runtime/VM.cpp2
34 files changed, 69 insertions, 57 deletions
diff --git a/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Libraries/LibJS/Runtime/ArrayConstructor.cpp
index e9f10781cf..ea399ece81 100644
--- a/Libraries/LibJS/Runtime/ArrayConstructor.cpp
+++ b/Libraries/LibJS/Runtime/ArrayConstructor.cpp
@@ -81,7 +81,7 @@ Value ArrayConstructor::call()
return array;
}
-Value ArrayConstructor::construct(Interpreter&, Function&)
+Value ArrayConstructor::construct(Function&)
{
return call();
}
diff --git a/Libraries/LibJS/Runtime/ArrayConstructor.h b/Libraries/LibJS/Runtime/ArrayConstructor.h
index b238226a73..5c85dfc04b 100644
--- a/Libraries/LibJS/Runtime/ArrayConstructor.h
+++ b/Libraries/LibJS/Runtime/ArrayConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~ArrayConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Libraries/LibJS/Runtime/BigIntConstructor.cpp
index e358d9e775..85ad748da2 100644
--- a/Libraries/LibJS/Runtime/BigIntConstructor.cpp
+++ b/Libraries/LibJS/Runtime/BigIntConstructor.cpp
@@ -72,9 +72,9 @@ Value BigIntConstructor::call()
return bigint;
}
-Value BigIntConstructor::construct(Interpreter& interpreter, Function&)
+Value BigIntConstructor::construct(Function&)
{
- interpreter.vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, "BigInt");
+ vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, "BigInt");
return {};
}
diff --git a/Libraries/LibJS/Runtime/BigIntConstructor.h b/Libraries/LibJS/Runtime/BigIntConstructor.h
index 4eeceec8fe..5a4fc6bef7 100644
--- a/Libraries/LibJS/Runtime/BigIntConstructor.h
+++ b/Libraries/LibJS/Runtime/BigIntConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~BigIntConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Libraries/LibJS/Runtime/BooleanConstructor.cpp
index 4c44647179..db88f1cb3e 100644
--- a/Libraries/LibJS/Runtime/BooleanConstructor.cpp
+++ b/Libraries/LibJS/Runtime/BooleanConstructor.cpp
@@ -54,9 +54,9 @@ Value BooleanConstructor::call()
return Value(vm().argument(0).to_boolean());
}
-Value BooleanConstructor::construct(Interpreter& interpreter, Function&)
+Value BooleanConstructor::construct(Function&)
{
- return BooleanObject::create(global_object(), interpreter.argument(0).to_boolean());
+ return BooleanObject::create(global_object(), vm().argument(0).to_boolean());
}
}
diff --git a/Libraries/LibJS/Runtime/BooleanConstructor.h b/Libraries/LibJS/Runtime/BooleanConstructor.h
index c5a438b1df..1c68814b21 100644
--- a/Libraries/LibJS/Runtime/BooleanConstructor.h
+++ b/Libraries/LibJS/Runtime/BooleanConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~BooleanConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/BoundFunction.cpp b/Libraries/LibJS/Runtime/BoundFunction.cpp
index 44e6b840b3..f249cd6335 100644
--- a/Libraries/LibJS/Runtime/BoundFunction.cpp
+++ b/Libraries/LibJS/Runtime/BoundFunction.cpp
@@ -54,14 +54,14 @@ Value BoundFunction::call()
return m_target_function->call();
}
-Value BoundFunction::construct(Interpreter& interpreter, Function& new_target)
+Value BoundFunction::construct(Function& new_target)
{
if (auto this_value = vm().this_value(global_object()); m_constructor_prototype && this_value.is_object()) {
this_value.as_object().set_prototype(m_constructor_prototype);
- if (interpreter.exception())
+ if (vm().exception())
return {};
}
- return m_target_function->construct(interpreter, new_target);
+ return m_target_function->construct(new_target);
}
LexicalEnvironment* BoundFunction::create_environment()
diff --git a/Libraries/LibJS/Runtime/BoundFunction.h b/Libraries/LibJS/Runtime/BoundFunction.h
index c889a63a82..f86f58e93e 100644
--- a/Libraries/LibJS/Runtime/BoundFunction.h
+++ b/Libraries/LibJS/Runtime/BoundFunction.h
@@ -40,7 +40,7 @@ public:
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
virtual LexicalEnvironment* create_environment() override;
diff --git a/Libraries/LibJS/Runtime/DateConstructor.cpp b/Libraries/LibJS/Runtime/DateConstructor.cpp
index 83765da1ac..32b8be3033 100644
--- a/Libraries/LibJS/Runtime/DateConstructor.cpp
+++ b/Libraries/LibJS/Runtime/DateConstructor.cpp
@@ -159,13 +159,13 @@ DateConstructor::~DateConstructor()
Value DateConstructor::call()
{
- auto date = construct(interpreter(), *this);
+ auto date = construct(*this);
if (!date.is_object())
return {};
return js_string(heap(), static_cast<Date&>(date.as_object()).string());
}
-Value DateConstructor::construct(Interpreter&, Function&)
+Value DateConstructor::construct(Function&)
{
if (vm().argument_count() == 0) {
struct timeval tv;
diff --git a/Libraries/LibJS/Runtime/DateConstructor.h b/Libraries/LibJS/Runtime/DateConstructor.h
index 1885057e88..cc16ee8e4a 100644
--- a/Libraries/LibJS/Runtime/DateConstructor.h
+++ b/Libraries/LibJS/Runtime/DateConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~DateConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Libraries/LibJS/Runtime/ErrorConstructor.cpp
index 939e1294e9..3e6b87316c 100644
--- a/Libraries/LibJS/Runtime/ErrorConstructor.cpp
+++ b/Libraries/LibJS/Runtime/ErrorConstructor.cpp
@@ -49,15 +49,16 @@ ErrorConstructor::~ErrorConstructor()
Value ErrorConstructor::call()
{
- return construct(interpreter(), *this);
+ return construct(*this);
}
-Value ErrorConstructor::construct(Interpreter& interpreter, Function&)
+Value ErrorConstructor::construct(Function&)
{
+ auto& vm = this->vm();
String message = "";
- if (!interpreter.call_frame().arguments.is_empty() && !interpreter.call_frame().arguments[0].is_undefined()) {
- message = interpreter.call_frame().arguments[0].to_string(global_object());
- if (interpreter.exception())
+ if (!vm.call_frame().arguments.is_empty() && !vm.call_frame().arguments[0].is_undefined()) {
+ message = vm.call_frame().arguments[0].to_string(global_object());
+ if (vm.exception())
return {};
}
return Error::create(global_object(), "Error", message);
@@ -77,9 +78,9 @@ Value ErrorConstructor::construct(Interpreter& interpreter, Function&)
ConstructorName::~ConstructorName() { } \
Value ConstructorName::call() \
{ \
- return construct(interpreter(), *this); \
+ return construct(*this); \
} \
- Value ConstructorName::construct(Interpreter&, Function&) \
+ Value ConstructorName::construct(Function&) \
{ \
String message = ""; \
if (!vm().call_frame().arguments.is_empty() && !vm().call_frame().arguments[0].is_undefined()) { \
diff --git a/Libraries/LibJS/Runtime/ErrorConstructor.h b/Libraries/LibJS/Runtime/ErrorConstructor.h
index 40a413a63a..5f7d69830e 100644
--- a/Libraries/LibJS/Runtime/ErrorConstructor.h
+++ b/Libraries/LibJS/Runtime/ErrorConstructor.h
@@ -40,7 +40,7 @@ public:
virtual ~ErrorConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
@@ -55,7 +55,7 @@ private:
virtual void initialize(GlobalObject&) override; \
virtual ~ConstructorName() override; \
virtual Value call() override; \
- virtual Value construct(Interpreter&, Function& new_target) override; \
+ virtual Value construct(Function& new_target) override; \
\
private: \
virtual bool has_constructor() const override { return true; } \
diff --git a/Libraries/LibJS/Runtime/Function.h b/Libraries/LibJS/Runtime/Function.h
index 8e0f9591a6..6c5832fc3f 100644
--- a/Libraries/LibJS/Runtime/Function.h
+++ b/Libraries/LibJS/Runtime/Function.h
@@ -44,7 +44,7 @@ public:
virtual void initialize(GlobalObject&) override { }
virtual Value call() = 0;
- virtual Value construct(Interpreter&, Function& new_target) = 0;
+ virtual Value construct(Function& new_target) = 0;
virtual const FlyString& name() const = 0;
virtual LexicalEnvironment* create_environment() = 0;
diff --git a/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Libraries/LibJS/Runtime/FunctionConstructor.cpp
index 6ae2923308..39c91d00b6 100644
--- a/Libraries/LibJS/Runtime/FunctionConstructor.cpp
+++ b/Libraries/LibJS/Runtime/FunctionConstructor.cpp
@@ -53,10 +53,10 @@ FunctionConstructor::~FunctionConstructor()
Value FunctionConstructor::call()
{
- return construct(interpreter(), *this);
+ return construct(*this);
}
-Value FunctionConstructor::construct(Interpreter& interpreter, Function&)
+Value FunctionConstructor::construct(Function&)
{
auto& vm = this->vm();
String parameters_source = "";
@@ -88,7 +88,17 @@ Value FunctionConstructor::construct(Interpreter& interpreter, Function&)
vm.throw_exception<SyntaxError>(global_object(), error.to_string());
return {};
}
- return function_expression->execute(interpreter, global_object());
+
+ OwnPtr<Interpreter> local_interpreter;
+ Interpreter* interpreter = vm.interpreter_if_exists();
+
+ if (!interpreter) {
+ local_interpreter = Interpreter::create_with_existing_global_object(global_object());
+ interpreter = local_interpreter.ptr();
+ }
+
+ VM::InterpreterExecutionScope scope(*interpreter);
+ return function_expression->execute(*interpreter, global_object());
}
}
diff --git a/Libraries/LibJS/Runtime/FunctionConstructor.h b/Libraries/LibJS/Runtime/FunctionConstructor.h
index 4bd266f5cb..70405d43e4 100644
--- a/Libraries/LibJS/Runtime/FunctionConstructor.h
+++ b/Libraries/LibJS/Runtime/FunctionConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~FunctionConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/NativeFunction.cpp b/Libraries/LibJS/Runtime/NativeFunction.cpp
index 3785b4865b..caa77e3801 100644
--- a/Libraries/LibJS/Runtime/NativeFunction.cpp
+++ b/Libraries/LibJS/Runtime/NativeFunction.cpp
@@ -63,7 +63,7 @@ Value NativeFunction::call()
return m_native_function(vm(), global_object());
}
-Value NativeFunction::construct(Interpreter&, Function&)
+Value NativeFunction::construct(Function&)
{
return {};
}
diff --git a/Libraries/LibJS/Runtime/NativeFunction.h b/Libraries/LibJS/Runtime/NativeFunction.h
index 6e2d818901..6d0f3bca84 100644
--- a/Libraries/LibJS/Runtime/NativeFunction.h
+++ b/Libraries/LibJS/Runtime/NativeFunction.h
@@ -42,7 +42,7 @@ public:
virtual ~NativeFunction() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
virtual const FlyString& name() const override { return m_name; };
virtual bool has_constructor() const { return false; }
diff --git a/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Libraries/LibJS/Runtime/NumberConstructor.cpp
index 1770472081..0346f99cf5 100644
--- a/Libraries/LibJS/Runtime/NumberConstructor.cpp
+++ b/Libraries/LibJS/Runtime/NumberConstructor.cpp
@@ -72,7 +72,7 @@ Value NumberConstructor::call()
return vm().argument(0).to_number(global_object());
}
-Value NumberConstructor::construct(Interpreter&, Function&)
+Value NumberConstructor::construct(Function&)
{
double number = 0;
if (vm().argument_count()) {
diff --git a/Libraries/LibJS/Runtime/NumberConstructor.h b/Libraries/LibJS/Runtime/NumberConstructor.h
index a401b9fb44..0ed58b70cb 100644
--- a/Libraries/LibJS/Runtime/NumberConstructor.h
+++ b/Libraries/LibJS/Runtime/NumberConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~NumberConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Libraries/LibJS/Runtime/ObjectConstructor.cpp
index c97b8bfbbb..4600d68326 100644
--- a/Libraries/LibJS/Runtime/ObjectConstructor.cpp
+++ b/Libraries/LibJS/Runtime/ObjectConstructor.cpp
@@ -69,7 +69,7 @@ Value ObjectConstructor::call()
return Object::create_empty(global_object());
}
-Value ObjectConstructor::construct(Interpreter&, Function&)
+Value ObjectConstructor::construct(Function&)
{
return call();
}
diff --git a/Libraries/LibJS/Runtime/ObjectConstructor.h b/Libraries/LibJS/Runtime/ObjectConstructor.h
index 7d7bb5e751..717539651c 100644
--- a/Libraries/LibJS/Runtime/ObjectConstructor.h
+++ b/Libraries/LibJS/Runtime/ObjectConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~ObjectConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Libraries/LibJS/Runtime/ProxyConstructor.cpp
index a107927db2..c38394f8ed 100644
--- a/Libraries/LibJS/Runtime/ProxyConstructor.cpp
+++ b/Libraries/LibJS/Runtime/ProxyConstructor.cpp
@@ -55,22 +55,23 @@ Value ProxyConstructor::call()
return {};
}
-Value ProxyConstructor::construct(Interpreter& interpreter, Function&)
+Value ProxyConstructor::construct(Function&)
{
- if (interpreter.argument_count() < 2) {
- interpreter.vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyTwoArguments);
+ auto& vm = this->vm();
+ if (vm.argument_count() < 2) {
+ vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyTwoArguments);
return {};
}
- auto target = interpreter.argument(0);
- auto handler = interpreter.argument(1);
+ auto target = vm.argument(0);
+ auto handler = vm.argument(1);
if (!target.is_object()) {
- interpreter.vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyConstructorBadType, "target", target.to_string_without_side_effects().characters());
+ vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyConstructorBadType, "target", target.to_string_without_side_effects().characters());
return {};
}
if (!handler.is_object()) {
- interpreter.vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyConstructorBadType, "handler", handler.to_string_without_side_effects().characters());
+ vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyConstructorBadType, "handler", handler.to_string_without_side_effects().characters());
return {};
}
return ProxyObject::create(global_object(), target.as_object(), handler.as_object());
diff --git a/Libraries/LibJS/Runtime/ProxyConstructor.h b/Libraries/LibJS/Runtime/ProxyConstructor.h
index 752c12fe6c..69d23b847a 100644
--- a/Libraries/LibJS/Runtime/ProxyConstructor.h
+++ b/Libraries/LibJS/Runtime/ProxyConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~ProxyConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/ProxyObject.cpp b/Libraries/LibJS/Runtime/ProxyObject.cpp
index ea435c7ec1..1654ad4005 100644
--- a/Libraries/LibJS/Runtime/ProxyObject.cpp
+++ b/Libraries/LibJS/Runtime/ProxyObject.cpp
@@ -492,7 +492,7 @@ Value ProxyObject::call()
return vm().call(trap.as_function(), Value(&m_handler), move(arguments));
}
-Value ProxyObject::construct(Interpreter& interpreter, Function& new_target)
+Value ProxyObject::construct(Function& new_target)
{
auto& vm = this->vm();
if (!is_function()) {
@@ -507,7 +507,7 @@ Value ProxyObject::construct(Interpreter& interpreter, Function& new_target)
if (vm.exception())
return {};
if (trap.is_empty() || trap.is_undefined() || trap.is_null())
- return static_cast<Function&>(m_target).construct(interpreter, new_target);
+ return static_cast<Function&>(m_target).construct(new_target);
if (!trap.is_function()) {
vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "construct");
return {};
diff --git a/Libraries/LibJS/Runtime/ProxyObject.h b/Libraries/LibJS/Runtime/ProxyObject.h
index 0c7cf16b7a..911bbe5067 100644
--- a/Libraries/LibJS/Runtime/ProxyObject.h
+++ b/Libraries/LibJS/Runtime/ProxyObject.h
@@ -40,7 +40,7 @@ public:
virtual ~ProxyObject() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
virtual const FlyString& name() const override;
virtual LexicalEnvironment* create_environment() override;
diff --git a/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Libraries/LibJS/Runtime/RegExpConstructor.cpp
index 82ae584e01..9a8b4fbba3 100644
--- a/Libraries/LibJS/Runtime/RegExpConstructor.cpp
+++ b/Libraries/LibJS/Runtime/RegExpConstructor.cpp
@@ -50,10 +50,10 @@ RegExpConstructor::~RegExpConstructor()
Value RegExpConstructor::call()
{
- return construct(interpreter(), *this);
+ return construct(*this);
}
-Value RegExpConstructor::construct(Interpreter&, Function&)
+Value RegExpConstructor::construct(Function&)
{
auto& vm = this->vm();
if (!vm.argument_count())
diff --git a/Libraries/LibJS/Runtime/RegExpConstructor.h b/Libraries/LibJS/Runtime/RegExpConstructor.h
index 31a36432a2..0c3d055636 100644
--- a/Libraries/LibJS/Runtime/RegExpConstructor.h
+++ b/Libraries/LibJS/Runtime/RegExpConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~RegExpConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp
index ccc524eb6b..8d61815130 100644
--- a/Libraries/LibJS/Runtime/ScriptFunction.cpp
+++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp
@@ -143,7 +143,7 @@ Value ScriptFunction::call()
return interpreter->execute_statement(global_object(), m_body, arguments, ScopeType::Function);
}
-Value ScriptFunction::construct(Interpreter&, Function&)
+Value ScriptFunction::construct(Function&)
{
if (m_is_arrow_function) {
vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, m_name.characters());
diff --git a/Libraries/LibJS/Runtime/ScriptFunction.h b/Libraries/LibJS/Runtime/ScriptFunction.h
index b1ca08a88d..3f0b2276ed 100644
--- a/Libraries/LibJS/Runtime/ScriptFunction.h
+++ b/Libraries/LibJS/Runtime/ScriptFunction.h
@@ -45,7 +45,7 @@ public:
const Vector<FunctionNode::Parameter>& parameters() const { return m_parameters; };
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
virtual const FlyString& name() const override { return m_name; };
void set_name(const FlyString& name) { m_name = name; };
diff --git a/Libraries/LibJS/Runtime/StringConstructor.cpp b/Libraries/LibJS/Runtime/StringConstructor.cpp
index d5afc9eeff..421c0899ac 100644
--- a/Libraries/LibJS/Runtime/StringConstructor.cpp
+++ b/Libraries/LibJS/Runtime/StringConstructor.cpp
@@ -67,7 +67,7 @@ Value StringConstructor::call()
return string;
}
-Value StringConstructor::construct(Interpreter&, Function&)
+Value StringConstructor::construct(Function&)
{
PrimitiveString* primitive_string = nullptr;
if (!vm().argument_count())
diff --git a/Libraries/LibJS/Runtime/StringConstructor.h b/Libraries/LibJS/Runtime/StringConstructor.h
index 34317edeeb..239d9e7596 100644
--- a/Libraries/LibJS/Runtime/StringConstructor.h
+++ b/Libraries/LibJS/Runtime/StringConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~StringConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Libraries/LibJS/Runtime/SymbolConstructor.cpp
index 2135b41917..d1b86303ed 100644
--- a/Libraries/LibJS/Runtime/SymbolConstructor.cpp
+++ b/Libraries/LibJS/Runtime/SymbolConstructor.cpp
@@ -63,9 +63,9 @@ Value SymbolConstructor::call()
return js_symbol(heap(), vm().argument(0).to_string(global_object()), false);
}
-Value SymbolConstructor::construct(Interpreter& interpreter, Function&)
+Value SymbolConstructor::construct(Function&)
{
- interpreter.vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, "Symbol");
+ vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, "Symbol");
return {};
}
diff --git a/Libraries/LibJS/Runtime/SymbolConstructor.h b/Libraries/LibJS/Runtime/SymbolConstructor.h
index 40d6a33690..8afba45fb5 100644
--- a/Libraries/LibJS/Runtime/SymbolConstructor.h
+++ b/Libraries/LibJS/Runtime/SymbolConstructor.h
@@ -39,7 +39,7 @@ public:
virtual ~SymbolConstructor() override;
virtual Value call() override;
- virtual Value construct(Interpreter&, Function& new_target) override;
+ virtual Value construct(Function& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
diff --git a/Libraries/LibJS/Runtime/VM.cpp b/Libraries/LibJS/Runtime/VM.cpp
index 8b3d16c357..273ba911a9 100644
--- a/Libraries/LibJS/Runtime/VM.cpp
+++ b/Libraries/LibJS/Runtime/VM.cpp
@@ -220,7 +220,7 @@ Value VM::construct(Function& function, Function& new_target, Optional<MarkedVal
// If we are a Derived constructor, |this| has not been constructed before super is called.
Value this_value = function.constructor_kind() == Function::ConstructorKind::Base ? new_object : Value {};
call_frame.this_value = this_value;
- auto result = function.construct(interpreter(), new_target);
+ auto result = function.construct(new_target);
this_value = current_environment()->get_this_binding();
pop_call_frame();