Fix POP2 not being called for double and long!
This commit is contained in:
parent
ba66f29fba
commit
3eebfdc9d9
@ -82,6 +82,13 @@ public class Codegen {
|
||||
}
|
||||
}
|
||||
|
||||
private void popValue(State state, TargetType type) {
|
||||
if (type.equals(TargetType.Double) || type.equals(TargetType.Long))
|
||||
state.mv.visitInsn(POP2);
|
||||
else
|
||||
state.mv.visitInsn(POP);
|
||||
}
|
||||
|
||||
private void boxPrimitive(State state, TargetType type) {
|
||||
var mv = state.mv;
|
||||
if (type.equals(TargetType.Boolean) || type.equals(TargetType.boolean_)) {
|
||||
@ -766,9 +773,11 @@ public class Codegen {
|
||||
for (var e : block.statements()) {
|
||||
generate(state, e);
|
||||
if (e instanceof TargetMethodCall) {
|
||||
if (e.type() != null) mv.visitInsn(POP);
|
||||
} else if (e instanceof TargetStatementExpression) {
|
||||
mv.visitInsn(POP);
|
||||
if (e.type() != null) popValue(state, e.type());
|
||||
} else if (e instanceof TargetAssign) {
|
||||
mv.visitInsn(POP); // TODO Nasty fix, we don't know if it is a primitive double or long
|
||||
} else if (e instanceof TargetStatementExpression se) {
|
||||
popValue(state, se.type());
|
||||
}
|
||||
}
|
||||
state.exitScope();
|
||||
@ -885,7 +894,7 @@ public class Codegen {
|
||||
if (_for.increment() != null) {
|
||||
generate(state, _for.increment());
|
||||
if (_for.increment().type() != null) {
|
||||
mv.visitInsn(POP);
|
||||
popValue(state, _for.increment().type());
|
||||
}
|
||||
}
|
||||
mv.visitJumpInsn(GOTO, start);
|
||||
|
Loading…
Reference in New Issue
Block a user