Fix > and == operators being miscompiled
This commit is contained in:
parent
c4916a4195
commit
77af4d067b
|
@ -136,9 +136,9 @@ pub const RuntimeEnv = struct {
|
||||||
.subtraction => .sub,
|
.subtraction => .sub,
|
||||||
.multiplication => .mul,
|
.multiplication => .mul,
|
||||||
.divsion => .div,
|
.divsion => .div,
|
||||||
.greater_equals_comparison => .eql,
|
.greater_equals_comparison => .cge,
|
||||||
.greater_than_comparison => .cgt,
|
.greater_than_comparison => .cgt,
|
||||||
.equals_comparison => .cge,
|
.equals_comparison => .eql,
|
||||||
.less_than_comparison => .clt,
|
.less_than_comparison => .clt,
|
||||||
.less_equals_comparison => .cle,
|
.less_equals_comparison => .cle,
|
||||||
});
|
});
|
||||||
|
@ -297,13 +297,13 @@ pub const RuntimeEnv = struct {
|
||||||
try self.compile_expression(chunk, @"if".condition_expression);
|
try self.compile_expression(chunk, @"if".condition_expression);
|
||||||
try chunk.opcodes.push_one(.{.jf = 0});
|
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| {
|
for (@"if".block_statements.values) |block_statement| {
|
||||||
try self.compile_statement(chunk, 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| {
|
if (@"if".else_statement) |else_statement| {
|
||||||
try self.compile_statement(chunk, else_statement.*);
|
try self.compile_statement(chunk, else_statement.*);
|
||||||
|
|
Loading…
Reference in New Issue