From ca41fc8f0a6abf964e99089777fc7b6953c09e14 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 11 Mar 2023 01:40:26 -0800 Subject: [PATCH] update to zig master --- src/lib.zig | 16 ++++++++-------- src/tokenize.zig | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib.zig b/src/lib.zig index 97b20a584d885eb6f11bdb3e417d2f8a8ef6f560..2d28eedee755bf6f1952589533e817ddea9a4572 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -26,7 +26,7 @@ pub fn compile(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, co try writer.writeAll("\n"); } -fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype, indent: usize, flag1: bool) anyerror!void { +inline fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype, indent: usize, flag1: bool) anyerror!void { switch (comptime value) { .element => |v| { const hastext = for (v.children) |x| { @@ -104,7 +104,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va try writer.writeAll(try x.toString(alloc)); return; } - @compileError("pek: print: unsupported type: " ++ @typeName(TO)); + @compileError(std.fmt.comptimePrint("pek: print {s}: unsupported type: {s}", .{ v, @typeName(TO) })); }, .block => |v| { const body = astgen.Value{ .body = v.body }; @@ -126,7 +126,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va switch (comptime TI) { .Bool => try doif(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, x), .Optional => try docap(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, x), - else => @compileError(comptime std.fmt.comptimePrint("pek: unable to use '{s}' in an #if block", .{@typeName(T)})), + else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #if block", .{@typeName(T)})), } }, .ifnot => { @@ -134,7 +134,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va switch (comptime TI) { .Bool => try doif(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, !x), .Optional => try docap(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, !x), - else => @compileError(comptime std.fmt.comptimePrint("pek: unable to use '{s}' in an #ifnot block", .{@typeName(T)})), + else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #ifnot block", .{@typeName(T)})), } }, .ifequal => { @@ -171,13 +171,13 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va var args: std.meta.ArgsTuple(@TypeOf(func)) = undefined; args.@"0" = alloc; args.@"1" = list.writer(); - inline for (v.args) |arg, i| { + inline for (v.args, 0..) |arg, i| { const field_name = comptime std.fmt.comptimePrint("{d}", .{i + 2}); @field(args, field_name) = if (comptime std.mem.eql(u8, arg[0], "this")) search(arg[1..], data) else search(arg, ctx); } const repvalue = astgen.Value{ .replacement = .{ .arms = &.{"this"} } }; - try @call(.{}, func, args); - try do(Ctx, alloc, writer, repvalue, list.toOwnedSlice(), ctx, indent, flag1); + try @call(.auto, func, args); + try do(Ctx, alloc, writer, repvalue, try list.toOwnedSlice(), ctx, indent, flag1); return; } @compileError("pek: unknown custom function: " ++ v.name); @@ -204,7 +204,7 @@ fn Field(comptime T: type, comptime field_name: string) type { return usize; } inline for (std.meta.fields(T)) |fld| { - if (std.mem.eql(u8, fld.name, field_name)) return fld.field_type; + if (comptime std.mem.eql(u8, fld.name, field_name)) return fld.type; } @compileError(std.fmt.comptimePrint("pek: unknown field {s} on type {s}", .{ field_name, @typeName(T) })); } diff --git a/src/tokenize.zig b/src/tokenize.zig index ce49a9ccc0590ee463efcb665674e5ec701505c8..4de4d302143dd5a6a6ca5411fe92347bf8d334a0 100644 --- a/src/tokenize.zig +++ b/src/tokenize.zig @@ -33,7 +33,7 @@ pub fn do(comptime input: string, comptime symbols: []const u8) []const Token { @setEvalBranchQuota(100000); - inline for (input) |c, i| { + inline for (input, 0..) |c, i| { const s = &[_]u8{c}; var shouldFlush: bool = undefined; -- 2.54.0