fix: main now uses new env API
This commit is contained in:
parent
153a1a9a49
commit
3343262e72
@ -18,11 +18,15 @@ import me.topchetoeu.jscript.events.Observer;
|
|||||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.exceptions.InterruptException;
|
import me.topchetoeu.jscript.exceptions.InterruptException;
|
||||||
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
||||||
|
import me.topchetoeu.jscript.filesystem.Filesystem;
|
||||||
import me.topchetoeu.jscript.filesystem.MemoryFilesystem;
|
import me.topchetoeu.jscript.filesystem.MemoryFilesystem;
|
||||||
import me.topchetoeu.jscript.filesystem.Mode;
|
import me.topchetoeu.jscript.filesystem.Mode;
|
||||||
import me.topchetoeu.jscript.filesystem.PhysicalFilesystem;
|
import me.topchetoeu.jscript.filesystem.PhysicalFilesystem;
|
||||||
|
import me.topchetoeu.jscript.filesystem.RootFilesystem;
|
||||||
import me.topchetoeu.jscript.lib.Internals;
|
import me.topchetoeu.jscript.lib.Internals;
|
||||||
import me.topchetoeu.jscript.modules.ModuleRepo;
|
import me.topchetoeu.jscript.modules.ModuleRepo;
|
||||||
|
import me.topchetoeu.jscript.permissions.PermissionsManager;
|
||||||
|
import me.topchetoeu.jscript.permissions.PermissionsProvider;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static class Printer implements Observer<Object> {
|
public static class Printer implements Observer<Object> {
|
||||||
@ -43,7 +47,7 @@ public class Main {
|
|||||||
static Thread engineTask, debugTask;
|
static Thread engineTask, debugTask;
|
||||||
static Engine engine = new Engine(true);
|
static Engine engine = new Engine(true);
|
||||||
static DebugServer debugServer = new DebugServer();
|
static DebugServer debugServer = new DebugServer();
|
||||||
static Environment environment = new Environment(null, null, null);
|
static Environment environment = new Environment();
|
||||||
|
|
||||||
static int j = 0;
|
static int j = 0;
|
||||||
static boolean exited = false;
|
static boolean exited = false;
|
||||||
@ -119,9 +123,13 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
environment.filesystem.protocols.put("temp", new MemoryFilesystem(Mode.READ_WRITE));
|
var fs = new RootFilesystem(PermissionsProvider.get(environment));
|
||||||
environment.filesystem.protocols.put("file", new PhysicalFilesystem("."));
|
fs.protocols.put("temp", new MemoryFilesystem(Mode.READ_WRITE));
|
||||||
environment.modules.repos.put("file", ModuleRepo.ofFilesystem(environment.filesystem));
|
fs.protocols.put("file", new PhysicalFilesystem("."));
|
||||||
|
|
||||||
|
environment.add(PermissionsProvider.ENV_KEY, PermissionsManager.ALL_PERMS);
|
||||||
|
environment.add(Filesystem.ENV_KEY, fs);
|
||||||
|
environment.add(ModuleRepo.ENV_KEY, ModuleRepo.ofFilesystem(fs));
|
||||||
}
|
}
|
||||||
private static void initEngine() {
|
private static void initEngine() {
|
||||||
debugServer.targets.put("target", (ws, req) -> new SimpleDebugger(ws, engine));
|
debugServer.targets.put("target", (ws, req) -> new SimpleDebugger(ws, engine));
|
||||||
@ -130,11 +138,11 @@ public class Main {
|
|||||||
}
|
}
|
||||||
private static void initTypescript() {
|
private static void initTypescript() {
|
||||||
try {
|
try {
|
||||||
var tsEnv = Internals.apply(new Environment(null, null, null));
|
var tsEnv = Internals.apply(new Environment());
|
||||||
tsEnv.stackHidden = false;
|
tsEnv.add(Environment.HIDE_STACK, true);
|
||||||
tsEnv.global.define(null, "module", false, new ObjectValue());
|
tsEnv.global.define(null, "module", false, new ObjectValue());
|
||||||
var bsEnv = Internals.apply(new Environment(null, null, null));
|
var bsEnv = Internals.apply(new Environment());
|
||||||
bsEnv.stackHidden = false;
|
bsEnv.add(Environment.HIDE_STACK, true);
|
||||||
|
|
||||||
engine.pushMsg(
|
engine.pushMsg(
|
||||||
false, tsEnv,
|
false, tsEnv,
|
||||||
|
Loading…
Reference in New Issue
Block a user