fix for latest zig

This commit is contained in:
Luna 2019-11-02 10:22:20 -03:00
parent 036e76d3a5
commit d2e865adfc
3 changed files with 28 additions and 28 deletions

View file

@ -5,39 +5,39 @@ const Allocator = std.mem.Allocator;
// hack. ugly hack. zig has compiler crash.
const AllOpcodes = struct {
pub Return: u8 = 0,
pub Constant: u8 = 1,
pub ConstantLong: u8 = 2,
pub Add: u8 = 3,
pub Subtract: u8 = 4,
pub Multiply: u8 = 5,
pub Divide: u8 = 6,
pub Negate: u8 = 7,
Return: u8 = 0,
Constant: u8 = 1,
ConstantLong: u8 = 2,
Add: u8 = 3,
Subtract: u8 = 4,
Multiply: u8 = 5,
Divide: u8 = 6,
Negate: u8 = 7,
// basic type op codes
pub Nil: u8 = 8,
pub True: u8 = 9,
pub False: u8 = 10,
Nil: u8 = 8,
True: u8 = 9,
False: u8 = 10,
pub Not: u8 = 11,
Not: u8 = 11,
// comparison op codes!
pub Equal: u8 = 12,
pub Greater: u8 = 13,
pub Less: u8 = 14,
Equal: u8 = 12,
Greater: u8 = 13,
Less: u8 = 14,
pub Print: u8 = 15,
pub Pop: u8 = 16,
Print: u8 = 15,
Pop: u8 = 16,
pub DefineGlobal: u8 = 17,
pub DefineGlobalLong: u8 = 18,
pub GetGlobal: u8 = 19,
pub GetGlobalLong: u8 = 20,
pub SetGlobal: u8 = 21,
pub SetGlobalLong: u8 = 22,
DefineGlobal: u8 = 17,
DefineGlobalLong: u8 = 18,
GetGlobal: u8 = 19,
GetGlobalLong: u8 = 20,
SetGlobal: u8 = 21,
SetGlobalLong: u8 = 22,
pub GetLocal: u8 = 23,
pub SetLocal: u8 = 24,
GetLocal: u8 = 23,
SetLocal: u8 = 24,
};
pub const OpCode = AllOpcodes{};

View file

@ -25,7 +25,7 @@ fn isAlphaNumeric(char: u8) bool {
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
/// use it here.

View file

@ -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 {
chk: *Chunk = undefined,
@ -47,7 +47,7 @@ pub const VM = struct {
stdout: StdOut,
debug_flag: bool,
pub allocator: *std.mem.Allocator,
allocator: *std.mem.Allocator,
objs: ?*objects.Object = null,
globals: ValueMap,