fix for latest zig

This commit is contained in:
Luna 2019-06-30 00:01:03 -03:00
parent d7b78e09e3
commit 036e76d3a5
5 changed files with 8 additions and 10 deletions

View file

@ -170,7 +170,7 @@ pub const Chunk = struct {
const v2: u8 = @intCast(u8, (idx_u24 >> 8) & mask); const v2: u8 = @intCast(u8, (idx_u24 >> 8) & mask);
const v3: u8 = @intCast(u8, (idx_u24 >> 16) & mask); const v3: u8 = @intCast(u8, (idx_u24 >> 16) & mask);
return ConstantIndex{ .Long = []u8{ v3, v2, v1 } }; return ConstantIndex{ .Long = [_]u8{ v3, v2, v1 } };
} }
} }

View file

@ -48,7 +48,7 @@ const ParseRule = struct {
}; };
/// For each token, this defines a parse rule for it. /// For each token, this defines a parse rule for it.
var rules = []ParseRule{ var rules = [_]ParseRule{
// for LEFT_PAREN, we determine it as a call precedence // for LEFT_PAREN, we determine it as a call precedence
// plus a prefix parse function of grouping // plus a prefix parse function of grouping
ParseRule{ .prefix = Compiler.grouping, .precedence = .Call }, ParseRule{ .prefix = Compiler.grouping, .precedence = .Call },
@ -150,7 +150,7 @@ pub const Compiler = struct {
.vmach = vmach, .vmach = vmach,
// local variable resolution // local variable resolution
.locals = []Local{Local{ .locals = [_]Local{Local{
.name = Token{}, .name = Token{},
.depth = -1, .depth = -1,
}} ** 256, }} ** 256,

View file

@ -94,8 +94,7 @@ fn runPrompt(allocator: *Allocator) !void {
} }
pub fn main() anyerror!void { pub fn main() anyerror!void {
var da = std.heap.DirectAllocator.init(); var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator);
var arena = std.heap.ArenaAllocator.init(&da.allocator);
defer arena.deinit(); defer arena.deinit();
var allocator = &arena.allocator; var allocator = &arena.allocator;
@ -115,8 +114,7 @@ pub fn main() anyerror!void {
} }
pub fn oldMain() !void { pub fn oldMain() !void {
var da = std.heap.DirectAllocator.init(); var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator);
var arena = std.heap.ArenaAllocator.init(&da.allocator);
defer arena.deinit(); defer arena.deinit();
var allocator = &arena.allocator; var allocator = &arena.allocator;

View file

@ -32,7 +32,7 @@ pub const KeywordMap = std.AutoHashMap([]const u8, u6);
fn initKeywordMap(allocator: *std.mem.Allocator) !KeywordMap { fn initKeywordMap(allocator: *std.mem.Allocator) !KeywordMap {
var map = KeywordMap.init(allocator); var map = KeywordMap.init(allocator);
const keywords = [][]const u8{ const keywords = [_][]const u8{
"and"[0..], "and"[0..],
"class"[0..], "class"[0..],
"else"[0..], "else"[0..],
@ -51,7 +51,7 @@ fn initKeywordMap(allocator: *std.mem.Allocator) !KeywordMap {
"while"[0..], "while"[0..],
}; };
const tags = []TokenType{ const tags = [_]TokenType{
TokenType.AND, TokenType.AND,
TokenType.CLASS, TokenType.CLASS,
TokenType.ELSE, TokenType.ELSE,

View file

@ -166,7 +166,7 @@ pub const VM = struct {
var res_str = try std.mem.join( var res_str = try std.mem.join(
self.allocator, self.allocator,
"", "",
[][]u8{ a, b }, [_][]u8{ a, b },
); );
var val = values.ObjVal(try objects.takeString(self, res_str)); var val = values.ObjVal(try objects.takeString(self, res_str));