1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

LibJS: Replace the global print() function with console.log() :^)

This commit is contained in:
Andreas Kling 2020-03-16 14:58:20 +01:00
parent 19452230cd
commit 086f68e878
10 changed files with 109 additions and 25 deletions

View file

@ -6,17 +6,12 @@
#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("console", heap().allocate<ConsoleObject>());
put_native_function("gc", [](Object* this_object, Vector<Value>) -> Value {
dbg() << "Forced garbage collection requested!";
this_object->heap().collect_garbage();