authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-03-11 01:40:26 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-03-11 01:40:26 -08:00
logca41fc8f0a6abf964e99089777fc7b6953c09e14
treece155f40263f9dd4837ecdbd6c8b969a6153e698
parent5c080a34d2e6b6d3d00de1e85d9f32f5ea2c2653

update to zig master


2 files changed, 9 insertions(+), 9 deletions(-)

src/lib.zig+8-8
......@@ -26,7 +26,7 @@ pub fn compile(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, co
2626 try writer.writeAll("\n");
2727}
2828
29fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype, indent: usize, flag1: bool) anyerror!void {
29inline 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 {
3030 switch (comptime value) {
3131 .element => |v| {
3232 const hastext = for (v.children) |x| {
......@@ -104,7 +104,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va
104104 try writer.writeAll(try x.toString(alloc));
105105 return;
106106 }
107 @compileError("pek: print: unsupported type: " ++ @typeName(TO));
107 @compileError(std.fmt.comptimePrint("pek: print {s}: unsupported type: {s}", .{ v, @typeName(TO) }));
108108 },
109109 .block => |v| {
110110 const body = astgen.Value{ .body = v.body };
......@@ -126,7 +126,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va
126126 switch (comptime TI) {
127127 .Bool => try doif(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, x),
128128 .Optional => try docap(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, x),
129 else => @compileError(comptime std.fmt.comptimePrint("pek: unable to use '{s}' in an #if block", .{@typeName(T)})),
129 else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #if block", .{@typeName(T)})),
130130 }
131131 },
132132 .ifnot => {
......@@ -134,7 +134,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va
134134 switch (comptime TI) {
135135 .Bool => try doif(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, !x),
136136 .Optional => try docap(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, !x),
137 else => @compileError(comptime std.fmt.comptimePrint("pek: unable to use '{s}' in an #ifnot block", .{@typeName(T)})),
137 else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #ifnot block", .{@typeName(T)})),
138138 }
139139 },
140140 .ifequal => {
......@@ -171,13 +171,13 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va
171171 var args: std.meta.ArgsTuple(@TypeOf(func)) = undefined;
172172 args.@"0" = alloc;
173173 args.@"1" = list.writer();
174 inline for (v.args) |arg, i| {
174 inline for (v.args, 0..) |arg, i| {
175175 const field_name = comptime std.fmt.comptimePrint("{d}", .{i + 2});
176176 @field(args, field_name) = if (comptime std.mem.eql(u8, arg[0], "this")) search(arg[1..], data) else search(arg, ctx);
177177 }
178178 const repvalue = astgen.Value{ .replacement = .{ .arms = &.{"this"} } };
179 try @call(.{}, func, args);
180 try do(Ctx, alloc, writer, repvalue, list.toOwnedSlice(), ctx, indent, flag1);
179 try @call(.auto, func, args);
180 try do(Ctx, alloc, writer, repvalue, try list.toOwnedSlice(), ctx, indent, flag1);
181181 return;
182182 }
183183 @compileError("pek: unknown custom function: " ++ v.name);
......@@ -204,7 +204,7 @@ fn Field(comptime T: type, comptime field_name: string) type {
204204 return usize;
205205 }
206206 inline for (std.meta.fields(T)) |fld| {
207 if (std.mem.eql(u8, fld.name, field_name)) return fld.field_type;
207 if (comptime std.mem.eql(u8, fld.name, field_name)) return fld.type;
208208 }
209209 @compileError(std.fmt.comptimePrint("pek: unknown field {s} on type {s}", .{ field_name, @typeName(T) }));
210210}
src/tokenize.zig+1-1
......@@ -33,7 +33,7 @@ pub fn do(comptime input: string, comptime symbols: []const u8) []const Token {
3333
3434 @setEvalBranchQuota(100000);
3535
36 inline for (input) |c, i| {
36 inline for (input, 0..) |c, i| {
3737 const s = &[_]u8{c};
3838
3939 var shouldFlush: bool = undefined;