mirror of
https://github.com/RGBCube/serenity
synced 2025-06-30 10:12:07 +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:
parent
9ad17d4674
commit
d1d136b4e5
5 changed files with 12 additions and 12 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue