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

This commit is contained in:
Andreas Kling 2020-03-16 14:58:20 +01:00
commit 086f68e878
Notes: sideshowbarker 2024-07-19 08:16:35 +09:00
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();