mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +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:
@@ -11,12 +11,12 @@ namespace JS {
|
||||
|
||||
GlobalObject::GlobalObject(Heap& heap)
|
||||
{
|
||||
put("print", heap.allocate<NativeFunction>([](Interpreter&, Vector<Argument> arguments) -> Value {
|
||||
put("print", heap.allocate<NativeFunction>([](Interpreter&, Vector<Value> arguments) -> Value {
|
||||
for (auto& argument : arguments)
|
||||
printf("%s ", argument.value.to_string().characters());
|
||||
printf("%s ", argument.to_string().characters());
|
||||
return js_undefined();
|
||||
}));
|
||||
put("gc", heap.allocate<NativeFunction>([](Interpreter& interpreter, Vector<Argument>) -> Value {
|
||||
put("gc", heap.allocate<NativeFunction>([](Interpreter& interpreter, Vector<Value>) -> Value {
|
||||
dbg() << "Forced garbage collection requested!";
|
||||
interpreter.heap().collect_garbage();
|
||||
return js_undefined();
|
||||
|
||||
Reference in New Issue
Block a user