From c80f88759745bc79dcbcbfed0931eaa8f16de8f3 Mon Sep 17 00:00:00 2001 From: Luna Date: Thu, 23 Jul 2020 16:38:26 -0300 Subject: [PATCH] update to latest zig --- src/ast_printer.zig | 22 +++++++++++----------- src/errors.zig | 2 +- src/parser.zig | 2 +- src/runner.zig | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ast_printer.zig b/src/ast_printer.zig index 2593619..f89adff 100644 --- a/src/ast_printer.zig +++ b/src/ast_printer.zig @@ -13,15 +13,15 @@ fn printIdent(ident: usize) void { } } -fn print(ident: usize, comptime fmt: []const u8, args: var) void { +fn print(ident: usize, comptime fmt: []const u8, args: anytype) void { printIdent(ident); std.debug.warn(fmt, args); } -fn printBlock(ident: usize, block: var, endNewline: bool) void { +fn printBlock(ident: usize, block: anytype, endNewline: bool) void { std.debug.warn("(\n", .{}); - for (block.toSlice()) |stmt| { + for (block.items) |stmt| { printIdent(ident); printStmt(ident, stmt); std.debug.warn("\n", .{}); @@ -56,7 +56,7 @@ pub fn printNode(node: *Node, ident: usize) void { warn("(fn {} {} (", .{ name, ret_type }); } - for (decl.params.toSlice()) |param| { + for (decl.params.items) |param| { warn("({} {}) ", .{ param.name.lexeme, param.typ.lexeme }); } @@ -67,7 +67,7 @@ pub fn printNode(node: *Node, ident: usize) void { .ConstDecl => |consts| { print(ident, "(const (\n", .{}); - for (consts.toSlice()) |const_decl| { + for (consts.items) |const_decl| { print(ident + 1, "({} ", .{ const_decl.name.lexeme, }); @@ -82,7 +82,7 @@ pub fn printNode(node: *Node, ident: usize) void { .Enum => |decl| { print(ident, "(enum {} (\n", .{decl.name.lexeme}); - for (decl.fields.toSlice()) |field| { + for (decl.fields.items) |field| { print(ident + 1, "{}\n", .{ field.lexeme, }); @@ -92,7 +92,7 @@ pub fn printNode(node: *Node, ident: usize) void { }, .Root => { - for (node.Root.toSlice()) |child| { + for (node.Root.items) |child| { printNode(child, ident + 1); } }, @@ -105,7 +105,7 @@ pub fn printNode(node: *Node, ident: usize) void { .Struct => |struc| { print(ident, "(struct {} (\n", .{struc.name.lexeme}); - for (struc.fields.toSlice()) |field| { + for (struc.fields.items) |field| { printIdent(ident + 1); if (field.mutable) { std.debug.warn("(mut ", .{}); @@ -157,7 +157,7 @@ pub fn printExpr(expr: *const Expr) void { .Float => |val| std.debug.warn("{}", .{val}), .String => |val| std.debug.warn("'{}'", .{val}), .Array => |exprs| { - parenthetize("array", exprs.toSlice()); + parenthetize("array", exprs.items); }, else => |typ| std.debug.warn("UnknownLiteral-{}", .{typ}), } @@ -188,7 +188,7 @@ pub fn printExpr(expr: *const Expr) void { std.debug.warn("(", .{}); printExpr(call.callee); - for (call.arguments.toSlice()) |arg| { + for (call.arguments.items) |arg| { std.debug.warn(" ", .{}); printExpr(arg); } @@ -199,7 +199,7 @@ pub fn printExpr(expr: *const Expr) void { .Struct => |val| { std.debug.warn("({} (", .{val.name.lexeme}); - for (val.inits.toSlice()) |init| { + for (val.inits.items) |init| { std.debug.warn(" ({} ", .{init.field.lexeme}); printExpr(init.expr); std.debug.warn(")", .{}); diff --git a/src/errors.zig b/src/errors.zig index eb95d27..8de1442 100644 --- a/src/errors.zig +++ b/src/errors.zig @@ -7,7 +7,7 @@ pub fn reportN(line: usize, message: []const u8) void { report(line, "", message); } -pub fn reportFmt(line: usize, comptime fmt: []const u8, args: var) void { +pub fn reportFmt(line: usize, comptime fmt: []const u8, args: anytype) void { std.debug.warn("[line {}] Error", .{line}); std.debug.warn(fmt, args); std.debug.warn("\n", .{}); diff --git a/src/parser.zig b/src/parser.zig index 818a540..00dd7c6 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -43,7 +43,7 @@ pub const Parser = struct { self.tokens.deinit(); } - fn doError(self: *Parser, comptime fmt: []const u8, args: var) void { + fn doError(self: *Parser, comptime fmt: []const u8, args: anytype) void { self.hadError = true; std.debug.warn("parser error at line {}\n\t", .{self.scanner.line}); diff --git a/src/runner.zig b/src/runner.zig index 49b0dd4..34f2b7a 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -15,7 +15,7 @@ pub const Runner = struct { allocator: *Allocator, stdout: std.fs.File.OutStream, - pub fn init(allocator: *Allocator, stdout: var) Runner { + pub fn init(allocator: *Allocator, stdout: anytype) Runner { return .{ .allocator = allocator, .stdout = stdout }; }