Compare commits
No commits in common. "eca2cfffb8592e37caef1ede93de0974b5e03d63" and "0d6e5250c79989486e2b12eff21a12e3bad6158e" have entirely different histories.
eca2cfffb8
...
0d6e5250c7
@ -272,15 +272,16 @@ 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 jump_opcode_index = chunk.opcodes.values.len - 1;
|
const jump_opcode = &chunk.opcodes.values[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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coral.debug.assert(jump_opcode.* == .jf);
|
||||||
coral.debug.assert(chunk.opcodes.values.len < coral.math.max_int(@typeInfo(u32).Int));
|
coral.debug.assert(chunk.opcodes.values.len < coral.math.max_int(@typeInfo(u32).Int));
|
||||||
|
|
||||||
chunk.opcodes.values[jump_opcode_index].jf = @intCast(chunk.opcodes.values.len - 1);
|
jump_opcode.jf = @intCast(chunk.opcodes.values.len);
|
||||||
},
|
},
|
||||||
|
|
||||||
.expression => |expression| try self.compile_expression(chunk, expression),
|
.expression => |expression| try self.compile_expression(chunk, expression),
|
||||||
@ -421,11 +422,15 @@ pub const RuntimeEnv = struct {
|
|||||||
},
|
},
|
||||||
|
|
||||||
.object_get => {
|
.object_get => {
|
||||||
const index = try self.env.expect(try self.pop_local());
|
const index = (try self.pop_local()) orelse {
|
||||||
|
return self.env.raise(error.TypeMismatch, "nil is not a valid index");
|
||||||
|
};
|
||||||
|
|
||||||
defer self.env.discard(index);
|
defer self.env.discard(index);
|
||||||
|
|
||||||
const indexable = try self.env.expect(try self.pop_local());
|
const indexable = (try self.pop_local()) orelse {
|
||||||
|
return self.env.raise(error.TypeMismatch, "nil is not a valid indexable");
|
||||||
|
};
|
||||||
|
|
||||||
defer self.env.discard(indexable);
|
defer self.env.discard(indexable);
|
||||||
|
|
||||||
@ -1549,21 +1554,6 @@ pub const RuntimeRef = opaque {
|
|||||||
.dynamic => true,
|
.dynamic => true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn typename(self: *const RuntimeRef) []const coral.io.Byte {
|
|
||||||
return switch (self.object().payload) {
|
|
||||||
.false => "false",
|
|
||||||
.true => "true",
|
|
||||||
.float => "float",
|
|
||||||
.fixed => "fixed",
|
|
||||||
.symbol => "symbol",
|
|
||||||
.vector2 => "vector2",
|
|
||||||
.vector3 => "vector3",
|
|
||||||
.syscall => "syscall",
|
|
||||||
.string => "string",
|
|
||||||
.dynamic => "dynamic",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Syscall = fn (env: *RuntimeEnv) RuntimeError!?*RuntimeRef;
|
pub const Syscall = fn (env: *RuntimeEnv) RuntimeError!?*RuntimeRef;
|
||||||
|
@ -42,13 +42,10 @@ pub const BinaryOperator = enum {
|
|||||||
"`");
|
"`");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove once Zig has fixed struct self-reassignment.
|
|
||||||
const unnecessary_temp = try coral.io.allocate_one(allocator, expression);
|
|
||||||
|
|
||||||
expression = .{
|
expression = .{
|
||||||
.binary_operation = .{
|
.binary_operation = .{
|
||||||
.operator = operator,
|
.operator = operator,
|
||||||
.lhs_expression = unnecessary_temp,
|
.lhs_expression = try coral.io.allocate_one(allocator, expression),
|
||||||
.rhs_expression = try coral.io.allocate_one(allocator, try build_next(self)),
|
.rhs_expression = try coral.io.allocate_one(allocator, try build_next(self)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user