feat: add this arg capture
This commit is contained in:
parent
f929015f55
commit
546d663466
@ -20,7 +20,7 @@ public final class CompileResult {
|
|||||||
public final List<CompileResult> children;
|
public final List<CompileResult> children;
|
||||||
public final FunctionMapBuilder map;
|
public final FunctionMapBuilder map;
|
||||||
public final Environment env;
|
public final Environment env;
|
||||||
public int length, assignN;
|
public int length;
|
||||||
public final Scope scope;
|
public final Scope scope;
|
||||||
|
|
||||||
public int temp() {
|
public int temp() {
|
||||||
@ -101,8 +101,7 @@ public final class CompileResult {
|
|||||||
|
|
||||||
return new FunctionBody(
|
return new FunctionBody(
|
||||||
scope.localsCount() + scope.allocCount(), scope.capturesCount(),
|
scope.localsCount() + scope.allocCount(), scope.capturesCount(),
|
||||||
length, assignN,
|
length, instrRes, builtChildren
|
||||||
instrRes, builtChildren
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import me.topchetoeu.jscript.runtime.values.Value;
|
|||||||
public final class CodeFunction extends FunctionValue {
|
public final class CodeFunction extends FunctionValue {
|
||||||
public final FunctionBody body;
|
public final FunctionBody body;
|
||||||
public final Value[][] captures;
|
public final Value[][] captures;
|
||||||
|
public Value self;
|
||||||
public Environment env;
|
public Environment env;
|
||||||
|
|
||||||
private Value onCall(Frame frame) {
|
private Value onCall(Frame frame) {
|
||||||
@ -25,8 +26,8 @@ public final class CodeFunction extends FunctionValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public Value onCall(Environment env, boolean isNew, String name, Value thisArg, Value ...args) {
|
@Override public Value onCall(Environment env, boolean isNew, String name, Value thisArg, Value ...args) {
|
||||||
var frame = new Frame(env, isNew, thisArg, args, this);
|
if (self != null) return onCall(new Frame(env, isNew, self, args, this));
|
||||||
return onCall(frame);
|
else return onCall(new Frame(env, isNew, thisArg, args, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodeFunction(Environment env, String name, FunctionBody body, Value[][] captures) {
|
public CodeFunction(Environment env, String name, FunctionBody body, Value[][] captures) {
|
||||||
|
Loading…
Reference in New Issue
Block a user