| author | |
| committer | |
| log | 4c393c7468a4f6a62ba8251cdeeddc47b5b2b73d |
| tree | b33be9336c6351c68ea13381b1283a078d1666a7 |
| parent | d8e7eda5f4a894fe8fec8c53f7bcc3d475dd55c9 |
`{}` for decls
`{p}` for enum fields
`{p_}` for struct fields and in contexts following a `.`
Elsewhere, `{p}` was used since it's equivalent to the old behavior.11 files changed, 77 insertions(+), 78 deletions(-)
lib/compiler/aro_translate_c/ast.zig+3-3| ... | ... | @@ -828,7 +828,7 @@ const Context = struct { |
| 828 | 828 | fn addIdentifier(c: *Context, bytes: []const u8) Allocator.Error!TokenIndex { |
| 829 | 829 | if (std.zig.primitives.isPrimitive(bytes)) |
| 830 | 830 | return c.addTokenFmt(.identifier, "@\"{s}\"", .{bytes}); |
| 831 | return c.addTokenFmt(.identifier, "{s}", .{std.zig.fmtId(bytes)}); | |
| 831 | return c.addTokenFmt(.identifier, "{p}", .{std.zig.fmtId(bytes)}); | |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | fn listToSpan(c: *Context, list: []const NodeIndex) Allocator.Error!NodeSubRange { |
| ... | ... | @@ -2106,7 +2106,7 @@ fn renderRecord(c: *Context, node: Node) !NodeIndex { |
| 2106 | 2106 | members[1] = 0; |
| 2107 | 2107 | |
| 2108 | 2108 | for (payload.fields, 0..) |field, i| { |
| 2109 | const name_tok = try c.addTokenFmt(.identifier, "{s}", .{std.zig.fmtId(field.name)}); | |
| 2109 | const name_tok = try c.addTokenFmt(.identifier, "{p}", .{std.zig.fmtId(field.name)}); | |
| 2110 | 2110 | _ = try c.addToken(.colon, ":"); |
| 2111 | 2111 | const type_expr = try renderNode(c, field.type); |
| 2112 | 2112 | |
| ... | ... | @@ -2199,7 +2199,7 @@ fn renderFieldAccess(c: *Context, lhs: NodeIndex, field_name: []const u8) !NodeI |
| 2199 | 2199 | .main_token = try c.addToken(.period, "."), |
| 2200 | 2200 | .data = .{ |
| 2201 | 2201 | .lhs = lhs, |
| 2202 | .rhs = try c.addTokenFmt(.identifier, "{s}", .{std.zig.fmtId(field_name)}), | |
| 2202 | .rhs = try c.addTokenFmt(.identifier, "{p}", .{std.zig.fmtId(field_name)}), | |
| 2203 | 2203 | }, |
| 2204 | 2204 | }); |
| 2205 | 2205 | } |
lib/std/Build/Step/Options.zig+6-6| ... | ... | @@ -234,7 +234,7 @@ fn printType(self: *Options, out: anytype, comptime T: type, value: T, indent: u |
| 234 | 234 | try printEnum(self, out, T, info, indent); |
| 235 | 235 | |
| 236 | 236 | if (name) |some| { |
| 237 | try out.print("pub const {}: {s} = .{s};\n", .{ | |
| 237 | try out.print("pub const {}: {} = .{p_};\n", .{ | |
| 238 | 238 | std.zig.fmtId(some), |
| 239 | 239 | std.zig.fmtId(@typeName(T)), |
| 240 | 240 | std.zig.fmtId(@tagName(value)), |
| ... | ... | @@ -246,7 +246,7 @@ fn printType(self: *Options, out: anytype, comptime T: type, value: T, indent: u |
| 246 | 246 | try printStruct(self, out, T, info, indent); |
| 247 | 247 | |
| 248 | 248 | if (name) |some| { |
| 249 | try out.print("pub const {}: {s} = ", .{ | |
| 249 | try out.print("pub const {}: {} = ", .{ | |
| 250 | 250 | std.zig.fmtId(some), |
| 251 | 251 | std.zig.fmtId(@typeName(T)), |
| 252 | 252 | }); |
| ... | ... | @@ -279,7 +279,7 @@ fn printEnum(self: *Options, out: anytype, comptime T: type, comptime val: std.b |
| 279 | 279 | |
| 280 | 280 | inline for (val.fields) |field| { |
| 281 | 281 | try out.writeByteNTimes(' ', indent); |
| 282 | try out.print(" {} = {d},\n", .{ std.zig.fmtId(field.name), field.value }); | |
| 282 | try out.print(" {p} = {d},\n", .{ std.zig.fmtId(field.name), field.value }); | |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | if (!val.is_exhaustive) { |
| ... | ... | @@ -313,9 +313,9 @@ fn printStruct(self: *Options, out: anytype, comptime T: type, comptime val: std |
| 313 | 313 | |
| 314 | 314 | // If the type name doesn't contains a '.' the type is from zig builtins. |
| 315 | 315 | if (std.mem.containsAtLeast(u8, type_name, 1, ".")) { |
| 316 | try out.print(" {}: {}", .{ std.zig.fmtId(field.name), std.zig.fmtId(type_name) }); | |
| 316 | try out.print(" {p_}: {}", .{ std.zig.fmtId(field.name), std.zig.fmtId(type_name) }); | |
| 317 | 317 | } else { |
| 318 | try out.print(" {}: {s}", .{ std.zig.fmtId(field.name), type_name }); | |
| 318 | try out.print(" {p_}: {s}", .{ std.zig.fmtId(field.name), type_name }); | |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | if (field.default_value != null) { |
| ... | ... | @@ -355,7 +355,7 @@ fn printStructValue(self: *Options, out: anytype, comptime struct_val: std.built |
| 355 | 355 | } else { |
| 356 | 356 | inline for (struct_val.fields) |field| { |
| 357 | 357 | try out.writeByteNTimes(' ', indent); |
| 358 | try out.print(" .{} = ", .{std.zig.fmtId(field.name)}); | |
| 358 | try out.print(" .{p_} = ", .{std.zig.fmtId(field.name)}); | |
| 359 | 359 | |
| 360 | 360 | const field_name = @field(val, field.name); |
| 361 | 361 | switch (@typeInfo(@TypeOf(field_name))) { |
lib/std/zig/render.zig+2-2| ... | ... | @@ -2847,8 +2847,8 @@ fn renderIdentifier(r: *Render, token_index: Ast.TokenIndex, space: Space, quote |
| 2847 | 2847 | return renderQuotedIdentifier(r, token_index, space, false); |
| 2848 | 2848 | } |
| 2849 | 2849 | |
| 2850 | // Special case for _ which would incorrectly be rejected by isValidId below. | |
| 2851 | if (contents.len == 1 and contents[0] == '_') switch (quote) { | |
| 2850 | // Special case for _. | |
| 2851 | if (std.zig.isUnderscore(contents)) switch (quote) { | |
| 2852 | 2852 | .eagerly_unquote => return renderQuotedIdentifier(r, token_index, space, true), |
| 2853 | 2853 | .eagerly_unquote_except_underscore, |
| 2854 | 2854 | .preserve_when_shadowing, |
src/Builtin.zig+14-15| ... | ... | @@ -35,17 +35,17 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void { |
| 35 | 35 | \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks. |
| 36 | 36 | \\pub const zig_version = std.SemanticVersion.parse(zig_version_string) catch unreachable; |
| 37 | 37 | \\pub const zig_version_string = "{s}"; |
| 38 | \\pub const zig_backend = std.builtin.CompilerBackend.{}; | |
| 38 | \\pub const zig_backend = std.builtin.CompilerBackend.{p_}; | |
| 39 | 39 | \\ |
| 40 | \\pub const output_mode = std.builtin.OutputMode.{}; | |
| 41 | \\pub const link_mode = std.builtin.LinkMode.{}; | |
| 40 | \\pub const output_mode = std.builtin.OutputMode.{p_}; | |
| 41 | \\pub const link_mode = std.builtin.LinkMode.{p_}; | |
| 42 | 42 | \\pub const is_test = {}; |
| 43 | 43 | \\pub const single_threaded = {}; |
| 44 | \\pub const abi = std.Target.Abi.{}; | |
| 44 | \\pub const abi = std.Target.Abi.{p_}; | |
| 45 | 45 | \\pub const cpu: std.Target.Cpu = .{{ |
| 46 | \\ .arch = .{}, | |
| 47 | \\ .model = &std.Target.{}.cpu.{}, | |
| 48 | \\ .features = std.Target.{}.featureSet(&[_]std.Target.{}.Feature{{ | |
| 46 | \\ .arch = .{p_}, | |
| 47 | \\ .model = &std.Target.{p_}.cpu.{p_}, | |
| 48 | \\ .features = std.Target.{p_}.featureSet(&[_]std.Target.{p_}.Feature{{ | |
| 49 | 49 | \\ |
| 50 | 50 | , .{ |
| 51 | 51 | build_options.version, |
| ... | ... | @@ -66,14 +66,14 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void { |
| 66 | 66 | const index = @as(std.Target.Cpu.Feature.Set.Index, @intCast(index_usize)); |
| 67 | 67 | const is_enabled = target.cpu.features.isEnabled(index); |
| 68 | 68 | if (is_enabled) { |
| 69 | try buffer.writer().print(" .{},\n", .{std.zig.fmtId(feature.name)}); | |
| 69 | try buffer.writer().print(" .{p_},\n", .{std.zig.fmtId(feature.name)}); | |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | try buffer.writer().print( |
| 73 | 73 | \\ }}), |
| 74 | 74 | \\}}; |
| 75 | 75 | \\pub const os = std.Target.Os{{ |
| 76 | \\ .tag = .{}, | |
| 76 | \\ .tag = .{p_}, | |
| 77 | 77 | \\ .version_range = .{{ |
| 78 | 78 | , |
| 79 | 79 | .{std.zig.fmtId(@tagName(target.os.tag))}, |
| ... | ... | @@ -180,8 +180,8 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void { |
| 180 | 180 | const link_libc = opts.link_libc; |
| 181 | 181 | |
| 182 | 182 | try buffer.writer().print( |
| 183 | \\pub const object_format = std.Target.ObjectFormat.{}; | |
| 184 | \\pub const mode = std.builtin.OptimizeMode.{}; | |
| 183 | \\pub const object_format = std.Target.ObjectFormat.{p_}; | |
| 184 | \\pub const mode = std.builtin.OptimizeMode.{p_}; | |
| 185 | 185 | \\pub const link_libc = {}; |
| 186 | 186 | \\pub const link_libcpp = {}; |
| 187 | 187 | \\pub const have_error_return_tracing = {}; |
| ... | ... | @@ -190,7 +190,7 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void { |
| 190 | 190 | \\pub const position_independent_code = {}; |
| 191 | 191 | \\pub const position_independent_executable = {}; |
| 192 | 192 | \\pub const strip_debug_info = {}; |
| 193 | \\pub const code_model = std.builtin.CodeModel.{}; | |
| 193 | \\pub const code_model = std.builtin.CodeModel.{p_}; | |
| 194 | 194 | \\pub const omit_frame_pointer = {}; |
| 195 | 195 | \\ |
| 196 | 196 | , .{ |
| ... | ... | @@ -209,11 +209,10 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void { |
| 209 | 209 | }); |
| 210 | 210 | |
| 211 | 211 | if (target.os.tag == .wasi) { |
| 212 | const wasi_exec_model_fmt = std.zig.fmtId(@tagName(opts.wasi_exec_model)); | |
| 213 | 212 | try buffer.writer().print( |
| 214 | \\pub const wasi_exec_model = std.builtin.WasiExecModel.{}; | |
| 213 | \\pub const wasi_exec_model = std.builtin.WasiExecModel.{p_}; | |
| 215 | 214 | \\ |
| 216 | , .{wasi_exec_model_fmt}); | |
| 215 | , .{std.zig.fmtId(@tagName(opts.wasi_exec_model))}); | |
| 217 | 216 | } |
| 218 | 217 | |
| 219 | 218 | if (opts.is_test) { |
src/InternPool.zig+1-1| ... | ... | @@ -488,7 +488,7 @@ pub const NullTerminatedString = enum(u32) { |
| 488 | 488 | if (comptime std.mem.eql(u8, specifier, "")) { |
| 489 | 489 | try writer.writeAll(s); |
| 490 | 490 | } else if (comptime std.mem.eql(u8, specifier, "i")) { |
| 491 | try writer.print("{}", .{std.zig.fmtId(s)}); | |
| 491 | try writer.print("{p}", .{std.zig.fmtId(s)}); | |
| 492 | 492 | } else @compileError("invalid format string '" ++ specifier ++ "' for '" ++ @typeName(NullTerminatedString) ++ "'"); |
| 493 | 493 | } |
| 494 | 494 |
src/main.zig+1-1| ... | ... | @@ -6943,7 +6943,7 @@ fn cmdFetch( |
| 6943 | 6943 | std.zig.fmtEscapes(&hex_digest), |
| 6944 | 6944 | }); |
| 6945 | 6945 | |
| 6946 | const new_node_text = try std.fmt.allocPrint(arena, ".{} = {s},\n", .{ | |
| 6946 | const new_node_text = try std.fmt.allocPrint(arena, ".{p_} = {s},\n", .{ | |
| 6947 | 6947 | std.zig.fmtId(name), new_node_init, |
| 6948 | 6948 | }); |
| 6949 | 6949 |
src/print_zir.zig+8-8| ... | ... | @@ -1005,7 +1005,7 @@ const Writer = struct { |
| 1005 | 1005 | const decl_name = self.code.nullTerminatedString(extra.decl_name); |
| 1006 | 1006 | |
| 1007 | 1007 | try self.writeInstRef(stream, extra.namespace); |
| 1008 | try stream.print(", {}, ", .{std.zig.fmtId(decl_name)}); | |
| 1008 | try stream.print(", {p}, ", .{std.zig.fmtId(decl_name)}); | |
| 1009 | 1009 | try self.writeInstRef(stream, extra.options); |
| 1010 | 1010 | try stream.writeAll(") "); |
| 1011 | 1011 | try self.writeSrc(stream, inst_data.src()); |
| ... | ... | @@ -1243,7 +1243,7 @@ const Writer = struct { |
| 1243 | 1243 | |
| 1244 | 1244 | const name = self.code.nullTerminatedString(output.data.name); |
| 1245 | 1245 | const constraint = self.code.nullTerminatedString(output.data.constraint); |
| 1246 | try stream.print("output({}, \"{}\", ", .{ | |
| 1246 | try stream.print("output({p}, \"{}\", ", .{ | |
| 1247 | 1247 | std.zig.fmtId(name), std.zig.fmtEscapes(constraint), |
| 1248 | 1248 | }); |
| 1249 | 1249 | try self.writeFlag(stream, "->", is_type); |
| ... | ... | @@ -1262,7 +1262,7 @@ const Writer = struct { |
| 1262 | 1262 | |
| 1263 | 1263 | const name = self.code.nullTerminatedString(input.data.name); |
| 1264 | 1264 | const constraint = self.code.nullTerminatedString(input.data.constraint); |
| 1265 | try stream.print("input({}, \"{}\", ", .{ | |
| 1265 | try stream.print("input({p}, \"{}\", ", .{ | |
| 1266 | 1266 | std.zig.fmtId(name), std.zig.fmtEscapes(constraint), |
| 1267 | 1267 | }); |
| 1268 | 1268 | try self.writeInstRef(stream, input.data.operand); |
| ... | ... | @@ -1278,7 +1278,7 @@ const Writer = struct { |
| 1278 | 1278 | const str_index = self.code.extra[extra_i]; |
| 1279 | 1279 | extra_i += 1; |
| 1280 | 1280 | const clobber = self.code.nullTerminatedString(@enumFromInt(str_index)); |
| 1281 | try stream.print("{}", .{std.zig.fmtId(clobber)}); | |
| 1281 | try stream.print("{p}", .{std.zig.fmtId(clobber)}); | |
| 1282 | 1282 | if (i + 1 < clobbers_len) { |
| 1283 | 1283 | try stream.writeAll(", "); |
| 1284 | 1284 | } |
| ... | ... | @@ -1559,7 +1559,7 @@ const Writer = struct { |
| 1559 | 1559 | try self.writeFlag(stream, "comptime ", field.is_comptime); |
| 1560 | 1560 | if (field.name != .empty) { |
| 1561 | 1561 | const field_name = self.code.nullTerminatedString(field.name); |
| 1562 | try stream.print("{}: ", .{std.zig.fmtId(field_name)}); | |
| 1562 | try stream.print("{p}: ", .{std.zig.fmtId(field_name)}); | |
| 1563 | 1563 | } else { |
| 1564 | 1564 | try stream.print("@\"{d}\": ", .{i}); |
| 1565 | 1565 | } |
| ... | ... | @@ -1738,7 +1738,7 @@ const Writer = struct { |
| 1738 | 1738 | |
| 1739 | 1739 | try self.writeDocComment(stream, doc_comment_index); |
| 1740 | 1740 | try stream.writeByteNTimes(' ', self.indent); |
| 1741 | try stream.print("{}", .{std.zig.fmtId(field_name)}); | |
| 1741 | try stream.print("{p}", .{std.zig.fmtId(field_name)}); | |
| 1742 | 1742 | |
| 1743 | 1743 | if (has_type) { |
| 1744 | 1744 | const field_type = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index])); |
| ... | ... | @@ -1891,7 +1891,7 @@ const Writer = struct { |
| 1891 | 1891 | try self.writeDocComment(stream, doc_comment_index); |
| 1892 | 1892 | |
| 1893 | 1893 | try stream.writeByteNTimes(' ', self.indent); |
| 1894 | try stream.print("{}", .{std.zig.fmtId(field_name)}); | |
| 1894 | try stream.print("{p}", .{std.zig.fmtId(field_name)}); | |
| 1895 | 1895 | |
| 1896 | 1896 | if (has_tag_value) { |
| 1897 | 1897 | const tag_value_ref = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index])); |
| ... | ... | @@ -1986,7 +1986,7 @@ const Writer = struct { |
| 1986 | 1986 | const doc_comment_index: Zir.NullTerminatedString = @enumFromInt(self.code.extra[extra_index + 1]); |
| 1987 | 1987 | try self.writeDocComment(stream, doc_comment_index); |
| 1988 | 1988 | try stream.writeByteNTimes(' ', self.indent); |
| 1989 | try stream.print("{},\n", .{std.zig.fmtId(name)}); | |
| 1989 | try stream.print("{p},\n", .{std.zig.fmtId(name)}); | |
| 1990 | 1990 | } |
| 1991 | 1991 | |
| 1992 | 1992 | self.indent -= 2; |
tools/gen_spirv_spec.zig+20-20| ... | ... | @@ -311,7 +311,7 @@ fn renderInstructionSet( |
| 311 | 311 | ); |
| 312 | 312 | |
| 313 | 313 | for (extensions) |ext| { |
| 314 | try writer.print("{},\n", .{std.zig.fmtId(ext.name)}); | |
| 314 | try writer.print("{p},\n", .{std.zig.fmtId(ext.name)}); | |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | try writer.writeAll( |
| ... | ... | @@ -344,7 +344,7 @@ fn renderInstructionsCase( |
| 344 | 344 | // but there aren't so many total aliases and that would add more overhead in total. We will |
| 345 | 345 | // just filter those out when needed. |
| 346 | 346 | |
| 347 | try writer.print(".{} => &[_]Instruction{{\n", .{std.zig.fmtId(set_name)}); | |
| 347 | try writer.print(".{p_} => &[_]Instruction{{\n", .{std.zig.fmtId(set_name)}); | |
| 348 | 348 | |
| 349 | 349 | for (instructions) |inst| { |
| 350 | 350 | try writer.print( |
| ... | ... | @@ -366,7 +366,7 @@ fn renderInstructionsCase( |
| 366 | 366 | |
| 367 | 367 | const kind = all_operand_kinds.get(.{ set_name, operand.kind }) orelse |
| 368 | 368 | all_operand_kinds.get(.{ "core", operand.kind }).?; |
| 369 | try writer.print(".{{.kind = .{}, .quantifier = .{s}}},\n", .{ std.zig.fmtId(kind.kind), quantifier }); | |
| 369 | try writer.print(".{{.kind = .{p_}, .quantifier = .{s}}},\n", .{ std.zig.fmtId(kind.kind), quantifier }); | |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | try writer.writeAll( |
| ... | ... | @@ -423,7 +423,7 @@ fn renderOperandKind(writer: anytype, operands: []const OperandKind) !void { |
| 423 | 423 | \\ |
| 424 | 424 | ); |
| 425 | 425 | for (operands) |operand| { |
| 426 | try writer.print("{},\n", .{std.zig.fmtId(operand.kind)}); | |
| 426 | try writer.print("{p},\n", .{std.zig.fmtId(operand.kind)}); | |
| 427 | 427 | } |
| 428 | 428 | try writer.writeAll( |
| 429 | 429 | \\ |
| ... | ... | @@ -440,7 +440,7 @@ fn renderOperandKind(writer: anytype, operands: []const OperandKind) !void { |
| 440 | 440 | .Literal => "literal", |
| 441 | 441 | .Composite => "composite", |
| 442 | 442 | }; |
| 443 | try writer.print(".{} => .{s},\n", .{ std.zig.fmtId(operand.kind), cat }); | |
| 443 | try writer.print(".{p_} => .{s},\n", .{ std.zig.fmtId(operand.kind), cat }); | |
| 444 | 444 | } |
| 445 | 445 | try writer.writeAll( |
| 446 | 446 | \\ }; |
| ... | ... | @@ -454,12 +454,12 @@ fn renderOperandKind(writer: anytype, operands: []const OperandKind) !void { |
| 454 | 454 | switch (operand.category) { |
| 455 | 455 | .BitEnum, .ValueEnum => {}, |
| 456 | 456 | else => { |
| 457 | try writer.print(".{} => unreachable,\n", .{std.zig.fmtId(operand.kind)}); | |
| 457 | try writer.print(".{p_} => unreachable,\n", .{std.zig.fmtId(operand.kind)}); | |
| 458 | 458 | continue; |
| 459 | 459 | }, |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | try writer.print(".{} => &[_]Enumerant{{", .{std.zig.fmtId(operand.kind)}); | |
| 462 | try writer.print(".{p_} => &[_]Enumerant{{", .{std.zig.fmtId(operand.kind)}); | |
| 463 | 463 | for (operand.enumerants.?) |enumerant| { |
| 464 | 464 | if (enumerant.value == .bitflag and std.mem.eql(u8, enumerant.enumerant, "None")) { |
| 465 | 465 | continue; |
| ... | ... | @@ -483,7 +483,7 @@ fn renderEnumerant(writer: anytype, enumerant: Enumerant) !void { |
| 483 | 483 | if (i != 0) |
| 484 | 484 | try writer.writeAll(", "); |
| 485 | 485 | // Note, param.quantifier will always be one. |
| 486 | try writer.print(".{}", .{std.zig.fmtId(param.kind)}); | |
| 486 | try writer.print(".{p_}", .{std.zig.fmtId(param.kind)}); | |
| 487 | 487 | } |
| 488 | 488 | try writer.writeAll("}}"); |
| 489 | 489 | } |
| ... | ... | @@ -529,7 +529,7 @@ fn renderOpcodes( |
| 529 | 529 | try writer.writeAll("pub const Opcode = enum(u16) {\n"); |
| 530 | 530 | for (instructions_indices) |i| { |
| 531 | 531 | const inst = instructions[i]; |
| 532 | try writer.print("{} = {},\n", .{ std.zig.fmtId(inst.opname), inst.opcode }); | |
| 532 | try writer.print("{p} = {},\n", .{ std.zig.fmtId(inst.opname), inst.opcode }); | |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | try writer.writeAll( |
| ... | ... | @@ -537,7 +537,7 @@ fn renderOpcodes( |
| 537 | 537 | ); |
| 538 | 538 | |
| 539 | 539 | for (aliases.items) |alias| { |
| 540 | try writer.print("pub const {} = Opcode.{};\n", .{ | |
| 540 | try writer.print("pub const {} = Opcode.{p_};\n", .{ | |
| 541 | 541 | std.zig.fmtId(instructions[alias.inst].opname), |
| 542 | 542 | std.zig.fmtId(instructions[alias.alias].opname), |
| 543 | 543 | }); |
| ... | ... | @@ -565,7 +565,7 @@ fn renderOpcodes( |
| 565 | 565 | |
| 566 | 566 | for (instructions_indices) |i| { |
| 567 | 567 | const inst = instructions[i]; |
| 568 | try writer.print(".{} => .", .{std.zig.fmtId(inst.opname)}); | |
| 568 | try writer.print(".{p_} => .", .{std.zig.fmtId(inst.opname)}); | |
| 569 | 569 | try renderInstructionClass(writer, inst.class.?); |
| 570 | 570 | try writer.writeAll(",\n"); |
| 571 | 571 | } |
| ... | ... | @@ -636,22 +636,22 @@ fn renderValueEnum( |
| 636 | 636 | |
| 637 | 637 | const enum_indices = enum_map.values(); |
| 638 | 638 | |
| 639 | try writer.print("pub const {s} = enum(u32) {{\n", .{std.zig.fmtId(enumeration.kind)}); | |
| 639 | try writer.print("pub const {} = enum(u32) {{\n", .{std.zig.fmtId(enumeration.kind)}); | |
| 640 | 640 | |
| 641 | 641 | for (enum_indices) |i| { |
| 642 | 642 | const enumerant = enumerants[i]; |
| 643 | 643 | // if (enumerant.value != .int) return error.InvalidRegistry; |
| 644 | 644 | |
| 645 | 645 | switch (enumerant.value) { |
| 646 | .int => |value| try writer.print("{} = {},\n", .{ std.zig.fmtId(enumerant.enumerant), value }), | |
| 647 | .bitflag => |value| try writer.print("{} = {s},\n", .{ std.zig.fmtId(enumerant.enumerant), value }), | |
| 646 | .int => |value| try writer.print("{p} = {},\n", .{ std.zig.fmtId(enumerant.enumerant), value }), | |
| 647 | .bitflag => |value| try writer.print("{p} = {s},\n", .{ std.zig.fmtId(enumerant.enumerant), value }), | |
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | try writer.writeByte('\n'); |
| 652 | 652 | |
| 653 | 653 | for (aliases.items) |alias| { |
| 654 | try writer.print("pub const {} = {}.{};\n", .{ | |
| 654 | try writer.print("pub const {} = {}.{p_};\n", .{ | |
| 655 | 655 | std.zig.fmtId(enumerants[alias.enumerant].enumerant), |
| 656 | 656 | std.zig.fmtId(enumeration.kind), |
| 657 | 657 | std.zig.fmtId(enumerants[alias.alias].enumerant), |
| ... | ... | @@ -679,7 +679,7 @@ fn renderBitEnum( |
| 679 | 679 | enumeration: OperandKind, |
| 680 | 680 | extended_structs: ExtendedStructSet, |
| 681 | 681 | ) !void { |
| 682 | try writer.print("pub const {s} = packed struct {{\n", .{std.zig.fmtId(enumeration.kind)}); | |
| 682 | try writer.print("pub const {} = packed struct {{\n", .{std.zig.fmtId(enumeration.kind)}); | |
| 683 | 683 | |
| 684 | 684 | var flags_by_bitpos = [_]?usize{null} ** 32; |
| 685 | 685 | const enumerants = enumeration.enumerants orelse return error.InvalidRegistry; |
| ... | ... | @@ -719,7 +719,7 @@ fn renderBitEnum( |
| 719 | 719 | |
| 720 | 720 | for (flags_by_bitpos, 0..) |maybe_flag_index, bitpos| { |
| 721 | 721 | if (maybe_flag_index) |flag_index| { |
| 722 | try writer.print("{}", .{std.zig.fmtId(enumerants[flag_index].enumerant)}); | |
| 722 | try writer.print("{p_}", .{std.zig.fmtId(enumerants[flag_index].enumerant)}); | |
| 723 | 723 | } else { |
| 724 | 724 | try writer.print("_reserved_bit_{}", .{bitpos}); |
| 725 | 725 | } |
| ... | ... | @@ -730,7 +730,7 @@ fn renderBitEnum( |
| 730 | 730 | try writer.writeByte('\n'); |
| 731 | 731 | |
| 732 | 732 | for (aliases.items) |alias| { |
| 733 | try writer.print("pub const {}: {} = .{{.{} = true}};\n", .{ | |
| 733 | try writer.print("pub const {}: {} = .{{.{p_} = true}};\n", .{ | |
| 734 | 734 | std.zig.fmtId(enumerants[alias.flag].enumerant), |
| 735 | 735 | std.zig.fmtId(enumeration.kind), |
| 736 | 736 | std.zig.fmtId(enumerants[flags_by_bitpos[alias.alias].?].enumerant), |
| ... | ... | @@ -858,7 +858,7 @@ fn renderFieldName(writer: anytype, operands: []const Operand, field_index: usiz |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | // Assume there are no duplicate 'name' fields. |
| 861 | try writer.print("{}", .{std.zig.fmtId(name_buffer.items)}); | |
| 861 | try writer.print("{p_}", .{std.zig.fmtId(name_buffer.items)}); | |
| 862 | 862 | return; |
| 863 | 863 | } |
| 864 | 864 | |
| ... | ... | @@ -876,7 +876,7 @@ fn renderFieldName(writer: anytype, operands: []const Operand, field_index: usiz |
| 876 | 876 | } |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | try writer.print("{}", .{std.zig.fmtId(name_buffer.items)}); | |
| 879 | try writer.print("{p_}", .{std.zig.fmtId(name_buffer.items)}); | |
| 880 | 880 | |
| 881 | 881 | // For fields derived from type name, there could be any amount. |
| 882 | 882 | // Simply check against all other fields, and if another similar one exists, add a number. |
tools/generate_linux_syscalls.zig+12-12| ... | ... | @@ -61,7 +61,7 @@ pub fn main() !void { |
| 61 | 61 | _ = fields.next() orelse return error.Incomplete; |
| 62 | 62 | const name = fields.next() orelse return error.Incomplete; |
| 63 | 63 | |
| 64 | try writer.print(" {s} = {s},\n", .{ zig.fmtId(name), number }); | |
| 64 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(name), number }); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | try writer.writeAll("};\n\n"); |
| ... | ... | @@ -82,7 +82,7 @@ pub fn main() !void { |
| 82 | 82 | const name = fields.next() orelse return error.Incomplete; |
| 83 | 83 | |
| 84 | 84 | const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name; |
| 85 | try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 85 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | try writer.writeAll("};\n\n"); |
| ... | ... | @@ -107,7 +107,7 @@ pub fn main() !void { |
| 107 | 107 | const name = fields.next() orelse return error.Incomplete; |
| 108 | 108 | |
| 109 | 109 | const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name; |
| 110 | try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 110 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // TODO: maybe extract these from arch/arm/include/uapi/asm/unistd.h |
| ... | ... | @@ -137,7 +137,7 @@ pub fn main() !void { |
| 137 | 137 | if (mem.eql(u8, abi, "32")) continue; |
| 138 | 138 | const name = fields.next() orelse return error.Incomplete; |
| 139 | 139 | |
| 140 | try writer.print(" {s} = {s},\n", .{ zig.fmtId(name), number }); | |
| 140 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(name), number }); | |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | try writer.writeAll("};\n\n"); |
| ... | ... | @@ -162,7 +162,7 @@ pub fn main() !void { |
| 162 | 162 | const name = fields.next() orelse return error.Incomplete; |
| 163 | 163 | if (mem.startsWith(u8, name, "unused")) continue; |
| 164 | 164 | |
| 165 | try writer.print(" {s} = Linux + {s},\n", .{ zig.fmtId(name), number }); | |
| 165 | try writer.print(" {p} = Linux + {s},\n", .{ zig.fmtId(name), number }); | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | try writer.writeAll("};\n\n"); |
| ... | ... | @@ -187,7 +187,7 @@ pub fn main() !void { |
| 187 | 187 | const name = fields.next() orelse return error.Incomplete; |
| 188 | 188 | const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name; |
| 189 | 189 | |
| 190 | try writer.print(" {s} = Linux + {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 190 | try writer.print(" {p} = Linux + {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | try writer.writeAll("};\n\n"); |
| ... | ... | @@ -210,12 +210,12 @@ pub fn main() !void { |
| 210 | 210 | if (mem.eql(u8, abi, "spu")) { |
| 211 | 211 | continue; |
| 212 | 212 | } else if (mem.eql(u8, abi, "32")) { |
| 213 | try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 213 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 214 | 214 | } else if (mem.eql(u8, abi, "64")) { |
| 215 | try list_64.writer().print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 215 | try list_64.writer().print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 216 | 216 | } else { // common/nospu |
| 217 | try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 218 | try list_64.writer().print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 217 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 218 | try list_64.writer().print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| ... | ... | @@ -291,7 +291,7 @@ pub fn main() !void { |
| 291 | 291 | if (mem.eql(u8, name, "syscalls")) break :loop; |
| 292 | 292 | |
| 293 | 293 | const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name; |
| 294 | try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 294 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | try writer.writeAll("};\n\n"); |
| ... | ... | @@ -352,7 +352,7 @@ pub fn main() !void { |
| 352 | 352 | if (mem.eql(u8, name, "syscalls")) break :loop; |
| 353 | 353 | |
| 354 | 354 | const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name; |
| 355 | try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 355 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); | |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | try writer.writeAll( |
tools/update_cpu_features.zig+5-5| ... | ... | @@ -1314,7 +1314,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1314 | 1314 | ); |
| 1315 | 1315 | |
| 1316 | 1316 | for (all_features.items) |feature| { |
| 1317 | try w.print(" {},\n", .{std.zig.fmtId(feature.zig_name)}); | |
| 1317 | try w.print(" {p},\n", .{std.zig.fmtId(feature.zig_name)}); | |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | try w.writeAll( |
| ... | ... | @@ -1341,7 +1341,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1341 | 1341 | for (all_features.items) |feature| { |
| 1342 | 1342 | if (feature.llvm_name) |llvm_name| { |
| 1343 | 1343 | try w.print( |
| 1344 | \\ result[@intFromEnum(Feature.{})] = .{{ | |
| 1344 | \\ result[@intFromEnum(Feature.{p_})] = .{{ | |
| 1345 | 1345 | \\ .llvm_name = "{}", |
| 1346 | 1346 | \\ .description = "{}", |
| 1347 | 1347 | \\ .dependencies = featureSet(&[_]Feature{{ |
| ... | ... | @@ -1354,7 +1354,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1354 | 1354 | ); |
| 1355 | 1355 | } else { |
| 1356 | 1356 | try w.print( |
| 1357 | \\ result[@intFromEnum(Feature.{})] = .{{ | |
| 1357 | \\ result[@intFromEnum(Feature.{p_})] = .{{ | |
| 1358 | 1358 | \\ .llvm_name = null, |
| 1359 | 1359 | \\ .description = "{}", |
| 1360 | 1360 | \\ .dependencies = featureSet(&[_]Feature{{ |
| ... | ... | @@ -1388,7 +1388,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1388 | 1388 | } else { |
| 1389 | 1389 | try w.writeAll("\n"); |
| 1390 | 1390 | for (dependencies.items) |dep| { |
| 1391 | try w.print(" .{},\n", .{std.zig.fmtId(dep)}); | |
| 1391 | try w.print(" .{p_},\n", .{std.zig.fmtId(dep)}); | |
| 1392 | 1392 | } |
| 1393 | 1393 | try w.writeAll( |
| 1394 | 1394 | \\ }), |
| ... | ... | @@ -1454,7 +1454,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1454 | 1454 | } else { |
| 1455 | 1455 | try w.writeAll("\n"); |
| 1456 | 1456 | for (cpu_features.items) |feature_zig_name| { |
| 1457 | try w.print(" .{},\n", .{std.zig.fmtId(feature_zig_name)}); | |
| 1457 | try w.print(" .{p_},\n", .{std.zig.fmtId(feature_zig_name)}); | |
| 1458 | 1458 | } |
| 1459 | 1459 | try w.writeAll( |
| 1460 | 1460 | \\ }), |
tools/update_spirv_features.zig+5-5| ... | ... | @@ -112,11 +112,11 @@ pub fn main() !void { |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | for (extensions) |ext| { |
| 115 | try w.print(" {},\n", .{std.zig.fmtId(ext)}); | |
| 115 | try w.print(" {p},\n", .{std.zig.fmtId(ext)}); | |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | for (capabilities) |cap| { |
| 119 | try w.print(" {},\n", .{std.zig.fmtId(cap.enumerant)}); | |
| 119 | try w.print(" {p},\n", .{std.zig.fmtId(cap.enumerant)}); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | try w.writeAll( |
| ... | ... | @@ -163,7 +163,7 @@ pub fn main() !void { |
| 163 | 163 | // TODO: Extension dependencies. |
| 164 | 164 | for (extensions) |ext| { |
| 165 | 165 | try w.print( |
| 166 | \\ result[@intFromEnum(Feature.{s})] = .{{ | |
| 166 | \\ result[@intFromEnum(Feature.{p_})] = .{{ | |
| 167 | 167 | \\ .llvm_name = null, |
| 168 | 168 | \\ .description = "SPIR-V extension {s}", |
| 169 | 169 | \\ .dependencies = featureSet(&[_]Feature{{}}), |
| ... | ... | @@ -178,7 +178,7 @@ pub fn main() !void { |
| 178 | 178 | // TODO: Capability extension dependencies. |
| 179 | 179 | for (capabilities) |cap| { |
| 180 | 180 | try w.print( |
| 181 | \\ result[@intFromEnum(Feature.{s})] = .{{ | |
| 181 | \\ result[@intFromEnum(Feature.{p_})] = .{{ | |
| 182 | 182 | \\ .llvm_name = null, |
| 183 | 183 | \\ .description = "Enable SPIR-V capability {s}", |
| 184 | 184 | \\ .dependencies = featureSet(&[_]Feature{{ |
| ... | ... | @@ -196,7 +196,7 @@ pub fn main() !void { |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | for (cap.capabilities) |cap_dep| { |
| 199 | try w.print(" .{},\n", .{std.zig.fmtId(cap_dep)}); | |
| 199 | try w.print(" .{p_},\n", .{std.zig.fmtId(cap_dep)}); | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | try w.writeAll( |