mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-28 04:08:08 +00:00
LibJS: Replace $gc() hack with a NativeFunction on the global object
To make this work, also start passing Interpreter& to native functions.
This commit is contained in:
@@ -38,11 +38,16 @@ Interpreter::Interpreter()
|
||||
: m_heap(*this)
|
||||
{
|
||||
m_global_object = heap().allocate<Object>();
|
||||
m_global_object->put("print", heap().allocate<NativeFunction>([](Vector<Argument> arguments) -> Value {
|
||||
m_global_object->put("print", heap().allocate<NativeFunction>([](Interpreter&, Vector<Argument> arguments) -> Value {
|
||||
for (auto& argument : arguments)
|
||||
printf("%s ", argument.value.to_string().characters());
|
||||
return js_undefined();
|
||||
}));
|
||||
m_global_object->put("gc", heap().allocate<NativeFunction>([](Interpreter& interpreter, Vector<Argument>) -> Value {
|
||||
dbg() << "Forced garbage collection requested!";
|
||||
interpreter.heap().collect_garbage();
|
||||
return js_undefined();
|
||||
}));
|
||||
}
|
||||
|
||||
Interpreter::~Interpreter()
|
||||
|
||||
Reference in New Issue
Block a user