mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:07:46 +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
|
@ -33,22 +33,16 @@ namespace JS {
|
|||
|
||||
class Function : public Object {
|
||||
public:
|
||||
Function(String name, const ScopeNode& body, Vector<String> parameters = {});
|
||||
virtual ~Function();
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
const ScopeNode& body() const { return m_body; }
|
||||
const Vector<String>& parameters() const { return m_parameters; };
|
||||
virtual Value call(Interpreter&, Vector<Value>) = 0;
|
||||
|
||||
protected:
|
||||
Function();
|
||||
virtual const char* class_name() const override { return "Function"; }
|
||||
|
||||
private:
|
||||
virtual bool is_function() const final { return true; }
|
||||
|
||||
String m_name;
|
||||
const ScopeNode& m_body;
|
||||
const Vector<String> m_parameters;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue