1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 19:24:57 +00:00
serenity/Libraries/LibJS/Runtime/GlobalObject.cpp
Andreas Kling 19452230cd LibJS: Add "Heap" and "Runtime" subdirectories
Let's try to keep LibJS tidy as it expands. :^)
2020-03-16 14:37:19 +01:00

31 lines
818 B
C++

#include <AK/LogStream.h>
#include <AK/String.h>
#include <LibJS/Heap/Heap.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/ConsoleObject.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/Value.h>
#include <stdio.h>
namespace JS {
GlobalObject::GlobalObject()
{
put_native_function("print", [](Object*, Vector<Value> arguments) -> Value {
for (auto& argument : arguments)
printf("%s ", argument.to_string().characters());
return js_undefined();
});
put_native_function("gc", [](Object* this_object, Vector<Value>) -> Value {
dbg() << "Forced garbage collection requested!";
this_object->heap().collect_garbage();
return js_undefined();
});
}
GlobalObject::~GlobalObject()
{
}
}