LibJS: Split Function into subclasses NativeFunction and ScriptFunction

Both types of functions are now Function and implement calling via:

    virtual Value call(Interpreter&, Vector<Value> arguments);

This removes the need for CallExpression::execute() to care about which
kind of function it's calling. :^)
This commit is contained in:
Andreas Kling 2020-03-13 10:08:52 +01:00
parent de6f697eba
commit d9c7009604
Notes: sideshowbarker 2024-07-19 08:20:02 +09:00
9 changed files with 133 additions and 42 deletions

View file

@ -30,7 +30,7 @@
namespace JS {
NativeFunction::NativeFunction(AK::Function<Value(Interpreter&, Vector<Argument>)> native_function)
NativeFunction::NativeFunction(AK::Function<Value(Interpreter&, Vector<Value>)> native_function)
: m_native_function(move(native_function))
{
}
@ -39,4 +39,9 @@ NativeFunction::~NativeFunction()
{
}
Value NativeFunction::call(Interpreter& interpreter, Vector<Value> arguments)
{
return m_native_function(interpreter, move(arguments));
}
}