fix: how the hell did i fix this (it was the cache all along)
This commit is contained in:
1
src/assets/js/bootstrap.js
vendored
1
src/assets/js/bootstrap.js
vendored
@@ -64,7 +64,6 @@
|
||||
|
||||
if (!environments[env.id]) environments[env.id] = []
|
||||
declSnapshots = environments[env.id];
|
||||
debugger;
|
||||
var emit = service.getEmitOutput("/src.ts");
|
||||
|
||||
var diagnostics = []
|
||||
|
||||
7
src/assets/js/lib.d.ts
vendored
7
src/assets/js/lib.d.ts
vendored
@@ -458,11 +458,16 @@ interface SymbolConstructor {
|
||||
readonly asyncIterator: unique symbol;
|
||||
}
|
||||
|
||||
|
||||
interface Promise<T> extends Thenable<T> {
|
||||
catch<ResT = void>(func: (err: unknown) => ResT): Promise<ResT>;
|
||||
finally(func: () => void): Promise<T>;
|
||||
constructor: PromiseConstructor;
|
||||
}
|
||||
interface PromiseConstructor {
|
||||
interface PromiseConstructorLike {
|
||||
new <T>(func: (res: (val: T) => void, rej: (err: unknown) => void) => void): Thenable<Awaited<T>>;
|
||||
}
|
||||
interface PromiseConstructor extends PromiseConstructorLike {
|
||||
prototype: Promise<any>;
|
||||
|
||||
new <T>(func: (res: (val: T) => void, rej: (err: unknown) => void) => void): Promise<Awaited<T>>;
|
||||
|
||||
@@ -15,15 +15,9 @@ public class CompileTarget {
|
||||
public final Map<Long, FunctionBody> functions;
|
||||
public final TreeSet<Location> breakpoints;
|
||||
private final HashMap<Location, Instruction> bpToInstr = new HashMap<>();
|
||||
private BreakpointType queueType = BreakpointType.NONE;
|
||||
private Location queueLoc = null;
|
||||
|
||||
public Instruction add(Instruction instr) {
|
||||
target.add(instr);
|
||||
if (queueType != BreakpointType.NONE) setDebug(queueType);
|
||||
if (queueLoc != null) instr.locate(queueLoc);
|
||||
queueType = BreakpointType.NONE;
|
||||
queueLoc = null;
|
||||
return instr;
|
||||
}
|
||||
public Instruction set(int i, Instruction instr) {
|
||||
@@ -56,13 +50,6 @@ public class CompileTarget {
|
||||
else return target.get(target.size() - 1).location;
|
||||
}
|
||||
|
||||
public void queueDebug(BreakpointType type) {
|
||||
queueType = type;
|
||||
}
|
||||
public void queueDebug(BreakpointType type, Location loc) {
|
||||
queueType = type;
|
||||
}
|
||||
|
||||
public Instruction[] array() { return target.toArray(Instruction[]::new); }
|
||||
|
||||
public FunctionBody body() {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package me.topchetoeu.jscript.compilation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import me.topchetoeu.jscript.Location;
|
||||
import me.topchetoeu.jscript.compilation.Instruction.BreakpointType;
|
||||
import me.topchetoeu.jscript.compilation.values.FunctionStatement;
|
||||
@@ -25,19 +28,21 @@ public class CompoundStatement extends Statement {
|
||||
|
||||
@Override
|
||||
public void compile(CompileTarget target, ScopeRecord scope, boolean pollute, BreakpointType type) {
|
||||
if (separateFuncs) for (var stm : statements) {
|
||||
List<Statement> statements = new Vector<Statement>();
|
||||
if (separateFuncs) for (var stm : this.statements) {
|
||||
if (stm instanceof FunctionStatement && ((FunctionStatement)stm).statement) {
|
||||
stm.compile(target, scope, false);
|
||||
}
|
||||
else statements.add(stm);
|
||||
}
|
||||
else statements = List.of(this.statements);
|
||||
|
||||
var polluted = false;
|
||||
|
||||
for (var i = 0; i < statements.length; i++) {
|
||||
var stm = statements[i];
|
||||
for (var i = 0; i < statements.size(); i++) {
|
||||
var stm = statements.get(i);
|
||||
|
||||
if (separateFuncs && stm instanceof FunctionStatement) continue;
|
||||
if (i != statements.length - 1) stm.compile(target, scope, false, BreakpointType.STEP_OVER);
|
||||
if (i != statements.size() - 1) stm.compile(target, scope, false, BreakpointType.STEP_OVER);
|
||||
else stm.compile(target, scope, polluted = pollute, BreakpointType.STEP_OVER);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@ public class VariableDeclareStatement extends Statement {
|
||||
|
||||
if (key instanceof String) target.add(Instruction.makeVar(entry.location, (String)key));
|
||||
|
||||
target.queueDebug(BreakpointType.STEP_OVER, entry.location);
|
||||
if (entry.value != null) FunctionStatement.compileWithName(entry.value, target, scope, true, entry.name);
|
||||
else target.add(Instruction.loadValue(entry.location, null));
|
||||
target.add(Instruction.storeVar(entry.location, key));
|
||||
if (entry.value != null) {
|
||||
FunctionStatement.compileWithName(entry.value, target, scope, true, entry.name, BreakpointType.STEP_OVER);
|
||||
target.add(Instruction.storeVar(entry.location, key));
|
||||
}
|
||||
}
|
||||
|
||||
if (pollute) target.add(Instruction.loadValue(loc(), null));
|
||||
|
||||
@@ -44,11 +44,10 @@ public class ForInStatement extends Statement {
|
||||
target.add(Instruction.nop(loc()));
|
||||
|
||||
target.add(Instruction.loadMember(varLocation, "value"));
|
||||
target.queueDebug(BreakpointType.STEP_OVER, object.loc());
|
||||
target.add(Instruction.storeVar(varLocation, key));
|
||||
target.add(Instruction.storeVar(object.loc(), key));
|
||||
target.setDebug(BreakpointType.STEP_OVER);
|
||||
|
||||
target.queueDebug(BreakpointType.STEP_OVER, body.loc());
|
||||
body.compile(target, scope, false);
|
||||
body.compile(target, scope, false, BreakpointType.STEP_OVER);
|
||||
|
||||
int end = target.size();
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ public class TryStatement extends Statement {
|
||||
target.add(Instruction.tryEnd(loc()));
|
||||
}
|
||||
|
||||
target.queueDebug(BreakpointType.STEP_OVER);
|
||||
target.set(start - 1, Instruction.tryStart(loc(), catchStart, finallyStart, target.size() - start));
|
||||
target.setDebug(start - 1, BreakpointType.STEP_OVER);
|
||||
if (pollute) target.add(Instruction.loadValue(loc(), null));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ public class CallStatement extends Statement {
|
||||
|
||||
for (var arg : args) arg.compile(target, scope, true);
|
||||
|
||||
target.queueDebug(type);
|
||||
if (isNew) target.add(Instruction.callNew(loc(), args.length));
|
||||
else target.add(Instruction.call(loc(), args.length));
|
||||
target.setDebug(type);
|
||||
|
||||
if (!pollute) target.add(Instruction.discard(loc()));
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class FunctionStatement extends Statement {
|
||||
}
|
||||
}
|
||||
|
||||
private long compileBody(CompileTarget target, ScopeRecord scope, boolean polute) {
|
||||
private long compileBody(CompileTarget target, ScopeRecord scope, boolean polute, BreakpointType bp) {
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
for (var j = 0; j < i; j++) {
|
||||
if (args[i].equals(args[j])) {
|
||||
@@ -68,6 +68,7 @@ public class FunctionStatement extends Statement {
|
||||
|
||||
if (!statement && this.varName != null) {
|
||||
subtarget.add(Instruction.storeSelfFunc(loc(), (int)subscope.define(this.varName)));
|
||||
subtarget.setDebug(bp);
|
||||
}
|
||||
|
||||
body.declare(subscope);
|
||||
@@ -84,13 +85,13 @@ public class FunctionStatement extends Statement {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void compile(CompileTarget target, ScopeRecord scope, boolean pollute, String name) {
|
||||
public void compile(CompileTarget target, ScopeRecord scope, boolean pollute, String name, BreakpointType bp) {
|
||||
if (this.varName != null) name = this.varName;
|
||||
|
||||
var hasVar = this.varName != null && statement;
|
||||
var hasName = name != null;
|
||||
|
||||
compileBody(target, scope, pollute || hasVar || hasName);
|
||||
compileBody(target, scope, pollute || hasVar || hasName, bp);
|
||||
|
||||
if (hasName) {
|
||||
if (pollute || hasVar) target.add(Instruction.dup(loc()));
|
||||
@@ -106,8 +107,14 @@ public class FunctionStatement extends Statement {
|
||||
target.add(Instruction.storeVar(loc(), scope.getKey(this.varName), false));
|
||||
}
|
||||
}
|
||||
public void compile(CompileTarget target, ScopeRecord scope, boolean pollute, String name) {
|
||||
compile(target, scope, pollute, name, BreakpointType.NONE);
|
||||
}
|
||||
@Override public void compile(CompileTarget target, ScopeRecord scope, boolean pollute, BreakpointType bp) {
|
||||
compile(target, scope, pollute, (String)null, bp);
|
||||
}
|
||||
@Override public void compile(CompileTarget target, ScopeRecord scope, boolean pollute) {
|
||||
compile(target, scope, pollute, BreakpointType.NONE);
|
||||
compile(target, scope, pollute, (String)null, BreakpointType.NONE);
|
||||
}
|
||||
|
||||
public FunctionStatement(Location loc, Location end, String varName, String[] args, boolean statement, CompoundStatement body) {
|
||||
@@ -125,4 +132,8 @@ public class FunctionStatement extends Statement {
|
||||
if (stm instanceof FunctionStatement) ((FunctionStatement)stm).compile(target, scope, pollute, name);
|
||||
else stm.compile(target, scope, pollute);
|
||||
}
|
||||
public static void compileWithName(Statement stm, CompileTarget target, ScopeRecord scope, boolean pollute, String name, BreakpointType bp) {
|
||||
if (stm instanceof FunctionStatement) ((FunctionStatement)stm).compile(target, scope, pollute, name, bp);
|
||||
else stm.compile(target, scope, pollute, bp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +198,7 @@ public class CodeFrame {
|
||||
|
||||
if (instr == null) returnValue = null;
|
||||
else {
|
||||
// System.out.println(instr + "@" + instr.location);
|
||||
ctx.engine.onInstruction(ctx, this, instr, Runners.NO_RETURN, null, false);
|
||||
|
||||
if (instr.location != null) prevLoc = instr.location;
|
||||
|
||||
@@ -880,7 +880,7 @@ public class Parsing {
|
||||
var callRes = parseCall(filename, tokens, i + n, valRes.result, 0);
|
||||
n += callRes.n;
|
||||
if (callRes.isError()) return callRes.transform();
|
||||
else if (callRes.isFailed()) return ParseRes.res(new CallStatement(loc, false, valRes.result), n);
|
||||
else if (callRes.isFailed()) return ParseRes.res(new CallStatement(loc, true, valRes.result), n);
|
||||
var call = (CallStatement)callRes.result;
|
||||
|
||||
return ParseRes.res(new CallStatement(loc, true, call.func, call.args), n);
|
||||
|
||||
Reference in New Issue
Block a user