diff --git a/src/chunk.zig b/src/chunk.zig index 27af808..ae6b958 100644 --- a/src/chunk.zig +++ b/src/chunk.zig @@ -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{}; diff --git a/src/scanner.zig b/src/scanner.zig index 1d8d831..77807cd 100644 --- a/src/scanner.zig +++ b/src/scanner.zig @@ -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. diff --git a/src/vm.zig b/src/vm.zig index 1a03f39..1a41288 100644 --- a/src/vm.zig +++ b/src/vm.zig @@ -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,