Implement Control Flow Statements in Kym #37
|
@ -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.*);
|
||||
|
|
Loading…
Reference in New Issue