fix: lazy operators incorrectly pop values from stack

This commit is contained in:
TopchetoEU 2023-11-05 19:44:08 +02:00
parent af31b1ab79
commit 26591d6631
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
2 changed files with 2 additions and 2 deletions

View File

@ -29,7 +29,7 @@ public class LazyAndStatement extends Statement {
if (pollute) target.add(Instruction.dup().locate(loc())); if (pollute) target.add(Instruction.dup().locate(loc()));
int start = target.size(); int start = target.size();
target.add(Instruction.nop()); target.add(Instruction.nop());
target.add(Instruction.discard().locate(loc())); if (pollute) target.add(Instruction.discard().locate(loc()));
second.compile(target, scope, pollute); second.compile(target, scope, pollute);
target.set(start, Instruction.jmpIfNot(target.size() - start).locate(loc())); target.set(start, Instruction.jmpIfNot(target.size() - start).locate(loc()));
} }

View File

@ -29,7 +29,7 @@ public class LazyOrStatement extends Statement {
if (pollute) target.add(Instruction.dup().locate(loc())); if (pollute) target.add(Instruction.dup().locate(loc()));
int start = target.size(); int start = target.size();
target.add(Instruction.nop()); target.add(Instruction.nop());
target.add(Instruction.discard().locate(loc())); if (pollute) target.add(Instruction.discard().locate(loc()));
second.compile(target, scope, pollute); second.compile(target, scope, pollute);
target.set(start, Instruction.jmpIf(target.size() - start).locate(loc())); target.set(start, Instruction.jmpIf(target.size() - start).locate(loc()));
} }