Module support #11

Merged
TopchetoEU merged 20 commits from TopchetoEU/modules into master 2023-12-26 12:20:55 +00:00
6 changed files with 5 additions and 10 deletions
Showing only changes of commit e9e020512e - Show all commits

View File

@ -26,11 +26,11 @@ public class Context {
return env.empty() ? null : env.peek();
}
public Context pushEnv(Environment env) {
private Context pushEnv(Environment env) {
this.env.push(env);
return this;
}
public void popEnv() {
private void popEnv() {
if (!env.empty()) this.env.pop();
}

View File

@ -106,10 +106,6 @@ public class Environment implements PermissionsProvider {
return permissions == null || permissions.hasPermission(perm);
}
public Context context(Engine engine) {
return new Context(engine).pushEnv(this);
}
public static Symbol getSymbol(String name) {
if (symbols.containsKey(name)) return symbols.get(name);
else {

View File

@ -482,7 +482,7 @@ public class SimpleDebugger implements Debugger {
env.global = new GlobalScope(codeFrame.local);
var ctx = new Context(engine).pushEnv(env);
var ctx = new Context(engine, env);
var awaiter = engine.pushMsg(false, ctx.environment(), new Filename("jscript", "eval"), code, codeFrame.frame.thisArg, codeFrame.frame.args);
engine.run(true);

View File

@ -741,7 +741,7 @@ public class Values {
try {
if (err instanceof EngineException) {
var ee = ((EngineException)err);
System.out.println(prefix + " " + ee.toString(new Context(ee.engine).pushEnv(ee.env)));
System.out.println(prefix + " " + ee.toString(new Context(ee.engine, ee.env)));
}
else if (err instanceof SyntaxException) {
System.out.println("Syntax error:" + ((SyntaxException)err).msg);

View File

@ -37,7 +37,7 @@ public class EngineException extends RuntimeException {
if (function.equals("")) function = null;
if (ctx == null) this.ctx = null;
else this.ctx = new Context(ctx.engine).pushEnv(ctx.environment());
else this.ctx = new Context(ctx.engine, ctx.environment());
this.location = location;
this.function = function;
}

View File

@ -21,7 +21,6 @@ import me.topchetoeu.jscript.interop.Native;
private void next(Context ctx, Object inducedValue, Object inducedError) {
Object res = null;
ctx.pushFrame(frame);
ctx.pushEnv(frame.function.environment);
awaiting = false;
while (!awaiting) {