refactor: remove testing junk in REPL

This commit is contained in:
TopchetoEU 2024-04-20 22:23:45 +03:00
parent f8553b79f9
commit 099201e4ad
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4

View File

@ -29,11 +29,7 @@ import me.topchetoeu.jscript.utils.filesystem.Mode;
import me.topchetoeu.jscript.utils.filesystem.PhysicalFilesystem; import me.topchetoeu.jscript.utils.filesystem.PhysicalFilesystem;
import me.topchetoeu.jscript.utils.filesystem.RootFilesystem; import me.topchetoeu.jscript.utils.filesystem.RootFilesystem;
import me.topchetoeu.jscript.utils.filesystem.STDFilesystem; import me.topchetoeu.jscript.utils.filesystem.STDFilesystem;
import me.topchetoeu.jscript.utils.interop.Arguments;
import me.topchetoeu.jscript.utils.interop.Expose;
import me.topchetoeu.jscript.utils.interop.ExposeType;
import me.topchetoeu.jscript.utils.interop.NativeWrapperProvider; import me.topchetoeu.jscript.utils.interop.NativeWrapperProvider;
import me.topchetoeu.jscript.utils.interop.WrapperName;
import me.topchetoeu.jscript.utils.modules.ModuleRepo; import me.topchetoeu.jscript.utils.modules.ModuleRepo;
import me.topchetoeu.jscript.utils.permissions.PermissionsManager; import me.topchetoeu.jscript.utils.permissions.PermissionsManager;
import me.topchetoeu.jscript.utils.permissions.PermissionsProvider; import me.topchetoeu.jscript.utils.permissions.PermissionsProvider;
@ -47,37 +43,6 @@ public class JScriptRepl {
static int j = 0; static int j = 0;
static String[] args; static String[] args;
public static interface Interface {
void print();
}
public static class Test implements Interface {
public final int a = 10;
public final int b = 5;
@Override
public void print() {
System.out.println("test!");
}
}
@WrapperName("Interface")
public static class InterfaceLib {
@Expose
public static void __print(Arguments args) { args.self(Interface.class).print(); }
}
@WrapperName("Testificate")
public static class TestLib {
@Expose(type = ExposeType.GETTER)
public static int __a(Arguments args) { return args.self(Test.class).a; }
@Expose(type = ExposeType.GETTER)
public static int __b(Arguments args) { return args.self(Test.class).b; }
@Expose
public static void __print(Arguments args) { System.out.println("NO!"); }
}
private static void reader() { private static void reader() {
try { try {
for (var arg : args) { for (var arg : args) {
@ -124,12 +89,8 @@ public class JScriptRepl {
private static void initEnv() { private static void initEnv() {
environment = Internals.apply(environment); environment = Internals.apply(environment);
var wp = NativeWrapperProvider.get(environment);
var glob = GlobalScope.get(environment); var glob = GlobalScope.get(environment);
wp.set(Interface.class, InterfaceLib.class);
wp.set(Test.class, TestLib.class);
glob.define(null, false, new NativeFunction("exit", args -> { glob.define(null, false, new NativeFunction("exit", args -> {
throw new InterruptException(); throw new InterruptException();
})); }));
@ -151,12 +112,6 @@ public class JScriptRepl {
return null; return null;
})); }));
var test = new Test();
glob.define(environment, "test1", false, test);
glob.define(environment, "test2", false, test);
glob.define(environment, false, wp.getConstr(TestLib.class));
var fs = new RootFilesystem(PermissionsProvider.get(environment)); var fs = new RootFilesystem(PermissionsProvider.get(environment));
fs.protocols.put("temp", new MemoryFilesystem(Mode.READ_WRITE)); fs.protocols.put("temp", new MemoryFilesystem(Mode.READ_WRITE));
fs.protocols.put("file", new PhysicalFilesystem(".")); fs.protocols.put("file", new PhysicalFilesystem("."));