move more instructions as intrinsics
This commit is contained in:
@@ -31,13 +31,18 @@ public class ForInNode extends Node {
|
||||
body.compileFunctions(target);
|
||||
}
|
||||
@Override public void compile(CompileResult target, boolean pollute) {
|
||||
target.add(Instruction.loadIntrinsics("keys"));
|
||||
object.compile(target, true, BreakpointType.STEP_OVER);
|
||||
target.add(Instruction.keys(false, true));
|
||||
target.add(Instruction.pushValue(false));
|
||||
target.add(Instruction.pushValue(true));
|
||||
target.add(Instruction.call(3, false));
|
||||
|
||||
int start = target.size();
|
||||
target.add(Instruction.dup());
|
||||
target.add(Instruction.call(0, false));
|
||||
target.add(Instruction.dup());
|
||||
target.add(Instruction.loadMember("done"));
|
||||
int mid = target.temp();
|
||||
|
||||
target.add(Instruction.loadMember("value")).setLocation(binding.loc());
|
||||
target.add(VariableNode.toSet(target, loc(), binding.name, false, true)).setLocation(binding.loc());
|
||||
|
||||
@@ -52,7 +57,7 @@ public class ForInNode extends Node {
|
||||
|
||||
target.add(Instruction.jmp(start - endI));
|
||||
target.add(Instruction.discard());
|
||||
target.set(mid, Instruction.jmpIfNot(endI - mid + 1));
|
||||
target.set(mid, Instruction.jmpIf(endI - mid + 1));
|
||||
|
||||
end.set(endI + 1);
|
||||
LabelContext.popLoop(target.env, label);
|
||||
|
||||
@@ -38,11 +38,20 @@ public final class PropertyMemberNode extends FunctionNode implements Member {
|
||||
}
|
||||
|
||||
@Override public void compile(CompileResult target, boolean pollute, String name, BreakpointType bp) {
|
||||
if (pollute) target.add(Instruction.dup());
|
||||
key.compile(target, true);
|
||||
if (isGetter()) {
|
||||
target.add(Instruction.loadIntrinsics("defGetter"));
|
||||
}
|
||||
else {
|
||||
target.add(Instruction.loadIntrinsics("defSetter"));
|
||||
}
|
||||
|
||||
target.add(Instruction.dup(1, 1));
|
||||
key.compile(target, true);
|
||||
target.add(Instruction.loadFunc(target.childrenIndices.get(this), name(name), captures(target))).setLocation(loc());
|
||||
target.add(Instruction.defProp(isSetter()));
|
||||
target.add(Instruction.call(3, false));
|
||||
target.add(Instruction.discard());
|
||||
|
||||
if (!pollute) target.add(Instruction.discard());
|
||||
}
|
||||
|
||||
public PropertyMemberNode(Location loc, Location end, Node key, VariableNode argument, CompoundNode body) {
|
||||
|
||||
@@ -39,9 +39,9 @@ public final class VariableIndex {
|
||||
}
|
||||
public final Instruction toSet(boolean keep) {
|
||||
switch (type) {
|
||||
case CAPTURES: return Instruction.storeVar(~index, keep, false);
|
||||
case CAPTURABLES: return Instruction.storeVar(index, keep, false);
|
||||
case LOCALS: return Instruction.storeVar(index, keep, false);
|
||||
case CAPTURES: return Instruction.storeVar(~index, keep);
|
||||
case CAPTURABLES: return Instruction.storeVar(index, keep);
|
||||
case LOCALS: return Instruction.storeVar(index, keep);
|
||||
default: throw new UnsupportedOperationException("Unknown index type " + type);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user