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...@@ -26,7 +26,7 @@ pub fn compile(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, co
26 try writer.writeAll("\n");26 try writer.writeAll("\n");
27}27}
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 {
30 switch (comptime value) {30 switch (comptime value) {
31 .element => |v| {31 .element => |v| {
32 const hastext = for (v.children) |x| {32 const hastext = for (v.children) |x| {
...@@ -104,7 +104,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va...@@ -104,7 +104,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va
104 try writer.writeAll(try x.toString(alloc));104 try writer.writeAll(try x.toString(alloc));
105 return;105 return;
106 }106 }
107 @compileError("pek: print: unsupported type: " ++ @typeName(TO));107 @compileError(std.fmt.comptimePrint("pek: print {s}: unsupported type: {s}", .{ v, @typeName(TO) }));
108 },108 },
109 .block => |v| {109 .block => |v| {
110 const body = astgen.Value{ .body = v.body };110 const body = astgen.Value{ .body = v.body };
...@@ -126,7 +126,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va...@@ -126,7 +126,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va
126 switch (comptime TI) {126 switch (comptime TI) {
127 .Bool => try doif(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, x),127 .Bool => try doif(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, x),
128 .Optional => try docap(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, x),128 .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)})),
130 }130 }
131 },131 },
132 .ifnot => {132 .ifnot => {
...@@ -134,7 +134,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va...@@ -134,7 +134,7 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va
134 switch (comptime TI) {134 switch (comptime TI) {
135 .Bool => try doif(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, !x),135 .Bool => try doif(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, !x),
136 .Optional => try docap(Ctx, alloc, writer, body, bottom, data, ctx, indent, flag1, !x),136 .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)})),
138 }138 }
139 },139 },
140 .ifequal => {140 .ifequal => {
...@@ -171,13 +171,13 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va...@@ -171,13 +171,13 @@ fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comptime va
171 var args: std.meta.ArgsTuple(@TypeOf(func)) = undefined;171 var args: std.meta.ArgsTuple(@TypeOf(func)) = undefined;
172 args.@"0" = alloc;172 args.@"0" = alloc;
173 args.@"1" = list.writer();173 args.@"1" = list.writer();
174 inline for (v.args) |arg, i| {174 inline for (v.args, 0..) |arg, i| {
175 const field_name = comptime std.fmt.comptimePrint("{d}", .{i + 2});175 const field_name = comptime std.fmt.comptimePrint("{d}", .{i + 2});
176 @field(args, field_name) = if (comptime std.mem.eql(u8, arg[0], "this")) search(arg[1..], data) else search(arg, ctx);176 @field(args, field_name) = if (comptime std.mem.eql(u8, arg[0], "this")) search(arg[1..], data) else search(arg, ctx);
177 }177 }
178 const repvalue = astgen.Value{ .replacement = .{ .arms = &.{"this"} } };178 const repvalue = astgen.Value{ .replacement = .{ .arms = &.{"this"} } };
179 try @call(.{}, func, args);179 try @call(.auto, func, args);
180 try do(Ctx, alloc, writer, repvalue, list.toOwnedSlice(), ctx, indent, flag1);180 try do(Ctx, alloc, writer, repvalue, try list.toOwnedSlice(), ctx, indent, flag1);
181 return;181 return;
182 }182 }
183 @compileError("pek: unknown custom function: " ++ v.name);183 @compileError("pek: unknown custom function: " ++ v.name);
...@@ -204,7 +204,7 @@ fn Field(comptime T: type, comptime field_name: string) type {...@@ -204,7 +204,7 @@ fn Field(comptime T: type, comptime field_name: string) type {
204 return usize;204 return usize;
205 }205 }
206 inline for (std.meta.fields(T)) |fld| {206 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;
208 }208 }
209 @compileError(std.fmt.comptimePrint("pek: unknown field {s} on type {s}", .{ field_name, @typeName(T) }));209 @compileError(std.fmt.comptimePrint("pek: unknown field {s} on type {s}", .{ field_name, @typeName(T) }));
210}210}
src/tokenize.zig+1-1
...@@ -33,7 +33,7 @@ pub fn do(comptime input: string, comptime symbols: []const u8) []const Token {...@@ -33,7 +33,7 @@ pub fn do(comptime input: string, comptime symbols: []const u8) []const Token {
3333
34 @setEvalBranchQuota(100000);34 @setEvalBranchQuota(100000);
3535
36 inline for (input) |c, i| {36 inline for (input, 0..) |c, i| {
37 const s = &[_]u8{c};37 const s = &[_]u8{c};
3838
39 var shouldFlush: bool = undefined;39 var shouldFlush: bool = undefined;