mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 04:37:55 +00:00
LibJS: Move GlobalObject to its own Object subclass
This is mostly for tidiness at the moment.
This commit is contained in:
@@ -26,28 +26,18 @@
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/GlobalObject.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/NativeFunction.h>
|
||||
#include <LibJS/Object.h>
|
||||
#include <LibJS/Value.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
Interpreter::Interpreter()
|
||||
: m_heap(*this)
|
||||
{
|
||||
m_global_object = heap().allocate<Object>();
|
||||
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();
|
||||
}));
|
||||
m_global_object = heap().allocate<GlobalObject>(heap());
|
||||
}
|
||||
|
||||
Interpreter::~Interpreter()
|
||||
|
||||
Reference in New Issue
Block a user