feat: make function logging configurable

This commit is contained in:
TopchetoEU 2024-11-24 12:49:04 +02:00
parent 5c2fd00bfb
commit 3c13799c2f
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4

View File

@ -15,6 +15,8 @@ import me.topchetoeu.jscript.common.parsing.Location;
import me.topchetoeu.jscript.compilation.scope.FunctionScope;
public final class CompileResult {
public static final Key<Void> DEBUG_LOG = new Key<>();
public static final class ChildData {
public final int id;
public final CompileResult result;
@ -85,7 +87,14 @@ public final class CompileResult {
var instrRes = instructions();
if (env.has(DEBUG_LOG)) {
System.out.println("================= BODY =================");
System.out.println("LOCALS: " + scope.localsCount());
System.out.println("CAPTURABLES: " + scope.capturablesCount());
System.out.println("CAPTURES: " + scope.capturesCount());
for (var instr : instrRes) System.out.println(instr);
}
return new FunctionBody(
scope.localsCount(), scope.capturablesCount(), scope.capturesCount(),