fix for latest zig
This commit is contained in:
parent
036e76d3a5
commit
d2e865adfc
3 changed files with 28 additions and 28 deletions
|
@ -5,39 +5,39 @@ const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
// hack. ugly hack. zig has compiler crash.
|
// hack. ugly hack. zig has compiler crash.
|
||||||
const AllOpcodes = struct {
|
const AllOpcodes = struct {
|
||||||
pub Return: u8 = 0,
|
Return: u8 = 0,
|
||||||
pub Constant: u8 = 1,
|
Constant: u8 = 1,
|
||||||
pub ConstantLong: u8 = 2,
|
ConstantLong: u8 = 2,
|
||||||
pub Add: u8 = 3,
|
Add: u8 = 3,
|
||||||
pub Subtract: u8 = 4,
|
Subtract: u8 = 4,
|
||||||
pub Multiply: u8 = 5,
|
Multiply: u8 = 5,
|
||||||
pub Divide: u8 = 6,
|
Divide: u8 = 6,
|
||||||
pub Negate: u8 = 7,
|
Negate: u8 = 7,
|
||||||
|
|
||||||
// basic type op codes
|
// basic type op codes
|
||||||
pub Nil: u8 = 8,
|
Nil: u8 = 8,
|
||||||
pub True: u8 = 9,
|
True: u8 = 9,
|
||||||
pub False: u8 = 10,
|
False: u8 = 10,
|
||||||
|
|
||||||
pub Not: u8 = 11,
|
Not: u8 = 11,
|
||||||
|
|
||||||
// comparison op codes!
|
// comparison op codes!
|
||||||
pub Equal: u8 = 12,
|
Equal: u8 = 12,
|
||||||
pub Greater: u8 = 13,
|
Greater: u8 = 13,
|
||||||
pub Less: u8 = 14,
|
Less: u8 = 14,
|
||||||
|
|
||||||
pub Print: u8 = 15,
|
Print: u8 = 15,
|
||||||
pub Pop: u8 = 16,
|
Pop: u8 = 16,
|
||||||
|
|
||||||
pub DefineGlobal: u8 = 17,
|
DefineGlobal: u8 = 17,
|
||||||
pub DefineGlobalLong: u8 = 18,
|
DefineGlobalLong: u8 = 18,
|
||||||
pub GetGlobal: u8 = 19,
|
GetGlobal: u8 = 19,
|
||||||
pub GetGlobalLong: u8 = 20,
|
GetGlobalLong: u8 = 20,
|
||||||
pub SetGlobal: u8 = 21,
|
SetGlobal: u8 = 21,
|
||||||
pub SetGlobalLong: u8 = 22,
|
SetGlobalLong: u8 = 22,
|
||||||
|
|
||||||
pub GetLocal: u8 = 23,
|
GetLocal: u8 = 23,
|
||||||
pub SetLocal: u8 = 24,
|
SetLocal: u8 = 24,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const OpCode = AllOpcodes{};
|
pub const OpCode = AllOpcodes{};
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn isAlphaNumeric(char: u8) bool {
|
||||||
return isAlpha(char) or isDigit(char);
|
return isAlpha(char) or isDigit(char);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const KeywordMap = std.AutoHashMap([]const u8, u6);
|
pub const KeywordMap = std.StringHashMap(u6);
|
||||||
|
|
||||||
/// The book does say that C doesn't have hashmaps. but Zig does. and I can
|
/// The book does say that C doesn't have hashmaps. but Zig does. and I can
|
||||||
/// use it here.
|
/// use it here.
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn valuesEqual(a: value.Value, b: value.Value) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const ValueMap = std.AutoHashMap([]const u8, values.Value);
|
pub const ValueMap = std.StringHashMap(values.Value);
|
||||||
|
|
||||||
pub const VM = struct {
|
pub const VM = struct {
|
||||||
chk: *Chunk = undefined,
|
chk: *Chunk = undefined,
|
||||||
|
@ -47,7 +47,7 @@ pub const VM = struct {
|
||||||
|
|
||||||
stdout: StdOut,
|
stdout: StdOut,
|
||||||
debug_flag: bool,
|
debug_flag: bool,
|
||||||
pub allocator: *std.mem.Allocator,
|
allocator: *std.mem.Allocator,
|
||||||
|
|
||||||
objs: ?*objects.Object = null,
|
objs: ?*objects.Object = null,
|
||||||
globals: ValueMap,
|
globals: ValueMap,
|
||||||
|
|
Loading…
Reference in a new issue