Fix > and == operators being miscompiled
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kayomn 2023-08-25 22:57:33 +01:00
parent c4916a4195
commit 77af4d067b
1 changed files with 4 additions and 4 deletions

View File

@ -136,9 +136,9 @@ pub const RuntimeEnv = struct {
.subtraction => .sub,
.multiplication => .mul,
.divsion => .div,
.greater_equals_comparison => .eql,
.greater_equals_comparison => .cge,
.greater_than_comparison => .cgt,
.equals_comparison => .cge,
.equals_comparison => .eql,
.less_than_comparison => .clt,
.less_equals_comparison => .cle,
});
@ -297,13 +297,13 @@ pub const RuntimeEnv = struct {
try self.compile_expression(chunk, @"if".condition_expression);
try chunk.opcodes.push_one(.{.jf = 0});
const then_origin_index = @as(u32, @intCast(chunk.opcodes.values.len - 1));
const origin_index = @as(u32, @intCast(chunk.opcodes.values.len - 1));
for (@"if".block_statements.values) |block_statement| {
try self.compile_statement(chunk, block_statement);
}
chunk.opcodes.values[then_origin_index].jf = @intCast(chunk.opcodes.values.len - 1);
chunk.opcodes.values[origin_index].jf = @intCast(chunk.opcodes.values.len - 1);
if (@"if".else_statement) |else_statement| {
try self.compile_statement(chunk, else_statement.*);