fix: use new global API

This commit is contained in:
TopchetoEU 2024-03-05 15:54:51 +02:00
parent 7c6622c53d
commit 3e6214659b
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4

View File

@ -87,10 +87,10 @@ public class JScriptRepl {
private static void initEnv() { private static void initEnv() {
environment = Internals.apply(environment); environment = Internals.apply(environment);
environment.global.define(false, new NativeFunction("exit", args -> { environment.global.define(null, false, new NativeFunction("exit", args -> {
throw new InterruptException(); throw new InterruptException();
})); }));
environment.global.define(false, new NativeFunction("go", args -> { environment.global.define(null, false, new NativeFunction("go", args -> {
try { try {
var f = Path.of("do.js"); var f = Path.of("do.js");
var func = args.ctx.compile(new Filename("do", "do/" + j++ + ".js"), new String(Files.readAllBytes(f))); var func = args.ctx.compile(new Filename("do", "do/" + j++ + ".js"), new String(Files.readAllBytes(f)));
@ -100,7 +100,7 @@ public class JScriptRepl {
throw new EngineException("Couldn't open do.js"); throw new EngineException("Couldn't open do.js");
} }
})); }));
environment.global.define(false, new NativeFunction("log", args -> { environment.global.define(null, false, new NativeFunction("log", args -> {
for (var el : args.args) { for (var el : args.args) {
Values.printValue(args.ctx, el); Values.printValue(args.ctx, el);
} }