Permissions and filesystems #9

Merged
TopchetoEU merged 36 commits from TopchetoEU/perms-and-fs into master 2023-11-25 18:10:59 +00:00
Showing only changes of commit 829bea755d - Show all commits

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Stack; import java.util.Stack;
import me.topchetoeu.jscript.Location; import me.topchetoeu.jscript.Location;
import me.topchetoeu.jscript.compilation.Instruction;
import me.topchetoeu.jscript.engine.Context; import me.topchetoeu.jscript.engine.Context;
import me.topchetoeu.jscript.engine.scope.LocalScope; import me.topchetoeu.jscript.engine.scope.LocalScope;
import me.topchetoeu.jscript.engine.scope.ValueVariable; import me.topchetoeu.jscript.engine.scope.ValueVariable;
@ -151,15 +152,17 @@ public class CodeFrame {
public Object next(Context ctx, Object value, Object returnValue, EngineException error) { public Object next(Context ctx, Object value, Object returnValue, EngineException error) {
if (value != Runners.NO_RETURN) push(ctx, value); if (value != Runners.NO_RETURN) push(ctx, value);
Instruction instr = null;
if (codePtr >= 0 && codePtr < function.body.length) instr = function.body[codePtr];
if (returnValue == Runners.NO_RETURN && error == null) { if (returnValue == Runners.NO_RETURN && error == null) {
try { try {
if (Thread.currentThread().isInterrupted()) throw new InterruptException(); if (Thread.currentThread().isInterrupted()) throw new InterruptException();
var instr = function.body[codePtr]; if (instr == null) returnValue = null;
ctx.engine.onInstruction(ctx, this, instr, Runners.NO_RETURN, null, false);
if (codePtr < 0 || codePtr >= function.body.length) returnValue = null;
else { else {
ctx.engine.onInstruction(ctx, this, instr, Runners.NO_RETURN, null, false);
if (instr.location != null) prevLoc = instr.location; if (instr.location != null) prevLoc = instr.location;
try { try {
@ -278,11 +281,11 @@ public class CodeFrame {
} }
if (error != null) { if (error != null) {
ctx.engine.onInstruction(ctx, this, function.body[codePtr], null, error, false); ctx.engine.onInstruction(ctx, this, instr, null, error, false);
throw error; throw error;
} }
if (returnValue != Runners.NO_RETURN) { if (returnValue != Runners.NO_RETURN) {
ctx.engine.onInstruction(ctx, this, function.body[codePtr], returnValue, null, false); ctx.engine.onInstruction(ctx, this, instr, returnValue, null, false);
return returnValue; return returnValue;
} }