2020-03-12 20:11:35 +01:00
|
|
|
#include <AK/LogStream.h>
|
|
|
|
#include <AK/String.h>
|
2020-03-16 14:20:30 +01:00
|
|
|
#include <LibJS/Heap/Heap.h>
|
2020-03-12 20:11:35 +01:00
|
|
|
#include <LibJS/Interpreter.h>
|
2020-03-16 14:20:30 +01:00
|
|
|
#include <LibJS/Runtime/ConsoleObject.h>
|
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
#include <LibJS/Runtime/NativeFunction.h>
|
|
|
|
#include <LibJS/Runtime/Value.h>
|
2020-03-12 20:11:35 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2020-03-13 11:06:32 +01:00
|
|
|
GlobalObject::GlobalObject()
|
2020-03-12 20:11:35 +01:00
|
|
|
{
|
2020-03-15 20:51:36 +01:00
|
|
|
put_native_function("print", [](Object*, Vector<Value> arguments) -> Value {
|
2020-03-12 20:11:35 +01:00
|
|
|
for (auto& argument : arguments)
|
2020-03-13 10:08:52 +01:00
|
|
|
printf("%s ", argument.to_string().characters());
|
2020-03-12 20:11:35 +01:00
|
|
|
return js_undefined();
|
2020-03-13 11:06:32 +01:00
|
|
|
});
|
2020-03-15 20:51:36 +01:00
|
|
|
put_native_function("gc", [](Object* this_object, Vector<Value>) -> Value {
|
2020-03-12 20:11:35 +01:00
|
|
|
dbg() << "Forced garbage collection requested!";
|
2020-03-15 20:51:36 +01:00
|
|
|
this_object->heap().collect_garbage();
|
2020-03-12 20:11:35 +01:00
|
|
|
return js_undefined();
|
2020-03-13 11:06:32 +01:00
|
|
|
});
|
2020-03-12 20:11:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GlobalObject::~GlobalObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|