mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
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:
parent
de6f697eba
commit
d9c7009604
9 changed files with 133 additions and 42 deletions
|
@ -27,22 +27,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <LibJS/Object.h>
|
||||
#include <LibJS/Function.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class NativeFunction final : public Object {
|
||||
class NativeFunction final : public Function {
|
||||
public:
|
||||
explicit NativeFunction(AK::Function<Value(Interpreter&, Vector<Argument>)>);
|
||||
explicit NativeFunction(AK::Function<Value(Interpreter&, Vector<Value>)>);
|
||||
virtual ~NativeFunction() override;
|
||||
|
||||
AK::Function<Value(Interpreter&, Vector<Argument>)>& native_function() { return m_native_function; }
|
||||
virtual Value call(Interpreter&, Vector<Value>) override;
|
||||
|
||||
private:
|
||||
virtual bool is_native_function() const override { return true; }
|
||||
virtual const char* class_name() const override { return "NativeFunction"; }
|
||||
|
||||
AK::Function<Value(Interpreter&, Vector<Argument>)> m_native_function;
|
||||
AK::Function<Value(Interpreter&, Vector<Value>)> m_native_function;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue