| author | |
| committer | |
| log | 4d8c24c6c52fe4adf4f9215278108734b635393d |
| tree | 64fc0998ec2ba6273d2661ef7e34ccaf93d74492 |
| parent | 133abdeda2994886c3476a3faf53f8a911513b32 |
| parent | 9804cc8bc6fe83b2a0cd5b61b8d2fc5d458cb221 |
| signature |
std.builtin.Type renames, and make it easier to modify std.builtin92 files changed, 1178 insertions(+), 947 deletions(-)
bootstrap.c+1| ... | @@ -141,6 +141,7 @@ int main(int argc, char **argv) { | ... | @@ -141,6 +141,7 @@ int main(int argc, char **argv) { |
| 141 | "pub const skip_non_native = false;\n" | 141 | "pub const skip_non_native = false;\n" |
| 142 | "pub const force_gpa = false;\n" | 142 | "pub const force_gpa = false;\n" |
| 143 | "pub const dev = .core;\n" | 143 | "pub const dev = .core;\n" |
| 144 | "pub const value_interpret_mode = .direct;\n" | ||
| 144 | , zig_version); | 145 | , zig_version); |
| 145 | if (written < 100) | 146 | if (written < 100) |
| 146 | panic("unable to write to config.zig file"); | 147 | panic("unable to write to config.zig file"); |
build.zig+20| ... | @@ -9,6 +9,7 @@ const fs = std.fs; | ... | @@ -9,6 +9,7 @@ const fs = std.fs; |
| 9 | const InstallDirectoryOptions = std.Build.InstallDirectoryOptions; | 9 | const InstallDirectoryOptions = std.Build.InstallDirectoryOptions; |
| 10 | const assert = std.debug.assert; | 10 | const assert = std.debug.assert; |
| 11 | const DevEnv = @import("src/dev.zig").Env; | 11 | const DevEnv = @import("src/dev.zig").Env; |
| 12 | const ValueInterpretMode = enum { direct, by_name }; | ||
| 12 | 13 | ||
| 13 | const zig_version: std.SemanticVersion = .{ .major = 0, .minor = 14, .patch = 0 }; | 14 | const zig_version: std.SemanticVersion = .{ .major = 0, .minor = 14, .patch = 0 }; |
| 14 | const stack_size = 46 * 1024 * 1024; | 15 | const stack_size = 46 * 1024 * 1024; |
| ... | @@ -177,6 +178,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -177,6 +178,7 @@ pub fn build(b: *std.Build) !void { |
| 177 | const strip = b.option(bool, "strip", "Omit debug information"); | 178 | const strip = b.option(bool, "strip", "Omit debug information"); |
| 178 | const valgrind = b.option(bool, "valgrind", "Enable valgrind integration"); | 179 | const valgrind = b.option(bool, "valgrind", "Enable valgrind integration"); |
| 179 | const pie = b.option(bool, "pie", "Produce a Position Independent Executable"); | 180 | const pie = b.option(bool, "pie", "Produce a Position Independent Executable"); |
| 181 | const value_interpret_mode = b.option(ValueInterpretMode, "value-interpret-mode", "How the compiler translates between 'std.builtin' types and its internal datastructures") orelse .direct; | ||
| 180 | const value_tracing = b.option(bool, "value-tracing", "Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API)") orelse false; | 182 | const value_tracing = b.option(bool, "value-tracing", "Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API)") orelse false; |
| 181 | 183 | ||
| 182 | const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: { | 184 | const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: { |
| ... | @@ -234,6 +236,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -234,6 +236,7 @@ pub fn build(b: *std.Build) !void { |
| 234 | exe_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa); | 236 | exe_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa); |
| 235 | exe_options.addOption(bool, "force_gpa", force_gpa); | 237 | exe_options.addOption(bool, "force_gpa", force_gpa); |
| 236 | exe_options.addOption(DevEnv, "dev", b.option(DevEnv, "dev", "Build a compiler with a reduced feature set for development of specific features") orelse if (only_c) .bootstrap else .full); | 238 | exe_options.addOption(DevEnv, "dev", b.option(DevEnv, "dev", "Build a compiler with a reduced feature set for development of specific features") orelse if (only_c) .bootstrap else .full); |
| 239 | exe_options.addOption(ValueInterpretMode, "value_interpret_mode", value_interpret_mode); | ||
| 237 | 240 | ||
| 238 | if (link_libc) { | 241 | if (link_libc) { |
| 239 | exe.root_module.link_libc = true; | 242 | exe.root_module.link_libc = true; |
| ... | @@ -620,6 +623,23 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { | ... | @@ -620,6 +623,23 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { |
| 620 | exe_options.addOption(bool, "value_tracing", false); | 623 | exe_options.addOption(bool, "value_tracing", false); |
| 621 | exe_options.addOption(DevEnv, "dev", .bootstrap); | 624 | exe_options.addOption(DevEnv, "dev", .bootstrap); |
| 622 | 625 | ||
| 626 | // zig1 chooses to interpret values by name. The tradeoff is as follows: | ||
| 627 | // | ||
| 628 | // * We lose a small amount of performance. This is essentially irrelevant for zig1. | ||
| 629 | // | ||
| 630 | // * We lose the ability to perform trivial renames on certain `std.builtin` types without | ||
| 631 | // zig1.wasm updates. For instance, we cannot rename an enum from PascalCase fields to | ||
| 632 | // snake_case fields without an update. | ||
| 633 | // | ||
| 634 | // * We gain the ability to add and remove fields to and from `std.builtin` types without | ||
| 635 | // zig1.wasm updates. For instance, we can add a new tag to `CallingConvention` without | ||
| 636 | // an update. | ||
| 637 | // | ||
| 638 | // Because field renames only happen when we apply a breaking change to the language (which | ||
| 639 | // is becoming progressively rarer), but tags may be added to or removed from target-dependent | ||
| 640 | // types over time in response to new targets coming into use, we gain more than we lose here. | ||
| 641 | exe_options.addOption(ValueInterpretMode, "value_interpret_mode", .by_name); | ||
| 642 | |||
| 623 | const run_opt = b.addSystemCommand(&.{ | 643 | const run_opt = b.addSystemCommand(&.{ |
| 624 | "wasm-opt", | 644 | "wasm-opt", |
| 625 | "-Oz", | 645 | "-Oz", |
lib/std/Build/Step/ConfigHeader.zig+2-2| ... | @@ -144,13 +144,13 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty | ... | @@ -144,13 +144,13 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty |
| 144 | .pointer => |ptr| { | 144 | .pointer => |ptr| { |
| 145 | switch (@typeInfo(ptr.child)) { | 145 | switch (@typeInfo(ptr.child)) { |
| 146 | .array => |array| { | 146 | .array => |array| { |
| 147 | if (ptr.size == .One and array.child == u8) { | 147 | if (ptr.size == .one and array.child == u8) { |
| 148 | try config_header.values.put(field_name, .{ .string = v }); | 148 | try config_header.values.put(field_name, .{ .string = v }); |
| 149 | return; | 149 | return; |
| 150 | } | 150 | } |
| 151 | }, | 151 | }, |
| 152 | .int => { | 152 | .int => { |
| 153 | if (ptr.size == .Slice and ptr.child == u8) { | 153 | if (ptr.size == .slice and ptr.child == u8) { |
| 154 | try config_header.values.put(field_name, .{ .string = v }); | 154 | try config_header.values.put(field_name, .{ .string = v }); |
| 155 | return; | 155 | return; |
| 156 | } | 156 | } |
lib/std/Build/Step/Options.zig+2-4| ... | @@ -172,7 +172,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent | ... | @@ -172,7 +172,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent |
| 172 | return; | 172 | return; |
| 173 | }, | 173 | }, |
| 174 | .pointer => |p| { | 174 | .pointer => |p| { |
| 175 | if (p.size != .Slice) { | 175 | if (p.size != .slice) { |
| 176 | @compileError("Non-slice pointers are not yet supported in build options"); | 176 | @compileError("Non-slice pointers are not yet supported in build options"); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| ... | @@ -318,9 +318,7 @@ fn printStruct(options: *Options, out: anytype, comptime T: type, comptime val: | ... | @@ -318,9 +318,7 @@ fn printStruct(options: *Options, out: anytype, comptime T: type, comptime val: |
| 318 | try out.print(" {p_}: {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 | if (field.default_value != null) { | 321 | if (field.defaultValue()) |default_value| { |
| 322 | const default_value = @as(*field.type, @ptrCast(@alignCast(@constCast(field.default_value.?)))).*; | ||
| 323 | |||
| 324 | try out.writeAll(" = "); | 322 | try out.writeAll(" = "); |
| 325 | switch (@typeInfo(@TypeOf(default_value))) { | 323 | switch (@typeInfo(@TypeOf(default_value))) { |
| 326 | .@"enum" => try out.print(".{s},\n", .{@tagName(default_value)}), | 324 | .@"enum" => try out.print(".{s},\n", .{@tagName(default_value)}), |
lib/std/Progress.zig+1-1| ... | @@ -1366,7 +1366,7 @@ fn maybeUpdateSize(resize_flag: bool) void { | ... | @@ -1366,7 +1366,7 @@ fn maybeUpdateSize(resize_flag: bool) void { |
| 1366 | } | 1366 | } |
| 1367 | } | 1367 | } |
| 1368 | 1368 | ||
| 1369 | fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) void { | 1369 | fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void { |
| 1370 | _ = info; | 1370 | _ = info; |
| 1371 | _ = ctx_ptr; | 1371 | _ = ctx_ptr; |
| 1372 | assert(sig == posix.SIG.WINCH); | 1372 | assert(sig == posix.SIG.WINCH); |
lib/std/Random.zig+1-1| ... | @@ -35,7 +35,7 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void, | ... | @@ -35,7 +35,7 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void, |
| 35 | pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random { | 35 | pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random { |
| 36 | const Ptr = @TypeOf(pointer); | 36 | const Ptr = @TypeOf(pointer); |
| 37 | assert(@typeInfo(Ptr) == .pointer); // Must be a pointer | 37 | assert(@typeInfo(Ptr) == .pointer); // Must be a pointer |
| 38 | assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer | 38 | assert(@typeInfo(Ptr).pointer.size == .one); // Must be a single-item pointer |
| 39 | assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct | 39 | assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct |
| 40 | const gen = struct { | 40 | const gen = struct { |
| 41 | fn fill(ptr: *anyopaque, buf: []u8) void { | 41 | fn fill(ptr: *anyopaque, buf: []u8) void { |
lib/std/builtin.zig+36-9| ... | @@ -607,16 +607,24 @@ pub const Type = union(enum) { | ... | @@ -607,16 +607,24 @@ pub const Type = union(enum) { |
| 607 | 607 | ||
| 608 | /// The type of the sentinel is the element type of the pointer, which is | 608 | /// The type of the sentinel is the element type of the pointer, which is |
| 609 | /// the value of the `child` field in this struct. However there is no way | 609 | /// the value of the `child` field in this struct. However there is no way |
| 610 | /// to refer to that type here, so we use pointer to `anyopaque`. | 610 | /// to refer to that type here, so we use `*const anyopaque`. |
| 611 | sentinel: ?*const anyopaque, | 611 | /// See also: `sentinel` |
| 612 | sentinel_ptr: ?*const anyopaque, | ||
| 613 | |||
| 614 | /// Loads the pointer type's sentinel value from `sentinel_ptr`. | ||
| 615 | /// Returns `null` if the pointer type has no sentinel. | ||
| 616 | pub inline fn sentinel(comptime ptr: Pointer) ?ptr.child { | ||
| 617 | const sp: *const ptr.child = @ptrCast(@alignCast(ptr.sentinel_ptr orelse return null)); | ||
| 618 | return sp.*; | ||
| 619 | } | ||
| 612 | 620 | ||
| 613 | /// This data structure is used by the Zig language code generation and | 621 | /// This data structure is used by the Zig language code generation and |
| 614 | /// therefore must be kept in sync with the compiler implementation. | 622 | /// therefore must be kept in sync with the compiler implementation. |
| 615 | pub const Size = enum(u2) { | 623 | pub const Size = enum(u2) { |
| 616 | One, | 624 | one, |
| 617 | Many, | 625 | many, |
| 618 | Slice, | 626 | slice, |
| 619 | C, | 627 | c, |
| 620 | }; | 628 | }; |
| 621 | }; | 629 | }; |
| 622 | 630 | ||
| ... | @@ -628,8 +636,16 @@ pub const Type = union(enum) { | ... | @@ -628,8 +636,16 @@ pub const Type = union(enum) { |
| 628 | 636 | ||
| 629 | /// The type of the sentinel is the element type of the array, which is | 637 | /// The type of the sentinel is the element type of the array, which is |
| 630 | /// the value of the `child` field in this struct. However there is no way | 638 | /// the value of the `child` field in this struct. However there is no way |
| 631 | /// to refer to that type here, so we use pointer to `anyopaque`. | 639 | /// to refer to that type here, so we use `*const anyopaque`. |
| 632 | sentinel: ?*const anyopaque, | 640 | /// See also: `sentinel`. |
| 641 | sentinel_ptr: ?*const anyopaque, | ||
| 642 | |||
| 643 | /// Loads the array type's sentinel value from `sentinel_ptr`. | ||
| 644 | /// Returns `null` if the array type has no sentinel. | ||
| 645 | pub inline fn sentinel(comptime arr: Array) ?arr.child { | ||
| 646 | const sp: *const arr.child = @ptrCast(@alignCast(arr.sentinel_ptr orelse return null)); | ||
| 647 | return sp.*; | ||
| 648 | } | ||
| 633 | }; | 649 | }; |
| 634 | 650 | ||
| 635 | /// This data structure is used by the Zig language code generation and | 651 | /// This data structure is used by the Zig language code generation and |
| ... | @@ -645,9 +661,20 @@ pub const Type = union(enum) { | ... | @@ -645,9 +661,20 @@ pub const Type = union(enum) { |
| 645 | pub const StructField = struct { | 661 | pub const StructField = struct { |
| 646 | name: [:0]const u8, | 662 | name: [:0]const u8, |
| 647 | type: type, | 663 | type: type, |
| 648 | default_value: ?*const anyopaque, | 664 | /// The type of the default value is the type of this struct field, which |
| 665 | /// is the value of the `type` field in this struct. However there is no | ||
| 666 | /// way to refer to that type here, so we use `*const anyopaque`. | ||
| 667 | /// See also: `defaultValue`. | ||
| 668 | default_value_ptr: ?*const anyopaque, | ||
| 649 | is_comptime: bool, | 669 | is_comptime: bool, |
| 650 | alignment: comptime_int, | 670 | alignment: comptime_int, |
| 671 | |||
| 672 | /// Loads the field's default value from `default_value_ptr`. | ||
| 673 | /// Returns `null` if the field has no default value. | ||
| 674 | pub inline fn defaultValue(comptime sf: StructField) ?sf.type { | ||
| 675 | const dp: *const sf.type = @ptrCast(@alignCast(sf.default_value_ptr orelse return null)); | ||
| 676 | return dp.*; | ||
| 677 | } | ||
| 651 | }; | 678 | }; |
| 652 | 679 | ||
| 653 | /// This data structure is used by the Zig language code generation and | 680 | /// This data structure is used by the Zig language code generation and |
lib/std/c.zig+31-31| ... | @@ -2733,8 +2733,8 @@ pub const Sigaction = switch (native_os) { | ... | @@ -2733,8 +2733,8 @@ pub const Sigaction = switch (native_os) { |
| 2733 | => if (builtin.target.isMusl()) | 2733 | => if (builtin.target.isMusl()) |
| 2734 | linux.Sigaction | 2734 | linux.Sigaction |
| 2735 | else if (builtin.target.ptrBitWidth() == 64) extern struct { | 2735 | else if (builtin.target.ptrBitWidth() == 64) extern struct { |
| 2736 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 2736 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 2737 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 2737 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 2738 | 2738 | ||
| 2739 | flags: c_uint, | 2739 | flags: c_uint, |
| 2740 | handler: extern union { | 2740 | handler: extern union { |
| ... | @@ -2742,10 +2742,10 @@ pub const Sigaction = switch (native_os) { | ... | @@ -2742,10 +2742,10 @@ pub const Sigaction = switch (native_os) { |
| 2742 | sigaction: ?sigaction_fn, | 2742 | sigaction: ?sigaction_fn, |
| 2743 | }, | 2743 | }, |
| 2744 | mask: sigset_t, | 2744 | mask: sigset_t, |
| 2745 | restorer: ?*const fn () callconv(.C) void = null, | 2745 | restorer: ?*const fn () callconv(.c) void = null, |
| 2746 | } else extern struct { | 2746 | } else extern struct { |
| 2747 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 2747 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 2748 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 2748 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 2749 | 2749 | ||
| 2750 | flags: c_uint, | 2750 | flags: c_uint, |
| 2751 | handler: extern union { | 2751 | handler: extern union { |
| ... | @@ -2753,12 +2753,12 @@ pub const Sigaction = switch (native_os) { | ... | @@ -2753,12 +2753,12 @@ pub const Sigaction = switch (native_os) { |
| 2753 | sigaction: ?sigaction_fn, | 2753 | sigaction: ?sigaction_fn, |
| 2754 | }, | 2754 | }, |
| 2755 | mask: sigset_t, | 2755 | mask: sigset_t, |
| 2756 | restorer: ?*const fn () callconv(.C) void = null, | 2756 | restorer: ?*const fn () callconv(.c) void = null, |
| 2757 | __resv: [1]c_int = .{0}, | 2757 | __resv: [1]c_int = .{0}, |
| 2758 | }, | 2758 | }, |
| 2759 | .s390x => if (builtin.abi == .gnu) extern struct { | 2759 | .s390x => if (builtin.abi == .gnu) extern struct { |
| 2760 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 2760 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 2761 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 2761 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 2762 | 2762 | ||
| 2763 | handler: extern union { | 2763 | handler: extern union { |
| 2764 | handler: ?handler_fn, | 2764 | handler: ?handler_fn, |
| ... | @@ -2766,15 +2766,15 @@ pub const Sigaction = switch (native_os) { | ... | @@ -2766,15 +2766,15 @@ pub const Sigaction = switch (native_os) { |
| 2766 | }, | 2766 | }, |
| 2767 | __glibc_reserved0: c_int = 0, | 2767 | __glibc_reserved0: c_int = 0, |
| 2768 | flags: c_uint, | 2768 | flags: c_uint, |
| 2769 | restorer: ?*const fn () callconv(.C) void = null, | 2769 | restorer: ?*const fn () callconv(.c) void = null, |
| 2770 | mask: sigset_t, | 2770 | mask: sigset_t, |
| 2771 | } else linux.Sigaction, | 2771 | } else linux.Sigaction, |
| 2772 | else => linux.Sigaction, | 2772 | else => linux.Sigaction, |
| 2773 | }, | 2773 | }, |
| 2774 | .emscripten => emscripten.Sigaction, | 2774 | .emscripten => emscripten.Sigaction, |
| 2775 | .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { | 2775 | .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { |
| 2776 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 2776 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 2777 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 2777 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 2778 | 2778 | ||
| 2779 | handler: extern union { | 2779 | handler: extern union { |
| 2780 | handler: ?handler_fn, | 2780 | handler: ?handler_fn, |
| ... | @@ -2784,8 +2784,8 @@ pub const Sigaction = switch (native_os) { | ... | @@ -2784,8 +2784,8 @@ pub const Sigaction = switch (native_os) { |
| 2784 | flags: c_uint, | 2784 | flags: c_uint, |
| 2785 | }, | 2785 | }, |
| 2786 | .dragonfly, .freebsd => extern struct { | 2786 | .dragonfly, .freebsd => extern struct { |
| 2787 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 2787 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 2788 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 2788 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 2789 | 2789 | ||
| 2790 | /// signal handler | 2790 | /// signal handler |
| 2791 | handler: extern union { | 2791 | handler: extern union { |
| ... | @@ -2798,8 +2798,8 @@ pub const Sigaction = switch (native_os) { | ... | @@ -2798,8 +2798,8 @@ pub const Sigaction = switch (native_os) { |
| 2798 | mask: sigset_t, | 2798 | mask: sigset_t, |
| 2799 | }, | 2799 | }, |
| 2800 | .solaris, .illumos => extern struct { | 2800 | .solaris, .illumos => extern struct { |
| 2801 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 2801 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 2802 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 2802 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 2803 | 2803 | ||
| 2804 | /// signal options | 2804 | /// signal options |
| 2805 | flags: c_uint, | 2805 | flags: c_uint, |
| ... | @@ -2812,8 +2812,8 @@ pub const Sigaction = switch (native_os) { | ... | @@ -2812,8 +2812,8 @@ pub const Sigaction = switch (native_os) { |
| 2812 | mask: sigset_t, | 2812 | mask: sigset_t, |
| 2813 | }, | 2813 | }, |
| 2814 | .haiku => extern struct { | 2814 | .haiku => extern struct { |
| 2815 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 2815 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 2816 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 2816 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 2817 | 2817 | ||
| 2818 | /// signal handler | 2818 | /// signal handler |
| 2819 | handler: extern union { | 2819 | handler: extern union { |
| ... | @@ -2831,8 +2831,8 @@ pub const Sigaction = switch (native_os) { | ... | @@ -2831,8 +2831,8 @@ pub const Sigaction = switch (native_os) { |
| 2831 | userdata: *allowzero anyopaque = undefined, | 2831 | userdata: *allowzero anyopaque = undefined, |
| 2832 | }, | 2832 | }, |
| 2833 | .openbsd => extern struct { | 2833 | .openbsd => extern struct { |
| 2834 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 2834 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 2835 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 2835 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 2836 | 2836 | ||
| 2837 | /// signal handler | 2837 | /// signal handler |
| 2838 | handler: extern union { | 2838 | handler: extern union { |
| ... | @@ -6410,7 +6410,7 @@ pub const EAI = switch (native_os) { | ... | @@ -6410,7 +6410,7 @@ pub const EAI = switch (native_os) { |
| 6410 | else => void, | 6410 | else => void, |
| 6411 | }; | 6411 | }; |
| 6412 | 6412 | ||
| 6413 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int; | 6413 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int; |
| 6414 | 6414 | ||
| 6415 | pub const Stat = switch (native_os) { | 6415 | pub const Stat = switch (native_os) { |
| 6416 | .linux => switch (native_arch) { | 6416 | .linux => switch (native_arch) { |
| ... | @@ -9396,7 +9396,7 @@ pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int; | ... | @@ -9396,7 +9396,7 @@ pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int; |
| 9396 | pub extern "c" fn pthread_create( | 9396 | pub extern "c" fn pthread_create( |
| 9397 | noalias newthread: *pthread_t, | 9397 | noalias newthread: *pthread_t, |
| 9398 | noalias attr: ?*const pthread_attr_t, | 9398 | noalias attr: ?*const pthread_attr_t, |
| 9399 | start_routine: *const fn (?*anyopaque) callconv(.C) ?*anyopaque, | 9399 | start_routine: *const fn (?*anyopaque) callconv(.c) ?*anyopaque, |
| 9400 | noalias arg: ?*anyopaque, | 9400 | noalias arg: ?*anyopaque, |
| 9401 | ) E; | 9401 | ) E; |
| 9402 | pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E; | 9402 | pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E; |
| ... | @@ -9408,13 +9408,13 @@ pub extern "c" fn pthread_self() pthread_t; | ... | @@ -9408,13 +9408,13 @@ pub extern "c" fn pthread_self() pthread_t; |
| 9408 | pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E; | 9408 | pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E; |
| 9409 | pub extern "c" fn pthread_detach(thread: pthread_t) E; | 9409 | pub extern "c" fn pthread_detach(thread: pthread_t) E; |
| 9410 | pub extern "c" fn pthread_atfork( | 9410 | pub extern "c" fn pthread_atfork( |
| 9411 | prepare: ?*const fn () callconv(.C) void, | 9411 | prepare: ?*const fn () callconv(.c) void, |
| 9412 | parent: ?*const fn () callconv(.C) void, | 9412 | parent: ?*const fn () callconv(.c) void, |
| 9413 | child: ?*const fn () callconv(.C) void, | 9413 | child: ?*const fn () callconv(.c) void, |
| 9414 | ) c_int; | 9414 | ) c_int; |
| 9415 | pub extern "c" fn pthread_key_create( | 9415 | pub extern "c" fn pthread_key_create( |
| 9416 | key: *pthread_key_t, | 9416 | key: *pthread_key_t, |
| 9417 | destructor: ?*const fn (value: *anyopaque) callconv(.C) void, | 9417 | destructor: ?*const fn (value: *anyopaque) callconv(.c) void, |
| 9418 | ) E; | 9418 | ) E; |
| 9419 | pub extern "c" fn pthread_key_delete(key: pthread_key_t) E; | 9419 | pub extern "c" fn pthread_key_delete(key: pthread_key_t) E; |
| 9420 | pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque; | 9420 | pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque; |
| ... | @@ -9530,12 +9530,12 @@ pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E; | ... | @@ -9530,12 +9530,12 @@ pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E; |
| 9530 | pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E; | 9530 | pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E; |
| 9531 | pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E; | 9531 | pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E; |
| 9532 | 9532 | ||
| 9533 | pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E; | 9533 | pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 9534 | pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E; | 9534 | pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 9535 | pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E; | 9535 | pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 9536 | pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E; | 9536 | pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 9537 | pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E; | 9537 | pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 9538 | pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E; | 9538 | pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 9539 | 9539 | ||
| 9540 | pub const pthread_t = *opaque {}; | 9540 | pub const pthread_t = *opaque {}; |
| 9541 | pub const FILE = opaque {}; | 9541 | pub const FILE = opaque {}; |
lib/std/c/darwin.zig+2-2| ... | @@ -379,7 +379,7 @@ pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) { | ... | @@ -379,7 +379,7 @@ pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) { |
| 379 | }; | 379 | }; |
| 380 | 380 | ||
| 381 | extern "c" var mach_task_self_: mach_port_t; | 381 | extern "c" var mach_task_self_: mach_port_t; |
| 382 | pub fn mach_task_self() callconv(.C) mach_port_t { | 382 | pub fn mach_task_self() callconv(.c) mach_port_t { |
| 383 | return mach_task_self_; | 383 | return mach_task_self_; |
| 384 | } | 384 | } |
| 385 | 385 | ||
| ... | @@ -873,7 +873,7 @@ pub const DISPATCH_TIME_FOREVER = ~@as(dispatch_time_t, 0); | ... | @@ -873,7 +873,7 @@ pub const DISPATCH_TIME_FOREVER = ~@as(dispatch_time_t, 0); |
| 873 | pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t; | 873 | pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t; |
| 874 | 874 | ||
| 875 | const dispatch_once_t = usize; | 875 | const dispatch_once_t = usize; |
| 876 | const dispatch_function_t = fn (?*anyopaque) callconv(.C) void; | 876 | const dispatch_function_t = fn (?*anyopaque) callconv(.c) void; |
| 877 | pub extern fn dispatch_once_f( | 877 | pub extern fn dispatch_once_f( |
| 878 | predicate: *dispatch_once_t, | 878 | predicate: *dispatch_once_t, |
| 879 | context: ?*anyopaque, | 879 | context: ?*anyopaque, |
lib/std/c/dragonfly.zig+1-1| ... | @@ -156,7 +156,7 @@ pub const E = enum(u16) { | ... | @@ -156,7 +156,7 @@ pub const E = enum(u16) { |
| 156 | 156 | ||
| 157 | pub const BADSIG = SIG.ERR; | 157 | pub const BADSIG = SIG.ERR; |
| 158 | 158 | ||
| 159 | pub const sig_t = *const fn (i32) callconv(.C) void; | 159 | pub const sig_t = *const fn (i32) callconv(.c) void; |
| 160 | 160 | ||
| 161 | pub const cmsghdr = extern struct { | 161 | pub const cmsghdr = extern struct { |
| 162 | len: socklen_t, | 162 | len: socklen_t, |
lib/std/crypto/phc_encoding.zig+1-1| ... | @@ -164,7 +164,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult | ... | @@ -164,7 +164,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult |
| 164 | // with default values | 164 | // with default values |
| 165 | var expected_fields: usize = 0; | 165 | var expected_fields: usize = 0; |
| 166 | inline for (comptime meta.fields(HashResult)) |p| { | 166 | inline for (comptime meta.fields(HashResult)) |p| { |
| 167 | if (@typeInfo(p.type) != .optional and p.default_value == null) { | 167 | if (@typeInfo(p.type) != .optional and p.default_value_ptr == null) { |
| 168 | expected_fields += 1; | 168 | expected_fields += 1; |
| 169 | } | 169 | } |
| 170 | } | 170 | } |
lib/std/crypto/tlcsprng.zig+1-1| ... | @@ -133,7 +133,7 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void { | ... | @@ -133,7 +133,7 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void { |
| 133 | return initAndFill(buffer); | 133 | return initAndFill(buffer); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | fn childAtForkHandler() callconv(.C) void { | 136 | fn childAtForkHandler() callconv(.c) void { |
| 137 | // The atfork handler is global, this function may be called after | 137 | // The atfork handler is global, this function may be called after |
| 138 | // fork()-ing threads that never initialized the CSPRNG context. | 138 | // fork()-ing threads that never initialized the CSPRNG context. |
| 139 | if (wipe_mem.len == 0) return; | 139 | if (wipe_mem.len == 0) return; |
lib/std/debug.zig+1-1| ... | @@ -1269,7 +1269,7 @@ fn resetSegfaultHandler() void { | ... | @@ -1269,7 +1269,7 @@ fn resetSegfaultHandler() void { |
| 1269 | updateSegfaultHandler(&act); | 1269 | updateSegfaultHandler(&act); |
| 1270 | } | 1270 | } |
| 1271 | 1271 | ||
| 1272 | fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) noreturn { | 1272 | fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn { |
| 1273 | // Reset to the default handler so that if a segfault happens in this handler it will crash | 1273 | // Reset to the default handler so that if a segfault happens in this handler it will crash |
| 1274 | // the process. Also when this handler returns, the original instruction will be repeated | 1274 | // the process. Also when this handler returns, the original instruction will be repeated |
| 1275 | // and the resulting segfault will crash the process rather than continually dump stack traces. | 1275 | // and the resulting segfault will crash the process rather than continually dump stack traces. |
lib/std/enums.zig+1-1| ... | @@ -19,7 +19,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def | ... | @@ -19,7 +19,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def |
| 19 | struct_field.* = .{ | 19 | struct_field.* = .{ |
| 20 | .name = enum_field.name ++ "", | 20 | .name = enum_field.name ++ "", |
| 21 | .type = Data, | 21 | .type = Data, |
| 22 | .default_value = if (field_default) |d| @as(?*const anyopaque, @ptrCast(&d)) else null, | 22 | .default_value_ptr = if (field_default) |d| @as(?*const anyopaque, @ptrCast(&d)) else null, |
| 23 | .is_comptime = false, | 23 | .is_comptime = false, |
| 24 | .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0, | 24 | .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0, |
| 25 | }; | 25 | }; |
lib/std/fmt.zig+8-8| ... | @@ -434,7 +434,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T | ... | @@ -434,7 +434,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T |
| 434 | switch (@typeInfo(T)) { | 434 | switch (@typeInfo(T)) { |
| 435 | .pointer => |info| { | 435 | .pointer => |info| { |
| 436 | try writer.writeAll(@typeName(info.child) ++ "@"); | 436 | try writer.writeAll(@typeName(info.child) ++ "@"); |
| 437 | if (info.size == .Slice) | 437 | if (info.size == .slice) |
| 438 | try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer) | 438 | try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer) |
| 439 | else | 439 | else |
| 440 | try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer); | 440 | try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer); |
| ... | @@ -460,12 +460,12 @@ pub fn defaultSpec(comptime T: type) [:0]const u8 { | ... | @@ -460,12 +460,12 @@ pub fn defaultSpec(comptime T: type) [:0]const u8 { |
| 460 | switch (@typeInfo(T)) { | 460 | switch (@typeInfo(T)) { |
| 461 | .array, .vector => return ANY, | 461 | .array, .vector => return ANY, |
| 462 | .pointer => |ptr_info| switch (ptr_info.size) { | 462 | .pointer => |ptr_info| switch (ptr_info.size) { |
| 463 | .One => switch (@typeInfo(ptr_info.child)) { | 463 | .one => switch (@typeInfo(ptr_info.child)) { |
| 464 | .array => return ANY, | 464 | .array => return ANY, |
| 465 | else => {}, | 465 | else => {}, |
| 466 | }, | 466 | }, |
| 467 | .Many, .C => return "*", | 467 | .many, .c => return "*", |
| 468 | .Slice => return ANY, | 468 | .slice => return ANY, |
| 469 | }, | 469 | }, |
| 470 | .optional => |info| return "?" ++ defaultSpec(info.child), | 470 | .optional => |info| return "?" ++ defaultSpec(info.child), |
| 471 | .error_union => |info| return "!" ++ defaultSpec(info.payload), | 471 | .error_union => |info| return "!" ++ defaultSpec(info.payload), |
| ... | @@ -624,16 +624,16 @@ pub fn formatType( | ... | @@ -624,16 +624,16 @@ pub fn formatType( |
| 624 | try writer.writeAll(" }"); | 624 | try writer.writeAll(" }"); |
| 625 | }, | 625 | }, |
| 626 | .pointer => |ptr_info| switch (ptr_info.size) { | 626 | .pointer => |ptr_info| switch (ptr_info.size) { |
| 627 | .One => switch (@typeInfo(ptr_info.child)) { | 627 | .one => switch (@typeInfo(ptr_info.child)) { |
| 628 | .array, .@"enum", .@"union", .@"struct" => { | 628 | .array, .@"enum", .@"union", .@"struct" => { |
| 629 | return formatType(value.*, actual_fmt, options, writer, max_depth); | 629 | return formatType(value.*, actual_fmt, options, writer, max_depth); |
| 630 | }, | 630 | }, |
| 631 | else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }), | 631 | else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }), |
| 632 | }, | 632 | }, |
| 633 | .Many, .C => { | 633 | .many, .c => { |
| 634 | if (actual_fmt.len == 0) | 634 | if (actual_fmt.len == 0) |
| 635 | @compileError("cannot format pointer without a specifier (i.e. {s} or {*})"); | 635 | @compileError("cannot format pointer without a specifier (i.e. {s} or {*})"); |
| 636 | if (ptr_info.sentinel) |_| { | 636 | if (ptr_info.sentinel() != null) { |
| 637 | return formatType(mem.span(value), actual_fmt, options, writer, max_depth); | 637 | return formatType(mem.span(value), actual_fmt, options, writer, max_depth); |
| 638 | } | 638 | } |
| 639 | if (actual_fmt[0] == 's' and ptr_info.child == u8) { | 639 | if (actual_fmt[0] == 's' and ptr_info.child == u8) { |
| ... | @@ -641,7 +641,7 @@ pub fn formatType( | ... | @@ -641,7 +641,7 @@ pub fn formatType( |
| 641 | } | 641 | } |
| 642 | invalidFmtError(fmt, value); | 642 | invalidFmtError(fmt, value); |
| 643 | }, | 643 | }, |
| 644 | .Slice => { | 644 | .slice => { |
| 645 | if (actual_fmt.len == 0) | 645 | if (actual_fmt.len == 0) |
| 646 | @compileError("cannot format slice without a specifier (i.e. {s} or {any})"); | 646 | @compileError("cannot format slice without a specifier (i.e. {s} or {any})"); |
| 647 | if (max_depth == 0) { | 647 | if (max_depth == 0) { |
lib/std/hash/auto_hash.zig+5-5| ... | @@ -23,13 +23,13 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) | ... | @@ -23,13 +23,13 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) |
| 23 | const info = @typeInfo(@TypeOf(key)); | 23 | const info = @typeInfo(@TypeOf(key)); |
| 24 | 24 | ||
| 25 | switch (info.pointer.size) { | 25 | switch (info.pointer.size) { |
| 26 | .One => switch (strat) { | 26 | .one => switch (strat) { |
| 27 | .Shallow => hash(hasher, @intFromPtr(key), .Shallow), | 27 | .Shallow => hash(hasher, @intFromPtr(key), .Shallow), |
| 28 | .Deep => hash(hasher, key.*, .Shallow), | 28 | .Deep => hash(hasher, key.*, .Shallow), |
| 29 | .DeepRecursive => hash(hasher, key.*, .DeepRecursive), | 29 | .DeepRecursive => hash(hasher, key.*, .DeepRecursive), |
| 30 | }, | 30 | }, |
| 31 | 31 | ||
| 32 | .Slice => { | 32 | .slice => { |
| 33 | switch (strat) { | 33 | switch (strat) { |
| 34 | .Shallow => { | 34 | .Shallow => { |
| 35 | hashPointer(hasher, key.ptr, .Shallow); | 35 | hashPointer(hasher, key.ptr, .Shallow); |
| ... | @@ -40,8 +40,8 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) | ... | @@ -40,8 +40,8 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) |
| 40 | hash(hasher, key.len, .Shallow); | 40 | hash(hasher, key.len, .Shallow); |
| 41 | }, | 41 | }, |
| 42 | 42 | ||
| 43 | .Many, | 43 | .many, |
| 44 | .C, | 44 | .c, |
| 45 | => switch (strat) { | 45 | => switch (strat) { |
| 46 | .Shallow => hash(hasher, @intFromPtr(key), .Shallow), | 46 | .Shallow => hash(hasher, @intFromPtr(key), .Shallow), |
| 47 | else => @compileError( | 47 | else => @compileError( |
| ... | @@ -167,7 +167,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { | ... | @@ -167,7 +167,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 167 | 167 | ||
| 168 | inline fn typeContainsSlice(comptime K: type) bool { | 168 | inline fn typeContainsSlice(comptime K: type) bool { |
| 169 | return switch (@typeInfo(K)) { | 169 | return switch (@typeInfo(K)) { |
| 170 | .pointer => |info| info.size == .Slice, | 170 | .pointer => |info| info.size == .slice, |
| 171 | 171 | ||
| 172 | inline .@"struct", .@"union" => |info| { | 172 | inline .@"struct", .@"union" => |info| { |
| 173 | inline for (info.fields) |field| { | 173 | inline for (info.fields) |field| { |
lib/std/io.zig+1-1| ... | @@ -805,7 +805,7 @@ pub fn PollFiles(comptime StreamEnum: type) type { | ... | @@ -805,7 +805,7 @@ pub fn PollFiles(comptime StreamEnum: type) type { |
| 805 | struct_field.* = .{ | 805 | struct_field.* = .{ |
| 806 | .name = enum_field.name ++ "", | 806 | .name = enum_field.name ++ "", |
| 807 | .type = fs.File, | 807 | .type = fs.File, |
| 808 | .default_value = null, | 808 | .default_value_ptr = null, |
| 809 | .is_comptime = false, | 809 | .is_comptime = false, |
| 810 | .alignment = @alignOf(fs.File), | 810 | .alignment = @alignOf(fs.File), |
| 811 | }; | 811 | }; |
lib/std/io/fixed_buffer_stream.zig+3-3| ... | @@ -118,14 +118,14 @@ fn Slice(comptime T: type) type { | ... | @@ -118,14 +118,14 @@ fn Slice(comptime T: type) type { |
| 118 | .pointer => |ptr_info| { | 118 | .pointer => |ptr_info| { |
| 119 | var new_ptr_info = ptr_info; | 119 | var new_ptr_info = ptr_info; |
| 120 | switch (ptr_info.size) { | 120 | switch (ptr_info.size) { |
| 121 | .Slice => {}, | 121 | .slice => {}, |
| 122 | .One => switch (@typeInfo(ptr_info.child)) { | 122 | .one => switch (@typeInfo(ptr_info.child)) { |
| 123 | .array => |info| new_ptr_info.child = info.child, | 123 | .array => |info| new_ptr_info.child = info.child, |
| 124 | else => @compileError("invalid type given to fixedBufferStream"), | 124 | else => @compileError("invalid type given to fixedBufferStream"), |
| 125 | }, | 125 | }, |
| 126 | else => @compileError("invalid type given to fixedBufferStream"), | 126 | else => @compileError("invalid type given to fixedBufferStream"), |
| 127 | } | 127 | } |
| 128 | new_ptr_info.size = .Slice; | 128 | new_ptr_info.size = .slice; |
| 129 | return @Type(.{ .pointer = new_ptr_info }); | 129 | return @Type(.{ .pointer = new_ptr_info }); |
| 130 | }, | 130 | }, |
| 131 | else => @compileError("invalid type given to fixedBufferStream"), | 131 | else => @compileError("invalid type given to fixedBufferStream"), |
lib/std/json/static.zig+13-15| ... | @@ -451,12 +451,12 @@ pub fn innerParse( | ... | @@ -451,12 +451,12 @@ pub fn innerParse( |
| 451 | 451 | ||
| 452 | .pointer => |ptrInfo| { | 452 | .pointer => |ptrInfo| { |
| 453 | switch (ptrInfo.size) { | 453 | switch (ptrInfo.size) { |
| 454 | .One => { | 454 | .one => { |
| 455 | const r: *ptrInfo.child = try allocator.create(ptrInfo.child); | 455 | const r: *ptrInfo.child = try allocator.create(ptrInfo.child); |
| 456 | r.* = try innerParse(ptrInfo.child, allocator, source, options); | 456 | r.* = try innerParse(ptrInfo.child, allocator, source, options); |
| 457 | return r; | 457 | return r; |
| 458 | }, | 458 | }, |
| 459 | .Slice => { | 459 | .slice => { |
| 460 | switch (try source.peekNextTokenType()) { | 460 | switch (try source.peekNextTokenType()) { |
| 461 | .array_begin => { | 461 | .array_begin => { |
| 462 | _ = try source.next(); | 462 | _ = try source.next(); |
| ... | @@ -476,9 +476,8 @@ pub fn innerParse( | ... | @@ -476,9 +476,8 @@ pub fn innerParse( |
| 476 | arraylist.appendAssumeCapacity(try innerParse(ptrInfo.child, allocator, source, options)); | 476 | arraylist.appendAssumeCapacity(try innerParse(ptrInfo.child, allocator, source, options)); |
| 477 | } | 477 | } |
| 478 | 478 | ||
| 479 | if (ptrInfo.sentinel) |some| { | 479 | if (ptrInfo.sentinel()) |s| { |
| 480 | const sentinel_value = @as(*align(1) const ptrInfo.child, @ptrCast(some)).*; | 480 | return try arraylist.toOwnedSliceSentinel(s); |
| 481 | return try arraylist.toOwnedSliceSentinel(sentinel_value); | ||
| 482 | } | 481 | } |
| 483 | 482 | ||
| 484 | return try arraylist.toOwnedSlice(); | 483 | return try arraylist.toOwnedSlice(); |
| ... | @@ -487,11 +486,11 @@ pub fn innerParse( | ... | @@ -487,11 +486,11 @@ pub fn innerParse( |
| 487 | if (ptrInfo.child != u8) return error.UnexpectedToken; | 486 | if (ptrInfo.child != u8) return error.UnexpectedToken; |
| 488 | 487 | ||
| 489 | // Dynamic length string. | 488 | // Dynamic length string. |
| 490 | if (ptrInfo.sentinel) |sentinel_ptr| { | 489 | if (ptrInfo.sentinel()) |s| { |
| 491 | // Use our own array list so we can append the sentinel. | 490 | // Use our own array list so we can append the sentinel. |
| 492 | var value_list = ArrayList(u8).init(allocator); | 491 | var value_list = ArrayList(u8).init(allocator); |
| 493 | _ = try source.allocNextIntoArrayList(&value_list, .alloc_always); | 492 | _ = try source.allocNextIntoArrayList(&value_list, .alloc_always); |
| 494 | return try value_list.toOwnedSliceSentinel(@as(*const u8, @ptrCast(sentinel_ptr)).*); | 493 | return try value_list.toOwnedSliceSentinel(s); |
| 495 | } | 494 | } |
| 496 | if (ptrInfo.is_const) { | 495 | if (ptrInfo.is_const) { |
| 497 | switch (try source.nextAllocMax(allocator, options.allocate.?, options.max_value_len.?)) { | 496 | switch (try source.nextAllocMax(allocator, options.allocate.?, options.max_value_len.?)) { |
| ... | @@ -706,16 +705,16 @@ pub fn innerParseFromValue( | ... | @@ -706,16 +705,16 @@ pub fn innerParseFromValue( |
| 706 | 705 | ||
| 707 | .pointer => |ptrInfo| { | 706 | .pointer => |ptrInfo| { |
| 708 | switch (ptrInfo.size) { | 707 | switch (ptrInfo.size) { |
| 709 | .One => { | 708 | .one => { |
| 710 | const r: *ptrInfo.child = try allocator.create(ptrInfo.child); | 709 | const r: *ptrInfo.child = try allocator.create(ptrInfo.child); |
| 711 | r.* = try innerParseFromValue(ptrInfo.child, allocator, source, options); | 710 | r.* = try innerParseFromValue(ptrInfo.child, allocator, source, options); |
| 712 | return r; | 711 | return r; |
| 713 | }, | 712 | }, |
| 714 | .Slice => { | 713 | .slice => { |
| 715 | switch (source) { | 714 | switch (source) { |
| 716 | .array => |array| { | 715 | .array => |array| { |
| 717 | const r = if (ptrInfo.sentinel) |sentinel_ptr| | 716 | const r = if (ptrInfo.sentinel()) |sentinel| |
| 718 | try allocator.allocSentinel(ptrInfo.child, array.items.len, @as(*align(1) const ptrInfo.child, @ptrCast(sentinel_ptr)).*) | 717 | try allocator.allocSentinel(ptrInfo.child, array.items.len, sentinel) |
| 719 | else | 718 | else |
| 720 | try allocator.alloc(ptrInfo.child, array.items.len); | 719 | try allocator.alloc(ptrInfo.child, array.items.len); |
| 721 | 720 | ||
| ... | @@ -729,8 +728,8 @@ pub fn innerParseFromValue( | ... | @@ -729,8 +728,8 @@ pub fn innerParseFromValue( |
| 729 | if (ptrInfo.child != u8) return error.UnexpectedToken; | 728 | if (ptrInfo.child != u8) return error.UnexpectedToken; |
| 730 | // Dynamic length string. | 729 | // Dynamic length string. |
| 731 | 730 | ||
| 732 | const r = if (ptrInfo.sentinel) |sentinel_ptr| | 731 | const r = if (ptrInfo.sentinel()) |sentinel| |
| 733 | try allocator.allocSentinel(ptrInfo.child, s.len, @as(*align(1) const ptrInfo.child, @ptrCast(sentinel_ptr)).*) | 732 | try allocator.allocSentinel(ptrInfo.child, s.len, sentinel) |
| 734 | else | 733 | else |
| 735 | try allocator.alloc(ptrInfo.child, s.len); | 734 | try allocator.alloc(ptrInfo.child, s.len); |
| 736 | @memcpy(r[0..], s); | 735 | @memcpy(r[0..], s); |
| ... | @@ -787,8 +786,7 @@ fn sliceToEnum(comptime T: type, slice: []const u8) !T { | ... | @@ -787,8 +786,7 @@ fn sliceToEnum(comptime T: type, slice: []const u8) !T { |
| 787 | fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).@"struct".fields.len]bool) !void { | 786 | fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).@"struct".fields.len]bool) !void { |
| 788 | inline for (@typeInfo(T).@"struct".fields, 0..) |field, i| { | 787 | inline for (@typeInfo(T).@"struct".fields, 0..) |field, i| { |
| 789 | if (!fields_seen[i]) { | 788 | if (!fields_seen[i]) { |
| 790 | if (field.default_value) |default_ptr| { | 789 | if (field.defaultValue()) |default| { |
| 791 | const default = @as(*align(1) const field.type, @ptrCast(default_ptr)).*; | ||
| 792 | @field(r, field.name) = default; | 790 | @field(r, field.name) = default; |
| 793 | } else { | 791 | } else { |
| 794 | return error.MissingField; | 792 | return error.MissingField; |
lib/std/json/stringify.zig+4-4| ... | @@ -631,7 +631,7 @@ pub fn WriteStream( | ... | @@ -631,7 +631,7 @@ pub fn WriteStream( |
| 631 | }, | 631 | }, |
| 632 | .error_set => return self.stringValue(@errorName(value)), | 632 | .error_set => return self.stringValue(@errorName(value)), |
| 633 | .pointer => |ptr_info| switch (ptr_info.size) { | 633 | .pointer => |ptr_info| switch (ptr_info.size) { |
| 634 | .One => switch (@typeInfo(ptr_info.child)) { | 634 | .one => switch (@typeInfo(ptr_info.child)) { |
| 635 | .array => { | 635 | .array => { |
| 636 | // Coerce `*[N]T` to `[]const T`. | 636 | // Coerce `*[N]T` to `[]const T`. |
| 637 | const Slice = []const std.meta.Elem(ptr_info.child); | 637 | const Slice = []const std.meta.Elem(ptr_info.child); |
| ... | @@ -641,10 +641,10 @@ pub fn WriteStream( | ... | @@ -641,10 +641,10 @@ pub fn WriteStream( |
| 641 | return self.write(value.*); | 641 | return self.write(value.*); |
| 642 | }, | 642 | }, |
| 643 | }, | 643 | }, |
| 644 | .Many, .Slice => { | 644 | .many, .slice => { |
| 645 | if (ptr_info.size == .Many and ptr_info.sentinel == null) | 645 | if (ptr_info.size == .many and ptr_info.sentinel() == null) |
| 646 | @compileError("unable to stringify type '" ++ @typeName(T) ++ "' without sentinel"); | 646 | @compileError("unable to stringify type '" ++ @typeName(T) ++ "' without sentinel"); |
| 647 | const slice = if (ptr_info.size == .Many) std.mem.span(value) else value; | 647 | const slice = if (ptr_info.size == .many) std.mem.span(value) else value; |
| 648 | 648 | ||
| 649 | if (ptr_info.child == u8) { | 649 | if (ptr_info.child == u8) { |
| 650 | // This is a []const u8, or some similar Zig string. | 650 | // This is a []const u8, or some similar Zig string. |
lib/std/mem.zig+60-73| ... | @@ -262,9 +262,9 @@ pub fn zeroes(comptime T: type) T { | ... | @@ -262,9 +262,9 @@ pub fn zeroes(comptime T: type) T { |
| 262 | }, | 262 | }, |
| 263 | .pointer => |ptr_info| { | 263 | .pointer => |ptr_info| { |
| 264 | switch (ptr_info.size) { | 264 | switch (ptr_info.size) { |
| 265 | .Slice => { | 265 | .slice => { |
| 266 | if (ptr_info.sentinel) |sentinel| { | 266 | if (ptr_info.sentinel()) |sentinel| { |
| 267 | if (ptr_info.child == u8 and @as(*const u8, @ptrCast(sentinel)).* == 0) { | 267 | if (ptr_info.child == u8 and sentinel == 0) { |
| 268 | return ""; // A special case for the most common use-case: null-terminated strings. | 268 | return ""; // A special case for the most common use-case: null-terminated strings. |
| 269 | } | 269 | } |
| 270 | @compileError("Can't set a sentinel slice to zero. This would require allocating memory."); | 270 | @compileError("Can't set a sentinel slice to zero. This would require allocating memory."); |
| ... | @@ -272,21 +272,17 @@ pub fn zeroes(comptime T: type) T { | ... | @@ -272,21 +272,17 @@ pub fn zeroes(comptime T: type) T { |
| 272 | return &[_]ptr_info.child{}; | 272 | return &[_]ptr_info.child{}; |
| 273 | } | 273 | } |
| 274 | }, | 274 | }, |
| 275 | .C => { | 275 | .c => { |
| 276 | return null; | 276 | return null; |
| 277 | }, | 277 | }, |
| 278 | .One, .Many => { | 278 | .one, .many => { |
| 279 | if (ptr_info.is_allowzero) return @ptrFromInt(0); | 279 | if (ptr_info.is_allowzero) return @ptrFromInt(0); |
| 280 | @compileError("Only nullable and allowzero pointers can be set to zero."); | 280 | @compileError("Only nullable and allowzero pointers can be set to zero."); |
| 281 | }, | 281 | }, |
| 282 | } | 282 | } |
| 283 | }, | 283 | }, |
| 284 | .array => |info| { | 284 | .array => |info| { |
| 285 | if (info.sentinel) |sentinel_ptr| { | 285 | return @splat(zeroes(info.child)); |
| 286 | const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; | ||
| 287 | return [_:sentinel]info.child{zeroes(info.child)} ** info.len; | ||
| 288 | } | ||
| 289 | return [_]info.child{zeroes(info.child)} ** info.len; | ||
| 290 | }, | 286 | }, |
| 291 | .vector => |info| { | 287 | .vector => |info| { |
| 292 | return @splat(zeroes(info.child)); | 288 | return @splat(zeroes(info.child)); |
| ... | @@ -456,9 +452,8 @@ pub fn zeroInit(comptime T: type, init: anytype) T { | ... | @@ -456,9 +452,8 @@ pub fn zeroInit(comptime T: type, init: anytype) T { |
| 456 | @field(value, field.name) = @field(init, field.name); | 452 | @field(value, field.name) = @field(init, field.name); |
| 457 | }, | 453 | }, |
| 458 | } | 454 | } |
| 459 | } else if (field.default_value) |default_value_ptr| { | 455 | } else if (field.defaultValue()) |val| { |
| 460 | const default_value = @as(*align(1) const field.type, @ptrCast(default_value_ptr)).*; | 456 | @field(value, field.name) = val; |
| 461 | @field(value, field.name) = default_value; | ||
| 462 | } else { | 457 | } else { |
| 463 | switch (@typeInfo(field.type)) { | 458 | switch (@typeInfo(field.type)) { |
| 464 | .@"struct" => { | 459 | .@"struct" => { |
| ... | @@ -781,14 +776,14 @@ fn Span(comptime T: type) type { | ... | @@ -781,14 +776,14 @@ fn Span(comptime T: type) type { |
| 781 | .pointer => |ptr_info| { | 776 | .pointer => |ptr_info| { |
| 782 | var new_ptr_info = ptr_info; | 777 | var new_ptr_info = ptr_info; |
| 783 | switch (ptr_info.size) { | 778 | switch (ptr_info.size) { |
| 784 | .C => { | 779 | .c => { |
| 785 | new_ptr_info.sentinel = &@as(ptr_info.child, 0); | 780 | new_ptr_info.sentinel_ptr = &@as(ptr_info.child, 0); |
| 786 | new_ptr_info.is_allowzero = false; | 781 | new_ptr_info.is_allowzero = false; |
| 787 | }, | 782 | }, |
| 788 | .Many => if (ptr_info.sentinel == null) @compileError("invalid type given to std.mem.span: " ++ @typeName(T)), | 783 | .many => if (ptr_info.sentinel() == null) @compileError("invalid type given to std.mem.span: " ++ @typeName(T)), |
| 789 | .One, .Slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)), | 784 | .one, .slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)), |
| 790 | } | 785 | } |
| 791 | new_ptr_info.size = .Slice; | 786 | new_ptr_info.size = .slice; |
| 792 | return @Type(.{ .pointer = new_ptr_info }); | 787 | return @Type(.{ .pointer = new_ptr_info }); |
| 793 | }, | 788 | }, |
| 794 | else => {}, | 789 | else => {}, |
| ... | @@ -822,8 +817,7 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) { | ... | @@ -822,8 +817,7 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) { |
| 822 | const Result = Span(@TypeOf(ptr)); | 817 | const Result = Span(@TypeOf(ptr)); |
| 823 | const l = len(ptr); | 818 | const l = len(ptr); |
| 824 | const ptr_info = @typeInfo(Result).pointer; | 819 | const ptr_info = @typeInfo(Result).pointer; |
| 825 | if (ptr_info.sentinel) |s_ptr| { | 820 | if (ptr_info.sentinel()) |s| { |
| 826 | const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*; | ||
| 827 | return ptr[0..l :s]; | 821 | return ptr[0..l :s]; |
| 828 | } else { | 822 | } else { |
| 829 | return ptr[0..l]; | 823 | return ptr[0..l]; |
| ... | @@ -845,40 +839,38 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type { | ... | @@ -845,40 +839,38 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type { |
| 845 | }, | 839 | }, |
| 846 | .pointer => |ptr_info| { | 840 | .pointer => |ptr_info| { |
| 847 | var new_ptr_info = ptr_info; | 841 | var new_ptr_info = ptr_info; |
| 848 | new_ptr_info.size = .Slice; | 842 | new_ptr_info.size = .slice; |
| 849 | switch (ptr_info.size) { | 843 | switch (ptr_info.size) { |
| 850 | .One => switch (@typeInfo(ptr_info.child)) { | 844 | .one => switch (@typeInfo(ptr_info.child)) { |
| 851 | .array => |array_info| { | 845 | .array => |array_info| { |
| 852 | new_ptr_info.child = array_info.child; | 846 | new_ptr_info.child = array_info.child; |
| 853 | // The return type must only be sentinel terminated if we are guaranteed | 847 | // The return type must only be sentinel terminated if we are guaranteed |
| 854 | // to find the value searched for, which is only the case if it matches | 848 | // to find the value searched for, which is only the case if it matches |
| 855 | // the sentinel of the type passed. | 849 | // the sentinel of the type passed. |
| 856 | if (array_info.sentinel) |sentinel_ptr| { | 850 | if (array_info.sentinel()) |s| { |
| 857 | const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; | 851 | if (end == s) { |
| 858 | if (end == sentinel) { | 852 | new_ptr_info.sentinel_ptr = &end; |
| 859 | new_ptr_info.sentinel = &end; | ||
| 860 | } else { | 853 | } else { |
| 861 | new_ptr_info.sentinel = null; | 854 | new_ptr_info.sentinel_ptr = null; |
| 862 | } | 855 | } |
| 863 | } | 856 | } |
| 864 | }, | 857 | }, |
| 865 | else => {}, | 858 | else => {}, |
| 866 | }, | 859 | }, |
| 867 | .Many, .Slice => { | 860 | .many, .slice => { |
| 868 | // The return type must only be sentinel terminated if we are guaranteed | 861 | // The return type must only be sentinel terminated if we are guaranteed |
| 869 | // to find the value searched for, which is only the case if it matches | 862 | // to find the value searched for, which is only the case if it matches |
| 870 | // the sentinel of the type passed. | 863 | // the sentinel of the type passed. |
| 871 | if (ptr_info.sentinel) |sentinel_ptr| { | 864 | if (ptr_info.sentinel()) |s| { |
| 872 | const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*; | 865 | if (end == s) { |
| 873 | if (end == sentinel) { | 866 | new_ptr_info.sentinel_ptr = &end; |
| 874 | new_ptr_info.sentinel = &end; | ||
| 875 | } else { | 867 | } else { |
| 876 | new_ptr_info.sentinel = null; | 868 | new_ptr_info.sentinel_ptr = null; |
| 877 | } | 869 | } |
| 878 | } | 870 | } |
| 879 | }, | 871 | }, |
| 880 | .C => { | 872 | .c => { |
| 881 | new_ptr_info.sentinel = &end; | 873 | new_ptr_info.sentinel_ptr = &end; |
| 882 | // C pointers are always allowzero, but we don't want the return type to be. | 874 | // C pointers are always allowzero, but we don't want the return type to be. |
| 883 | assert(new_ptr_info.is_allowzero); | 875 | assert(new_ptr_info.is_allowzero); |
| 884 | new_ptr_info.is_allowzero = false; | 876 | new_ptr_info.is_allowzero = false; |
| ... | @@ -906,8 +898,7 @@ pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo( | ... | @@ -906,8 +898,7 @@ pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo( |
| 906 | const Result = SliceTo(@TypeOf(ptr), end); | 898 | const Result = SliceTo(@TypeOf(ptr), end); |
| 907 | const length = lenSliceTo(ptr, end); | 899 | const length = lenSliceTo(ptr, end); |
| 908 | const ptr_info = @typeInfo(Result).pointer; | 900 | const ptr_info = @typeInfo(Result).pointer; |
| 909 | if (ptr_info.sentinel) |s_ptr| { | 901 | if (ptr_info.sentinel()) |s| { |
| 910 | const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*; | ||
| 911 | return ptr[0..length :s]; | 902 | return ptr[0..length :s]; |
| 912 | } else { | 903 | } else { |
| 913 | return ptr[0..length]; | 904 | return ptr[0..length]; |
| ... | @@ -957,11 +948,10 @@ test sliceTo { | ... | @@ -957,11 +948,10 @@ test sliceTo { |
| 957 | fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize { | 948 | fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize { |
| 958 | switch (@typeInfo(@TypeOf(ptr))) { | 949 | switch (@typeInfo(@TypeOf(ptr))) { |
| 959 | .pointer => |ptr_info| switch (ptr_info.size) { | 950 | .pointer => |ptr_info| switch (ptr_info.size) { |
| 960 | .One => switch (@typeInfo(ptr_info.child)) { | 951 | .one => switch (@typeInfo(ptr_info.child)) { |
| 961 | .array => |array_info| { | 952 | .array => |array_info| { |
| 962 | if (array_info.sentinel) |sentinel_ptr| { | 953 | if (array_info.sentinel()) |s| { |
| 963 | const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; | 954 | if (s == end) { |
| 964 | if (sentinel == end) { | ||
| 965 | return indexOfSentinel(array_info.child, end, ptr); | 955 | return indexOfSentinel(array_info.child, end, ptr); |
| 966 | } | 956 | } |
| 967 | } | 957 | } |
| ... | @@ -969,27 +959,25 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize { | ... | @@ -969,27 +959,25 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize { |
| 969 | }, | 959 | }, |
| 970 | else => {}, | 960 | else => {}, |
| 971 | }, | 961 | }, |
| 972 | .Many => if (ptr_info.sentinel) |sentinel_ptr| { | 962 | .many => if (ptr_info.sentinel()) |s| { |
| 973 | const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*; | 963 | if (s == end) { |
| 974 | if (sentinel == end) { | ||
| 975 | return indexOfSentinel(ptr_info.child, end, ptr); | 964 | return indexOfSentinel(ptr_info.child, end, ptr); |
| 976 | } | 965 | } |
| 977 | // We're looking for something other than the sentinel, | 966 | // We're looking for something other than the sentinel, |
| 978 | // but iterating past the sentinel would be a bug so we need | 967 | // but iterating past the sentinel would be a bug so we need |
| 979 | // to check for both. | 968 | // to check for both. |
| 980 | var i: usize = 0; | 969 | var i: usize = 0; |
| 981 | while (ptr[i] != end and ptr[i] != sentinel) i += 1; | 970 | while (ptr[i] != end and ptr[i] != s) i += 1; |
| 982 | return i; | 971 | return i; |
| 983 | }, | 972 | }, |
| 984 | .C => { | 973 | .c => { |
| 985 | assert(ptr != null); | 974 | assert(ptr != null); |
| 986 | return indexOfSentinel(ptr_info.child, end, ptr); | 975 | return indexOfSentinel(ptr_info.child, end, ptr); |
| 987 | }, | 976 | }, |
| 988 | .Slice => { | 977 | .slice => { |
| 989 | if (ptr_info.sentinel) |sentinel_ptr| { | 978 | if (ptr_info.sentinel()) |s| { |
| 990 | const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*; | 979 | if (s == end) { |
| 991 | if (sentinel == end) { | 980 | return indexOfSentinel(ptr_info.child, s, ptr); |
| 992 | return indexOfSentinel(ptr_info.child, sentinel, ptr); | ||
| 993 | } | 981 | } |
| 994 | } | 982 | } |
| 995 | return indexOfScalar(ptr_info.child, ptr, end) orelse ptr.len; | 983 | return indexOfScalar(ptr_info.child, ptr, end) orelse ptr.len; |
| ... | @@ -1039,13 +1027,12 @@ test lenSliceTo { | ... | @@ -1039,13 +1027,12 @@ test lenSliceTo { |
| 1039 | pub fn len(value: anytype) usize { | 1027 | pub fn len(value: anytype) usize { |
| 1040 | switch (@typeInfo(@TypeOf(value))) { | 1028 | switch (@typeInfo(@TypeOf(value))) { |
| 1041 | .pointer => |info| switch (info.size) { | 1029 | .pointer => |info| switch (info.size) { |
| 1042 | .Many => { | 1030 | .many => { |
| 1043 | const sentinel_ptr = info.sentinel orelse | 1031 | const sentinel = info.sentinel() orelse |
| 1044 | @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value))); | 1032 | @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value))); |
| 1045 | const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; | ||
| 1046 | return indexOfSentinel(info.child, sentinel, value); | 1033 | return indexOfSentinel(info.child, sentinel, value); |
| 1047 | }, | 1034 | }, |
| 1048 | .C => { | 1035 | .c => { |
| 1049 | assert(value != null); | 1036 | assert(value != null); |
| 1050 | return indexOfSentinel(info.child, 0, value); | 1037 | return indexOfSentinel(info.child, 0, value); |
| 1051 | }, | 1038 | }, |
| ... | @@ -3582,19 +3569,19 @@ fn ReverseIterator(comptime T: type) type { | ... | @@ -3582,19 +3569,19 @@ fn ReverseIterator(comptime T: type) type { |
| 3582 | const Pointer = blk: { | 3569 | const Pointer = blk: { |
| 3583 | switch (@typeInfo(T)) { | 3570 | switch (@typeInfo(T)) { |
| 3584 | .pointer => |ptr_info| switch (ptr_info.size) { | 3571 | .pointer => |ptr_info| switch (ptr_info.size) { |
| 3585 | .One => switch (@typeInfo(ptr_info.child)) { | 3572 | .one => switch (@typeInfo(ptr_info.child)) { |
| 3586 | .array => |array_info| { | 3573 | .array => |array_info| { |
| 3587 | var new_ptr_info = ptr_info; | 3574 | var new_ptr_info = ptr_info; |
| 3588 | new_ptr_info.size = .Many; | 3575 | new_ptr_info.size = .many; |
| 3589 | new_ptr_info.child = array_info.child; | 3576 | new_ptr_info.child = array_info.child; |
| 3590 | new_ptr_info.sentinel = array_info.sentinel; | 3577 | new_ptr_info.sentinel_ptr = array_info.sentinel_ptr; |
| 3591 | break :blk @Type(.{ .pointer = new_ptr_info }); | 3578 | break :blk @Type(.{ .pointer = new_ptr_info }); |
| 3592 | }, | 3579 | }, |
| 3593 | else => {}, | 3580 | else => {}, |
| 3594 | }, | 3581 | }, |
| 3595 | .Slice => { | 3582 | .slice => { |
| 3596 | var new_ptr_info = ptr_info; | 3583 | var new_ptr_info = ptr_info; |
| 3597 | new_ptr_info.size = .Many; | 3584 | new_ptr_info.size = .many; |
| 3598 | break :blk @Type(.{ .pointer = new_ptr_info }); | 3585 | break :blk @Type(.{ .pointer = new_ptr_info }); |
| 3599 | }, | 3586 | }, |
| 3600 | else => {}, | 3587 | else => {}, |
| ... | @@ -3606,9 +3593,9 @@ fn ReverseIterator(comptime T: type) type { | ... | @@ -3606,9 +3593,9 @@ fn ReverseIterator(comptime T: type) type { |
| 3606 | const Element = std.meta.Elem(Pointer); | 3593 | const Element = std.meta.Elem(Pointer); |
| 3607 | const ElementPointer = @Type(.{ .pointer = ptr: { | 3594 | const ElementPointer = @Type(.{ .pointer = ptr: { |
| 3608 | var ptr = @typeInfo(Pointer).pointer; | 3595 | var ptr = @typeInfo(Pointer).pointer; |
| 3609 | ptr.size = .One; | 3596 | ptr.size = .one; |
| 3610 | ptr.child = Element; | 3597 | ptr.child = Element; |
| 3611 | ptr.sentinel = null; | 3598 | ptr.sentinel_ptr = null; |
| 3612 | break :ptr ptr; | 3599 | break :ptr ptr; |
| 3613 | } }); | 3600 | } }); |
| 3614 | return struct { | 3601 | return struct { |
| ... | @@ -3912,7 +3899,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize { | ... | @@ -3912,7 +3899,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize { |
| 3912 | 3899 | ||
| 3913 | const T = @TypeOf(ptr); | 3900 | const T = @TypeOf(ptr); |
| 3914 | const info = @typeInfo(T); | 3901 | const info = @typeInfo(T); |
| 3915 | if (info != .pointer or info.pointer.size != .Many) | 3902 | if (info != .pointer or info.pointer.size != .many) |
| 3916 | @compileError("expected many item pointer, got " ++ @typeName(T)); | 3903 | @compileError("expected many item pointer, got " ++ @typeName(T)); |
| 3917 | 3904 | ||
| 3918 | // Do nothing if the pointer is already well-aligned. | 3905 | // Do nothing if the pointer is already well-aligned. |
| ... | @@ -3979,16 +3966,16 @@ fn CopyPtrAttrs( | ... | @@ -3979,16 +3966,16 @@ fn CopyPtrAttrs( |
| 3979 | .alignment = info.alignment, | 3966 | .alignment = info.alignment, |
| 3980 | .address_space = info.address_space, | 3967 | .address_space = info.address_space, |
| 3981 | .child = child, | 3968 | .child = child, |
| 3982 | .sentinel = null, | 3969 | .sentinel_ptr = null, |
| 3983 | }, | 3970 | }, |
| 3984 | }); | 3971 | }); |
| 3985 | } | 3972 | } |
| 3986 | 3973 | ||
| 3987 | fn AsBytesReturnType(comptime P: type) type { | 3974 | fn AsBytesReturnType(comptime P: type) type { |
| 3988 | const pointer = @typeInfo(P).pointer; | 3975 | const pointer = @typeInfo(P).pointer; |
| 3989 | assert(pointer.size == .One); | 3976 | assert(pointer.size == .one); |
| 3990 | const size = @sizeOf(pointer.child); | 3977 | const size = @sizeOf(pointer.child); |
| 3991 | return CopyPtrAttrs(P, .One, [size]u8); | 3978 | return CopyPtrAttrs(P, .one, [size]u8); |
| 3992 | } | 3979 | } |
| 3993 | 3980 | ||
| 3994 | /// Given a pointer to a single item, returns a slice of the underlying bytes, preserving pointer attributes. | 3981 | /// Given a pointer to a single item, returns a slice of the underlying bytes, preserving pointer attributes. |
| ... | @@ -4071,7 +4058,7 @@ test toBytes { | ... | @@ -4071,7 +4058,7 @@ test toBytes { |
| 4071 | } | 4058 | } |
| 4072 | 4059 | ||
| 4073 | fn BytesAsValueReturnType(comptime T: type, comptime B: type) type { | 4060 | fn BytesAsValueReturnType(comptime T: type, comptime B: type) type { |
| 4074 | return CopyPtrAttrs(B, .One, T); | 4061 | return CopyPtrAttrs(B, .one, T); |
| 4075 | } | 4062 | } |
| 4076 | 4063 | ||
| 4077 | /// Given a pointer to an array of bytes, returns a pointer to a value of the specified type | 4064 | /// Given a pointer to an array of bytes, returns a pointer to a value of the specified type |
| ... | @@ -4150,7 +4137,7 @@ test bytesToValue { | ... | @@ -4150,7 +4137,7 @@ test bytesToValue { |
| 4150 | } | 4137 | } |
| 4151 | 4138 | ||
| 4152 | fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type { | 4139 | fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type { |
| 4153 | return CopyPtrAttrs(bytesType, .Slice, T); | 4140 | return CopyPtrAttrs(bytesType, .slice, T); |
| 4154 | } | 4141 | } |
| 4155 | 4142 | ||
| 4156 | /// Given a slice of bytes, returns a slice of the specified type | 4143 | /// Given a slice of bytes, returns a slice of the specified type |
| ... | @@ -4162,7 +4149,7 @@ pub fn bytesAsSlice(comptime T: type, bytes: anytype) BytesAsSliceReturnType(T, | ... | @@ -4162,7 +4149,7 @@ pub fn bytesAsSlice(comptime T: type, bytes: anytype) BytesAsSliceReturnType(T, |
| 4162 | return &[0]T{}; | 4149 | return &[0]T{}; |
| 4163 | } | 4150 | } |
| 4164 | 4151 | ||
| 4165 | const cast_target = CopyPtrAttrs(@TypeOf(bytes), .Many, T); | 4152 | const cast_target = CopyPtrAttrs(@TypeOf(bytes), .many, T); |
| 4166 | 4153 | ||
| 4167 | return @as(cast_target, @ptrCast(bytes))[0..@divExact(bytes.len, @sizeOf(T))]; | 4154 | return @as(cast_target, @ptrCast(bytes))[0..@divExact(bytes.len, @sizeOf(T))]; |
| 4168 | } | 4155 | } |
| ... | @@ -4237,7 +4224,7 @@ test "bytesAsSlice preserves pointer attributes" { | ... | @@ -4237,7 +4224,7 @@ test "bytesAsSlice preserves pointer attributes" { |
| 4237 | } | 4224 | } |
| 4238 | 4225 | ||
| 4239 | fn SliceAsBytesReturnType(comptime Slice: type) type { | 4226 | fn SliceAsBytesReturnType(comptime Slice: type) type { |
| 4240 | return CopyPtrAttrs(Slice, .Slice, u8); | 4227 | return CopyPtrAttrs(Slice, .slice, u8); |
| 4241 | } | 4228 | } |
| 4242 | 4229 | ||
| 4243 | /// Given a slice, returns a slice of the underlying bytes, preserving pointer attributes. | 4230 | /// Given a slice, returns a slice of the underlying bytes, preserving pointer attributes. |
| ... | @@ -4251,7 +4238,7 @@ pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) { | ... | @@ -4251,7 +4238,7 @@ pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) { |
| 4251 | // it may be equal to zero and fail a null check | 4238 | // it may be equal to zero and fail a null check |
| 4252 | if (slice.len == 0 and std.meta.sentinel(Slice) == null) return &[0]u8{}; | 4239 | if (slice.len == 0 and std.meta.sentinel(Slice) == null) return &[0]u8{}; |
| 4253 | 4240 | ||
| 4254 | const cast_target = CopyPtrAttrs(Slice, .Many, u8); | 4241 | const cast_target = CopyPtrAttrs(Slice, .many, u8); |
| 4255 | 4242 | ||
| 4256 | return @as(cast_target, @ptrCast(slice))[0 .. slice.len * @sizeOf(std.meta.Elem(Slice))]; | 4243 | return @as(cast_target, @ptrCast(slice))[0 .. slice.len * @sizeOf(std.meta.Elem(Slice))]; |
| 4257 | } | 4244 | } |
| ... | @@ -4540,14 +4527,14 @@ fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) t | ... | @@ -4540,14 +4527,14 @@ fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) t |
| 4540 | const info = @typeInfo(AttributeSource).pointer; | 4527 | const info = @typeInfo(AttributeSource).pointer; |
| 4541 | return @Type(.{ | 4528 | return @Type(.{ |
| 4542 | .pointer = .{ | 4529 | .pointer = .{ |
| 4543 | .size = .Slice, | 4530 | .size = .slice, |
| 4544 | .is_const = info.is_const, | 4531 | .is_const = info.is_const, |
| 4545 | .is_volatile = info.is_volatile, | 4532 | .is_volatile = info.is_volatile, |
| 4546 | .is_allowzero = info.is_allowzero, | 4533 | .is_allowzero = info.is_allowzero, |
| 4547 | .alignment = new_alignment, | 4534 | .alignment = new_alignment, |
| 4548 | .address_space = info.address_space, | 4535 | .address_space = info.address_space, |
| 4549 | .child = info.child, | 4536 | .child = info.child, |
| 4550 | .sentinel = null, | 4537 | .sentinel_ptr = null, |
| 4551 | }, | 4538 | }, |
| 4552 | }); | 4539 | }); |
| 4553 | } | 4540 | } |
lib/std/mem/Allocator.zig+2-2| ... | @@ -110,7 +110,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T { | ... | @@ -110,7 +110,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T { |
| 110 | /// have the same address and alignment property. | 110 | /// have the same address and alignment property. |
| 111 | pub fn destroy(self: Allocator, ptr: anytype) void { | 111 | pub fn destroy(self: Allocator, ptr: anytype) void { |
| 112 | const info = @typeInfo(@TypeOf(ptr)).pointer; | 112 | const info = @typeInfo(@TypeOf(ptr)).pointer; |
| 113 | if (info.size != .One) @compileError("ptr must be a single item pointer"); | 113 | if (info.size != .one) @compileError("ptr must be a single item pointer"); |
| 114 | const T = info.child; | 114 | const T = info.child; |
| 115 | if (@sizeOf(T) == 0) return; | 115 | if (@sizeOf(T) == 0) return; |
| 116 | const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr))); | 116 | const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr))); |
| ... | @@ -307,7 +307,7 @@ pub fn reallocAdvanced( | ... | @@ -307,7 +307,7 @@ pub fn reallocAdvanced( |
| 307 | pub fn free(self: Allocator, memory: anytype) void { | 307 | pub fn free(self: Allocator, memory: anytype) void { |
| 308 | const Slice = @typeInfo(@TypeOf(memory)).pointer; | 308 | const Slice = @typeInfo(@TypeOf(memory)).pointer; |
| 309 | const bytes = mem.sliceAsBytes(memory); | 309 | const bytes = mem.sliceAsBytes(memory); |
| 310 | const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0; | 310 | const bytes_len = bytes.len + if (Slice.sentinel() != null) @sizeOf(Slice.child) else 0; |
| 311 | if (bytes_len == 0) return; | 311 | if (bytes_len == 0) return; |
| 312 | const non_const_ptr = @constCast(bytes.ptr); | 312 | const non_const_ptr = @constCast(bytes.ptr); |
| 313 | // TODO: https://github.com/ziglang/zig/issues/4298 | 313 | // TODO: https://github.com/ziglang/zig/issues/4298 |
lib/std/meta.zig+22-31| ... | @@ -103,12 +103,12 @@ pub fn Elem(comptime T: type) type { | ... | @@ -103,12 +103,12 @@ pub fn Elem(comptime T: type) type { |
| 103 | .array => |info| return info.child, | 103 | .array => |info| return info.child, |
| 104 | .vector => |info| return info.child, | 104 | .vector => |info| return info.child, |
| 105 | .pointer => |info| switch (info.size) { | 105 | .pointer => |info| switch (info.size) { |
| 106 | .One => switch (@typeInfo(info.child)) { | 106 | .one => switch (@typeInfo(info.child)) { |
| 107 | .array => |array_info| return array_info.child, | 107 | .array => |array_info| return array_info.child, |
| 108 | .vector => |vector_info| return vector_info.child, | 108 | .vector => |vector_info| return vector_info.child, |
| 109 | else => {}, | 109 | else => {}, |
| 110 | }, | 110 | }, |
| 111 | .Many, .C, .Slice => return info.child, | 111 | .many, .c, .slice => return info.child, |
| 112 | }, | 112 | }, |
| 113 | .optional => |info| return Elem(info.child), | 113 | .optional => |info| return Elem(info.child), |
| 114 | else => {}, | 114 | else => {}, |
| ... | @@ -132,21 +132,12 @@ test Elem { | ... | @@ -132,21 +132,12 @@ test Elem { |
| 132 | /// Result is always comptime-known. | 132 | /// Result is always comptime-known. |
| 133 | pub inline fn sentinel(comptime T: type) ?Elem(T) { | 133 | pub inline fn sentinel(comptime T: type) ?Elem(T) { |
| 134 | switch (@typeInfo(T)) { | 134 | switch (@typeInfo(T)) { |
| 135 | .array => |info| { | 135 | .array => |info| return info.sentinel(), |
| 136 | const sentinel_ptr = info.sentinel orelse return null; | ||
| 137 | return @as(*const info.child, @ptrCast(sentinel_ptr)).*; | ||
| 138 | }, | ||
| 139 | .pointer => |info| { | 136 | .pointer => |info| { |
| 140 | switch (info.size) { | 137 | switch (info.size) { |
| 141 | .Many, .Slice => { | 138 | .many, .slice => return info.sentinel(), |
| 142 | const sentinel_ptr = info.sentinel orelse return null; | 139 | .one => switch (@typeInfo(info.child)) { |
| 143 | return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; | 140 | .array => |array_info| return array_info.sentinel(), |
| 144 | }, | ||
| 145 | .One => switch (@typeInfo(info.child)) { | ||
| 146 | .array => |array_info| { | ||
| 147 | const sentinel_ptr = array_info.sentinel orelse return null; | ||
| 148 | return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; | ||
| 149 | }, | ||
| 150 | else => {}, | 141 | else => {}, |
| 151 | }, | 142 | }, |
| 152 | else => {}, | 143 | else => {}, |
| ... | @@ -178,7 +169,7 @@ fn testSentinel() !void { | ... | @@ -178,7 +169,7 @@ fn testSentinel() !void { |
| 178 | pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { | 169 | pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { |
| 179 | switch (@typeInfo(T)) { | 170 | switch (@typeInfo(T)) { |
| 180 | .pointer => |info| switch (info.size) { | 171 | .pointer => |info| switch (info.size) { |
| 181 | .One => switch (@typeInfo(info.child)) { | 172 | .one => switch (@typeInfo(info.child)) { |
| 182 | .array => |array_info| return @Type(.{ | 173 | .array => |array_info| return @Type(.{ |
| 183 | .pointer = .{ | 174 | .pointer = .{ |
| 184 | .size = info.size, | 175 | .size = info.size, |
| ... | @@ -190,16 +181,16 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { | ... | @@ -190,16 +181,16 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { |
| 190 | .array = .{ | 181 | .array = .{ |
| 191 | .len = array_info.len, | 182 | .len = array_info.len, |
| 192 | .child = array_info.child, | 183 | .child = array_info.child, |
| 193 | .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)), | 184 | .sentinel_ptr = @as(?*const anyopaque, @ptrCast(&sentinel_val)), |
| 194 | }, | 185 | }, |
| 195 | }), | 186 | }), |
| 196 | .is_allowzero = info.is_allowzero, | 187 | .is_allowzero = info.is_allowzero, |
| 197 | .sentinel = info.sentinel, | 188 | .sentinel_ptr = info.sentinel_ptr, |
| 198 | }, | 189 | }, |
| 199 | }), | 190 | }), |
| 200 | else => {}, | 191 | else => {}, |
| 201 | }, | 192 | }, |
| 202 | .Many, .Slice => return @Type(.{ | 193 | .many, .slice => return @Type(.{ |
| 203 | .pointer = .{ | 194 | .pointer = .{ |
| 204 | .size = info.size, | 195 | .size = info.size, |
| 205 | .is_const = info.is_const, | 196 | .is_const = info.is_const, |
| ... | @@ -208,14 +199,14 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { | ... | @@ -208,14 +199,14 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { |
| 208 | .address_space = info.address_space, | 199 | .address_space = info.address_space, |
| 209 | .child = info.child, | 200 | .child = info.child, |
| 210 | .is_allowzero = info.is_allowzero, | 201 | .is_allowzero = info.is_allowzero, |
| 211 | .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)), | 202 | .sentinel_ptr = @as(?*const anyopaque, @ptrCast(&sentinel_val)), |
| 212 | }, | 203 | }, |
| 213 | }), | 204 | }), |
| 214 | else => {}, | 205 | else => {}, |
| 215 | }, | 206 | }, |
| 216 | .optional => |info| switch (@typeInfo(info.child)) { | 207 | .optional => |info| switch (@typeInfo(info.child)) { |
| 217 | .pointer => |ptr_info| switch (ptr_info.size) { | 208 | .pointer => |ptr_info| switch (ptr_info.size) { |
| 218 | .Many => return @Type(.{ | 209 | .many => return @Type(.{ |
| 219 | .optional = .{ | 210 | .optional = .{ |
| 220 | .child = @Type(.{ | 211 | .child = @Type(.{ |
| 221 | .pointer = .{ | 212 | .pointer = .{ |
| ... | @@ -226,7 +217,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { | ... | @@ -226,7 +217,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { |
| 226 | .address_space = ptr_info.address_space, | 217 | .address_space = ptr_info.address_space, |
| 227 | .child = ptr_info.child, | 218 | .child = ptr_info.child, |
| 228 | .is_allowzero = ptr_info.is_allowzero, | 219 | .is_allowzero = ptr_info.is_allowzero, |
| 229 | .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)), | 220 | .sentinel_ptr = @as(?*const anyopaque, @ptrCast(&sentinel_val)), |
| 230 | }, | 221 | }, |
| 231 | }), | 222 | }), |
| 232 | }, | 223 | }, |
| ... | @@ -786,8 +777,8 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { | ... | @@ -786,8 +777,8 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { |
| 786 | }, | 777 | }, |
| 787 | .pointer => |info| { | 778 | .pointer => |info| { |
| 788 | return switch (info.size) { | 779 | return switch (info.size) { |
| 789 | .One, .Many, .C => a == b, | 780 | .one, .many, .c => a == b, |
| 790 | .Slice => a.ptr == b.ptr and a.len == b.len, | 781 | .slice => a.ptr == b.ptr and a.len == b.len, |
| 791 | }; | 782 | }; |
| 792 | }, | 783 | }, |
| 793 | .optional => { | 784 | .optional => { |
| ... | @@ -1018,7 +1009,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { | ... | @@ -1018,7 +1009,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { |
| 1018 | tuple_fields[i] = .{ | 1009 | tuple_fields[i] = .{ |
| 1019 | .name = std.fmt.bufPrintZ(&num_buf, "{d}", .{i}) catch unreachable, | 1010 | .name = std.fmt.bufPrintZ(&num_buf, "{d}", .{i}) catch unreachable, |
| 1020 | .type = T, | 1011 | .type = T, |
| 1021 | .default_value = null, | 1012 | .default_value_ptr = null, |
| 1022 | .is_comptime = false, | 1013 | .is_comptime = false, |
| 1023 | .alignment = 0, | 1014 | .alignment = 0, |
| 1024 | }; | 1015 | }; |
| ... | @@ -1090,7 +1081,7 @@ test "Tuple deduplication" { | ... | @@ -1090,7 +1081,7 @@ test "Tuple deduplication" { |
| 1090 | test "ArgsTuple forwarding" { | 1081 | test "ArgsTuple forwarding" { |
| 1091 | const T1 = std.meta.Tuple(&.{ u32, f32, i8 }); | 1082 | const T1 = std.meta.Tuple(&.{ u32, f32, i8 }); |
| 1092 | const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void); | 1083 | const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void); |
| 1093 | const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.C) noreturn); | 1084 | const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn); |
| 1094 | 1085 | ||
| 1095 | if (T1 != T2) { | 1086 | if (T1 != T2) { |
| 1096 | @compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple"); | 1087 | @compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple"); |
| ... | @@ -1144,8 +1135,8 @@ test hasFn { | ... | @@ -1144,8 +1135,8 @@ test hasFn { |
| 1144 | pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool { | 1135 | pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool { |
| 1145 | return switch (@typeInfo(T)) { | 1136 | return switch (@typeInfo(T)) { |
| 1146 | .pointer => |P| switch (P.size) { | 1137 | .pointer => |P| switch (P.size) { |
| 1147 | .One => hasFn(P.child, name), | 1138 | .one => hasFn(P.child, name), |
| 1148 | .Many, .Slice, .C => false, | 1139 | .many, .slice, .c => false, |
| 1149 | }, | 1140 | }, |
| 1150 | else => hasFn(T, name), | 1141 | else => hasFn(T, name), |
| 1151 | }; | 1142 | }; |
| ... | @@ -1200,12 +1191,12 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { | ... | @@ -1200,12 +1191,12 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { |
| 1200 | 1191 | ||
| 1201 | .int => |info| @sizeOf(T) * 8 == info.bits, | 1192 | .int => |info| @sizeOf(T) * 8 == info.bits, |
| 1202 | 1193 | ||
| 1203 | .pointer => |info| info.size != .Slice, | 1194 | .pointer => |info| info.size != .slice, |
| 1204 | 1195 | ||
| 1205 | .optional => |info| switch (@typeInfo(info.child)) { | 1196 | .optional => |info| switch (@typeInfo(info.child)) { |
| 1206 | .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) { | 1197 | .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) { |
| 1207 | .Slice, .C => false, | 1198 | .slice, .c => false, |
| 1208 | .One, .Many => true, | 1199 | .one, .many => true, |
| 1209 | }, | 1200 | }, |
| 1210 | else => false, | 1201 | else => false, |
| 1211 | }, | 1202 | }, |
lib/std/meta/trailer_flags.zig+1-1| ... | @@ -25,7 +25,7 @@ pub fn TrailerFlags(comptime Fields: type) type { | ... | @@ -25,7 +25,7 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 25 | fields[i] = Type.StructField{ | 25 | fields[i] = Type.StructField{ |
| 26 | .name = struct_field.name, | 26 | .name = struct_field.name, |
| 27 | .type = ?struct_field.type, | 27 | .type = ?struct_field.type, |
| 28 | .default_value = &@as(?struct_field.type, null), | 28 | .default_value_ptr = &@as(?struct_field.type, null), |
| 29 | .is_comptime = false, | 29 | .is_comptime = false, |
| 30 | .alignment = @alignOf(?struct_field.type), | 30 | .alignment = @alignOf(?struct_field.type), |
| 31 | }; | 31 | }; |
lib/std/multi_array_list.zig+1-1| ... | @@ -571,7 +571,7 @@ pub fn MultiArrayList(comptime T: type) type { | ... | @@ -571,7 +571,7 @@ pub fn MultiArrayList(comptime T: type) type { |
| 571 | for (&entry_fields, sizes.fields) |*entry_field, i| entry_field.* = .{ | 571 | for (&entry_fields, sizes.fields) |*entry_field, i| entry_field.* = .{ |
| 572 | .name = fields[i].name ++ "_ptr", | 572 | .name = fields[i].name ++ "_ptr", |
| 573 | .type = *fields[i].type, | 573 | .type = *fields[i].type, |
| 574 | .default_value = null, | 574 | .default_value_ptr = null, |
| 575 | .is_comptime = fields[i].is_comptime, | 575 | .is_comptime = fields[i].is_comptime, |
| 576 | .alignment = fields[i].alignment, | 576 | .alignment = fields[i].alignment, |
| 577 | }; | 577 | }; |
lib/std/os/emscripten.zig+22-22| ... | @@ -12,7 +12,7 @@ const c = std.c; | ... | @@ -12,7 +12,7 @@ const c = std.c; |
| 12 | pub const FILE = c.FILE; | 12 | pub const FILE = c.FILE; |
| 13 | 13 | ||
| 14 | var __stack_chk_guard: usize = 0; | 14 | var __stack_chk_guard: usize = 0; |
| 15 | fn __stack_chk_fail() callconv(.C) void { | 15 | fn __stack_chk_fail() callconv(.c) void { |
| 16 | std.debug.print("stack smashing detected: terminated\n", .{}); | 16 | std.debug.print("stack smashing detected: terminated\n", .{}); |
| 17 | emscripten_force_exit(127); | 17 | emscripten_force_exit(127); |
| 18 | } | 18 | } |
| ... | @@ -547,8 +547,8 @@ pub const SIG = struct { | ... | @@ -547,8 +547,8 @@ pub const SIG = struct { |
| 547 | }; | 547 | }; |
| 548 | 548 | ||
| 549 | pub const Sigaction = extern struct { | 549 | pub const Sigaction = extern struct { |
| 550 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 550 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 551 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 551 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 552 | 552 | ||
| 553 | handler: extern union { | 553 | handler: extern union { |
| 554 | handler: ?handler_fn, | 554 | handler: ?handler_fn, |
| ... | @@ -556,7 +556,7 @@ pub const Sigaction = extern struct { | ... | @@ -556,7 +556,7 @@ pub const Sigaction = extern struct { |
| 556 | }, | 556 | }, |
| 557 | mask: sigset_t, | 557 | mask: sigset_t, |
| 558 | flags: c_uint, | 558 | flags: c_uint, |
| 559 | restorer: ?*const fn () callconv(.C) void = null, | 559 | restorer: ?*const fn () callconv(.c) void = null, |
| 560 | }; | 560 | }; |
| 561 | 561 | ||
| 562 | pub const sigset_t = [1024 / 32]u32; | 562 | pub const sigset_t = [1024 / 32]u32; |
| ... | @@ -909,23 +909,23 @@ pub const LOG = struct { | ... | @@ -909,23 +909,23 @@ pub const LOG = struct { |
| 909 | pub const INFO = 512; | 909 | pub const INFO = 512; |
| 910 | }; | 910 | }; |
| 911 | 911 | ||
| 912 | pub const em_callback_func = ?*const fn () callconv(.C) void; | 912 | pub const em_callback_func = ?*const fn () callconv(.c) void; |
| 913 | pub const em_arg_callback_func = ?*const fn (?*anyopaque) callconv(.C) void; | 913 | pub const em_arg_callback_func = ?*const fn (?*anyopaque) callconv(.c) void; |
| 914 | pub const em_str_callback_func = ?*const fn ([*:0]const u8) callconv(.C) void; | 914 | pub const em_str_callback_func = ?*const fn ([*:0]const u8) callconv(.c) void; |
| 915 | 915 | ||
| 916 | pub extern "c" fn emscripten_async_wget(url: [*:0]const u8, file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) void; | 916 | pub extern "c" fn emscripten_async_wget(url: [*:0]const u8, file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) void; |
| 917 | 917 | ||
| 918 | pub const em_async_wget_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void; | 918 | pub const em_async_wget_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void; |
| 919 | pub extern "c" fn emscripten_async_wget_data(url: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget_onload_func, onerror: em_arg_callback_func) void; | 919 | pub extern "c" fn emscripten_async_wget_data(url: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget_onload_func, onerror: em_arg_callback_func) void; |
| 920 | 920 | ||
| 921 | pub const em_async_wget2_onload_func = ?*const fn (c_uint, ?*anyopaque, [*:0]const u8) callconv(.C) void; | 921 | pub const em_async_wget2_onload_func = ?*const fn (c_uint, ?*anyopaque, [*:0]const u8) callconv(.c) void; |
| 922 | pub const em_async_wget2_onstatus_func = ?*const fn (c_uint, ?*anyopaque, c_int) callconv(.C) void; | 922 | pub const em_async_wget2_onstatus_func = ?*const fn (c_uint, ?*anyopaque, c_int) callconv(.c) void; |
| 923 | 923 | ||
| 924 | pub extern "c" fn emscripten_async_wget2(url: [*:0]const u8, file: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget2_onload_func, onerror: em_async_wget2_onstatus_func, onprogress: em_async_wget2_onstatus_func) c_int; | 924 | pub extern "c" fn emscripten_async_wget2(url: [*:0]const u8, file: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget2_onload_func, onerror: em_async_wget2_onstatus_func, onprogress: em_async_wget2_onstatus_func) c_int; |
| 925 | 925 | ||
| 926 | pub const em_async_wget2_data_onload_func = ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, c_uint) callconv(.C) void; | 926 | pub const em_async_wget2_data_onload_func = ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, c_uint) callconv(.c) void; |
| 927 | pub const em_async_wget2_data_onerror_func = ?*const fn (c_uint, ?*anyopaque, c_int, [*:0]const u8) callconv(.C) void; | 927 | pub const em_async_wget2_data_onerror_func = ?*const fn (c_uint, ?*anyopaque, c_int, [*:0]const u8) callconv(.c) void; |
| 928 | pub const em_async_wget2_data_onprogress_func = ?*const fn (c_uint, ?*anyopaque, c_int, c_int) callconv(.C) void; | 928 | pub const em_async_wget2_data_onprogress_func = ?*const fn (c_uint, ?*anyopaque, c_int, c_int) callconv(.c) void; |
| 929 | 929 | ||
| 930 | pub extern "c" fn emscripten_async_wget2_data(url: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, free: c_int, onload: em_async_wget2_data_onload_func, onerror: em_async_wget2_data_onerror_func, onprogress: em_async_wget2_data_onprogress_func) c_int; | 930 | pub extern "c" fn emscripten_async_wget2_data(url: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, free: c_int, onload: em_async_wget2_data_onload_func, onerror: em_async_wget2_data_onerror_func, onprogress: em_async_wget2_data_onprogress_func) c_int; |
| 931 | pub extern "c" fn emscripten_async_wget2_abort(handle: c_int) void; | 931 | pub extern "c" fn emscripten_async_wget2_abort(handle: c_int) void; |
| ... | @@ -944,8 +944,8 @@ pub extern "c" fn emscripten_pause_main_loop() void; | ... | @@ -944,8 +944,8 @@ pub extern "c" fn emscripten_pause_main_loop() void; |
| 944 | pub extern "c" fn emscripten_resume_main_loop() void; | 944 | pub extern "c" fn emscripten_resume_main_loop() void; |
| 945 | pub extern "c" fn emscripten_cancel_main_loop() void; | 945 | pub extern "c" fn emscripten_cancel_main_loop() void; |
| 946 | 946 | ||
| 947 | pub const em_socket_callback = ?*const fn (c_int, ?*anyopaque) callconv(.C) void; | 947 | pub const em_socket_callback = ?*const fn (c_int, ?*anyopaque) callconv(.c) void; |
| 948 | pub const em_socket_error_callback = ?*const fn (c_int, c_int, [*:0]const u8, ?*anyopaque) callconv(.C) void; | 948 | pub const em_socket_error_callback = ?*const fn (c_int, c_int, [*:0]const u8, ?*anyopaque) callconv(.c) void; |
| 949 | 949 | ||
| 950 | pub extern "c" fn emscripten_set_socket_error_callback(userData: ?*anyopaque, callback: em_socket_error_callback) void; | 950 | pub extern "c" fn emscripten_set_socket_error_callback(userData: ?*anyopaque, callback: em_socket_error_callback) void; |
| 951 | pub extern "c" fn emscripten_set_socket_open_callback(userData: ?*anyopaque, callback: em_socket_callback) void; | 951 | pub extern "c" fn emscripten_set_socket_open_callback(userData: ?*anyopaque, callback: em_socket_callback) void; |
| ... | @@ -968,11 +968,11 @@ pub extern "c" fn emscripten_set_canvas_size(width: c_int, height: c_int) void; | ... | @@ -968,11 +968,11 @@ pub extern "c" fn emscripten_set_canvas_size(width: c_int, height: c_int) void; |
| 968 | pub extern "c" fn emscripten_get_canvas_size(width: *c_int, height: *c_int, isFullscreen: *c_int) void; | 968 | pub extern "c" fn emscripten_get_canvas_size(width: *c_int, height: *c_int, isFullscreen: *c_int) void; |
| 969 | pub extern "c" fn emscripten_get_now() f64; | 969 | pub extern "c" fn emscripten_get_now() f64; |
| 970 | pub extern "c" fn emscripten_random() f32; | 970 | pub extern "c" fn emscripten_random() f32; |
| 971 | pub const em_idb_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void; | 971 | pub const em_idb_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void; |
| 972 | pub extern "c" fn emscripten_idb_async_load(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, onload: em_idb_onload_func, onerror: em_arg_callback_func) void; | 972 | pub extern "c" fn emscripten_idb_async_load(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, onload: em_idb_onload_func, onerror: em_arg_callback_func) void; |
| 973 | pub extern "c" fn emscripten_idb_async_store(db_name: [*:0]const u8, file_id: [*:0]const u8, ptr: ?*anyopaque, num: c_int, arg: ?*anyopaque, onstore: em_arg_callback_func, onerror: em_arg_callback_func) void; | 973 | pub extern "c" fn emscripten_idb_async_store(db_name: [*:0]const u8, file_id: [*:0]const u8, ptr: ?*anyopaque, num: c_int, arg: ?*anyopaque, onstore: em_arg_callback_func, onerror: em_arg_callback_func) void; |
| 974 | pub extern "c" fn emscripten_idb_async_delete(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, ondelete: em_arg_callback_func, onerror: em_arg_callback_func) void; | 974 | pub extern "c" fn emscripten_idb_async_delete(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, ondelete: em_arg_callback_func, onerror: em_arg_callback_func) void; |
| 975 | pub const em_idb_exists_func = ?*const fn (?*anyopaque, c_int) callconv(.C) void; | 975 | pub const em_idb_exists_func = ?*const fn (?*anyopaque, c_int) callconv(.c) void; |
| 976 | pub extern "c" fn emscripten_idb_async_exists(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, oncheck: em_idb_exists_func, onerror: em_arg_callback_func) void; | 976 | pub extern "c" fn emscripten_idb_async_exists(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, oncheck: em_idb_exists_func, onerror: em_arg_callback_func) void; |
| 977 | pub extern "c" fn emscripten_idb_load(db_name: [*:0]const u8, file_id: [*:0]const u8, pbuffer: *?*anyopaque, pnum: *c_int, perror: *c_int) void; | 977 | pub extern "c" fn emscripten_idb_load(db_name: [*:0]const u8, file_id: [*:0]const u8, pbuffer: *?*anyopaque, pnum: *c_int, perror: *c_int) void; |
| 978 | pub extern "c" fn emscripten_idb_store(db_name: [*:0]const u8, file_id: [*:0]const u8, buffer: *anyopaque, num: c_int, perror: *c_int) void; | 978 | pub extern "c" fn emscripten_idb_store(db_name: [*:0]const u8, file_id: [*:0]const u8, buffer: *anyopaque, num: c_int, perror: *c_int) void; |
| ... | @@ -983,13 +983,13 @@ pub extern "c" fn emscripten_idb_store_blob(db_name: [*:0]const u8, file_id: [*: | ... | @@ -983,13 +983,13 @@ pub extern "c" fn emscripten_idb_store_blob(db_name: [*:0]const u8, file_id: [*: |
| 983 | pub extern "c" fn emscripten_idb_read_from_blob(blob: c_int, start: c_int, num: c_int, buffer: ?*anyopaque) void; | 983 | pub extern "c" fn emscripten_idb_read_from_blob(blob: c_int, start: c_int, num: c_int, buffer: ?*anyopaque) void; |
| 984 | pub extern "c" fn emscripten_idb_free_blob(blob: c_int) void; | 984 | pub extern "c" fn emscripten_idb_free_blob(blob: c_int) void; |
| 985 | pub extern "c" fn emscripten_run_preload_plugins(file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) c_int; | 985 | pub extern "c" fn emscripten_run_preload_plugins(file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) c_int; |
| 986 | pub const em_run_preload_plugins_data_onload_func = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.C) void; | 986 | pub const em_run_preload_plugins_data_onload_func = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.c) void; |
| 987 | pub extern "c" fn emscripten_run_preload_plugins_data(data: [*]u8, size: c_int, suffix: [*:0]const u8, arg: ?*anyopaque, onload: em_run_preload_plugins_data_onload_func, onerror: em_arg_callback_func) void; | 987 | pub extern "c" fn emscripten_run_preload_plugins_data(data: [*]u8, size: c_int, suffix: [*:0]const u8, arg: ?*anyopaque, onload: em_run_preload_plugins_data_onload_func, onerror: em_arg_callback_func) void; |
| 988 | pub extern "c" fn emscripten_lazy_load_code() void; | 988 | pub extern "c" fn emscripten_lazy_load_code() void; |
| 989 | pub const worker_handle = c_int; | 989 | pub const worker_handle = c_int; |
| 990 | pub extern "c" fn emscripten_create_worker(url: [*:0]const u8) worker_handle; | 990 | pub extern "c" fn emscripten_create_worker(url: [*:0]const u8) worker_handle; |
| 991 | pub extern "c" fn emscripten_destroy_worker(worker: worker_handle) void; | 991 | pub extern "c" fn emscripten_destroy_worker(worker: worker_handle) void; |
| 992 | pub const em_worker_callback_func = ?*const fn ([*]u8, c_int, ?*anyopaque) callconv(.C) void; | 992 | pub const em_worker_callback_func = ?*const fn ([*]u8, c_int, ?*anyopaque) callconv(.c) void; |
| 993 | pub extern "c" fn emscripten_call_worker(worker: worker_handle, funcname: [*:0]const u8, data: [*]u8, size: c_int, callback: em_worker_callback_func, arg: ?*anyopaque) void; | 993 | pub extern "c" fn emscripten_call_worker(worker: worker_handle, funcname: [*:0]const u8, data: [*]u8, size: c_int, callback: em_worker_callback_func, arg: ?*anyopaque) void; |
| 994 | pub extern "c" fn emscripten_worker_respond(data: [*]u8, size: c_int) void; | 994 | pub extern "c" fn emscripten_worker_respond(data: [*]u8, size: c_int) void; |
| 995 | pub extern "c" fn emscripten_worker_respond_provisionally(data: [*]u8, size: c_int) void; | 995 | pub extern "c" fn emscripten_worker_respond_provisionally(data: [*]u8, size: c_int) void; |
| ... | @@ -1003,10 +1003,10 @@ pub extern "c" fn emscripten_get_preloaded_image_data_from_FILE(file: *FILE, w: | ... | @@ -1003,10 +1003,10 @@ pub extern "c" fn emscripten_get_preloaded_image_data_from_FILE(file: *FILE, w: |
| 1003 | pub extern "c" fn emscripten_log(flags: c_int, format: [*:0]const u8, ...) void; | 1003 | pub extern "c" fn emscripten_log(flags: c_int, format: [*:0]const u8, ...) void; |
| 1004 | pub extern "c" fn emscripten_get_callstack(flags: c_int, out: ?[*]u8, maxbytes: c_int) c_int; | 1004 | pub extern "c" fn emscripten_get_callstack(flags: c_int, out: ?[*]u8, maxbytes: c_int) c_int; |
| 1005 | pub extern "c" fn emscripten_print_double(x: f64, to: ?[*]u8, max: c_int) c_int; | 1005 | pub extern "c" fn emscripten_print_double(x: f64, to: ?[*]u8, max: c_int) c_int; |
| 1006 | pub const em_scan_func = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void; | 1006 | pub const em_scan_func = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.c) void; |
| 1007 | pub extern "c" fn emscripten_scan_registers(func: em_scan_func) void; | 1007 | pub extern "c" fn emscripten_scan_registers(func: em_scan_func) void; |
| 1008 | pub extern "c" fn emscripten_scan_stack(func: em_scan_func) void; | 1008 | pub extern "c" fn emscripten_scan_stack(func: em_scan_func) void; |
| 1009 | pub const em_dlopen_callback = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void; | 1009 | pub const em_dlopen_callback = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.c) void; |
| 1010 | pub extern "c" fn emscripten_dlopen(filename: [*:0]const u8, flags: c_int, user_data: ?*anyopaque, onsuccess: em_dlopen_callback, onerror: em_arg_callback_func) void; | 1010 | pub extern "c" fn emscripten_dlopen(filename: [*:0]const u8, flags: c_int, user_data: ?*anyopaque, onsuccess: em_dlopen_callback, onerror: em_arg_callback_func) void; |
| 1011 | pub extern "c" fn emscripten_dlopen_promise(filename: [*:0]const u8, flags: c_int) em_promise_t; | 1011 | pub extern "c" fn emscripten_dlopen_promise(filename: [*:0]const u8, flags: c_int) em_promise_t; |
| 1012 | pub extern "c" fn emscripten_throw_number(number: f64) void; | 1012 | pub extern "c" fn emscripten_throw_number(number: f64) void; |
| ... | @@ -1024,7 +1024,7 @@ pub const struct__em_promise = opaque {}; | ... | @@ -1024,7 +1024,7 @@ pub const struct__em_promise = opaque {}; |
| 1024 | pub const em_promise_t = ?*struct__em_promise; | 1024 | pub const em_promise_t = ?*struct__em_promise; |
| 1025 | pub const enum_em_promise_result_t = c_uint; | 1025 | pub const enum_em_promise_result_t = c_uint; |
| 1026 | pub const em_promise_result_t = enum_em_promise_result_t; | 1026 | pub const em_promise_result_t = enum_em_promise_result_t; |
| 1027 | pub const em_promise_callback_t = ?*const fn (?*?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.C) em_promise_result_t; | 1027 | pub const em_promise_callback_t = ?*const fn (?*?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.c) em_promise_result_t; |
| 1028 | 1028 | ||
| 1029 | pub extern "c" fn emscripten_promise_create() em_promise_t; | 1029 | pub extern "c" fn emscripten_promise_create() em_promise_t; |
| 1030 | pub extern "c" fn emscripten_promise_destroy(promise: em_promise_t) void; | 1030 | pub extern "c" fn emscripten_promise_destroy(promise: em_promise_t) void; |
lib/std/os/linux.zig+11-11| ... | @@ -67,7 +67,7 @@ pub const syscall_pipe = syscall_bits.syscall_pipe; | ... | @@ -67,7 +67,7 @@ pub const syscall_pipe = syscall_bits.syscall_pipe; |
| 67 | pub const syscall_fork = syscall_bits.syscall_fork; | 67 | pub const syscall_fork = syscall_bits.syscall_fork; |
| 68 | 68 | ||
| 69 | pub fn clone( | 69 | pub fn clone( |
| 70 | func: *const fn (arg: usize) callconv(.C) u8, | 70 | func: *const fn (arg: usize) callconv(.c) u8, |
| 71 | stack: usize, | 71 | stack: usize, |
| 72 | flags: u32, | 72 | flags: u32, |
| 73 | arg: usize, | 73 | arg: usize, |
| ... | @@ -77,14 +77,14 @@ pub fn clone( | ... | @@ -77,14 +77,14 @@ pub fn clone( |
| 77 | ) usize { | 77 | ) usize { |
| 78 | // Can't directly call a naked function; cast to C calling convention first. | 78 | // Can't directly call a naked function; cast to C calling convention first. |
| 79 | return @as(*const fn ( | 79 | return @as(*const fn ( |
| 80 | *const fn (arg: usize) callconv(.C) u8, | 80 | *const fn (arg: usize) callconv(.c) u8, |
| 81 | usize, | 81 | usize, |
| 82 | u32, | 82 | u32, |
| 83 | usize, | 83 | usize, |
| 84 | ?*i32, | 84 | ?*i32, |
| 85 | usize, | 85 | usize, |
| 86 | ?*i32, | 86 | ?*i32, |
| 87 | ) callconv(.C) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid); | 87 | ) callconv(.c) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | pub const ARCH = arch_bits.ARCH; | 90 | pub const ARCH = arch_bits.ARCH; |
| ... | @@ -494,7 +494,7 @@ pub const getauxval = if (extern_getauxval) struct { | ... | @@ -494,7 +494,7 @@ pub const getauxval = if (extern_getauxval) struct { |
| 494 | extern fn getauxval(index: usize) usize; | 494 | extern fn getauxval(index: usize) usize; |
| 495 | }.getauxval else getauxvalImpl; | 495 | }.getauxval else getauxvalImpl; |
| 496 | 496 | ||
| 497 | fn getauxvalImpl(index: usize) callconv(.C) usize { | 497 | fn getauxvalImpl(index: usize) callconv(.c) usize { |
| 498 | const auxv = elf_aux_maybe orelse return 0; | 498 | const auxv = elf_aux_maybe orelse return 0; |
| 499 | var i: usize = 0; | 499 | var i: usize = 0; |
| 500 | while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { | 500 | while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { |
| ... | @@ -1485,7 +1485,7 @@ pub fn flock(fd: fd_t, operation: i32) usize { | ... | @@ -1485,7 +1485,7 @@ pub fn flock(fd: fd_t, operation: i32) usize { |
| 1485 | } | 1485 | } |
| 1486 | 1486 | ||
| 1487 | // We must follow the C calling convention when we call into the VDSO | 1487 | // We must follow the C calling convention when we call into the VDSO |
| 1488 | const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C) usize; | 1488 | const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.c) usize; |
| 1489 | var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime; | 1489 | var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime; |
| 1490 | 1490 | ||
| 1491 | pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize { | 1491 | pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize { |
| ... | @@ -1502,7 +1502,7 @@ pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize { | ... | @@ -1502,7 +1502,7 @@ pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize { |
| 1502 | return syscall2(.clock_gettime, @intFromEnum(clk_id), @intFromPtr(tp)); | 1502 | return syscall2(.clock_gettime, @intFromEnum(clk_id), @intFromPtr(tp)); |
| 1503 | } | 1503 | } |
| 1504 | 1504 | ||
| 1505 | fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.C) usize { | 1505 | fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.c) usize { |
| 1506 | const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM)); | 1506 | const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM)); |
| 1507 | // Note that we may not have a VDSO at all, update the stub address anyway | 1507 | // Note that we may not have a VDSO at all, update the stub address anyway |
| 1508 | // so that clock_gettime will fall back on the good old (and slow) syscall | 1508 | // so that clock_gettime will fall back on the good old (and slow) syscall |
| ... | @@ -5070,8 +5070,8 @@ pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.l | ... | @@ -5070,8 +5070,8 @@ pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.l |
| 5070 | pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30; | 5070 | pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30; |
| 5071 | 5071 | ||
| 5072 | const k_sigaction_funcs = struct { | 5072 | const k_sigaction_funcs = struct { |
| 5073 | const handler = ?*align(1) const fn (i32) callconv(.C) void; | 5073 | const handler = ?*align(1) const fn (i32) callconv(.c) void; |
| 5074 | const restorer = *const fn () callconv(.C) void; | 5074 | const restorer = *const fn () callconv(.c) void; |
| 5075 | }; | 5075 | }; |
| 5076 | 5076 | ||
| 5077 | pub const k_sigaction = switch (native_arch) { | 5077 | pub const k_sigaction = switch (native_arch) { |
| ... | @@ -5097,8 +5097,8 @@ pub const k_sigaction = switch (native_arch) { | ... | @@ -5097,8 +5097,8 @@ pub const k_sigaction = switch (native_arch) { |
| 5097 | 5097 | ||
| 5098 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | 5098 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. |
| 5099 | pub const Sigaction = extern struct { | 5099 | pub const Sigaction = extern struct { |
| 5100 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 5100 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
| 5101 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 5101 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 5102 | 5102 | ||
| 5103 | handler: extern union { | 5103 | handler: extern union { |
| 5104 | handler: ?handler_fn, | 5104 | handler: ?handler_fn, |
| ... | @@ -5106,7 +5106,7 @@ pub const Sigaction = extern struct { | ... | @@ -5106,7 +5106,7 @@ pub const Sigaction = extern struct { |
| 5106 | }, | 5106 | }, |
| 5107 | mask: sigset_t, | 5107 | mask: sigset_t, |
| 5108 | flags: c_uint, | 5108 | flags: c_uint, |
| 5109 | restorer: ?*const fn () callconv(.C) void = null, | 5109 | restorer: ?*const fn () callconv(.c) void = null, |
| 5110 | }; | 5110 | }; |
| 5111 | 5111 | ||
| 5112 | const sigset_len = @typeInfo(sigset_t).array.len; | 5112 | const sigset_len = @typeInfo(sigset_t).array.len; |
lib/std/os/linux/sparc64.zig+1-1| ... | @@ -233,7 +233,7 @@ pub const restore = restore_rt; | ... | @@ -233,7 +233,7 @@ pub const restore = restore_rt; |
| 233 | 233 | ||
| 234 | // Need to use C ABI here instead of naked | 234 | // Need to use C ABI here instead of naked |
| 235 | // to prevent an infinite loop when calling rt_sigreturn. | 235 | // to prevent an infinite loop when calling rt_sigreturn. |
| 236 | pub fn restore_rt() callconv(.C) void { | 236 | pub fn restore_rt() callconv(.c) void { |
| 237 | return asm volatile ("t 0x6d" | 237 | return asm volatile ("t 0x6d" |
| 238 | : | 238 | : |
| 239 | : [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)), | 239 | : [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)), |
lib/std/os/plan9.zig+2-2| ... | @@ -186,8 +186,8 @@ pub const empty_sigset = 0; | ... | @@ -186,8 +186,8 @@ pub const empty_sigset = 0; |
| 186 | pub const siginfo_t = c_long; | 186 | pub const siginfo_t = c_long; |
| 187 | // TODO plan9 doesn't have sigaction_fn. Sigaction is not a union, but we include it here to be compatible. | 187 | // TODO plan9 doesn't have sigaction_fn. Sigaction is not a union, but we include it here to be compatible. |
| 188 | pub const Sigaction = extern struct { | 188 | pub const Sigaction = extern struct { |
| 189 | pub const handler_fn = *const fn (i32) callconv(.C) void; | 189 | pub const handler_fn = *const fn (i32) callconv(.c) void; |
| 190 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | 190 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 191 | 191 | ||
| 192 | handler: extern union { | 192 | handler: extern union { |
| 193 | handler: ?handler_fn, | 193 | handler: ?handler_fn, |
lib/std/os/uefi/tables/boot_services.zig+2-2| ... | @@ -149,11 +149,11 @@ pub const BootServices = extern struct { | ... | @@ -149,11 +149,11 @@ pub const BootServices = extern struct { |
| 149 | 149 | ||
| 150 | /// Installs one or more protocol interfaces into the boot services environment | 150 | /// Installs one or more protocol interfaces into the boot services environment |
| 151 | // TODO: use callconv(cc) instead once that works | 151 | // TODO: use callconv(cc) instead once that works |
| 152 | installMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.C) Status, | 152 | installMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.c) Status, |
| 153 | 153 | ||
| 154 | /// Removes one or more protocol interfaces into the boot services environment | 154 | /// Removes one or more protocol interfaces into the boot services environment |
| 155 | // TODO: use callconv(cc) instead once that works | 155 | // TODO: use callconv(cc) instead once that works |
| 156 | uninstallMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.C) Status, | 156 | uninstallMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.c) Status, |
| 157 | 157 | ||
| 158 | /// Computes and returns a 32-bit CRC for a data buffer. | 158 | /// Computes and returns a 32-bit CRC for a data buffer. |
| 159 | calculateCrc32: *const fn (data: [*]const u8, data_size: usize, *u32) callconv(cc) Status, | 159 | calculateCrc32: *const fn (data: [*]const u8, data_size: usize, *u32) callconv(cc) Status, |
lib/std/posix.zig+1-1| ... | @@ -5552,7 +5552,7 @@ pub fn dl_iterate_phdr( | ... | @@ -5552,7 +5552,7 @@ pub fn dl_iterate_phdr( |
| 5552 | 5552 | ||
| 5553 | if (builtin.link_libc) { | 5553 | if (builtin.link_libc) { |
| 5554 | switch (system.dl_iterate_phdr(struct { | 5554 | switch (system.dl_iterate_phdr(struct { |
| 5555 | fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int { | 5555 | fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int { |
| 5556 | const context_ptr: *const Context = @ptrCast(@alignCast(data)); | 5556 | const context_ptr: *const Context = @ptrCast(@alignCast(data)); |
| 5557 | callback(info, size, context_ptr.*) catch |err| return @intFromError(err); | 5557 | callback(info, size, context_ptr.*) catch |err| return @intFromError(err); |
| 5558 | return 0; | 5558 | return 0; |
lib/std/posix/test.zig+1-1| ... | @@ -849,7 +849,7 @@ test "sigaction" { | ... | @@ -849,7 +849,7 @@ test "sigaction" { |
| 849 | const S = struct { | 849 | const S = struct { |
| 850 | var handler_called_count: u32 = 0; | 850 | var handler_called_count: u32 = 0; |
| 851 | 851 | ||
| 852 | fn handler(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) void { | 852 | fn handler(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void { |
| 853 | _ = ctx_ptr; | 853 | _ = ctx_ptr; |
| 854 | // Check that we received the correct signal. | 854 | // Check that we received the correct signal. |
| 855 | switch (native_os) { | 855 | switch (native_os) { |
lib/std/testing.zig+5-5| ... | @@ -100,13 +100,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { | ... | @@ -100,13 +100,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { |
| 100 | 100 | ||
| 101 | .pointer => |pointer| { | 101 | .pointer => |pointer| { |
| 102 | switch (pointer.size) { | 102 | switch (pointer.size) { |
| 103 | .One, .Many, .C => { | 103 | .one, .many, .c => { |
| 104 | if (actual != expected) { | 104 | if (actual != expected) { |
| 105 | print("expected {*}, found {*}\n", .{ expected, actual }); | 105 | print("expected {*}, found {*}\n", .{ expected, actual }); |
| 106 | return error.TestExpectedEqual; | 106 | return error.TestExpectedEqual; |
| 107 | } | 107 | } |
| 108 | }, | 108 | }, |
| 109 | .Slice => { | 109 | .slice => { |
| 110 | if (actual.ptr != expected.ptr) { | 110 | if (actual.ptr != expected.ptr) { |
| 111 | print("expected slice ptr {*}, found {*}\n", .{ expected.ptr, actual.ptr }); | 111 | print("expected slice ptr {*}, found {*}\n", .{ expected.ptr, actual.ptr }); |
| 112 | return error.TestExpectedEqual; | 112 | return error.TestExpectedEqual; |
| ... | @@ -726,13 +726,13 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe | ... | @@ -726,13 +726,13 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 726 | .pointer => |pointer| { | 726 | .pointer => |pointer| { |
| 727 | switch (pointer.size) { | 727 | switch (pointer.size) { |
| 728 | // We have no idea what is behind those pointers, so the best we can do is `==` check. | 728 | // We have no idea what is behind those pointers, so the best we can do is `==` check. |
| 729 | .C, .Many => { | 729 | .c, .many => { |
| 730 | if (actual != expected) { | 730 | if (actual != expected) { |
| 731 | print("expected {*}, found {*}\n", .{ expected, actual }); | 731 | print("expected {*}, found {*}\n", .{ expected, actual }); |
| 732 | return error.TestExpectedEqual; | 732 | return error.TestExpectedEqual; |
| 733 | } | 733 | } |
| 734 | }, | 734 | }, |
| 735 | .One => { | 735 | .one => { |
| 736 | // Length of those pointers are runtime value, so the best we can do is `==` check. | 736 | // Length of those pointers are runtime value, so the best we can do is `==` check. |
| 737 | switch (@typeInfo(pointer.child)) { | 737 | switch (@typeInfo(pointer.child)) { |
| 738 | .@"fn", .@"opaque" => { | 738 | .@"fn", .@"opaque" => { |
| ... | @@ -744,7 +744,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe | ... | @@ -744,7 +744,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe |
| 744 | else => try expectEqualDeep(expected.*, actual.*), | 744 | else => try expectEqualDeep(expected.*, actual.*), |
| 745 | } | 745 | } |
| 746 | }, | 746 | }, |
| 747 | .Slice => { | 747 | .slice => { |
| 748 | if (expected.len != actual.len) { | 748 | if (expected.len != actual.len) { |
| 749 | print("Slice len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len }); | 749 | print("Slice len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len }); |
| 750 | return error.TestExpectedEqual; | 750 | return error.TestExpectedEqual; |
lib/std/zig/Ast.zig+5-6| ... | @@ -2157,14 +2157,13 @@ fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto | ... | @@ -2157,14 +2157,13 @@ fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto |
| 2157 | 2157 | ||
| 2158 | fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType { | 2158 | fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType { |
| 2159 | const token_tags = tree.tokens.items(.tag); | 2159 | const token_tags = tree.tokens.items(.tag); |
| 2160 | const Size = std.builtin.Type.Pointer.Size; | 2160 | const size: std.builtin.Type.Pointer.Size = switch (token_tags[info.main_token]) { |
| 2161 | const size: Size = switch (token_tags[info.main_token]) { | ||
| 2162 | .asterisk, | 2161 | .asterisk, |
| 2163 | .asterisk_asterisk, | 2162 | .asterisk_asterisk, |
| 2164 | => .One, | 2163 | => .one, |
| 2165 | .l_bracket => switch (token_tags[info.main_token + 1]) { | 2164 | .l_bracket => switch (token_tags[info.main_token + 1]) { |
| 2166 | .asterisk => if (token_tags[info.main_token + 2] == .identifier) Size.C else Size.Many, | 2165 | .asterisk => if (token_tags[info.main_token + 2] == .identifier) .c else .many, |
| 2167 | else => Size.Slice, | 2166 | else => .slice, |
| 2168 | }, | 2167 | }, |
| 2169 | else => unreachable, | 2168 | else => unreachable, |
| 2170 | }; | 2169 | }; |
| ... | @@ -2180,7 +2179,7 @@ fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType | ... | @@ -2180,7 +2179,7 @@ fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType |
| 2180 | // positives. Therefore, start after a sentinel if there is one and | 2179 | // positives. Therefore, start after a sentinel if there is one and |
| 2181 | // skip over any align node and bit range nodes. | 2180 | // skip over any align node and bit range nodes. |
| 2182 | var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else switch (size) { | 2181 | var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else switch (size) { |
| 2183 | .Many, .C => info.main_token + 1, | 2182 | .many, .c => info.main_token + 1, |
| 2184 | else => info.main_token, | 2183 | else => info.main_token, |
| 2185 | }; | 2184 | }; |
| 2186 | const end = tree.firstToken(info.child_type); | 2185 | const end = tree.firstToken(info.child_type); |
lib/std/zig/AstGen.zig+2-2| ... | @@ -3917,7 +3917,7 @@ fn ptrType( | ... | @@ -3917,7 +3917,7 @@ fn ptrType( |
| 3917 | node: Ast.Node.Index, | 3917 | node: Ast.Node.Index, |
| 3918 | ptr_info: Ast.full.PtrType, | 3918 | ptr_info: Ast.full.PtrType, |
| 3919 | ) InnerError!Zir.Inst.Ref { | 3919 | ) InnerError!Zir.Inst.Ref { |
| 3920 | if (ptr_info.size == .C and ptr_info.allowzero_token != null) { | 3920 | if (ptr_info.size == .c and ptr_info.allowzero_token != null) { |
| 3921 | return gz.astgen.failTok(ptr_info.allowzero_token.?, "C pointers always allow address zero", .{}); | 3921 | return gz.astgen.failTok(ptr_info.allowzero_token.?, "C pointers always allow address zero", .{}); |
| 3922 | } | 3922 | } |
| 3923 | 3923 | ||
| ... | @@ -3946,7 +3946,7 @@ fn ptrType( | ... | @@ -3946,7 +3946,7 @@ fn ptrType( |
| 3946 | .{ .rl = .{ .ty = elem_type } }, | 3946 | .{ .rl = .{ .ty = elem_type } }, |
| 3947 | ptr_info.ast.sentinel, | 3947 | ptr_info.ast.sentinel, |
| 3948 | switch (ptr_info.size) { | 3948 | switch (ptr_info.size) { |
| 3949 | .Slice => .slice_sentinel, | 3949 | .slice => .slice_sentinel, |
| 3950 | else => .pointer_sentinel, | 3950 | else => .pointer_sentinel, |
| 3951 | }, | 3951 | }, |
| 3952 | ); | 3952 | ); |
lib/std/zig/c_translation.zig+5-8| ... | @@ -170,7 +170,7 @@ pub fn sizeof(target: anytype) usize { | ... | @@ -170,7 +170,7 @@ pub fn sizeof(target: anytype) usize { |
| 170 | } | 170 | } |
| 171 | }, | 171 | }, |
| 172 | .pointer => |ptr| { | 172 | .pointer => |ptr| { |
| 173 | if (ptr.size == .Slice) { | 173 | if (ptr.size == .slice) { |
| 174 | @compileError("Cannot use C sizeof on slice type " ++ @typeName(T)); | 174 | @compileError("Cannot use C sizeof on slice type " ++ @typeName(T)); |
| 175 | } | 175 | } |
| 176 | // for strings, sizeof("a") returns 2. | 176 | // for strings, sizeof("a") returns 2. |
| ... | @@ -178,12 +178,9 @@ pub fn sizeof(target: anytype) usize { | ... | @@ -178,12 +178,9 @@ pub fn sizeof(target: anytype) usize { |
| 178 | // in the .array case above, but strings remain literals | 178 | // in the .array case above, but strings remain literals |
| 179 | // and are therefore always pointers, so they need to be | 179 | // and are therefore always pointers, so they need to be |
| 180 | // specially handled here. | 180 | // specially handled here. |
| 181 | if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .array) { | 181 | if (ptr.size == .one and ptr.is_const and @typeInfo(ptr.child) == .array) { |
| 182 | const array_info = @typeInfo(ptr.child).array; | 182 | const array_info = @typeInfo(ptr.child).array; |
| 183 | if ((array_info.child == u8 or array_info.child == u16) and | 183 | if ((array_info.child == u8 or array_info.child == u16) and array_info.sentinel() == 0) { |
| 184 | array_info.sentinel != null and | ||
| 185 | @as(*align(1) const array_info.child, @ptrCast(array_info.sentinel.?)).* == 0) | ||
| 186 | { | ||
| 187 | // length of the string plus one for the null terminator. | 184 | // length of the string plus one for the null terminator. |
| 188 | return (array_info.len + 1) * @sizeOf(array_info.child); | 185 | return (array_info.len + 1) * @sizeOf(array_info.child); |
| 189 | } | 186 | } |
| ... | @@ -341,14 +338,14 @@ pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) ty | ... | @@ -341,14 +338,14 @@ pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) ty |
| 341 | switch (@typeInfo(SelfType)) { | 338 | switch (@typeInfo(SelfType)) { |
| 342 | .pointer => |ptr| { | 339 | .pointer => |ptr| { |
| 343 | return @Type(.{ .pointer = .{ | 340 | return @Type(.{ .pointer = .{ |
| 344 | .size = .C, | 341 | .size = .c, |
| 345 | .is_const = ptr.is_const, | 342 | .is_const = ptr.is_const, |
| 346 | .is_volatile = ptr.is_volatile, | 343 | .is_volatile = ptr.is_volatile, |
| 347 | .alignment = @alignOf(ElementType), | 344 | .alignment = @alignOf(ElementType), |
| 348 | .address_space = .generic, | 345 | .address_space = .generic, |
| 349 | .child = ElementType, | 346 | .child = ElementType, |
| 350 | .is_allowzero = true, | 347 | .is_allowzero = true, |
| 351 | .sentinel = null, | 348 | .sentinel_ptr = null, |
| 352 | } }); | 349 | } }); |
| 353 | }, | 350 | }, |
| 354 | else => |info| @compileError("Invalid self type \"" ++ @tagName(info) ++ "\" for flexible array getter: " ++ @typeName(SelfType)), | 351 | else => |info| @compileError("Invalid self type \"" ++ @tagName(info) ++ "\" for flexible array getter: " ++ @typeName(SelfType)), |
lib/std/zig/parser_test.zig+4-4| ... | @@ -552,7 +552,7 @@ test "zig fmt: trailing comma in fn parameter list" { | ... | @@ -552,7 +552,7 @@ test "zig fmt: trailing comma in fn parameter list" { |
| 552 | \\pub fn f( | 552 | \\pub fn f( |
| 553 | \\ a: i32, | 553 | \\ a: i32, |
| 554 | \\ b: i32, | 554 | \\ b: i32, |
| 555 | \\) callconv(.C) i32 {} | 555 | \\) callconv(.c) i32 {} |
| 556 | \\pub fn f( | 556 | \\pub fn f( |
| 557 | \\ a: i32, | 557 | \\ a: i32, |
| 558 | \\ b: i32, | 558 | \\ b: i32, |
| ... | @@ -560,15 +560,15 @@ test "zig fmt: trailing comma in fn parameter list" { | ... | @@ -560,15 +560,15 @@ test "zig fmt: trailing comma in fn parameter list" { |
| 560 | \\pub fn f( | 560 | \\pub fn f( |
| 561 | \\ a: i32, | 561 | \\ a: i32, |
| 562 | \\ b: i32, | 562 | \\ b: i32, |
| 563 | \\) align(8) callconv(.C) i32 {} | 563 | \\) align(8) callconv(.c) i32 {} |
| 564 | \\pub fn f( | 564 | \\pub fn f( |
| 565 | \\ a: i32, | 565 | \\ a: i32, |
| 566 | \\ b: i32, | 566 | \\ b: i32, |
| 567 | \\) align(8) linksection(".text") callconv(.C) i32 {} | 567 | \\) align(8) linksection(".text") callconv(.c) i32 {} |
| 568 | \\pub fn f( | 568 | \\pub fn f( |
| 569 | \\ a: i32, | 569 | \\ a: i32, |
| 570 | \\ b: i32, | 570 | \\ b: i32, |
| 571 | \\) linksection(".text") callconv(.C) i32 {} | 571 | \\) linksection(".text") callconv(.c) i32 {} |
| 572 | \\ | 572 | \\ |
| 573 | ); | 573 | ); |
| 574 | } | 574 | } |
lib/std/zig/render.zig+4-4| ... | @@ -938,7 +938,7 @@ fn renderArrayType( | ... | @@ -938,7 +938,7 @@ fn renderArrayType( |
| 938 | fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!void { | 938 | fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!void { |
| 939 | const tree = r.tree; | 939 | const tree = r.tree; |
| 940 | switch (ptr_type.size) { | 940 | switch (ptr_type.size) { |
| 941 | .One => { | 941 | .one => { |
| 942 | // Since ** tokens exist and the same token is shared by two | 942 | // Since ** tokens exist and the same token is shared by two |
| 943 | // nested pointer types, we check to see if we are the parent | 943 | // nested pointer types, we check to see if we are the parent |
| 944 | // in such a relationship. If so, skip rendering anything for | 944 | // in such a relationship. If so, skip rendering anything for |
| ... | @@ -951,7 +951,7 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi | ... | @@ -951,7 +951,7 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi |
| 951 | } | 951 | } |
| 952 | try renderToken(r, ptr_type.ast.main_token, .none); // asterisk | 952 | try renderToken(r, ptr_type.ast.main_token, .none); // asterisk |
| 953 | }, | 953 | }, |
| 954 | .Many => { | 954 | .many => { |
| 955 | if (ptr_type.ast.sentinel == 0) { | 955 | if (ptr_type.ast.sentinel == 0) { |
| 956 | try renderToken(r, ptr_type.ast.main_token, .none); // lbracket | 956 | try renderToken(r, ptr_type.ast.main_token, .none); // lbracket |
| 957 | try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk | 957 | try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk |
| ... | @@ -964,13 +964,13 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi | ... | @@ -964,13 +964,13 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi |
| 964 | try renderToken(r, tree.lastToken(ptr_type.ast.sentinel) + 1, .none); // rbracket | 964 | try renderToken(r, tree.lastToken(ptr_type.ast.sentinel) + 1, .none); // rbracket |
| 965 | } | 965 | } |
| 966 | }, | 966 | }, |
| 967 | .C => { | 967 | .c => { |
| 968 | try renderToken(r, ptr_type.ast.main_token, .none); // lbracket | 968 | try renderToken(r, ptr_type.ast.main_token, .none); // lbracket |
| 969 | try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk | 969 | try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk |
| 970 | try renderToken(r, ptr_type.ast.main_token + 2, .none); // c | 970 | try renderToken(r, ptr_type.ast.main_token + 2, .none); // c |
| 971 | try renderToken(r, ptr_type.ast.main_token + 3, .none); // rbracket | 971 | try renderToken(r, ptr_type.ast.main_token + 3, .none); // rbracket |
| 972 | }, | 972 | }, |
| 973 | .Slice => { | 973 | .slice => { |
| 974 | if (ptr_type.ast.sentinel == 0) { | 974 | if (ptr_type.ast.sentinel == 0) { |
| 975 | try renderToken(r, ptr_type.ast.main_token, .none); // lbracket | 975 | try renderToken(r, ptr_type.ast.main_token, .none); // lbracket |
| 976 | try renderToken(r, ptr_type.ast.main_token + 1, .none); // rbracket | 976 | try renderToken(r, ptr_type.ast.main_token + 1, .none); // rbracket |
lib/std/zig/system/x86.zig+2-2| ... | @@ -475,7 +475,7 @@ const CpuidLeaf = packed struct { | ... | @@ -475,7 +475,7 @@ const CpuidLeaf = packed struct { |
| 475 | 475 | ||
| 476 | /// This is a workaround for the C backend until zig has the ability to put | 476 | /// This is a workaround for the C backend until zig has the ability to put |
| 477 | /// C code in inline assembly. | 477 | /// C code in inline assembly. |
| 478 | extern fn zig_x86_cpuid(leaf_id: u32, subid: u32, eax: *u32, ebx: *u32, ecx: *u32, edx: *u32) callconv(.C) void; | 478 | extern fn zig_x86_cpuid(leaf_id: u32, subid: u32, eax: *u32, ebx: *u32, ecx: *u32, edx: *u32) callconv(.c) void; |
| 479 | 479 | ||
| 480 | fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf { | 480 | fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf { |
| 481 | // valid for both x86 and x86_64 | 481 | // valid for both x86 and x86_64 |
| ... | @@ -502,7 +502,7 @@ fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf { | ... | @@ -502,7 +502,7 @@ fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf { |
| 502 | 502 | ||
| 503 | /// This is a workaround for the C backend until zig has the ability to put | 503 | /// This is a workaround for the C backend until zig has the ability to put |
| 504 | /// C code in inline assembly. | 504 | /// C code in inline assembly. |
| 505 | extern fn zig_x86_get_xcr0() callconv(.C) u32; | 505 | extern fn zig_x86_get_xcr0() callconv(.c) u32; |
| 506 | 506 | ||
| 507 | // Read control register 0 (XCR0). Used to detect features such as AVX. | 507 | // Read control register 0 (XCR0). Used to detect features such as AVX. |
| 508 | fn getXCR0() u32 { | 508 | fn getXCR0() u32 { |
src/InternPool.zig+34-34| ... | @@ -1134,7 +1134,7 @@ const Local = struct { | ... | @@ -1134,7 +1134,7 @@ const Local = struct { |
| 1134 | for (&new_fields, elem_fields) |*new_field, elem_field| new_field.* = .{ | 1134 | for (&new_fields, elem_fields) |*new_field, elem_field| new_field.* = .{ |
| 1135 | .name = elem_field.name, | 1135 | .name = elem_field.name, |
| 1136 | .type = *[len]elem_field.type, | 1136 | .type = *[len]elem_field.type, |
| 1137 | .default_value = null, | 1137 | .default_value_ptr = null, |
| 1138 | .is_comptime = false, | 1138 | .is_comptime = false, |
| 1139 | .alignment = 0, | 1139 | .alignment = 0, |
| 1140 | }; | 1140 | }; |
| ... | @@ -1162,9 +1162,9 @@ const Local = struct { | ... | @@ -1162,9 +1162,9 @@ const Local = struct { |
| 1162 | .address_space = .generic, | 1162 | .address_space = .generic, |
| 1163 | .child = elem_field.type, | 1163 | .child = elem_field.type, |
| 1164 | .is_allowzero = false, | 1164 | .is_allowzero = false, |
| 1165 | .sentinel = null, | 1165 | .sentinel_ptr = null, |
| 1166 | } }), | 1166 | } }), |
| 1167 | .default_value = null, | 1167 | .default_value_ptr = null, |
| 1168 | .is_comptime = false, | 1168 | .is_comptime = false, |
| 1169 | .alignment = 0, | 1169 | .alignment = 0, |
| 1170 | }; | 1170 | }; |
| ... | @@ -1176,17 +1176,17 @@ const Local = struct { | ... | @@ -1176,17 +1176,17 @@ const Local = struct { |
| 1176 | } }); | 1176 | } }); |
| 1177 | } | 1177 | } |
| 1178 | 1178 | ||
| 1179 | pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .One }) { | 1179 | pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .one }) { |
| 1180 | try mutable.ensureUnusedCapacity(1); | 1180 | try mutable.ensureUnusedCapacity(1); |
| 1181 | return mutable.addOneAssumeCapacity(); | 1181 | return mutable.addOneAssumeCapacity(); |
| 1182 | } | 1182 | } |
| 1183 | 1183 | ||
| 1184 | pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .One }) { | 1184 | pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .one }) { |
| 1185 | const index = mutable.mutate.len; | 1185 | const index = mutable.mutate.len; |
| 1186 | assert(index < mutable.list.header().capacity); | 1186 | assert(index < mutable.list.header().capacity); |
| 1187 | mutable.mutate.len = index + 1; | 1187 | mutable.mutate.len = index + 1; |
| 1188 | const mutable_view = mutable.view().slice(); | 1188 | const mutable_view = mutable.view().slice(); |
| 1189 | var ptr: PtrElem(.{ .size = .One }) = undefined; | 1189 | var ptr: PtrElem(.{ .size = .one }) = undefined; |
| 1190 | inline for (fields) |field| { | 1190 | inline for (fields) |field| { |
| 1191 | @field(ptr, @tagName(field)) = &mutable_view.items(field)[index]; | 1191 | @field(ptr, @tagName(field)) = &mutable_view.items(field)[index]; |
| 1192 | } | 1192 | } |
| ... | @@ -1206,7 +1206,7 @@ const Local = struct { | ... | @@ -1206,7 +1206,7 @@ const Local = struct { |
| 1206 | 1206 | ||
| 1207 | pub fn appendSliceAssumeCapacity( | 1207 | pub fn appendSliceAssumeCapacity( |
| 1208 | mutable: Mutable, | 1208 | mutable: Mutable, |
| 1209 | slice: PtrElem(.{ .size = .Slice, .is_const = true }), | 1209 | slice: PtrElem(.{ .size = .slice, .is_const = true }), |
| 1210 | ) void { | 1210 | ) void { |
| 1211 | if (fields.len == 0) return; | 1211 | if (fields.len == 0) return; |
| 1212 | const start = mutable.mutate.len; | 1212 | const start = mutable.mutate.len; |
| ... | @@ -1253,17 +1253,17 @@ const Local = struct { | ... | @@ -1253,17 +1253,17 @@ const Local = struct { |
| 1253 | return ptr_array; | 1253 | return ptr_array; |
| 1254 | } | 1254 | } |
| 1255 | 1255 | ||
| 1256 | pub fn addManyAsSlice(mutable: Mutable, len: usize) Allocator.Error!PtrElem(.{ .size = .Slice }) { | 1256 | pub fn addManyAsSlice(mutable: Mutable, len: usize) Allocator.Error!PtrElem(.{ .size = .slice }) { |
| 1257 | try mutable.ensureUnusedCapacity(len); | 1257 | try mutable.ensureUnusedCapacity(len); |
| 1258 | return mutable.addManyAsSliceAssumeCapacity(len); | 1258 | return mutable.addManyAsSliceAssumeCapacity(len); |
| 1259 | } | 1259 | } |
| 1260 | 1260 | ||
| 1261 | pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .Slice }) { | 1261 | pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .slice }) { |
| 1262 | const start = mutable.mutate.len; | 1262 | const start = mutable.mutate.len; |
| 1263 | assert(len <= mutable.list.header().capacity - start); | 1263 | assert(len <= mutable.list.header().capacity - start); |
| 1264 | mutable.mutate.len = @intCast(start + len); | 1264 | mutable.mutate.len = @intCast(start + len); |
| 1265 | const mutable_view = mutable.view().slice(); | 1265 | const mutable_view = mutable.view().slice(); |
| 1266 | var slice: PtrElem(.{ .size = .Slice }) = undefined; | 1266 | var slice: PtrElem(.{ .size = .slice }) = undefined; |
| 1267 | inline for (fields) |field| { | 1267 | inline for (fields) |field| { |
| 1268 | @field(slice, @tagName(field)) = mutable_view.items(field)[start..][0..len]; | 1268 | @field(slice, @tagName(field)) = mutable_view.items(field)[start..][0..len]; |
| 1269 | } | 1269 | } |
| ... | @@ -2060,7 +2060,7 @@ pub const Key = union(enum) { | ... | @@ -2060,7 +2060,7 @@ pub const Key = union(enum) { |
| 2060 | }; | 2060 | }; |
| 2061 | 2061 | ||
| 2062 | pub const Flags = packed struct(u32) { | 2062 | pub const Flags = packed struct(u32) { |
| 2063 | size: Size = .One, | 2063 | size: Size = .one, |
| 2064 | /// `none` indicates the ABI alignment of the pointee_type. In this | 2064 | /// `none` indicates the ABI alignment of the pointee_type. In this |
| 2065 | /// case, this field *must* be set to `none`, otherwise the | 2065 | /// case, this field *must* be set to `none`, otherwise the |
| 2066 | /// `InternPool` equality and hashing functions will return incorrect | 2066 | /// `InternPool` equality and hashing functions will return incorrect |
| ... | @@ -4891,7 +4891,7 @@ pub const Index = enum(u32) { | ... | @@ -4891,7 +4891,7 @@ pub const Index = enum(u32) { |
| 4891 | checkField(name ++ ".?", info.child); | 4891 | checkField(name ++ ".?", info.child); |
| 4892 | }, | 4892 | }, |
| 4893 | .pointer => |info| { | 4893 | .pointer => |info| { |
| 4894 | assert(info.size == .Slice); | 4894 | assert(info.size == .slice); |
| 4895 | checkConfig(name ++ ".len"); | 4895 | checkConfig(name ++ ".len"); |
| 4896 | checkField(name ++ "[0]", info.child); | 4896 | checkField(name ++ "[0]", info.child); |
| 4897 | }, | 4897 | }, |
| ... | @@ -5016,7 +5016,7 @@ pub const static_keys = [_]Key{ | ... | @@ -5016,7 +5016,7 @@ pub const static_keys = [_]Key{ |
| 5016 | .{ .ptr_type = .{ | 5016 | .{ .ptr_type = .{ |
| 5017 | .child = .u8_type, | 5017 | .child = .u8_type, |
| 5018 | .flags = .{ | 5018 | .flags = .{ |
| 5019 | .size = .Many, | 5019 | .size = .many, |
| 5020 | }, | 5020 | }, |
| 5021 | } }, | 5021 | } }, |
| 5022 | 5022 | ||
| ... | @@ -5024,7 +5024,7 @@ pub const static_keys = [_]Key{ | ... | @@ -5024,7 +5024,7 @@ pub const static_keys = [_]Key{ |
| 5024 | .{ .ptr_type = .{ | 5024 | .{ .ptr_type = .{ |
| 5025 | .child = .u8_type, | 5025 | .child = .u8_type, |
| 5026 | .flags = .{ | 5026 | .flags = .{ |
| 5027 | .size = .Many, | 5027 | .size = .many, |
| 5028 | .is_const = true, | 5028 | .is_const = true, |
| 5029 | }, | 5029 | }, |
| 5030 | } }, | 5030 | } }, |
| ... | @@ -5034,7 +5034,7 @@ pub const static_keys = [_]Key{ | ... | @@ -5034,7 +5034,7 @@ pub const static_keys = [_]Key{ |
| 5034 | .child = .u8_type, | 5034 | .child = .u8_type, |
| 5035 | .sentinel = .zero_u8, | 5035 | .sentinel = .zero_u8, |
| 5036 | .flags = .{ | 5036 | .flags = .{ |
| 5037 | .size = .Many, | 5037 | .size = .many, |
| 5038 | .is_const = true, | 5038 | .is_const = true, |
| 5039 | }, | 5039 | }, |
| 5040 | } }, | 5040 | } }, |
| ... | @@ -5043,7 +5043,7 @@ pub const static_keys = [_]Key{ | ... | @@ -5043,7 +5043,7 @@ pub const static_keys = [_]Key{ |
| 5043 | .{ .ptr_type = .{ | 5043 | .{ .ptr_type = .{ |
| 5044 | .child = .comptime_int_type, | 5044 | .child = .comptime_int_type, |
| 5045 | .flags = .{ | 5045 | .flags = .{ |
| 5046 | .size = .One, | 5046 | .size = .one, |
| 5047 | .is_const = true, | 5047 | .is_const = true, |
| 5048 | }, | 5048 | }, |
| 5049 | } }, | 5049 | } }, |
| ... | @@ -5052,7 +5052,7 @@ pub const static_keys = [_]Key{ | ... | @@ -5052,7 +5052,7 @@ pub const static_keys = [_]Key{ |
| 5052 | .{ .ptr_type = .{ | 5052 | .{ .ptr_type = .{ |
| 5053 | .child = .u8_type, | 5053 | .child = .u8_type, |
| 5054 | .flags = .{ | 5054 | .flags = .{ |
| 5055 | .size = .Slice, | 5055 | .size = .slice, |
| 5056 | .is_const = true, | 5056 | .is_const = true, |
| 5057 | }, | 5057 | }, |
| 5058 | } }, | 5058 | } }, |
| ... | @@ -5062,7 +5062,7 @@ pub const static_keys = [_]Key{ | ... | @@ -5062,7 +5062,7 @@ pub const static_keys = [_]Key{ |
| 5062 | .child = .u8_type, | 5062 | .child = .u8_type, |
| 5063 | .sentinel = .zero_u8, | 5063 | .sentinel = .zero_u8, |
| 5064 | .flags = .{ | 5064 | .flags = .{ |
| 5065 | .size = .Slice, | 5065 | .size = .slice, |
| 5066 | .is_const = true, | 5066 | .is_const = true, |
| 5067 | }, | 5067 | }, |
| 5068 | } }, | 5068 | } }, |
| ... | @@ -6749,7 +6749,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { | ... | @@ -6749,7 +6749,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { |
| 6749 | const many_ptr_item = many_ptr_unwrapped.getItem(ip); | 6749 | const many_ptr_item = many_ptr_unwrapped.getItem(ip); |
| 6750 | assert(many_ptr_item.tag == .type_pointer); | 6750 | assert(many_ptr_item.tag == .type_pointer); |
| 6751 | var ptr_info = extraData(many_ptr_unwrapped.getExtra(ip), Tag.TypePointer, many_ptr_item.data); | 6751 | var ptr_info = extraData(many_ptr_unwrapped.getExtra(ip), Tag.TypePointer, many_ptr_item.data); |
| 6752 | ptr_info.flags.size = .Slice; | 6752 | ptr_info.flags.size = .slice; |
| 6753 | return .{ .ptr_type = ptr_info }; | 6753 | return .{ .ptr_type = ptr_info }; |
| 6754 | }, | 6754 | }, |
| 6755 | 6755 | ||
| ... | @@ -7572,10 +7572,10 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All | ... | @@ -7572,10 +7572,10 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7572 | assert(ptr_type.child != .none); | 7572 | assert(ptr_type.child != .none); |
| 7573 | assert(ptr_type.sentinel == .none or ip.typeOf(ptr_type.sentinel) == ptr_type.child); | 7573 | assert(ptr_type.sentinel == .none or ip.typeOf(ptr_type.sentinel) == ptr_type.child); |
| 7574 | 7574 | ||
| 7575 | if (ptr_type.flags.size == .Slice) { | 7575 | if (ptr_type.flags.size == .slice) { |
| 7576 | gop.cancel(); | 7576 | gop.cancel(); |
| 7577 | var new_key = key; | 7577 | var new_key = key; |
| 7578 | new_key.ptr_type.flags.size = .Many; | 7578 | new_key.ptr_type.flags.size = .many; |
| 7579 | const ptr_type_index = try ip.get(gpa, tid, new_key); | 7579 | const ptr_type_index = try ip.get(gpa, tid, new_key); |
| 7580 | gop = try ip.getOrPutKey(gpa, tid, key); | 7580 | gop = try ip.getOrPutKey(gpa, tid, key); |
| 7581 | 7581 | ||
| ... | @@ -7588,7 +7588,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All | ... | @@ -7588,7 +7588,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7588 | } | 7588 | } |
| 7589 | 7589 | ||
| 7590 | var ptr_type_adjusted = ptr_type; | 7590 | var ptr_type_adjusted = ptr_type; |
| 7591 | if (ptr_type.flags.size == .C) ptr_type_adjusted.flags.is_allowzero = true; | 7591 | if (ptr_type.flags.size == .c) ptr_type_adjusted.flags.is_allowzero = true; |
| 7592 | 7592 | ||
| 7593 | items.appendAssumeCapacity(.{ | 7593 | items.appendAssumeCapacity(.{ |
| 7594 | .tag = .type_pointer, | 7594 | .tag = .type_pointer, |
| ... | @@ -7731,8 +7731,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All | ... | @@ -7731,8 +7731,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7731 | }, | 7731 | }, |
| 7732 | 7732 | ||
| 7733 | .slice => |slice| { | 7733 | .slice => |slice| { |
| 7734 | assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .Slice); | 7734 | assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .slice); |
| 7735 | assert(ip.indexToKey(ip.typeOf(slice.ptr)).ptr_type.flags.size == .Many); | 7735 | assert(ip.indexToKey(ip.typeOf(slice.ptr)).ptr_type.flags.size == .many); |
| 7736 | items.appendAssumeCapacity(.{ | 7736 | items.appendAssumeCapacity(.{ |
| 7737 | .tag = .ptr_slice, | 7737 | .tag = .ptr_slice, |
| 7738 | .data = try addExtra(extra, PtrSlice{ | 7738 | .data = try addExtra(extra, PtrSlice{ |
| ... | @@ -7745,7 +7745,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All | ... | @@ -7745,7 +7745,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7745 | 7745 | ||
| 7746 | .ptr => |ptr| { | 7746 | .ptr => |ptr| { |
| 7747 | const ptr_type = ip.indexToKey(ptr.ty).ptr_type; | 7747 | const ptr_type = ip.indexToKey(ptr.ty).ptr_type; |
| 7748 | assert(ptr_type.flags.size != .Slice); | 7748 | assert(ptr_type.flags.size != .slice); |
| 7749 | items.appendAssumeCapacity(switch (ptr.base_addr) { | 7749 | items.appendAssumeCapacity(switch (ptr.base_addr) { |
| 7750 | .nav => |nav| .{ | 7750 | .nav => |nav| .{ |
| 7751 | .tag = .ptr_nav, | 7751 | .tag = .ptr_nav, |
| ... | @@ -7804,9 +7804,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All | ... | @@ -7804,9 +7804,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7804 | .arr_elem, .field => |base_index| { | 7804 | .arr_elem, .field => |base_index| { |
| 7805 | const base_ptr_type = ip.indexToKey(ip.typeOf(base_index.base)).ptr_type; | 7805 | const base_ptr_type = ip.indexToKey(ip.typeOf(base_index.base)).ptr_type; |
| 7806 | switch (ptr.base_addr) { | 7806 | switch (ptr.base_addr) { |
| 7807 | .arr_elem => assert(base_ptr_type.flags.size == .Many), | 7807 | .arr_elem => assert(base_ptr_type.flags.size == .many), |
| 7808 | .field => { | 7808 | .field => { |
| 7809 | assert(base_ptr_type.flags.size == .One); | 7809 | assert(base_ptr_type.flags.size == .one); |
| 7810 | switch (ip.indexToKey(base_ptr_type.child)) { | 7810 | switch (ip.indexToKey(base_ptr_type.child)) { |
| 7811 | .tuple_type => |tuple_type| { | 7811 | .tuple_type => |tuple_type| { |
| 7812 | assert(ptr.base_addr == .field); | 7812 | assert(ptr.base_addr == .field); |
| ... | @@ -7823,7 +7823,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All | ... | @@ -7823,7 +7823,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All |
| 7823 | }, | 7823 | }, |
| 7824 | .ptr_type => |slice_type| { | 7824 | .ptr_type => |slice_type| { |
| 7825 | assert(ptr.base_addr == .field); | 7825 | assert(ptr.base_addr == .field); |
| 7826 | assert(slice_type.flags.size == .Slice); | 7826 | assert(slice_type.flags.size == .slice); |
| 7827 | assert(base_index.index < 2); | 7827 | assert(base_index.index < 2); |
| 7828 | }, | 7828 | }, |
| 7829 | else => unreachable, | 7829 | else => unreachable, |
| ... | @@ -10314,12 +10314,12 @@ pub fn getCoerced( | ... | @@ -10314,12 +10314,12 @@ pub fn getCoerced( |
| 10314 | } }); | 10314 | } }); |
| 10315 | 10315 | ||
| 10316 | if (ip.isPointerType(new_ty)) switch (ip.indexToKey(new_ty).ptr_type.flags.size) { | 10316 | if (ip.isPointerType(new_ty)) switch (ip.indexToKey(new_ty).ptr_type.flags.size) { |
| 10317 | .One, .Many, .C => return ip.get(gpa, tid, .{ .ptr = .{ | 10317 | .one, .many, .c => return ip.get(gpa, tid, .{ .ptr = .{ |
| 10318 | .ty = new_ty, | 10318 | .ty = new_ty, |
| 10319 | .base_addr = .int, | 10319 | .base_addr = .int, |
| 10320 | .byte_offset = 0, | 10320 | .byte_offset = 0, |
| 10321 | } }), | 10321 | } }), |
| 10322 | .Slice => return ip.get(gpa, tid, .{ .slice = .{ | 10322 | .slice => return ip.get(gpa, tid, .{ .slice = .{ |
| 10323 | .ty = new_ty, | 10323 | .ty = new_ty, |
| 10324 | .ptr = try ip.get(gpa, tid, .{ .ptr = .{ | 10324 | .ptr = try ip.get(gpa, tid, .{ .ptr = .{ |
| 10325 | .ty = ip.slicePtrType(new_ty), | 10325 | .ty = ip.slicePtrType(new_ty), |
| ... | @@ -10408,7 +10408,7 @@ pub fn getCoerced( | ... | @@ -10408,7 +10408,7 @@ pub fn getCoerced( |
| 10408 | }, | 10408 | }, |
| 10409 | else => {}, | 10409 | else => {}, |
| 10410 | }, | 10410 | }, |
| 10411 | .slice => |slice| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size == .Slice) | 10411 | .slice => |slice| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size == .slice) |
| 10412 | return ip.get(gpa, tid, .{ .slice = .{ | 10412 | return ip.get(gpa, tid, .{ .slice = .{ |
| 10413 | .ty = new_ty, | 10413 | .ty = new_ty, |
| 10414 | .ptr = try ip.getCoerced(gpa, tid, slice.ptr, ip.slicePtrType(new_ty)), | 10414 | .ptr = try ip.getCoerced(gpa, tid, slice.ptr, ip.slicePtrType(new_ty)), |
| ... | @@ -10416,7 +10416,7 @@ pub fn getCoerced( | ... | @@ -10416,7 +10416,7 @@ pub fn getCoerced( |
| 10416 | } }) | 10416 | } }) |
| 10417 | else if (ip.isIntegerType(new_ty)) | 10417 | else if (ip.isIntegerType(new_ty)) |
| 10418 | return ip.getCoerced(gpa, tid, slice.ptr, new_ty), | 10418 | return ip.getCoerced(gpa, tid, slice.ptr, new_ty), |
| 10419 | .ptr => |ptr| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size != .Slice) | 10419 | .ptr => |ptr| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size != .slice) |
| 10420 | return ip.get(gpa, tid, .{ .ptr = .{ | 10420 | return ip.get(gpa, tid, .{ .ptr = .{ |
| 10421 | .ty = new_ty, | 10421 | .ty = new_ty, |
| 10422 | .base_addr = ptr.base_addr, | 10422 | .base_addr = ptr.base_addr, |
| ... | @@ -10433,12 +10433,12 @@ pub fn getCoerced( | ... | @@ -10433,12 +10433,12 @@ pub fn getCoerced( |
| 10433 | .opt => |opt| switch (ip.indexToKey(new_ty)) { | 10433 | .opt => |opt| switch (ip.indexToKey(new_ty)) { |
| 10434 | .ptr_type => |ptr_type| return switch (opt.val) { | 10434 | .ptr_type => |ptr_type| return switch (opt.val) { |
| 10435 | .none => switch (ptr_type.flags.size) { | 10435 | .none => switch (ptr_type.flags.size) { |
| 10436 | .One, .Many, .C => try ip.get(gpa, tid, .{ .ptr = .{ | 10436 | .one, .many, .c => try ip.get(gpa, tid, .{ .ptr = .{ |
| 10437 | .ty = new_ty, | 10437 | .ty = new_ty, |
| 10438 | .base_addr = .int, | 10438 | .base_addr = .int, |
| 10439 | .byte_offset = 0, | 10439 | .byte_offset = 0, |
| 10440 | } }), | 10440 | } }), |
| 10441 | .Slice => try ip.get(gpa, tid, .{ .slice = .{ | 10441 | .slice => try ip.get(gpa, tid, .{ .slice = .{ |
| 10442 | .ty = new_ty, | 10442 | .ty = new_ty, |
| 10443 | .ptr = try ip.get(gpa, tid, .{ .ptr = .{ | 10443 | .ptr = try ip.get(gpa, tid, .{ .ptr = .{ |
| 10444 | .ty = ip.slicePtrType(new_ty), | 10444 | .ty = ip.slicePtrType(new_ty), |
src/Sema.zig+196-207| ... | @@ -2479,7 +2479,7 @@ fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.Nul | ... | @@ -2479,7 +2479,7 @@ fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.Nul |
| 2479 | .array => return field_name.eqlSlice("len", ip), | 2479 | .array => return field_name.eqlSlice("len", ip), |
| 2480 | .pointer => { | 2480 | .pointer => { |
| 2481 | const ptr_info = ty.ptrInfo(zcu); | 2481 | const ptr_info = ty.ptrInfo(zcu); |
| 2482 | if (ptr_info.flags.size == .Slice) { | 2482 | if (ptr_info.flags.size == .slice) { |
| 2483 | return field_name.eqlSlice("ptr", ip) or field_name.eqlSlice("len", ip); | 2483 | return field_name.eqlSlice("ptr", ip) or field_name.eqlSlice("len", ip); |
| 2484 | } else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { | 2484 | } else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { |
| 2485 | return field_name.eqlSlice("len", ip); | 2485 | return field_name.eqlSlice("len", ip); |
| ... | @@ -2713,8 +2713,18 @@ fn analyzeValueAsCallconv( | ... | @@ -2713,8 +2713,18 @@ fn analyzeValueAsCallconv( |
| 2713 | src: LazySrcLoc, | 2713 | src: LazySrcLoc, |
| 2714 | unresolved_val: Value, | 2714 | unresolved_val: Value, |
| 2715 | ) !std.builtin.CallingConvention { | 2715 | ) !std.builtin.CallingConvention { |
| 2716 | return interpretBuiltinType(sema, block, src, unresolved_val, std.builtin.CallingConvention); | ||
| 2717 | } | ||
| 2718 | |||
| 2719 | fn interpretBuiltinType( | ||
| 2720 | sema: *Sema, | ||
| 2721 | block: *Block, | ||
| 2722 | src: LazySrcLoc, | ||
| 2723 | unresolved_val: Value, | ||
| 2724 | comptime T: type, | ||
| 2725 | ) !T { | ||
| 2716 | const resolved_val = try sema.resolveLazyValue(unresolved_val); | 2726 | const resolved_val = try sema.resolveLazyValue(unresolved_val); |
| 2717 | return resolved_val.interpret(std.builtin.CallingConvention, sema.pt) catch |err| switch (err) { | 2727 | return resolved_val.interpret(T, sema.pt) catch |err| switch (err) { |
| 2718 | error.OutOfMemory => |e| return e, | 2728 | error.OutOfMemory => |e| return e, |
| 2719 | error.UndefinedValue => return sema.failWithUseOfUndef(block, src), | 2729 | error.UndefinedValue => return sema.failWithUseOfUndef(block, src), |
| 2720 | error.TypeMismatch => @panic("std.builtin is corrupt"), | 2730 | error.TypeMismatch => @panic("std.builtin is corrupt"), |
| ... | @@ -3653,7 +3663,7 @@ fn indexablePtrLenOrNone( | ... | @@ -3653,7 +3663,7 @@ fn indexablePtrLenOrNone( |
| 3653 | const zcu = pt.zcu; | 3663 | const zcu = pt.zcu; |
| 3654 | const operand_ty = sema.typeOf(operand); | 3664 | const operand_ty = sema.typeOf(operand); |
| 3655 | try checkMemOperand(sema, block, src, operand_ty); | 3665 | try checkMemOperand(sema, block, src, operand_ty); |
| 3656 | if (operand_ty.ptrSize(zcu) == .Many) return .none; | 3666 | if (operand_ty.ptrSize(zcu) == .many) return .none; |
| 3657 | const field_name = try zcu.intern_pool.getOrPutString(sema.gpa, pt.tid, "len", .no_embedded_nulls); | 3667 | const field_name = try zcu.intern_pool.getOrPutString(sema.gpa, pt.tid, "len", .no_embedded_nulls); |
| 3658 | return sema.fieldVal(block, src, operand, field_name, src); | 3668 | return sema.fieldVal(block, src, operand, field_name, src); |
| 3659 | } | 3669 | } |
| ... | @@ -4544,7 +4554,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -4544,7 +4554,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 4544 | assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction | 4554 | assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction |
| 4545 | const elem_ty = ptr_ty.childType(zcu); | 4555 | const elem_ty = ptr_ty.childType(zcu); |
| 4546 | switch (ptr_ty.ptrSize(zcu)) { | 4556 | switch (ptr_ty.ptrSize(zcu)) { |
| 4547 | .One => { | 4557 | .one => { |
| 4548 | const uncoerced_ty = sema.typeOf(uncoerced_val); | 4558 | const uncoerced_ty = sema.typeOf(uncoerced_val); |
| 4549 | if (elem_ty.zigTypeTag(zcu) == .array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) { | 4559 | if (elem_ty.zigTypeTag(zcu) == .array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) { |
| 4550 | // We're trying to initialize a *[1]T with a reference to a T - don't perform any coercion. | 4560 | // We're trying to initialize a *[1]T with a reference to a T - don't perform any coercion. |
| ... | @@ -4557,7 +4567,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -4557,7 +4567,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 4557 | return sema.coerce(block, elem_ty, uncoerced_val, src); | 4567 | return sema.coerce(block, elem_ty, uncoerced_val, src); |
| 4558 | } | 4568 | } |
| 4559 | }, | 4569 | }, |
| 4560 | .Slice, .Many => { | 4570 | .slice, .many => { |
| 4561 | // Our goal is to coerce `uncoerced_val` to an array of `elem_ty`. | 4571 | // Our goal is to coerce `uncoerced_val` to an array of `elem_ty`. |
| 4562 | const val_ty = sema.typeOf(uncoerced_val); | 4572 | const val_ty = sema.typeOf(uncoerced_val); |
| 4563 | switch (val_ty.zigTypeTag(zcu)) { | 4573 | switch (val_ty.zigTypeTag(zcu)) { |
| ... | @@ -4573,7 +4583,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -4573,7 +4583,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 4573 | }); | 4583 | }); |
| 4574 | return sema.coerce(block, want_ty, uncoerced_val, src); | 4584 | return sema.coerce(block, want_ty, uncoerced_val, src); |
| 4575 | }, | 4585 | }, |
| 4576 | .C => { | 4586 | .c => { |
| 4577 | // There's nothing meaningful to do here, because we don't know if this is meant to be a | 4587 | // There's nothing meaningful to do here, because we don't know if this is meant to be a |
| 4578 | // single-pointer or a many-pointer. | 4588 | // single-pointer or a many-pointer. |
| 4579 | return uncoerced_val; | 4589 | return uncoerced_val; |
| ... | @@ -4685,7 +4695,7 @@ fn zirValidateArrayInitRefTy( | ... | @@ -4685,7 +4695,7 @@ fn zirValidateArrayInitRefTy( |
| 4685 | assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction | 4695 | assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction |
| 4686 | switch (zcu.intern_pool.indexToKey(ptr_ty.toIntern())) { | 4696 | switch (zcu.intern_pool.indexToKey(ptr_ty.toIntern())) { |
| 4687 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 4697 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 4688 | .Slice, .Many => { | 4698 | .slice, .many => { |
| 4689 | // Use array of correct length | 4699 | // Use array of correct length |
| 4690 | const arr_ty = try pt.arrayType(.{ | 4700 | const arr_ty = try pt.arrayType(.{ |
| 4691 | .len = extra.elem_count, | 4701 | .len = extra.elem_count, |
| ... | @@ -5502,9 +5512,9 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -5502,9 +5512,9 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 5502 | if (operand_ty.zigTypeTag(zcu) != .pointer) { | 5512 | if (operand_ty.zigTypeTag(zcu) != .pointer) { |
| 5503 | return sema.fail(block, src, "cannot dereference non-pointer type '{}'", .{operand_ty.fmt(pt)}); | 5513 | return sema.fail(block, src, "cannot dereference non-pointer type '{}'", .{operand_ty.fmt(pt)}); |
| 5504 | } else switch (operand_ty.ptrSize(zcu)) { | 5514 | } else switch (operand_ty.ptrSize(zcu)) { |
| 5505 | .One, .C => {}, | 5515 | .one, .c => {}, |
| 5506 | .Many => return sema.fail(block, src, "index syntax required for unknown-length pointer type '{}'", .{operand_ty.fmt(pt)}), | 5516 | .many => return sema.fail(block, src, "index syntax required for unknown-length pointer type '{}'", .{operand_ty.fmt(pt)}), |
| 5507 | .Slice => return sema.fail(block, src, "index syntax required for slice type '{}'", .{operand_ty.fmt(pt)}), | 5517 | .slice => return sema.fail(block, src, "index syntax required for slice type '{}'", .{operand_ty.fmt(pt)}), |
| 5508 | } | 5518 | } |
| 5509 | 5519 | ||
| 5510 | if ((try sema.typeHasOnePossibleValue(operand_ty.childType(zcu))) != null) { | 5520 | if ((try sema.typeHasOnePossibleValue(operand_ty.childType(zcu))) != null) { |
| ... | @@ -6521,7 +6531,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -6521,7 +6531,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 6521 | return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)}); | 6531 | return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)}); |
| 6522 | } | 6532 | } |
| 6523 | const ptr_ty_info = ptr_ty.ptrInfo(zcu); | 6533 | const ptr_ty_info = ptr_ty.ptrInfo(zcu); |
| 6524 | if (ptr_ty_info.flags.size == .Slice) { | 6534 | if (ptr_ty_info.flags.size == .slice) { |
| 6525 | return sema.fail(block, ptr_src, "export target cannot be slice", .{}); | 6535 | return sema.fail(block, ptr_src, "export target cannot be slice", .{}); |
| 6526 | } | 6536 | } |
| 6527 | if (ptr_ty_info.packed_offset.host_size != 0) { | 6537 | if (ptr_ty_info.packed_offset.host_size != 0) { |
| ... | @@ -7271,7 +7281,7 @@ fn checkCallArgumentCount( | ... | @@ -7271,7 +7281,7 @@ fn checkCallArgumentCount( |
| 7271 | .@"fn" => break :func_ty callee_ty, | 7281 | .@"fn" => break :func_ty callee_ty, |
| 7272 | .pointer => { | 7282 | .pointer => { |
| 7273 | const ptr_info = callee_ty.ptrInfo(zcu); | 7283 | const ptr_info = callee_ty.ptrInfo(zcu); |
| 7274 | if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { | 7284 | if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { |
| 7275 | break :func_ty Type.fromInterned(ptr_info.child); | 7285 | break :func_ty Type.fromInterned(ptr_info.child); |
| 7276 | } | 7286 | } |
| 7277 | }, | 7287 | }, |
| ... | @@ -7350,7 +7360,7 @@ fn callBuiltin( | ... | @@ -7350,7 +7360,7 @@ fn callBuiltin( |
| 7350 | .@"fn" => break :func_ty callee_ty, | 7360 | .@"fn" => break :func_ty callee_ty, |
| 7351 | .pointer => { | 7361 | .pointer => { |
| 7352 | const ptr_info = callee_ty.ptrInfo(zcu); | 7362 | const ptr_info = callee_ty.ptrInfo(zcu); |
| 7353 | if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { | 7363 | if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") { |
| 7354 | break :func_ty Type.fromInterned(ptr_info.child); | 7364 | break :func_ty Type.fromInterned(ptr_info.child); |
| 7355 | } | 7365 | } |
| 7356 | }, | 7366 | }, |
| ... | @@ -8344,8 +8354,8 @@ fn zirIndexablePtrElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -8344,8 +8354,8 @@ fn zirIndexablePtrElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 8344 | }; | 8354 | }; |
| 8345 | try sema.checkMemOperand(block, src, ptr_ty); | 8355 | try sema.checkMemOperand(block, src, ptr_ty); |
| 8346 | const elem_ty = switch (ptr_ty.ptrSize(zcu)) { | 8356 | const elem_ty = switch (ptr_ty.ptrSize(zcu)) { |
| 8347 | .Slice, .Many, .C => ptr_ty.childType(zcu), | 8357 | .slice, .many, .c => ptr_ty.childType(zcu), |
| 8348 | .One => ptr_ty.childType(zcu).childType(zcu), | 8358 | .one => ptr_ty.childType(zcu).childType(zcu), |
| 8349 | }; | 8359 | }; |
| 8350 | return Air.internedToRef(elem_ty.toIntern()); | 8360 | return Air.internedToRef(elem_ty.toIntern()); |
| 8351 | } | 8361 | } |
| ... | @@ -8943,7 +8953,7 @@ fn zirOptionalPayload( | ... | @@ -8943,7 +8953,7 @@ fn zirOptionalPayload( |
| 8943 | const result_ty = switch (operand_ty.zigTypeTag(zcu)) { | 8953 | const result_ty = switch (operand_ty.zigTypeTag(zcu)) { |
| 8944 | .optional => operand_ty.optionalChild(zcu), | 8954 | .optional => operand_ty.optionalChild(zcu), |
| 8945 | .pointer => t: { | 8955 | .pointer => t: { |
| 8946 | if (operand_ty.ptrSize(zcu) != .C) { | 8956 | if (operand_ty.ptrSize(zcu) != .c) { |
| 8947 | return sema.failWithExpectedOptionalType(block, src, operand_ty); | 8957 | return sema.failWithExpectedOptionalType(block, src, operand_ty); |
| 8948 | } | 8958 | } |
| 8949 | // TODO https://github.com/ziglang/zig/issues/6597 | 8959 | // TODO https://github.com/ziglang/zig/issues/6597 |
| ... | @@ -13972,7 +13982,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13972,7 +13982,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13972 | const has_field = hf: { | 13982 | const has_field = hf: { |
| 13973 | switch (ip.indexToKey(ty.toIntern())) { | 13983 | switch (ip.indexToKey(ty.toIntern())) { |
| 13974 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 13984 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 13975 | .Slice => { | 13985 | .slice => { |
| 13976 | if (field_name.eqlSlice("ptr", ip)) break :hf true; | 13986 | if (field_name.eqlSlice("ptr", ip)) break :hf true; |
| 13977 | if (field_name.eqlSlice("len", ip)) break :hf true; | 13987 | if (field_name.eqlSlice("len", ip)) break :hf true; |
| 13978 | break :hf false; | 13988 | break :hf false; |
| ... | @@ -14797,7 +14807,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14797,7 +14807,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14797 | const slice_ty = try pt.ptrTypeSema(.{ | 14807 | const slice_ty = try pt.ptrTypeSema(.{ |
| 14798 | .child = resolved_elem_ty.toIntern(), | 14808 | .child = resolved_elem_ty.toIntern(), |
| 14799 | .flags = .{ | 14809 | .flags = .{ |
| 14800 | .size = .Slice, | 14810 | .size = .slice, |
| 14801 | .address_space = ptr_as, | 14811 | .address_space = ptr_as, |
| 14802 | }, | 14812 | }, |
| 14803 | }); | 14813 | }); |
| ... | @@ -14925,7 +14935,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins | ... | @@ -14925,7 +14935,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins |
| 14925 | .pointer => { | 14935 | .pointer => { |
| 14926 | const ptr_info = operand_ty.ptrInfo(zcu); | 14936 | const ptr_info = operand_ty.ptrInfo(zcu); |
| 14927 | switch (ptr_info.flags.size) { | 14937 | switch (ptr_info.flags.size) { |
| 14928 | .Slice => { | 14938 | .slice => { |
| 14929 | const val = try sema.resolveConstDefinedValue(block, src, operand, .{ .simple = .slice_cat_operand }); | 14939 | const val = try sema.resolveConstDefinedValue(block, src, operand, .{ .simple = .slice_cat_operand }); |
| 14930 | return Type.ArrayInfo{ | 14940 | return Type.ArrayInfo{ |
| 14931 | .elem_type = Type.fromInterned(ptr_info.child), | 14941 | .elem_type = Type.fromInterned(ptr_info.child), |
| ... | @@ -14936,12 +14946,12 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins | ... | @@ -14936,12 +14946,12 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins |
| 14936 | .len = try val.sliceLen(pt), | 14946 | .len = try val.sliceLen(pt), |
| 14937 | }; | 14947 | }; |
| 14938 | }, | 14948 | }, |
| 14939 | .One => { | 14949 | .one => { |
| 14940 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { | 14950 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { |
| 14941 | return Type.fromInterned(ptr_info.child).arrayInfo(zcu); | 14951 | return Type.fromInterned(ptr_info.child).arrayInfo(zcu); |
| 14942 | } | 14952 | } |
| 14943 | }, | 14953 | }, |
| 14944 | .C, .Many => {}, | 14954 | .c, .many => {}, |
| 14945 | } | 14955 | } |
| 14946 | }, | 14956 | }, |
| 14947 | .@"struct" => { | 14957 | .@"struct" => { |
| ... | @@ -16610,7 +16620,7 @@ fn analyzeArithmetic( | ... | @@ -16610,7 +16620,7 @@ fn analyzeArithmetic( |
| 16610 | 16620 | ||
| 16611 | if (lhs_zig_ty_tag == .pointer) { | 16621 | if (lhs_zig_ty_tag == .pointer) { |
| 16612 | if (rhs_zig_ty_tag == .pointer) { | 16622 | if (rhs_zig_ty_tag == .pointer) { |
| 16613 | if (lhs_ty.ptrSize(zcu) != .Slice and rhs_ty.ptrSize(zcu) != .Slice) { | 16623 | if (lhs_ty.ptrSize(zcu) != .slice and rhs_ty.ptrSize(zcu) != .slice) { |
| 16614 | if (zir_tag != .sub) { | 16624 | if (zir_tag != .sub) { |
| 16615 | return sema.failWithInvalidPtrArithmetic(block, src, "pointer-pointer", "subtraction"); | 16625 | return sema.failWithInvalidPtrArithmetic(block, src, "pointer-pointer", "subtraction"); |
| 16616 | } | 16626 | } |
| ... | @@ -16662,8 +16672,8 @@ fn analyzeArithmetic( | ... | @@ -16662,8 +16672,8 @@ fn analyzeArithmetic( |
| 16662 | } | 16672 | } |
| 16663 | } else { | 16673 | } else { |
| 16664 | switch (lhs_ty.ptrSize(zcu)) { | 16674 | switch (lhs_ty.ptrSize(zcu)) { |
| 16665 | .One, .Slice => {}, | 16675 | .one, .slice => {}, |
| 16666 | .Many, .C => { | 16676 | .many, .c => { |
| 16667 | const air_tag: Air.Inst.Tag = switch (zir_tag) { | 16677 | const air_tag: Air.Inst.Tag = switch (zir_tag) { |
| 16668 | .add => .ptr_add, | 16678 | .add => .ptr_add, |
| 16669 | .sub => .ptr_sub, | 16679 | .sub => .ptr_sub, |
| ... | @@ -17160,7 +17170,7 @@ fn analyzePtrArithmetic( | ... | @@ -17160,7 +17170,7 @@ fn analyzePtrArithmetic( |
| 17160 | const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset); | 17170 | const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset); |
| 17161 | const ptr_ty = sema.typeOf(ptr); | 17171 | const ptr_ty = sema.typeOf(ptr); |
| 17162 | const ptr_info = ptr_ty.ptrInfo(zcu); | 17172 | const ptr_info = ptr_ty.ptrInfo(zcu); |
| 17163 | assert(ptr_info.flags.size == .Many or ptr_info.flags.size == .C); | 17173 | assert(ptr_info.flags.size == .many or ptr_info.flags.size == .c); |
| 17164 | 17174 | ||
| 17165 | const new_ptr_ty = t: { | 17175 | const new_ptr_ty = t: { |
| 17166 | // Calculate the new pointer alignment. | 17176 | // Calculate the new pointer alignment. |
| ... | @@ -18092,7 +18102,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18092,7 +18102,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18092 | const slice_ty = (try pt.ptrTypeSema(.{ | 18102 | const slice_ty = (try pt.ptrTypeSema(.{ |
| 18093 | .child = param_info_ty.toIntern(), | 18103 | .child = param_info_ty.toIntern(), |
| 18094 | .flags = .{ | 18104 | .flags = .{ |
| 18095 | .size = .Slice, | 18105 | .size = .slice, |
| 18096 | .is_const = true, | 18106 | .is_const = true, |
| 18097 | }, | 18107 | }, |
| 18098 | })).toIntern(); | 18108 | })).toIntern(); |
| ... | @@ -18335,7 +18345,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18335,7 +18345,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18335 | const slice_errors_ty = try pt.ptrTypeSema(.{ | 18345 | const slice_errors_ty = try pt.ptrTypeSema(.{ |
| 18336 | .child = error_field_ty.toIntern(), | 18346 | .child = error_field_ty.toIntern(), |
| 18337 | .flags = .{ | 18347 | .flags = .{ |
| 18338 | .size = .Slice, | 18348 | .size = .slice, |
| 18339 | .is_const = true, | 18349 | .is_const = true, |
| 18340 | }, | 18350 | }, |
| 18341 | }); | 18351 | }); |
| ... | @@ -18462,7 +18472,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18462,7 +18472,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18462 | const slice_ty = (try pt.ptrTypeSema(.{ | 18472 | const slice_ty = (try pt.ptrTypeSema(.{ |
| 18463 | .child = enum_field_ty.toIntern(), | 18473 | .child = enum_field_ty.toIntern(), |
| 18464 | .flags = .{ | 18474 | .flags = .{ |
| 18465 | .size = .Slice, | 18475 | .size = .slice, |
| 18466 | .is_const = true, | 18476 | .is_const = true, |
| 18467 | }, | 18477 | }, |
| 18468 | })).toIntern(); | 18478 | })).toIntern(); |
| ... | @@ -18575,7 +18585,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18575,7 +18585,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18575 | const slice_ty = (try pt.ptrTypeSema(.{ | 18585 | const slice_ty = (try pt.ptrTypeSema(.{ |
| 18576 | .child = union_field_ty.toIntern(), | 18586 | .child = union_field_ty.toIntern(), |
| 18577 | .flags = .{ | 18587 | .flags = .{ |
| 18578 | .size = .Slice, | 18588 | .size = .slice, |
| 18579 | .is_const = true, | 18589 | .is_const = true, |
| 18580 | }, | 18590 | }, |
| 18581 | })).toIntern(); | 18591 | })).toIntern(); |
| ... | @@ -18770,7 +18780,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18770,7 +18780,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18770 | const slice_ty = (try pt.ptrTypeSema(.{ | 18780 | const slice_ty = (try pt.ptrTypeSema(.{ |
| 18771 | .child = struct_field_ty.toIntern(), | 18781 | .child = struct_field_ty.toIntern(), |
| 18772 | .flags = .{ | 18782 | .flags = .{ |
| 18773 | .size = .Slice, | 18783 | .size = .slice, |
| 18774 | .is_const = true, | 18784 | .is_const = true, |
| 18775 | }, | 18785 | }, |
| 18776 | })).toIntern(); | 18786 | })).toIntern(); |
| ... | @@ -18879,7 +18889,7 @@ fn typeInfoDecls( | ... | @@ -18879,7 +18889,7 @@ fn typeInfoDecls( |
| 18879 | const slice_ty = (try pt.ptrTypeSema(.{ | 18889 | const slice_ty = (try pt.ptrTypeSema(.{ |
| 18880 | .child = declaration_ty.toIntern(), | 18890 | .child = declaration_ty.toIntern(), |
| 18881 | .flags = .{ | 18891 | .flags = .{ |
| 18882 | .size = .Slice, | 18892 | .size = .slice, |
| 18883 | .is_const = true, | 18893 | .is_const = true, |
| 18884 | }, | 18894 | }, |
| 18885 | })).toIntern(); | 18895 | })).toIntern(); |
| ... | @@ -20138,12 +20148,12 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -20138,12 +20148,12 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 20138 | } | 20148 | } |
| 20139 | 20149 | ||
| 20140 | if (elem_ty.zigTypeTag(zcu) == .@"fn") { | 20150 | if (elem_ty.zigTypeTag(zcu) == .@"fn") { |
| 20141 | if (inst_data.size != .One) { | 20151 | if (inst_data.size != .one) { |
| 20142 | return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{}); | 20152 | return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{}); |
| 20143 | } | 20153 | } |
| 20144 | } else if (inst_data.size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") { | 20154 | } else if (inst_data.size == .many and elem_ty.zigTypeTag(zcu) == .@"opaque") { |
| 20145 | return sema.fail(block, elem_ty_src, "unknown-length pointer to opaque not allowed", .{}); | 20155 | return sema.fail(block, elem_ty_src, "unknown-length pointer to opaque not allowed", .{}); |
| 20146 | } else if (inst_data.size == .C) { | 20156 | } else if (inst_data.size == .c) { |
| 20147 | if (!try sema.validateExternType(elem_ty, .other)) { | 20157 | if (!try sema.validateExternType(elem_ty, .other)) { |
| 20148 | const msg = msg: { | 20158 | const msg = msg: { |
| 20149 | const msg = try sema.errMsg(elem_ty_src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)}); | 20159 | const msg = try sema.errMsg(elem_ty_src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)}); |
| ... | @@ -21536,19 +21546,8 @@ fn zirReify( | ... | @@ -21536,19 +21546,8 @@ fn zirReify( |
| 21536 | .@"anyframe" => return sema.failWithUseOfAsync(block, src), | 21546 | .@"anyframe" => return sema.failWithUseOfAsync(block, src), |
| 21537 | .enum_literal => return .enum_literal_type, | 21547 | .enum_literal => return .enum_literal_type, |
| 21538 | .int => { | 21548 | .int => { |
| 21539 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); | 21549 | const int = try sema.interpretBuiltinType(block, operand_src, .fromInterned(union_val.val), std.builtin.Type.Int); |
| 21540 | const signedness_val = try Value.fromInterned(union_val.val).fieldValue( | 21550 | const ty = try pt.intType(int.signedness, int.bits); |
| 21541 | pt, | ||
| 21542 | struct_type.nameIndex(ip, try ip.getOrPutString(gpa, pt.tid, "signedness", .no_embedded_nulls)).?, | ||
| 21543 | ); | ||
| 21544 | const bits_val = try Value.fromInterned(union_val.val).fieldValue( | ||
| 21545 | pt, | ||
| 21546 | struct_type.nameIndex(ip, try ip.getOrPutString(gpa, pt.tid, "bits", .no_embedded_nulls)).?, | ||
| 21547 | ); | ||
| 21548 | |||
| 21549 | const signedness = zcu.toEnum(std.builtin.Signedness, signedness_val); | ||
| 21550 | const bits: u16 = @intCast(try bits_val.toUnsignedIntSema(pt)); | ||
| 21551 | const ty = try pt.intType(signedness, bits); | ||
| 21552 | return Air.internedToRef(ty.toIntern()); | 21551 | return Air.internedToRef(ty.toIntern()); |
| 21553 | }, | 21552 | }, |
| 21554 | .vector => { | 21553 | .vector => { |
| ... | @@ -21574,20 +21573,15 @@ fn zirReify( | ... | @@ -21574,20 +21573,15 @@ fn zirReify( |
| 21574 | return Air.internedToRef(ty.toIntern()); | 21573 | return Air.internedToRef(ty.toIntern()); |
| 21575 | }, | 21574 | }, |
| 21576 | .float => { | 21575 | .float => { |
| 21577 | const struct_type = ip.loadStructType(ip.typeOf(union_val.val)); | 21576 | const float = try sema.interpretBuiltinType(block, operand_src, .fromInterned(union_val.val), std.builtin.Type.Float); |
| 21578 | const bits_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( | ||
| 21579 | ip, | ||
| 21580 | try ip.getOrPutString(gpa, pt.tid, "bits", .no_embedded_nulls), | ||
| 21581 | ).?); | ||
| 21582 | 21577 | ||
| 21583 | const bits: u16 = @intCast(try bits_val.toUnsignedIntSema(pt)); | 21578 | const ty = switch (float.bits) { |
| 21584 | const ty = switch (bits) { | ||
| 21585 | 16 => Type.f16, | 21579 | 16 => Type.f16, |
| 21586 | 32 => Type.f32, | 21580 | 32 => Type.f32, |
| 21587 | 64 => Type.f64, | 21581 | 64 => Type.f64, |
| 21588 | 80 => Type.f80, | 21582 | 80 => Type.f80, |
| 21589 | 128 => Type.f128, | 21583 | 128 => Type.f128, |
| 21590 | else => return sema.fail(block, src, "{}-bit float unsupported", .{bits}), | 21584 | else => return sema.fail(block, src, "{}-bit float unsupported", .{float.bits}), |
| 21591 | }; | 21585 | }; |
| 21592 | return Air.internedToRef(ty.toIntern()); | 21586 | return Air.internedToRef(ty.toIntern()); |
| 21593 | }, | 21587 | }, |
| ... | @@ -21623,7 +21617,7 @@ fn zirReify( | ... | @@ -21623,7 +21617,7 @@ fn zirReify( |
| 21623 | ).?); | 21617 | ).?); |
| 21624 | const sentinel_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( | 21618 | const sentinel_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21625 | ip, | 21619 | ip, |
| 21626 | try ip.getOrPutString(gpa, pt.tid, "sentinel", .no_embedded_nulls), | 21620 | try ip.getOrPutString(gpa, pt.tid, "sentinel_ptr", .no_embedded_nulls), |
| 21627 | ).?); | 21621 | ).?); |
| 21628 | 21622 | ||
| 21629 | if (!try sema.intFitsInType(alignment_val, Type.u32, null)) { | 21623 | if (!try sema.intFitsInType(alignment_val, Type.u32, null)) { |
| ... | @@ -21641,11 +21635,11 @@ fn zirReify( | ... | @@ -21641,11 +21635,11 @@ fn zirReify( |
| 21641 | try elem_ty.resolveLayout(pt); | 21635 | try elem_ty.resolveLayout(pt); |
| 21642 | } | 21636 | } |
| 21643 | 21637 | ||
| 21644 | const ptr_size = zcu.toEnum(std.builtin.Type.Pointer.Size, size_val); | 21638 | const ptr_size = try sema.interpretBuiltinType(block, operand_src, size_val, std.builtin.Type.Pointer.Size); |
| 21645 | 21639 | ||
| 21646 | const actual_sentinel: InternPool.Index = s: { | 21640 | const actual_sentinel: InternPool.Index = s: { |
| 21647 | if (!sentinel_val.isNull(zcu)) { | 21641 | if (!sentinel_val.isNull(zcu)) { |
| 21648 | if (ptr_size == .One or ptr_size == .C) { | 21642 | if (ptr_size == .one or ptr_size == .c) { |
| 21649 | return sema.fail(block, src, "sentinels are only allowed on slices and unknown-length pointers", .{}); | 21643 | return sema.fail(block, src, "sentinels are only allowed on slices and unknown-length pointers", .{}); |
| 21650 | } | 21644 | } |
| 21651 | const sentinel_ptr_val = sentinel_val.optionalValue(zcu).?; | 21645 | const sentinel_ptr_val = sentinel_val.optionalValue(zcu).?; |
| ... | @@ -21660,12 +21654,12 @@ fn zirReify( | ... | @@ -21660,12 +21654,12 @@ fn zirReify( |
| 21660 | if (elem_ty.zigTypeTag(zcu) == .noreturn) { | 21654 | if (elem_ty.zigTypeTag(zcu) == .noreturn) { |
| 21661 | return sema.fail(block, src, "pointer to noreturn not allowed", .{}); | 21655 | return sema.fail(block, src, "pointer to noreturn not allowed", .{}); |
| 21662 | } else if (elem_ty.zigTypeTag(zcu) == .@"fn") { | 21656 | } else if (elem_ty.zigTypeTag(zcu) == .@"fn") { |
| 21663 | if (ptr_size != .One) { | 21657 | if (ptr_size != .one) { |
| 21664 | return sema.fail(block, src, "function pointers must be single pointers", .{}); | 21658 | return sema.fail(block, src, "function pointers must be single pointers", .{}); |
| 21665 | } | 21659 | } |
| 21666 | } else if (ptr_size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") { | 21660 | } else if (ptr_size == .many and elem_ty.zigTypeTag(zcu) == .@"opaque") { |
| 21667 | return sema.fail(block, src, "unknown-length pointer to opaque not allowed", .{}); | 21661 | return sema.fail(block, src, "unknown-length pointer to opaque not allowed", .{}); |
| 21668 | } else if (ptr_size == .C) { | 21662 | } else if (ptr_size == .c) { |
| 21669 | if (!try sema.validateExternType(elem_ty, .other)) { | 21663 | if (!try sema.validateExternType(elem_ty, .other)) { |
| 21670 | const msg = msg: { | 21664 | const msg = msg: { |
| 21671 | const msg = try sema.errMsg(src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)}); | 21665 | const msg = try sema.errMsg(src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)}); |
| ... | @@ -21691,7 +21685,7 @@ fn zirReify( | ... | @@ -21691,7 +21685,7 @@ fn zirReify( |
| 21691 | .is_const = is_const_val.toBool(), | 21685 | .is_const = is_const_val.toBool(), |
| 21692 | .is_volatile = is_volatile_val.toBool(), | 21686 | .is_volatile = is_volatile_val.toBool(), |
| 21693 | .alignment = abi_align, | 21687 | .alignment = abi_align, |
| 21694 | .address_space = zcu.toEnum(std.builtin.AddressSpace, address_space_val), | 21688 | .address_space = try sema.interpretBuiltinType(block, operand_src, address_space_val, std.builtin.AddressSpace), |
| 21695 | .is_allowzero = is_allowzero_val.toBool(), | 21689 | .is_allowzero = is_allowzero_val.toBool(), |
| 21696 | }, | 21690 | }, |
| 21697 | }); | 21691 | }); |
| ... | @@ -21709,7 +21703,7 @@ fn zirReify( | ... | @@ -21709,7 +21703,7 @@ fn zirReify( |
| 21709 | ).?); | 21703 | ).?); |
| 21710 | const sentinel_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( | 21704 | const sentinel_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex( |
| 21711 | ip, | 21705 | ip, |
| 21712 | try ip.getOrPutString(gpa, pt.tid, "sentinel", .no_embedded_nulls), | 21706 | try ip.getOrPutString(gpa, pt.tid, "sentinel_ptr", .no_embedded_nulls), |
| 21713 | ).?); | 21707 | ).?); |
| 21714 | 21708 | ||
| 21715 | const len = try len_val.toUnsignedIntSema(pt); | 21709 | const len = try len_val.toUnsignedIntSema(pt); |
| ... | @@ -21813,7 +21807,7 @@ fn zirReify( | ... | @@ -21813,7 +21807,7 @@ fn zirReify( |
| 21813 | try ip.getOrPutString(gpa, pt.tid, "is_tuple", .no_embedded_nulls), | 21807 | try ip.getOrPutString(gpa, pt.tid, "is_tuple", .no_embedded_nulls), |
| 21814 | ).?); | 21808 | ).?); |
| 21815 | 21809 | ||
| 21816 | const layout = zcu.toEnum(std.builtin.Type.ContainerLayout, layout_val); | 21810 | const layout = try sema.interpretBuiltinType(block, operand_src, layout_val, std.builtin.Type.ContainerLayout); |
| 21817 | 21811 | ||
| 21818 | // Decls | 21812 | // Decls |
| 21819 | if (try decls_val.sliceLen(pt) > 0) { | 21813 | if (try decls_val.sliceLen(pt) > 0) { |
| ... | @@ -21929,7 +21923,7 @@ fn zirReify( | ... | @@ -21929,7 +21923,7 @@ fn zirReify( |
| 21929 | if (try decls_val.sliceLen(pt) > 0) { | 21923 | if (try decls_val.sliceLen(pt) > 0) { |
| 21930 | return sema.fail(block, src, "reified unions must have no decls", .{}); | 21924 | return sema.fail(block, src, "reified unions must have no decls", .{}); |
| 21931 | } | 21925 | } |
| 21932 | const layout = zcu.toEnum(std.builtin.Type.ContainerLayout, layout_val); | 21926 | const layout = try sema.interpretBuiltinType(block, operand_src, layout_val, std.builtin.Type.ContainerLayout); |
| 21933 | 21927 | ||
| 21934 | const fields_arr = try sema.derefSliceAsArray(block, operand_src, fields_val, .{ .simple = .union_fields }); | 21928 | const fields_arr = try sema.derefSliceAsArray(block, operand_src, fields_val, .{ .simple = .union_fields }); |
| 21935 | 21929 | ||
| ... | @@ -23321,21 +23315,21 @@ fn ptrCastFull( | ... | @@ -23321,21 +23315,21 @@ fn ptrCastFull( |
| 23321 | try Type.fromInterned(src_info.child).resolveLayout(pt); | 23315 | try Type.fromInterned(src_info.child).resolveLayout(pt); |
| 23322 | try Type.fromInterned(dest_info.child).resolveLayout(pt); | 23316 | try Type.fromInterned(dest_info.child).resolveLayout(pt); |
| 23323 | 23317 | ||
| 23324 | const src_slice_like = src_info.flags.size == .Slice or | 23318 | const src_slice_like = src_info.flags.size == .slice or |
| 23325 | (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array); | 23319 | (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array); |
| 23326 | 23320 | ||
| 23327 | const dest_slice_like = dest_info.flags.size == .Slice or | 23321 | const dest_slice_like = dest_info.flags.size == .slice or |
| 23328 | (dest_info.flags.size == .One and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .array); | 23322 | (dest_info.flags.size == .one and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .array); |
| 23329 | 23323 | ||
| 23330 | if (dest_info.flags.size == .Slice and !src_slice_like) { | 23324 | if (dest_info.flags.size == .slice and !src_slice_like) { |
| 23331 | return sema.fail(block, src, "illegal pointer cast to slice", .{}); | 23325 | return sema.fail(block, src, "illegal pointer cast to slice", .{}); |
| 23332 | } | 23326 | } |
| 23333 | 23327 | ||
| 23334 | if (dest_info.flags.size == .Slice) { | 23328 | if (dest_info.flags.size == .slice) { |
| 23335 | const src_elem_size = switch (src_info.flags.size) { | 23329 | const src_elem_size = switch (src_info.flags.size) { |
| 23336 | .Slice => Type.fromInterned(src_info.child).abiSize(zcu), | 23330 | .slice => Type.fromInterned(src_info.child).abiSize(zcu), |
| 23337 | // pointer to array | 23331 | // pointer to array |
| 23338 | .One => Type.fromInterned(src_info.child).childType(zcu).abiSize(zcu), | 23332 | .one => Type.fromInterned(src_info.child).childType(zcu).abiSize(zcu), |
| 23339 | else => unreachable, | 23333 | else => unreachable, |
| 23340 | }; | 23334 | }; |
| 23341 | const dest_elem_size = Type.fromInterned(dest_info.child).abiSize(zcu); | 23335 | const dest_elem_size = Type.fromInterned(dest_info.child).abiSize(zcu); |
| ... | @@ -23350,17 +23344,17 @@ fn ptrCastFull( | ... | @@ -23350,17 +23344,17 @@ fn ptrCastFull( |
| 23350 | check_size: { | 23344 | check_size: { |
| 23351 | if (src_info.flags.size == dest_info.flags.size) break :check_size; | 23345 | if (src_info.flags.size == dest_info.flags.size) break :check_size; |
| 23352 | if (src_slice_like and dest_slice_like) break :check_size; | 23346 | if (src_slice_like and dest_slice_like) break :check_size; |
| 23353 | if (src_info.flags.size == .C) break :check_size; | 23347 | if (src_info.flags.size == .c) break :check_size; |
| 23354 | if (dest_info.flags.size == .C) break :check_size; | 23348 | if (dest_info.flags.size == .c) break :check_size; |
| 23355 | return sema.failWithOwnedErrorMsg(block, msg: { | 23349 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 23356 | const msg = try sema.errMsg(src, "cannot implicitly convert {s} to {s}", .{ | 23350 | const msg = try sema.errMsg(src, "cannot implicitly convert {s} to {s}", .{ |
| 23357 | pointerSizeString(src_info.flags.size), | 23351 | pointerSizeString(src_info.flags.size), |
| 23358 | pointerSizeString(dest_info.flags.size), | 23352 | pointerSizeString(dest_info.flags.size), |
| 23359 | }); | 23353 | }); |
| 23360 | errdefer msg.destroy(sema.gpa); | 23354 | errdefer msg.destroy(sema.gpa); |
| 23361 | if (dest_info.flags.size == .Many and | 23355 | if (dest_info.flags.size == .many and |
| 23362 | (src_info.flags.size == .Slice or | 23356 | (src_info.flags.size == .slice or |
| 23363 | (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array))) | 23357 | (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array))) |
| 23364 | { | 23358 | { |
| 23365 | try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{}); | 23359 | try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{}); |
| 23366 | } else { | 23360 | } else { |
| ... | @@ -23371,7 +23365,7 @@ fn ptrCastFull( | ... | @@ -23371,7 +23365,7 @@ fn ptrCastFull( |
| 23371 | } | 23365 | } |
| 23372 | 23366 | ||
| 23373 | check_child: { | 23367 | check_child: { |
| 23374 | const src_child = if (dest_info.flags.size == .Slice and src_info.flags.size == .One) blk: { | 23368 | const src_child = if (dest_info.flags.size == .slice and src_info.flags.size == .one) blk: { |
| 23375 | // *[n]T -> []T | 23369 | // *[n]T -> []T |
| 23376 | break :blk Type.fromInterned(src_info.child).childType(zcu); | 23370 | break :blk Type.fromInterned(src_info.child).childType(zcu); |
| 23377 | } else Type.fromInterned(src_info.child); | 23371 | } else Type.fromInterned(src_info.child); |
| ... | @@ -23402,12 +23396,12 @@ fn ptrCastFull( | ... | @@ -23402,12 +23396,12 @@ fn ptrCastFull( |
| 23402 | 23396 | ||
| 23403 | check_sent: { | 23397 | check_sent: { |
| 23404 | if (dest_info.sentinel == .none) break :check_sent; | 23398 | if (dest_info.sentinel == .none) break :check_sent; |
| 23405 | if (src_info.flags.size == .C) break :check_sent; | 23399 | if (src_info.flags.size == .c) break :check_sent; |
| 23406 | if (src_info.sentinel != .none) { | 23400 | if (src_info.sentinel != .none) { |
| 23407 | const coerced_sent = try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_info.sentinel, dest_info.child); | 23401 | const coerced_sent = try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_info.sentinel, dest_info.child); |
| 23408 | if (dest_info.sentinel == coerced_sent) break :check_sent; | 23402 | if (dest_info.sentinel == coerced_sent) break :check_sent; |
| 23409 | } | 23403 | } |
| 23410 | if (src_slice_like and src_info.flags.size == .One and dest_info.flags.size == .Slice) { | 23404 | if (src_slice_like and src_info.flags.size == .one and dest_info.flags.size == .slice) { |
| 23411 | // [*]nT -> []T | 23405 | // [*]nT -> []T |
| 23412 | const arr_ty = Type.fromInterned(src_info.child); | 23406 | const arr_ty = Type.fromInterned(src_info.child); |
| 23413 | if (arr_ty.sentinel(zcu)) |src_sentinel| { | 23407 | if (arr_ty.sentinel(zcu)) |src_sentinel| { |
| ... | @@ -23555,7 +23549,7 @@ fn ptrCastFull( | ... | @@ -23555,7 +23549,7 @@ fn ptrCastFull( |
| 23555 | } | 23549 | } |
| 23556 | } | 23550 | } |
| 23557 | 23551 | ||
| 23558 | const ptr = if (src_info.flags.size == .Slice and dest_info.flags.size != .Slice) ptr: { | 23552 | const ptr = if (src_info.flags.size == .slice and dest_info.flags.size != .slice) ptr: { |
| 23559 | if (operand_ty.zigTypeTag(zcu) == .optional) { | 23553 | if (operand_ty.zigTypeTag(zcu) == .optional) { |
| 23560 | break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty); | 23554 | break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty); |
| 23561 | } else { | 23555 | } else { |
| ... | @@ -23563,10 +23557,10 @@ fn ptrCastFull( | ... | @@ -23563,10 +23557,10 @@ fn ptrCastFull( |
| 23563 | } | 23557 | } |
| 23564 | } else operand; | 23558 | } else operand; |
| 23565 | 23559 | ||
| 23566 | const dest_ptr_ty = if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) blk: { | 23560 | const dest_ptr_ty = if (dest_info.flags.size == .slice and src_info.flags.size != .slice) blk: { |
| 23567 | // Only convert to a many-pointer at first | 23561 | // Only convert to a many-pointer at first |
| 23568 | var info = dest_info; | 23562 | var info = dest_info; |
| 23569 | info.flags.size = .Many; | 23563 | info.flags.size = .many; |
| 23570 | const ty = try pt.ptrTypeSema(info); | 23564 | const ty = try pt.ptrTypeSema(info); |
| 23571 | if (dest_ty.zigTypeTag(zcu) == .optional) { | 23565 | if (dest_ty.zigTypeTag(zcu) == .optional) { |
| 23572 | break :blk try pt.optionalType(ty.toIntern()); | 23566 | break :blk try pt.optionalType(ty.toIntern()); |
| ... | @@ -23594,7 +23588,7 @@ fn ptrCastFull( | ... | @@ -23594,7 +23588,7 @@ fn ptrCastFull( |
| 23594 | } | 23588 | } |
| 23595 | } | 23589 | } |
| 23596 | } | 23590 | } |
| 23597 | if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) { | 23591 | if (dest_info.flags.size == .slice and src_info.flags.size != .slice) { |
| 23598 | if (ptr_val.isUndef(zcu)) return pt.undefRef(dest_ty); | 23592 | if (ptr_val.isUndef(zcu)) return pt.undefRef(dest_ty); |
| 23599 | const arr_len = try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu)); | 23593 | const arr_len = try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu)); |
| 23600 | const ptr_val_key = zcu.intern_pool.indexToKey(ptr_val.toIntern()).ptr; | 23594 | const ptr_val_key = zcu.intern_pool.indexToKey(ptr_val.toIntern()).ptr; |
| ... | @@ -23622,7 +23616,7 @@ fn ptrCastFull( | ... | @@ -23622,7 +23616,7 @@ fn ptrCastFull( |
| 23622 | { | 23616 | { |
| 23623 | const ptr_int = try block.addUnOp(.int_from_ptr, ptr); | 23617 | const ptr_int = try block.addUnOp(.int_from_ptr, ptr); |
| 23624 | const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize); | 23618 | const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize); |
| 23625 | const ok = if (src_info.flags.size == .Slice and dest_info.flags.size == .Slice) ok: { | 23619 | const ok = if (src_info.flags.size == .slice and dest_info.flags.size == .slice) ok: { |
| 23626 | const len = try sema.analyzeSliceLen(block, operand_src, ptr); | 23620 | const len = try sema.analyzeSliceLen(block, operand_src, ptr); |
| 23627 | const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize); | 23621 | const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize); |
| 23628 | break :ok try block.addBinOp(.bool_or, len_zero, is_non_zero); | 23622 | break :ok try block.addBinOp(.bool_or, len_zero, is_non_zero); |
| ... | @@ -23639,7 +23633,7 @@ fn ptrCastFull( | ... | @@ -23639,7 +23633,7 @@ fn ptrCastFull( |
| 23639 | const ptr_int = try block.addUnOp(.int_from_ptr, ptr); | 23633 | const ptr_int = try block.addUnOp(.int_from_ptr, ptr); |
| 23640 | const remainder = try block.addBinOp(.bit_and, ptr_int, align_minus_1); | 23634 | const remainder = try block.addBinOp(.bit_and, ptr_int, align_minus_1); |
| 23641 | const is_aligned = try block.addBinOp(.cmp_eq, remainder, .zero_usize); | 23635 | const is_aligned = try block.addBinOp(.cmp_eq, remainder, .zero_usize); |
| 23642 | const ok = if (src_info.flags.size == .Slice and dest_info.flags.size == .Slice) ok: { | 23636 | const ok = if (src_info.flags.size == .slice and dest_info.flags.size == .slice) ok: { |
| 23643 | const len = try sema.analyzeSliceLen(block, operand_src, ptr); | 23637 | const len = try sema.analyzeSliceLen(block, operand_src, ptr); |
| 23644 | const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize); | 23638 | const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize); |
| 23645 | break :ok try block.addBinOp(.bool_or, len_zero, is_aligned); | 23639 | break :ok try block.addBinOp(.bool_or, len_zero, is_aligned); |
| ... | @@ -23672,7 +23666,7 @@ fn ptrCastFull( | ... | @@ -23672,7 +23666,7 @@ fn ptrCastFull( |
| 23672 | break :ptr try block.addBitCast(dest_ptr_ty, ptr); | 23666 | break :ptr try block.addBitCast(dest_ptr_ty, ptr); |
| 23673 | }; | 23667 | }; |
| 23674 | 23668 | ||
| 23675 | if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) { | 23669 | if (dest_info.flags.size == .slice and src_info.flags.size != .slice) { |
| 23676 | // We have to construct a slice using the operand's child's array length | 23670 | // We have to construct a slice using the operand's child's array length |
| 23677 | // Note that we know from the check at the start of the function that operand_ty is slice-like | 23671 | // Note that we know from the check at the start of the function that operand_ty is slice-like |
| 23678 | const arr_len = Air.internedToRef((try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu))).toIntern()); | 23672 | const arr_len = Air.internedToRef((try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu))).toIntern()); |
| ... | @@ -24066,8 +24060,8 @@ fn checkInvalidPtrIntArithmetic( | ... | @@ -24066,8 +24060,8 @@ fn checkInvalidPtrIntArithmetic( |
| 24066 | const zcu = pt.zcu; | 24060 | const zcu = pt.zcu; |
| 24067 | switch (try ty.zigTypeTagOrPoison(zcu)) { | 24061 | switch (try ty.zigTypeTagOrPoison(zcu)) { |
| 24068 | .pointer => switch (ty.ptrSize(zcu)) { | 24062 | .pointer => switch (ty.ptrSize(zcu)) { |
| 24069 | .One, .Slice => return, | 24063 | .one, .slice => return, |
| 24070 | .Many, .C => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"), | 24064 | .many, .c => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"), |
| 24071 | }, | 24065 | }, |
| 24072 | else => return, | 24066 | else => return, |
| 24073 | } | 24067 | } |
| ... | @@ -24456,7 +24450,7 @@ fn resolveExportOptions( | ... | @@ -24456,7 +24450,7 @@ fn resolveExportOptions( |
| 24456 | 24450 | ||
| 24457 | const linkage_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "linkage", .no_embedded_nulls), linkage_src); | 24451 | const linkage_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "linkage", .no_embedded_nulls), linkage_src); |
| 24458 | const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_operand, .{ .simple = .export_options }); | 24452 | const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_operand, .{ .simple = .export_options }); |
| 24459 | const linkage = zcu.toEnum(std.builtin.GlobalLinkage, linkage_val); | 24453 | const linkage = try sema.interpretBuiltinType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage); |
| 24460 | 24454 | ||
| 24461 | const section_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "section", .no_embedded_nulls), section_src); | 24455 | const section_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "section", .no_embedded_nulls), section_src); |
| 24462 | const section_opt_val = try sema.resolveConstDefinedValue(block, section_src, section_operand, .{ .simple = .export_options }); | 24456 | const section_opt_val = try sema.resolveConstDefinedValue(block, section_src, section_operand, .{ .simple = .export_options }); |
| ... | @@ -24467,7 +24461,7 @@ fn resolveExportOptions( | ... | @@ -24467,7 +24461,7 @@ fn resolveExportOptions( |
| 24467 | 24461 | ||
| 24468 | const visibility_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "visibility", .no_embedded_nulls), visibility_src); | 24462 | const visibility_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "visibility", .no_embedded_nulls), visibility_src); |
| 24469 | const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_operand, .{ .simple = .export_options }); | 24463 | const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_operand, .{ .simple = .export_options }); |
| 24470 | const visibility = zcu.toEnum(std.builtin.SymbolVisibility, visibility_val); | 24464 | const visibility = try sema.interpretBuiltinType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility); |
| 24471 | 24465 | ||
| 24472 | if (name.len < 1) { | 24466 | if (name.len < 1) { |
| 24473 | return sema.fail(block, name_src, "exported symbol name cannot be empty", .{}); | 24467 | return sema.fail(block, name_src, "exported symbol name cannot be empty", .{}); |
| ... | @@ -24495,12 +24489,11 @@ fn resolveBuiltinEnum( | ... | @@ -24495,12 +24489,11 @@ fn resolveBuiltinEnum( |
| 24495 | comptime name: Zcu.BuiltinDecl, | 24489 | comptime name: Zcu.BuiltinDecl, |
| 24496 | reason: ComptimeReason, | 24490 | reason: ComptimeReason, |
| 24497 | ) CompileError!@field(std.builtin, @tagName(name)) { | 24491 | ) CompileError!@field(std.builtin, @tagName(name)) { |
| 24498 | const pt = sema.pt; | ||
| 24499 | const ty = try sema.getBuiltinType(src, name); | 24492 | const ty = try sema.getBuiltinType(src, name); |
| 24500 | const air_ref = try sema.resolveInst(zir_ref); | 24493 | const air_ref = try sema.resolveInst(zir_ref); |
| 24501 | const coerced = try sema.coerce(block, ty, air_ref, src); | 24494 | const coerced = try sema.coerce(block, ty, air_ref, src); |
| 24502 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); | 24495 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); |
| 24503 | return pt.zcu.toEnum(@field(std.builtin, @tagName(name)), val); | 24496 | return sema.interpretBuiltinType(block, src, val, @field(std.builtin, @tagName(name))); |
| 24504 | } | 24497 | } |
| 24505 | 24498 | ||
| 24506 | fn resolveAtomicOrder( | 24499 | fn resolveAtomicOrder( |
| ... | @@ -25293,7 +25286,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -25293,7 +25286,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 25293 | const air_ref = try sema.resolveInst(extra.modifier); | 25286 | const air_ref = try sema.resolveInst(extra.modifier); |
| 25294 | const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src); | 25287 | const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src); |
| 25295 | const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ .simple = .call_modifier }); | 25288 | const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ .simple = .call_modifier }); |
| 25296 | var modifier = zcu.toEnum(std.builtin.CallModifier, modifier_val); | 25289 | var modifier = try sema.interpretBuiltinType(block, modifier_src, modifier_val, std.builtin.CallModifier); |
| 25297 | switch (modifier) { | 25290 | switch (modifier) { |
| 25298 | // These can be upgraded to comptime or nosuspend calls. | 25291 | // These can be upgraded to comptime or nosuspend calls. |
| 25299 | .auto, .never_tail, .no_async => { | 25292 | .auto, .never_tail, .no_async => { |
| ... | @@ -25384,7 +25377,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -25384,7 +25377,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 25384 | const parent_ptr_ty = try sema.resolveDestType(block, inst_src, extra.parent_ptr_type, .remove_eu, "@fieldParentPtr"); | 25377 | const parent_ptr_ty = try sema.resolveDestType(block, inst_src, extra.parent_ptr_type, .remove_eu, "@fieldParentPtr"); |
| 25385 | try sema.checkPtrType(block, inst_src, parent_ptr_ty, true); | 25378 | try sema.checkPtrType(block, inst_src, parent_ptr_ty, true); |
| 25386 | const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu); | 25379 | const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu); |
| 25387 | if (parent_ptr_info.flags.size != .One) { | 25380 | if (parent_ptr_info.flags.size != .one) { |
| 25388 | return sema.fail(block, inst_src, "expected single pointer type, found '{}'", .{parent_ptr_ty.fmt(pt)}); | 25381 | return sema.fail(block, inst_src, "expected single pointer type, found '{}'", .{parent_ptr_ty.fmt(pt)}); |
| 25389 | } | 25382 | } |
| 25390 | const parent_ty = Type.fromInterned(parent_ptr_info.child); | 25383 | const parent_ty = Type.fromInterned(parent_ptr_info.child); |
| ... | @@ -25862,7 +25855,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A | ... | @@ -25862,7 +25855,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A |
| 25862 | const zcu = pt.zcu; | 25855 | const zcu = pt.zcu; |
| 25863 | const ptr_ty = sema.typeOf(ptr); | 25856 | const ptr_ty = sema.typeOf(ptr); |
| 25864 | const info = ptr_ty.ptrInfo(zcu); | 25857 | const info = ptr_ty.ptrInfo(zcu); |
| 25865 | if (info.flags.size == .One) { | 25858 | if (info.flags.size == .one) { |
| 25866 | // Already an array pointer. | 25859 | // Already an array pointer. |
| 25867 | return ptr; | 25860 | return ptr; |
| 25868 | } | 25861 | } |
| ... | @@ -25880,7 +25873,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A | ... | @@ -25880,7 +25873,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A |
| 25880 | .address_space = info.flags.address_space, | 25873 | .address_space = info.flags.address_space, |
| 25881 | }, | 25874 | }, |
| 25882 | }); | 25875 | }); |
| 25883 | const non_slice_ptr = if (info.flags.size == .Slice) | 25876 | const non_slice_ptr = if (info.flags.size == .slice) |
| 25884 | try block.addTyOp(.slice_ptr, ptr_ty.slicePtrFieldType(zcu), ptr) | 25877 | try block.addTyOp(.slice_ptr, ptr_ty.slicePtrFieldType(zcu), ptr) |
| 25885 | else | 25878 | else |
| 25886 | ptr; | 25879 | ptr; |
| ... | @@ -26069,22 +26062,22 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -26069,22 +26062,22 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 26069 | const new_dest_ptr_ty = sema.typeOf(new_dest_ptr); | 26062 | const new_dest_ptr_ty = sema.typeOf(new_dest_ptr); |
| 26070 | const raw_dest_ptr = if (new_dest_ptr_ty.isSlice(zcu)) | 26063 | const raw_dest_ptr = if (new_dest_ptr_ty.isSlice(zcu)) |
| 26071 | try sema.analyzeSlicePtr(block, dest_src, new_dest_ptr, new_dest_ptr_ty) | 26064 | try sema.analyzeSlicePtr(block, dest_src, new_dest_ptr, new_dest_ptr_ty) |
| 26072 | else if (new_dest_ptr_ty.ptrSize(zcu) == .One) ptr: { | 26065 | else if (new_dest_ptr_ty.ptrSize(zcu) == .one) ptr: { |
| 26073 | var dest_manyptr_ty_key = zcu.intern_pool.indexToKey(new_dest_ptr_ty.toIntern()).ptr_type; | 26066 | var dest_manyptr_ty_key = zcu.intern_pool.indexToKey(new_dest_ptr_ty.toIntern()).ptr_type; |
| 26074 | assert(dest_manyptr_ty_key.flags.size == .One); | 26067 | assert(dest_manyptr_ty_key.flags.size == .one); |
| 26075 | dest_manyptr_ty_key.child = dest_elem_ty.toIntern(); | 26068 | dest_manyptr_ty_key.child = dest_elem_ty.toIntern(); |
| 26076 | dest_manyptr_ty_key.flags.size = .Many; | 26069 | dest_manyptr_ty_key.flags.size = .many; |
| 26077 | break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(dest_manyptr_ty_key), new_dest_ptr, dest_src); | 26070 | break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(dest_manyptr_ty_key), new_dest_ptr, dest_src); |
| 26078 | } else new_dest_ptr; | 26071 | } else new_dest_ptr; |
| 26079 | 26072 | ||
| 26080 | const new_src_ptr_ty = sema.typeOf(new_src_ptr); | 26073 | const new_src_ptr_ty = sema.typeOf(new_src_ptr); |
| 26081 | const raw_src_ptr = if (new_src_ptr_ty.isSlice(zcu)) | 26074 | const raw_src_ptr = if (new_src_ptr_ty.isSlice(zcu)) |
| 26082 | try sema.analyzeSlicePtr(block, src_src, new_src_ptr, new_src_ptr_ty) | 26075 | try sema.analyzeSlicePtr(block, src_src, new_src_ptr, new_src_ptr_ty) |
| 26083 | else if (new_src_ptr_ty.ptrSize(zcu) == .One) ptr: { | 26076 | else if (new_src_ptr_ty.ptrSize(zcu) == .one) ptr: { |
| 26084 | var src_manyptr_ty_key = zcu.intern_pool.indexToKey(new_src_ptr_ty.toIntern()).ptr_type; | 26077 | var src_manyptr_ty_key = zcu.intern_pool.indexToKey(new_src_ptr_ty.toIntern()).ptr_type; |
| 26085 | assert(src_manyptr_ty_key.flags.size == .One); | 26078 | assert(src_manyptr_ty_key.flags.size == .one); |
| 26086 | src_manyptr_ty_key.child = src_elem_ty.toIntern(); | 26079 | src_manyptr_ty_key.child = src_elem_ty.toIntern(); |
| 26087 | src_manyptr_ty_key.flags.size = .Many; | 26080 | src_manyptr_ty_key.flags.size = .many; |
| 26088 | break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(src_manyptr_ty_key), new_src_ptr, src_src); | 26081 | break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(src_manyptr_ty_key), new_src_ptr, src_src); |
| 26089 | } else new_src_ptr; | 26082 | } else new_src_ptr; |
| 26090 | 26083 | ||
| ... | @@ -26129,13 +26122,13 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -26129,13 +26122,13 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 26129 | const dest_elem_ty: Type = dest_elem_ty: { | 26122 | const dest_elem_ty: Type = dest_elem_ty: { |
| 26130 | const ptr_info = dest_ptr_ty.ptrInfo(zcu); | 26123 | const ptr_info = dest_ptr_ty.ptrInfo(zcu); |
| 26131 | switch (ptr_info.flags.size) { | 26124 | switch (ptr_info.flags.size) { |
| 26132 | .Slice => break :dest_elem_ty Type.fromInterned(ptr_info.child), | 26125 | .slice => break :dest_elem_ty Type.fromInterned(ptr_info.child), |
| 26133 | .One => { | 26126 | .one => { |
| 26134 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { | 26127 | if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) { |
| 26135 | break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu); | 26128 | break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu); |
| 26136 | } | 26129 | } |
| 26137 | }, | 26130 | }, |
| 26138 | .Many, .C => {}, | 26131 | .many, .c => {}, |
| 26139 | } | 26132 | } |
| 26140 | return sema.failWithOwnedErrorMsg(block, msg: { | 26133 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 26141 | const msg = try sema.errMsg(src, "unknown @memset length", .{}); | 26134 | const msg = try sema.errMsg(src, "unknown @memset length", .{}); |
| ... | @@ -26172,7 +26165,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -26172,7 +26165,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 26172 | } })); | 26165 | } })); |
| 26173 | const array_ptr_ty = ty: { | 26166 | const array_ptr_ty = ty: { |
| 26174 | var info = dest_ptr_ty.ptrInfo(zcu); | 26167 | var info = dest_ptr_ty.ptrInfo(zcu); |
| 26175 | info.flags.size = .One; | 26168 | info.flags.size = .one; |
| 26176 | info.child = array_ty.toIntern(); | 26169 | info.child = array_ty.toIntern(); |
| 26177 | break :ty try pt.ptrType(info); | 26170 | break :ty try pt.ptrType(info); |
| 26178 | }; | 26171 | }; |
| ... | @@ -26468,9 +26461,9 @@ fn resolvePrefetchOptions( | ... | @@ -26468,9 +26461,9 @@ fn resolvePrefetchOptions( |
| 26468 | const cache_val = try sema.resolveConstDefinedValue(block, cache_src, cache, .{ .simple = .prefetch_options }); | 26461 | const cache_val = try sema.resolveConstDefinedValue(block, cache_src, cache, .{ .simple = .prefetch_options }); |
| 26469 | 26462 | ||
| 26470 | return std.builtin.PrefetchOptions{ | 26463 | return std.builtin.PrefetchOptions{ |
| 26471 | .rw = zcu.toEnum(std.builtin.PrefetchOptions.Rw, rw_val), | 26464 | .rw = try sema.interpretBuiltinType(block, rw_src, rw_val, std.builtin.PrefetchOptions.Rw), |
| 26472 | .locality = @intCast(try locality_val.toUnsignedIntSema(pt)), | 26465 | .locality = @intCast(try locality_val.toUnsignedIntSema(pt)), |
| 26473 | .cache = zcu.toEnum(std.builtin.PrefetchOptions.Cache, cache_val), | 26466 | .cache = try sema.interpretBuiltinType(block, cache_src, cache_val, std.builtin.PrefetchOptions.Cache), |
| 26474 | }; | 26467 | }; |
| 26475 | } | 26468 | } |
| 26476 | 26469 | ||
| ... | @@ -26536,7 +26529,7 @@ fn resolveExternOptions( | ... | @@ -26536,7 +26529,7 @@ fn resolveExternOptions( |
| 26536 | 26529 | ||
| 26537 | const linkage_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "linkage", .no_embedded_nulls), linkage_src); | 26530 | const linkage_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "linkage", .no_embedded_nulls), linkage_src); |
| 26538 | const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_ref, .{ .simple = .extern_options }); | 26531 | const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_ref, .{ .simple = .extern_options }); |
| 26539 | const linkage = zcu.toEnum(std.builtin.GlobalLinkage, linkage_val); | 26532 | const linkage = try sema.interpretBuiltinType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage); |
| 26540 | 26533 | ||
| 26541 | const is_thread_local = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "is_thread_local", .no_embedded_nulls), thread_local_src); | 26534 | const is_thread_local = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "is_thread_local", .no_embedded_nulls), thread_local_src); |
| 26542 | const is_thread_local_val = try sema.resolveConstDefinedValue(block, thread_local_src, is_thread_local, .{ .simple = .extern_options }); | 26535 | const is_thread_local_val = try sema.resolveConstDefinedValue(block, thread_local_src, is_thread_local, .{ .simple = .extern_options }); |
| ... | @@ -26754,15 +26747,15 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co | ... | @@ -26754,15 +26747,15 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co |
| 26754 | .add_eq => ty: { | 26747 | .add_eq => ty: { |
| 26755 | const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty; | 26748 | const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty; |
| 26756 | switch (ptr_size) { | 26749 | switch (ptr_size) { |
| 26757 | .One, .Slice => break :ty lhs_ty, // invalid, let it error | 26750 | .one, .slice => break :ty lhs_ty, // invalid, let it error |
| 26758 | .Many, .C => break :ty .usize, // `[*]T + usize` | 26751 | .many, .c => break :ty .usize, // `[*]T + usize` |
| 26759 | } | 26752 | } |
| 26760 | }, | 26753 | }, |
| 26761 | .sub_eq => ty: { | 26754 | .sub_eq => ty: { |
| 26762 | const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty; | 26755 | const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty; |
| 26763 | switch (ptr_size) { | 26756 | switch (ptr_size) { |
| 26764 | .One, .Slice => break :ty lhs_ty, // invalid, let it error | 26757 | .one, .slice => break :ty lhs_ty, // invalid, let it error |
| 26765 | .Many, .C => break :ty .generic_poison, // could be `[*]T - [*]T` or `[*]T - usize` | 26758 | .many, .c => break :ty .generic_poison, // could be `[*]T - [*]T` or `[*]T - usize` |
| 26766 | } | 26759 | } |
| 26767 | }, | 26760 | }, |
| 26768 | }; | 26761 | }; |
| ... | @@ -26770,9 +26763,6 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co | ... | @@ -26770,9 +26763,6 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co |
| 26770 | } | 26763 | } |
| 26771 | 26764 | ||
| 26772 | fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void { | 26765 | fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void { |
| 26773 | const pt = sema.pt; | ||
| 26774 | const zcu = pt.zcu; | ||
| 26775 | |||
| 26776 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 26766 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 26777 | const uncoerced_hint = try sema.resolveInst(extra.operand); | 26767 | const uncoerced_hint = try sema.resolveInst(extra.operand); |
| 26778 | const operand_src = block.builtinCallArgSrc(extra.node, 0); | 26768 | const operand_src = block.builtinCallArgSrc(extra.node, 0); |
| ... | @@ -26784,7 +26774,7 @@ fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat | ... | @@ -26784,7 +26774,7 @@ fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat |
| 26784 | // We only apply the first hint in a branch. | 26774 | // We only apply the first hint in a branch. |
| 26785 | // This allows user-provided hints to override implicit cold hints. | 26775 | // This allows user-provided hints to override implicit cold hints. |
| 26786 | if (sema.branch_hint == null) { | 26776 | if (sema.branch_hint == null) { |
| 26787 | sema.branch_hint = zcu.toEnum(std.builtin.BranchHint, hint_val); | 26777 | sema.branch_hint = try sema.interpretBuiltinType(block, operand_src, hint_val, std.builtin.BranchHint); |
| 26788 | } | 26778 | } |
| 26789 | } | 26779 | } |
| 26790 | 26780 | ||
| ... | @@ -27556,7 +27546,7 @@ fn fieldVal( | ... | @@ -27556,7 +27546,7 @@ fn fieldVal( |
| 27556 | .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(), | 27546 | .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(), |
| 27557 | .sentinel = if (inner_ty.sentinel(zcu)) |s| s.toIntern() else .none, | 27547 | .sentinel = if (inner_ty.sentinel(zcu)) |s| s.toIntern() else .none, |
| 27558 | .flags = .{ | 27548 | .flags = .{ |
| 27559 | .size = .Many, | 27549 | .size = .many, |
| 27560 | .alignment = ptr_info.flags.alignment, | 27550 | .alignment = ptr_info.flags.alignment, |
| 27561 | .is_const = ptr_info.flags.is_const, | 27551 | .is_const = ptr_info.flags.is_const, |
| 27562 | .is_volatile = ptr_info.flags.is_volatile, | 27552 | .is_volatile = ptr_info.flags.is_volatile, |
| ... | @@ -27578,7 +27568,7 @@ fn fieldVal( | ... | @@ -27578,7 +27568,7 @@ fn fieldVal( |
| 27578 | }, | 27568 | }, |
| 27579 | .pointer => { | 27569 | .pointer => { |
| 27580 | const ptr_info = inner_ty.ptrInfo(zcu); | 27570 | const ptr_info = inner_ty.ptrInfo(zcu); |
| 27581 | if (ptr_info.flags.size == .Slice) { | 27571 | if (ptr_info.flags.size == .slice) { |
| 27582 | if (field_name.eqlSlice("ptr", ip)) { | 27572 | if (field_name.eqlSlice("ptr", ip)) { |
| 27583 | const slice = if (is_pointer_to) | 27573 | const slice = if (is_pointer_to) |
| 27584 | try sema.analyzeLoad(block, src, object, object_src) | 27574 | try sema.analyzeLoad(block, src, object, object_src) |
| ... | @@ -27740,7 +27730,7 @@ fn fieldPtr( | ... | @@ -27740,7 +27730,7 @@ fn fieldPtr( |
| 27740 | .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(), | 27730 | .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(), |
| 27741 | .sentinel = if (object_ty.sentinel(zcu)) |s| s.toIntern() else .none, | 27731 | .sentinel = if (object_ty.sentinel(zcu)) |s| s.toIntern() else .none, |
| 27742 | .flags = .{ | 27732 | .flags = .{ |
| 27743 | .size = .Many, | 27733 | .size = .many, |
| 27744 | .alignment = ptr_info.flags.alignment, | 27734 | .alignment = ptr_info.flags.alignment, |
| 27745 | .is_const = ptr_info.flags.is_const, | 27735 | .is_const = ptr_info.flags.is_const, |
| 27746 | .is_volatile = ptr_info.flags.is_volatile, | 27736 | .is_volatile = ptr_info.flags.is_volatile, |
| ... | @@ -27953,13 +27943,13 @@ fn fieldCallBind( | ... | @@ -27953,13 +27943,13 @@ fn fieldCallBind( |
| 27953 | const ip = &zcu.intern_pool; | 27943 | const ip = &zcu.intern_pool; |
| 27954 | const raw_ptr_src = src; // TODO better source location | 27944 | const raw_ptr_src = src; // TODO better source location |
| 27955 | const raw_ptr_ty = sema.typeOf(raw_ptr); | 27945 | const raw_ptr_ty = sema.typeOf(raw_ptr); |
| 27956 | const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .One or raw_ptr_ty.ptrSize(zcu) == .C)) | 27946 | const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .one or raw_ptr_ty.ptrSize(zcu) == .c)) |
| 27957 | raw_ptr_ty.childType(zcu) | 27947 | raw_ptr_ty.childType(zcu) |
| 27958 | else | 27948 | else |
| 27959 | return sema.fail(block, raw_ptr_src, "expected single pointer, found '{}'", .{raw_ptr_ty.fmt(pt)}); | 27949 | return sema.fail(block, raw_ptr_src, "expected single pointer, found '{}'", .{raw_ptr_ty.fmt(pt)}); |
| 27960 | 27950 | ||
| 27961 | // Optionally dereference a second pointer to get the concrete type. | 27951 | // Optionally dereference a second pointer to get the concrete type. |
| 27962 | const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .One; | 27952 | const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .one; |
| 27963 | const concrete_ty = if (is_double_ptr) inner_ty.childType(zcu) else inner_ty; | 27953 | const concrete_ty = if (is_double_ptr) inner_ty.childType(zcu) else inner_ty; |
| 27964 | const ptr_ty = if (is_double_ptr) inner_ty else raw_ptr_ty; | 27954 | const ptr_ty = if (is_double_ptr) inner_ty else raw_ptr_ty; |
| 27965 | const object_ptr = if (is_double_ptr) | 27955 | const object_ptr = if (is_double_ptr) |
| ... | @@ -28025,8 +28015,8 @@ fn fieldCallBind( | ... | @@ -28025,8 +28015,8 @@ fn fieldCallBind( |
| 28025 | const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]); | 28015 | const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]); |
| 28026 | if (first_param_type.isGenericPoison() or | 28016 | if (first_param_type.isGenericPoison() or |
| 28027 | (first_param_type.zigTypeTag(zcu) == .pointer and | 28017 | (first_param_type.zigTypeTag(zcu) == .pointer and |
| 28028 | (first_param_type.ptrSize(zcu) == .One or | 28018 | (first_param_type.ptrSize(zcu) == .one or |
| 28029 | first_param_type.ptrSize(zcu) == .C) and | 28019 | first_param_type.ptrSize(zcu) == .c) and |
| 28030 | first_param_type.childType(zcu).eql(concrete_ty, zcu))) | 28020 | first_param_type.childType(zcu).eql(concrete_ty, zcu))) |
| 28031 | { | 28021 | { |
| 28032 | // Note that if the param type is generic poison, we know that it must | 28022 | // Note that if the param type is generic poison, we know that it must |
| ... | @@ -28053,7 +28043,7 @@ fn fieldCallBind( | ... | @@ -28053,7 +28043,7 @@ fn fieldCallBind( |
| 28053 | .arg0_inst = deref, | 28043 | .arg0_inst = deref, |
| 28054 | } }; | 28044 | } }; |
| 28055 | } else if (child.zigTypeTag(zcu) == .pointer and | 28045 | } else if (child.zigTypeTag(zcu) == .pointer and |
| 28056 | child.ptrSize(zcu) == .One and | 28046 | child.ptrSize(zcu) == .one and |
| 28057 | child.childType(zcu).eql(concrete_ty, zcu)) | 28047 | child.childType(zcu).eql(concrete_ty, zcu)) |
| 28058 | { | 28048 | { |
| 28059 | return .{ .method = .{ | 28049 | return .{ .method = .{ |
| ... | @@ -28673,8 +28663,8 @@ fn elemPtrOneLayerOnly( | ... | @@ -28673,8 +28663,8 @@ fn elemPtrOneLayerOnly( |
| 28673 | try checkIndexable(sema, block, src, indexable_ty); | 28663 | try checkIndexable(sema, block, src, indexable_ty); |
| 28674 | 28664 | ||
| 28675 | switch (indexable_ty.ptrSize(zcu)) { | 28665 | switch (indexable_ty.ptrSize(zcu)) { |
| 28676 | .Slice => return sema.elemPtrSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety), | 28666 | .slice => return sema.elemPtrSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety), |
| 28677 | .Many, .C => { | 28667 | .many, .c => { |
| 28678 | const maybe_ptr_val = try sema.resolveDefinedValue(block, indexable_src, indexable); | 28668 | const maybe_ptr_val = try sema.resolveDefinedValue(block, indexable_src, indexable); |
| 28679 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); | 28669 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); |
| 28680 | ct: { | 28670 | ct: { |
| ... | @@ -28688,7 +28678,7 @@ fn elemPtrOneLayerOnly( | ... | @@ -28688,7 +28678,7 @@ fn elemPtrOneLayerOnly( |
| 28688 | 28678 | ||
| 28689 | return block.addPtrElemPtr(indexable, elem_index, result_ty); | 28679 | return block.addPtrElemPtr(indexable, elem_index, result_ty); |
| 28690 | }, | 28680 | }, |
| 28691 | .One => { | 28681 | .one => { |
| 28692 | const child_ty = indexable_ty.childType(zcu); | 28682 | const child_ty = indexable_ty.childType(zcu); |
| 28693 | const elem_ptr = switch (child_ty.zigTypeTag(zcu)) { | 28683 | const elem_ptr = switch (child_ty.zigTypeTag(zcu)) { |
| 28694 | .array, .vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety), | 28684 | .array, .vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety), |
| ... | @@ -28728,8 +28718,8 @@ fn elemVal( | ... | @@ -28728,8 +28718,8 @@ fn elemVal( |
| 28728 | 28718 | ||
| 28729 | switch (indexable_ty.zigTypeTag(zcu)) { | 28719 | switch (indexable_ty.zigTypeTag(zcu)) { |
| 28730 | .pointer => switch (indexable_ty.ptrSize(zcu)) { | 28720 | .pointer => switch (indexable_ty.ptrSize(zcu)) { |
| 28731 | .Slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety), | 28721 | .slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety), |
| 28732 | .Many, .C => { | 28722 | .many, .c => { |
| 28733 | const maybe_indexable_val = try sema.resolveDefinedValue(block, indexable_src, indexable); | 28723 | const maybe_indexable_val = try sema.resolveDefinedValue(block, indexable_src, indexable); |
| 28734 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); | 28724 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); |
| 28735 | 28725 | ||
| ... | @@ -28748,7 +28738,7 @@ fn elemVal( | ... | @@ -28748,7 +28738,7 @@ fn elemVal( |
| 28748 | 28738 | ||
| 28749 | return block.addBinOp(.ptr_elem_val, indexable, elem_index); | 28739 | return block.addBinOp(.ptr_elem_val, indexable, elem_index); |
| 28750 | }, | 28740 | }, |
| 28751 | .One => { | 28741 | .one => { |
| 28752 | arr_sent: { | 28742 | arr_sent: { |
| 28753 | const inner_ty = indexable_ty.childType(zcu); | 28743 | const inner_ty = indexable_ty.childType(zcu); |
| 28754 | if (inner_ty.zigTypeTag(zcu) != .array) break :arr_sent; | 28744 | if (inner_ty.zigTypeTag(zcu) != .array) break :arr_sent; |
| ... | @@ -29293,7 +29283,7 @@ fn coerceExtra( | ... | @@ -29293,7 +29283,7 @@ fn coerceExtra( |
| 29293 | 29283 | ||
| 29294 | // *T to *[1]T | 29284 | // *T to *[1]T |
| 29295 | single_item: { | 29285 | single_item: { |
| 29296 | if (dest_info.flags.size != .One) break :single_item; | 29286 | if (dest_info.flags.size != .one) break :single_item; |
| 29297 | if (!inst_ty.isSinglePointer(zcu)) break :single_item; | 29287 | if (!inst_ty.isSinglePointer(zcu)) break :single_item; |
| 29298 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; | 29288 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 29299 | const ptr_elem_ty = inst_ty.childType(zcu); | 29289 | const ptr_elem_ty = inst_ty.childType(zcu); |
| ... | @@ -29312,7 +29302,7 @@ fn coerceExtra( | ... | @@ -29312,7 +29302,7 @@ fn coerceExtra( |
| 29312 | // Coercions where the source is a single pointer to an array. | 29302 | // Coercions where the source is a single pointer to an array. |
| 29313 | src_array_ptr: { | 29303 | src_array_ptr: { |
| 29314 | if (!inst_ty.isSinglePointer(zcu)) break :src_array_ptr; | 29304 | if (!inst_ty.isSinglePointer(zcu)) break :src_array_ptr; |
| 29315 | if (dest_info.flags.size == .One) break :src_array_ptr; // `*[n]T` -> `*T` isn't valid | 29305 | if (dest_info.flags.size == .one) break :src_array_ptr; // `*[n]T` -> `*T` isn't valid |
| 29316 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; | 29306 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 29317 | const array_ty = inst_ty.childType(zcu); | 29307 | const array_ty = inst_ty.childType(zcu); |
| 29318 | if (array_ty.zigTypeTag(zcu) != .array) break :src_array_ptr; | 29308 | if (array_ty.zigTypeTag(zcu) != .array) break :src_array_ptr; |
| ... | @@ -29356,25 +29346,25 @@ fn coerceExtra( | ... | @@ -29356,25 +29346,25 @@ fn coerceExtra( |
| 29356 | } | 29346 | } |
| 29357 | 29347 | ||
| 29358 | switch (dest_info.flags.size) { | 29348 | switch (dest_info.flags.size) { |
| 29359 | .Slice => { | 29349 | .slice => { |
| 29360 | // *[N]T to []T | 29350 | // *[N]T to []T |
| 29361 | return sema.coerceArrayPtrToSlice(block, dest_ty, inst, inst_src); | 29351 | return sema.coerceArrayPtrToSlice(block, dest_ty, inst, inst_src); |
| 29362 | }, | 29352 | }, |
| 29363 | .C => { | 29353 | .c => { |
| 29364 | // *[N]T to [*c]T | 29354 | // *[N]T to [*c]T |
| 29365 | return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src); | 29355 | return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src); |
| 29366 | }, | 29356 | }, |
| 29367 | .Many => { | 29357 | .many => { |
| 29368 | // *[N]T to [*]T | 29358 | // *[N]T to [*]T |
| 29369 | return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src); | 29359 | return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src); |
| 29370 | }, | 29360 | }, |
| 29371 | .One => unreachable, // early exit at top of block | 29361 | .one => unreachable, // early exit at top of block |
| 29372 | } | 29362 | } |
| 29373 | } | 29363 | } |
| 29374 | 29364 | ||
| 29375 | // coercion from C pointer | 29365 | // coercion from C pointer |
| 29376 | if (inst_ty.isCPtr(zcu)) src_c_ptr: { | 29366 | if (inst_ty.isCPtr(zcu)) src_c_ptr: { |
| 29377 | if (dest_info.flags.size == .Slice) break :src_c_ptr; | 29367 | if (dest_info.flags.size == .slice) break :src_c_ptr; |
| 29378 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :src_c_ptr; | 29368 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :src_c_ptr; |
| 29379 | // In this case we must add a safety check because the C pointer | 29369 | // In this case we must add a safety check because the C pointer |
| 29380 | // could be null. | 29370 | // could be null. |
| ... | @@ -29413,7 +29403,7 @@ fn coerceExtra( | ... | @@ -29413,7 +29403,7 @@ fn coerceExtra( |
| 29413 | 29403 | ||
| 29414 | switch (dest_info.flags.size) { | 29404 | switch (dest_info.flags.size) { |
| 29415 | // coercion to C pointer | 29405 | // coercion to C pointer |
| 29416 | .C => switch (inst_ty.zigTypeTag(zcu)) { | 29406 | .c => switch (inst_ty.zigTypeTag(zcu)) { |
| 29417 | .null => return Air.internedToRef(try pt.intern(.{ .ptr = .{ | 29407 | .null => return Air.internedToRef(try pt.intern(.{ .ptr = .{ |
| 29418 | .ty = dest_ty.toIntern(), | 29408 | .ty = dest_ty.toIntern(), |
| 29419 | .base_addr = .int, | 29409 | .base_addr = .int, |
| ... | @@ -29457,7 +29447,7 @@ fn coerceExtra( | ... | @@ -29457,7 +29447,7 @@ fn coerceExtra( |
| 29457 | .ok => {}, | 29447 | .ok => {}, |
| 29458 | else => break :p, | 29448 | else => break :p, |
| 29459 | } | 29449 | } |
| 29460 | if (inst_info.flags.size == .Slice) { | 29450 | if (inst_info.flags.size == .slice) { |
| 29461 | assert(dest_info.sentinel == .none); | 29451 | assert(dest_info.sentinel == .none); |
| 29462 | if (inst_info.sentinel == .none or | 29452 | if (inst_info.sentinel == .none or |
| 29463 | inst_info.sentinel != (try pt.intValue(Type.fromInterned(inst_info.child), 0)).toIntern()) | 29453 | inst_info.sentinel != (try pt.intValue(Type.fromInterned(inst_info.child), 0)).toIntern()) |
| ... | @@ -29470,8 +29460,8 @@ fn coerceExtra( | ... | @@ -29470,8 +29460,8 @@ fn coerceExtra( |
| 29470 | }, | 29460 | }, |
| 29471 | else => {}, | 29461 | else => {}, |
| 29472 | }, | 29462 | }, |
| 29473 | .One => {}, | 29463 | .one => {}, |
| 29474 | .Slice => to_slice: { | 29464 | .slice => to_slice: { |
| 29475 | if (inst_ty.zigTypeTag(zcu) == .array) { | 29465 | if (inst_ty.zigTypeTag(zcu) == .array) { |
| 29476 | return sema.fail( | 29466 | return sema.fail( |
| 29477 | block, | 29467 | block, |
| ... | @@ -29512,7 +29502,7 @@ fn coerceExtra( | ... | @@ -29512,7 +29502,7 @@ fn coerceExtra( |
| 29512 | } | 29502 | } |
| 29513 | return sema.coerceTupleToSlicePtrs(block, dest_ty, dest_ty_src, inst, inst_src); | 29503 | return sema.coerceTupleToSlicePtrs(block, dest_ty, dest_ty_src, inst, inst_src); |
| 29514 | }, | 29504 | }, |
| 29515 | .Many => p: { | 29505 | .many => p: { |
| 29516 | if (!inst_ty.isSlice(zcu)) break :p; | 29506 | if (!inst_ty.isSlice(zcu)) break :p; |
| 29517 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :p; | 29507 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :p; |
| 29518 | const inst_info = inst_ty.ptrInfo(zcu); | 29508 | const inst_info = inst_ty.ptrInfo(zcu); |
| ... | @@ -30224,10 +30214,10 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -30224,10 +30214,10 @@ const InMemoryCoercionResult = union(enum) { |
| 30224 | 30214 | ||
| 30225 | fn pointerSizeString(size: std.builtin.Type.Pointer.Size) []const u8 { | 30215 | fn pointerSizeString(size: std.builtin.Type.Pointer.Size) []const u8 { |
| 30226 | return switch (size) { | 30216 | return switch (size) { |
| 30227 | .One => "single pointer", | 30217 | .one => "single pointer", |
| 30228 | .Many => "many pointer", | 30218 | .many => "many pointer", |
| 30229 | .C => "C pointer", | 30219 | .c => "C pointer", |
| 30230 | .Slice => "slice", | 30220 | .slice => "slice", |
| 30231 | }; | 30221 | }; |
| 30232 | } | 30222 | } |
| 30233 | 30223 | ||
| ... | @@ -30775,7 +30765,7 @@ fn coerceInMemoryAllowedPtrs( | ... | @@ -30775,7 +30765,7 @@ fn coerceInMemoryAllowedPtrs( |
| 30775 | const src_info = src_ptr_ty.ptrInfo(zcu); | 30765 | const src_info = src_ptr_ty.ptrInfo(zcu); |
| 30776 | 30766 | ||
| 30777 | const ok_ptr_size = src_info.flags.size == dest_info.flags.size or | 30767 | const ok_ptr_size = src_info.flags.size == dest_info.flags.size or |
| 30778 | src_info.flags.size == .C or dest_info.flags.size == .C; | 30768 | src_info.flags.size == .c or dest_info.flags.size == .c; |
| 30779 | if (!ok_ptr_size) { | 30769 | if (!ok_ptr_size) { |
| 30780 | return InMemoryCoercionResult{ .ptr_size = .{ | 30770 | return InMemoryCoercionResult{ .ptr_size = .{ |
| 30781 | .actual = src_info.flags.size, | 30771 | .actual = src_info.flags.size, |
| ... | @@ -30874,7 +30864,7 @@ fn coerceInMemoryAllowedPtrs( | ... | @@ -30874,7 +30864,7 @@ fn coerceInMemoryAllowedPtrs( |
| 30874 | if (ss != .none and ds != .none) { | 30864 | if (ss != .none and ds != .none) { |
| 30875 | if (ds == try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, ss, dest_info.child)) break :ok true; | 30865 | if (ds == try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, ss, dest_info.child)) break :ok true; |
| 30876 | } | 30866 | } |
| 30877 | if (src_info.flags.size == .C) break :ok true; | 30867 | if (src_info.flags.size == .c) break :ok true; |
| 30878 | if (!dest_is_mut and dest_info.sentinel == .none) break :ok true; | 30868 | if (!dest_is_mut and dest_info.sentinel == .none) break :ok true; |
| 30879 | break :ok false; | 30869 | break :ok false; |
| 30880 | }; | 30870 | }; |
| ... | @@ -31392,7 +31382,7 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul | ... | @@ -31392,7 +31382,7 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul |
| 31392 | const dest_info = dest_ty.ptrInfo(zcu); | 31382 | const dest_info = dest_ty.ptrInfo(zcu); |
| 31393 | const inst_info = inst_ty.ptrInfo(zcu); | 31383 | const inst_info = inst_ty.ptrInfo(zcu); |
| 31394 | const len0 = (Type.fromInterned(inst_info.child).zigTypeTag(zcu) == .array and (Type.fromInterned(inst_info.child).arrayLenIncludingSentinel(zcu) == 0 or | 31384 | const len0 = (Type.fromInterned(inst_info.child).zigTypeTag(zcu) == .array and (Type.fromInterned(inst_info.child).arrayLenIncludingSentinel(zcu) == 0 or |
| 31395 | (Type.fromInterned(inst_info.child).arrayLen(zcu) == 0 and dest_info.sentinel == .none and dest_info.flags.size != .C and dest_info.flags.size != .Many))) or | 31385 | (Type.fromInterned(inst_info.child).arrayLen(zcu) == 0 and dest_info.sentinel == .none and dest_info.flags.size != .c and dest_info.flags.size != .many))) or |
| 31396 | (Type.fromInterned(inst_info.child).isTuple(zcu) and Type.fromInterned(inst_info.child).structFieldCount(zcu) == 0); | 31386 | (Type.fromInterned(inst_info.child).isTuple(zcu) and Type.fromInterned(inst_info.child).structFieldCount(zcu) == 0); |
| 31397 | 31387 | ||
| 31398 | const ok_const = (!inst_info.flags.is_const or dest_info.flags.is_const) or len0; | 31388 | const ok_const = (!inst_info.flags.is_const or dest_info.flags.is_const) or len0; |
| ... | @@ -32631,7 +32621,7 @@ fn analyzeSlice( | ... | @@ -32631,7 +32621,7 @@ fn analyzeSlice( |
| 32631 | elem_ty = ptr_ptr_child_ty.childType(zcu); | 32621 | elem_ty = ptr_ptr_child_ty.childType(zcu); |
| 32632 | }, | 32622 | }, |
| 32633 | .pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) { | 32623 | .pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) { |
| 32634 | .One => { | 32624 | .one => { |
| 32635 | const double_child_ty = ptr_ptr_child_ty.childType(zcu); | 32625 | const double_child_ty = ptr_ptr_child_ty.childType(zcu); |
| 32636 | ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src); | 32626 | ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src); |
| 32637 | if (double_child_ty.zigTypeTag(zcu) == .array) { | 32627 | if (double_child_ty.zigTypeTag(zcu) == .array) { |
| ... | @@ -32721,14 +32711,14 @@ fn analyzeSlice( | ... | @@ -32721,14 +32711,14 @@ fn analyzeSlice( |
| 32721 | elem_ty = double_child_ty; | 32711 | elem_ty = double_child_ty; |
| 32722 | } | 32712 | } |
| 32723 | }, | 32713 | }, |
| 32724 | .Many, .C => { | 32714 | .many, .c => { |
| 32725 | ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu); | 32715 | ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu); |
| 32726 | ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src); | 32716 | ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src); |
| 32727 | slice_ty = ptr_ptr_child_ty; | 32717 | slice_ty = ptr_ptr_child_ty; |
| 32728 | array_ty = ptr_ptr_child_ty; | 32718 | array_ty = ptr_ptr_child_ty; |
| 32729 | elem_ty = ptr_ptr_child_ty.childType(zcu); | 32719 | elem_ty = ptr_ptr_child_ty.childType(zcu); |
| 32730 | 32720 | ||
| 32731 | if (ptr_ptr_child_ty.ptrSize(zcu) == .C) { | 32721 | if (ptr_ptr_child_ty.ptrSize(zcu) == .c) { |
| 32732 | if (try sema.resolveDefinedValue(block, ptr_src, ptr_or_slice)) |ptr_val| { | 32722 | if (try sema.resolveDefinedValue(block, ptr_src, ptr_or_slice)) |ptr_val| { |
| 32733 | if (ptr_val.isNull(zcu)) { | 32723 | if (ptr_val.isNull(zcu)) { |
| 32734 | return sema.fail(block, src, "slice of null pointer", .{}); | 32724 | return sema.fail(block, src, "slice of null pointer", .{}); |
| ... | @@ -32736,7 +32726,7 @@ fn analyzeSlice( | ... | @@ -32736,7 +32726,7 @@ fn analyzeSlice( |
| 32736 | } | 32726 | } |
| 32737 | } | 32727 | } |
| 32738 | }, | 32728 | }, |
| 32739 | .Slice => { | 32729 | .slice => { |
| 32740 | ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu); | 32730 | ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu); |
| 32741 | ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src); | 32731 | ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src); |
| 32742 | slice_ty = ptr_ptr_child_ty; | 32732 | slice_ty = ptr_ptr_child_ty; |
| ... | @@ -32752,9 +32742,9 @@ fn analyzeSlice( | ... | @@ -32752,9 +32742,9 @@ fn analyzeSlice( |
| 32752 | else if (array_ty.zigTypeTag(zcu) == .array) ptr: { | 32742 | else if (array_ty.zigTypeTag(zcu) == .array) ptr: { |
| 32753 | var manyptr_ty_key = zcu.intern_pool.indexToKey(slice_ty.toIntern()).ptr_type; | 32743 | var manyptr_ty_key = zcu.intern_pool.indexToKey(slice_ty.toIntern()).ptr_type; |
| 32754 | assert(manyptr_ty_key.child == array_ty.toIntern()); | 32744 | assert(manyptr_ty_key.child == array_ty.toIntern()); |
| 32755 | assert(manyptr_ty_key.flags.size == .One); | 32745 | assert(manyptr_ty_key.flags.size == .one); |
| 32756 | manyptr_ty_key.child = elem_ty.toIntern(); | 32746 | manyptr_ty_key.child = elem_ty.toIntern(); |
| 32757 | manyptr_ty_key.flags.size = .Many; | 32747 | manyptr_ty_key.flags.size = .many; |
| 32758 | break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(manyptr_ty_key), ptr_or_slice, ptr_src); | 32748 | break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(manyptr_ty_key), ptr_or_slice, ptr_src); |
| 32759 | } else ptr_or_slice; | 32749 | } else ptr_or_slice; |
| 32760 | 32750 | ||
| ... | @@ -32967,7 +32957,7 @@ fn analyzeSlice( | ... | @@ -32967,7 +32957,7 @@ fn analyzeSlice( |
| 32967 | const opt_new_len_val = try sema.resolveDefinedValue(block, src, new_len); | 32957 | const opt_new_len_val = try sema.resolveDefinedValue(block, src, new_len); |
| 32968 | 32958 | ||
| 32969 | const new_ptr_ty_info = new_ptr_ty.ptrInfo(zcu); | 32959 | const new_ptr_ty_info = new_ptr_ty.ptrInfo(zcu); |
| 32970 | const new_allowzero = new_ptr_ty_info.flags.is_allowzero and sema.typeOf(ptr).ptrSize(zcu) != .C; | 32960 | const new_allowzero = new_ptr_ty_info.flags.is_allowzero and sema.typeOf(ptr).ptrSize(zcu) != .c; |
| 32971 | 32961 | ||
| 32972 | if (opt_new_len_val) |new_len_val| { | 32962 | if (opt_new_len_val) |new_len_val| { |
| 32973 | const new_len_int = try new_len_val.toUnsignedIntSema(pt); | 32963 | const new_len_int = try new_len_val.toUnsignedIntSema(pt); |
| ... | @@ -33038,7 +33028,7 @@ fn analyzeSlice( | ... | @@ -33038,7 +33028,7 @@ fn analyzeSlice( |
| 33038 | .child = elem_ty.toIntern(), | 33028 | .child = elem_ty.toIntern(), |
| 33039 | .sentinel = if (sentinel) |s| s.toIntern() else .none, | 33029 | .sentinel = if (sentinel) |s| s.toIntern() else .none, |
| 33040 | .flags = .{ | 33030 | .flags = .{ |
| 33041 | .size = .Slice, | 33031 | .size = .slice, |
| 33042 | .alignment = new_ptr_ty_info.flags.alignment, | 33032 | .alignment = new_ptr_ty_info.flags.alignment, |
| 33043 | .is_const = new_ptr_ty_info.flags.is_const, | 33033 | .is_const = new_ptr_ty_info.flags.is_const, |
| 33044 | .is_volatile = new_ptr_ty_info.flags.is_volatile, | 33034 | .is_volatile = new_ptr_ty_info.flags.is_volatile, |
| ... | @@ -33739,7 +33729,7 @@ const PeerResolveStrategy = enum { | ... | @@ -33739,7 +33729,7 @@ const PeerResolveStrategy = enum { |
| 33739 | .int => .fixed_int, | 33729 | .int => .fixed_int, |
| 33740 | .comptime_float => .comptime_float, | 33730 | .comptime_float => .comptime_float, |
| 33741 | .float => .fixed_float, | 33731 | .float => .fixed_float, |
| 33742 | .pointer => if (ty.ptrInfo(zcu).flags.size == .C) .c_ptr else .ptr, | 33732 | .pointer => if (ty.ptrInfo(zcu).flags.size == .c) .c_ptr else .ptr, |
| 33743 | .array => .array, | 33733 | .array => .array, |
| 33744 | .vector => .vector, | 33734 | .vector => .vector, |
| 33745 | .optional => .optional, | 33735 | .optional => .optional, |
| ... | @@ -34235,7 +34225,7 @@ fn resolvePeerTypesInner( | ... | @@ -34235,7 +34225,7 @@ fn resolvePeerTypesInner( |
| 34235 | 34225 | ||
| 34236 | var ptr_info = opt_ptr_info orelse { | 34226 | var ptr_info = opt_ptr_info orelse { |
| 34237 | opt_ptr_info = peer_info; | 34227 | opt_ptr_info = peer_info; |
| 34238 | opt_ptr_info.?.flags.size = .C; | 34228 | opt_ptr_info.?.flags.size = .c; |
| 34239 | first_idx = i; | 34229 | first_idx = i; |
| 34240 | continue; | 34230 | continue; |
| 34241 | }; | 34231 | }; |
| ... | @@ -34323,9 +34313,9 @@ fn resolvePeerTypesInner( | ... | @@ -34323,9 +34313,9 @@ fn resolvePeerTypesInner( |
| 34323 | }; | 34313 | }; |
| 34324 | 34314 | ||
| 34325 | switch (peer_info.flags.size) { | 34315 | switch (peer_info.flags.size) { |
| 34326 | .One, .Many => {}, | 34316 | .one, .many => {}, |
| 34327 | .Slice => opt_slice_idx = i, | 34317 | .slice => opt_slice_idx = i, |
| 34328 | .C => return .{ .conflict = .{ | 34318 | .c => return .{ .conflict = .{ |
| 34329 | .peer_idx_a = strat_reason, | 34319 | .peer_idx_a = strat_reason, |
| 34330 | .peer_idx_b = i, | 34320 | .peer_idx_b = i, |
| 34331 | } }, | 34321 | } }, |
| ... | @@ -34370,21 +34360,21 @@ fn resolvePeerTypesInner( | ... | @@ -34370,21 +34360,21 @@ fn resolvePeerTypesInner( |
| 34370 | ptr_info.flags.is_allowzero = ptr_info.flags.is_allowzero or peer_info.flags.is_allowzero; | 34360 | ptr_info.flags.is_allowzero = ptr_info.flags.is_allowzero or peer_info.flags.is_allowzero; |
| 34371 | 34361 | ||
| 34372 | const peer_sentinel: InternPool.Index = switch (peer_info.flags.size) { | 34362 | const peer_sentinel: InternPool.Index = switch (peer_info.flags.size) { |
| 34373 | .One => switch (ip.indexToKey(peer_info.child)) { | 34363 | .one => switch (ip.indexToKey(peer_info.child)) { |
| 34374 | .array_type => |array_type| array_type.sentinel, | 34364 | .array_type => |array_type| array_type.sentinel, |
| 34375 | else => .none, | 34365 | else => .none, |
| 34376 | }, | 34366 | }, |
| 34377 | .Many, .Slice => peer_info.sentinel, | 34367 | .many, .slice => peer_info.sentinel, |
| 34378 | .C => unreachable, | 34368 | .c => unreachable, |
| 34379 | }; | 34369 | }; |
| 34380 | 34370 | ||
| 34381 | const cur_sentinel: InternPool.Index = switch (ptr_info.flags.size) { | 34371 | const cur_sentinel: InternPool.Index = switch (ptr_info.flags.size) { |
| 34382 | .One => switch (ip.indexToKey(ptr_info.child)) { | 34372 | .one => switch (ip.indexToKey(ptr_info.child)) { |
| 34383 | .array_type => |array_type| array_type.sentinel, | 34373 | .array_type => |array_type| array_type.sentinel, |
| 34384 | else => .none, | 34374 | else => .none, |
| 34385 | }, | 34375 | }, |
| 34386 | .Many, .Slice => ptr_info.sentinel, | 34376 | .many, .slice => ptr_info.sentinel, |
| 34387 | .C => unreachable, | 34377 | .c => unreachable, |
| 34388 | }; | 34378 | }; |
| 34389 | 34379 | ||
| 34390 | // We abstract array handling slightly so that tuple pointers can work like array pointers | 34380 | // We abstract array handling slightly so that tuple pointers can work like array pointers |
| ... | @@ -34395,8 +34385,8 @@ fn resolvePeerTypesInner( | ... | @@ -34395,8 +34385,8 @@ fn resolvePeerTypesInner( |
| 34395 | // single-pointer array sentinel). | 34385 | // single-pointer array sentinel). |
| 34396 | good: { | 34386 | good: { |
| 34397 | switch (peer_info.flags.size) { | 34387 | switch (peer_info.flags.size) { |
| 34398 | .One => switch (ptr_info.flags.size) { | 34388 | .one => switch (ptr_info.flags.size) { |
| 34399 | .One => { | 34389 | .one => { |
| 34400 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { | 34390 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { |
| 34401 | ptr_info.child = pointee.toIntern(); | 34391 | ptr_info.child = pointee.toIntern(); |
| 34402 | break :good; | 34392 | break :good; |
| ... | @@ -34415,28 +34405,28 @@ fn resolvePeerTypesInner( | ... | @@ -34415,28 +34405,28 @@ fn resolvePeerTypesInner( |
| 34415 | break :good; | 34405 | break :good; |
| 34416 | } | 34406 | } |
| 34417 | // *[a]T + *[b]T = []T | 34407 | // *[a]T + *[b]T = []T |
| 34418 | ptr_info.flags.size = .Slice; | 34408 | ptr_info.flags.size = .slice; |
| 34419 | ptr_info.child = elem_ty.toIntern(); | 34409 | ptr_info.child = elem_ty.toIntern(); |
| 34420 | break :good; | 34410 | break :good; |
| 34421 | } | 34411 | } |
| 34422 | 34412 | ||
| 34423 | if (peer_arr.elem_ty.toIntern() == .noreturn_type) { | 34413 | if (peer_arr.elem_ty.toIntern() == .noreturn_type) { |
| 34424 | // *struct{} + *[a]T = []T | 34414 | // *struct{} + *[a]T = []T |
| 34425 | ptr_info.flags.size = .Slice; | 34415 | ptr_info.flags.size = .slice; |
| 34426 | ptr_info.child = cur_arr.elem_ty.toIntern(); | 34416 | ptr_info.child = cur_arr.elem_ty.toIntern(); |
| 34427 | break :good; | 34417 | break :good; |
| 34428 | } | 34418 | } |
| 34429 | 34419 | ||
| 34430 | if (cur_arr.elem_ty.toIntern() == .noreturn_type) { | 34420 | if (cur_arr.elem_ty.toIntern() == .noreturn_type) { |
| 34431 | // *[a]T + *struct{} = []T | 34421 | // *[a]T + *struct{} = []T |
| 34432 | ptr_info.flags.size = .Slice; | 34422 | ptr_info.flags.size = .slice; |
| 34433 | ptr_info.child = peer_arr.elem_ty.toIntern(); | 34423 | ptr_info.child = peer_arr.elem_ty.toIntern(); |
| 34434 | break :good; | 34424 | break :good; |
| 34435 | } | 34425 | } |
| 34436 | 34426 | ||
| 34437 | return generic_err; | 34427 | return generic_err; |
| 34438 | }, | 34428 | }, |
| 34439 | .Many => { | 34429 | .many => { |
| 34440 | // Only works for *[n]T + [*]T -> [*]T | 34430 | // Only works for *[n]T + [*]T -> [*]T |
| 34441 | const arr = peer_pointee_array orelse return generic_err; | 34431 | const arr = peer_pointee_array orelse return generic_err; |
| 34442 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| { | 34432 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| { |
| ... | @@ -34449,7 +34439,7 @@ fn resolvePeerTypesInner( | ... | @@ -34449,7 +34439,7 @@ fn resolvePeerTypesInner( |
| 34449 | } | 34439 | } |
| 34450 | return generic_err; | 34440 | return generic_err; |
| 34451 | }, | 34441 | }, |
| 34452 | .Slice => { | 34442 | .slice => { |
| 34453 | // Only works for *[n]T + []T -> []T | 34443 | // Only works for *[n]T + []T -> []T |
| 34454 | const arr = peer_pointee_array orelse return generic_err; | 34444 | const arr = peer_pointee_array orelse return generic_err; |
| 34455 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| { | 34445 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| { |
| ... | @@ -34462,33 +34452,33 @@ fn resolvePeerTypesInner( | ... | @@ -34462,33 +34452,33 @@ fn resolvePeerTypesInner( |
| 34462 | } | 34452 | } |
| 34463 | return generic_err; | 34453 | return generic_err; |
| 34464 | }, | 34454 | }, |
| 34465 | .C => unreachable, | 34455 | .c => unreachable, |
| 34466 | }, | 34456 | }, |
| 34467 | .Many => switch (ptr_info.flags.size) { | 34457 | .many => switch (ptr_info.flags.size) { |
| 34468 | .One => { | 34458 | .one => { |
| 34469 | // Only works for [*]T + *[n]T -> [*]T | 34459 | // Only works for [*]T + *[n]T -> [*]T |
| 34470 | const arr = cur_pointee_array orelse return generic_err; | 34460 | const arr = cur_pointee_array orelse return generic_err; |
| 34471 | if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| { | 34461 | if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| { |
| 34472 | ptr_info.flags.size = .Many; | 34462 | ptr_info.flags.size = .many; |
| 34473 | ptr_info.child = pointee.toIntern(); | 34463 | ptr_info.child = pointee.toIntern(); |
| 34474 | break :good; | 34464 | break :good; |
| 34475 | } | 34465 | } |
| 34476 | if (arr.elem_ty.toIntern() == .noreturn_type) { | 34466 | if (arr.elem_ty.toIntern() == .noreturn_type) { |
| 34477 | // [*]T + *struct{} -> [*]T | 34467 | // [*]T + *struct{} -> [*]T |
| 34478 | ptr_info.flags.size = .Many; | 34468 | ptr_info.flags.size = .many; |
| 34479 | ptr_info.child = peer_info.child; | 34469 | ptr_info.child = peer_info.child; |
| 34480 | break :good; | 34470 | break :good; |
| 34481 | } | 34471 | } |
| 34482 | return generic_err; | 34472 | return generic_err; |
| 34483 | }, | 34473 | }, |
| 34484 | .Many => { | 34474 | .many => { |
| 34485 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { | 34475 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { |
| 34486 | ptr_info.child = pointee.toIntern(); | 34476 | ptr_info.child = pointee.toIntern(); |
| 34487 | break :good; | 34477 | break :good; |
| 34488 | } | 34478 | } |
| 34489 | return generic_err; | 34479 | return generic_err; |
| 34490 | }, | 34480 | }, |
| 34491 | .Slice => { | 34481 | .slice => { |
| 34492 | // Only works if no peers are actually slices | 34482 | // Only works if no peers are actually slices |
| 34493 | if (opt_slice_idx) |slice_idx| { | 34483 | if (opt_slice_idx) |slice_idx| { |
| 34494 | return .{ .conflict = .{ | 34484 | return .{ .conflict = .{ |
| ... | @@ -34498,54 +34488,54 @@ fn resolvePeerTypesInner( | ... | @@ -34498,54 +34488,54 @@ fn resolvePeerTypesInner( |
| 34498 | } | 34488 | } |
| 34499 | // Okay, then works for [*]T + "[]T" -> [*]T | 34489 | // Okay, then works for [*]T + "[]T" -> [*]T |
| 34500 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { | 34490 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { |
| 34501 | ptr_info.flags.size = .Many; | 34491 | ptr_info.flags.size = .many; |
| 34502 | ptr_info.child = pointee.toIntern(); | 34492 | ptr_info.child = pointee.toIntern(); |
| 34503 | break :good; | 34493 | break :good; |
| 34504 | } | 34494 | } |
| 34505 | return generic_err; | 34495 | return generic_err; |
| 34506 | }, | 34496 | }, |
| 34507 | .C => unreachable, | 34497 | .c => unreachable, |
| 34508 | }, | 34498 | }, |
| 34509 | .Slice => switch (ptr_info.flags.size) { | 34499 | .slice => switch (ptr_info.flags.size) { |
| 34510 | .One => { | 34500 | .one => { |
| 34511 | // Only works for []T + *[n]T -> []T | 34501 | // Only works for []T + *[n]T -> []T |
| 34512 | const arr = cur_pointee_array orelse return generic_err; | 34502 | const arr = cur_pointee_array orelse return generic_err; |
| 34513 | if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| { | 34503 | if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| { |
| 34514 | ptr_info.flags.size = .Slice; | 34504 | ptr_info.flags.size = .slice; |
| 34515 | ptr_info.child = pointee.toIntern(); | 34505 | ptr_info.child = pointee.toIntern(); |
| 34516 | break :good; | 34506 | break :good; |
| 34517 | } | 34507 | } |
| 34518 | if (arr.elem_ty.toIntern() == .noreturn_type) { | 34508 | if (arr.elem_ty.toIntern() == .noreturn_type) { |
| 34519 | // []T + *struct{} -> []T | 34509 | // []T + *struct{} -> []T |
| 34520 | ptr_info.flags.size = .Slice; | 34510 | ptr_info.flags.size = .slice; |
| 34521 | ptr_info.child = peer_info.child; | 34511 | ptr_info.child = peer_info.child; |
| 34522 | break :good; | 34512 | break :good; |
| 34523 | } | 34513 | } |
| 34524 | return generic_err; | 34514 | return generic_err; |
| 34525 | }, | 34515 | }, |
| 34526 | .Many => { | 34516 | .many => { |
| 34527 | // Impossible! (current peer is an actual slice) | 34517 | // Impossible! (current peer is an actual slice) |
| 34528 | return generic_err; | 34518 | return generic_err; |
| 34529 | }, | 34519 | }, |
| 34530 | .Slice => { | 34520 | .slice => { |
| 34531 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { | 34521 | if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| { |
| 34532 | ptr_info.child = pointee.toIntern(); | 34522 | ptr_info.child = pointee.toIntern(); |
| 34533 | break :good; | 34523 | break :good; |
| 34534 | } | 34524 | } |
| 34535 | return generic_err; | 34525 | return generic_err; |
| 34536 | }, | 34526 | }, |
| 34537 | .C => unreachable, | 34527 | .c => unreachable, |
| 34538 | }, | 34528 | }, |
| 34539 | .C => unreachable, | 34529 | .c => unreachable, |
| 34540 | } | 34530 | } |
| 34541 | } | 34531 | } |
| 34542 | 34532 | ||
| 34543 | const sentinel_ty = switch (ptr_info.flags.size) { | 34533 | const sentinel_ty = switch (ptr_info.flags.size) { |
| 34544 | .One => switch (ip.indexToKey(ptr_info.child)) { | 34534 | .one => switch (ip.indexToKey(ptr_info.child)) { |
| 34545 | .array_type => |array_type| array_type.child, | 34535 | .array_type => |array_type| array_type.child, |
| 34546 | else => ptr_info.child, | 34536 | else => ptr_info.child, |
| 34547 | }, | 34537 | }, |
| 34548 | .Many, .Slice, .C => ptr_info.child, | 34538 | .many, .slice, .c => ptr_info.child, |
| 34549 | }; | 34539 | }; |
| 34550 | 34540 | ||
| 34551 | sentinel: { | 34541 | sentinel: { |
| ... | @@ -34556,7 +34546,7 @@ fn resolvePeerTypesInner( | ... | @@ -34556,7 +34546,7 @@ fn resolvePeerTypesInner( |
| 34556 | const cur_sent_coerced = try ip.getCoerced(sema.gpa, pt.tid, cur_sentinel, sentinel_ty); | 34546 | const cur_sent_coerced = try ip.getCoerced(sema.gpa, pt.tid, cur_sentinel, sentinel_ty); |
| 34557 | if (peer_sent_coerced != cur_sent_coerced) break :no_sentinel; | 34547 | if (peer_sent_coerced != cur_sent_coerced) break :no_sentinel; |
| 34558 | // Sentinels match | 34548 | // Sentinels match |
| 34559 | if (ptr_info.flags.size == .One) switch (ip.indexToKey(ptr_info.child)) { | 34549 | if (ptr_info.flags.size == .one) switch (ip.indexToKey(ptr_info.child)) { |
| 34560 | .array_type => |array_type| ptr_info.child = (try pt.arrayType(.{ | 34550 | .array_type => |array_type| ptr_info.child = (try pt.arrayType(.{ |
| 34561 | .len = array_type.len, | 34551 | .len = array_type.len, |
| 34562 | .child = array_type.child, | 34552 | .child = array_type.child, |
| ... | @@ -35416,8 +35406,8 @@ fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void | ... | @@ -35416,8 +35406,8 @@ fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void |
| 35416 | const zcu = pt.zcu; | 35406 | const zcu = pt.zcu; |
| 35417 | if (ty.zigTypeTag(zcu) == .pointer) { | 35407 | if (ty.zigTypeTag(zcu) == .pointer) { |
| 35418 | switch (ty.ptrSize(zcu)) { | 35408 | switch (ty.ptrSize(zcu)) { |
| 35419 | .Slice, .Many, .C => return, | 35409 | .slice, .many, .c => return, |
| 35420 | .One => { | 35410 | .one => { |
| 35421 | const elem_ty = ty.childType(zcu); | 35411 | const elem_ty = ty.childType(zcu); |
| 35422 | if (elem_ty.zigTypeTag(zcu) == .array) return; | 35412 | if (elem_ty.zigTypeTag(zcu) == .array) return; |
| 35423 | // TODO https://github.com/ziglang/zig/issues/15479 | 35413 | // TODO https://github.com/ziglang/zig/issues/15479 |
| ... | @@ -37136,11 +37126,10 @@ pub fn analyzeAsAddressSpace( | ... | @@ -37136,11 +37126,10 @@ pub fn analyzeAsAddressSpace( |
| 37136 | ctx: AddressSpaceContext, | 37126 | ctx: AddressSpaceContext, |
| 37137 | ) !std.builtin.AddressSpace { | 37127 | ) !std.builtin.AddressSpace { |
| 37138 | const pt = sema.pt; | 37128 | const pt = sema.pt; |
| 37139 | const zcu = pt.zcu; | ||
| 37140 | const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace); | 37129 | const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace); |
| 37141 | const coerced = try sema.coerce(block, addrspace_ty, air_ref, src); | 37130 | const coerced = try sema.coerce(block, addrspace_ty, air_ref, src); |
| 37142 | const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{ .simple = .@"addrspace" }); | 37131 | const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{ .simple = .@"addrspace" }); |
| 37143 | const address_space = zcu.toEnum(std.builtin.AddressSpace, addrspace_val); | 37132 | const address_space = try sema.interpretBuiltinType(block, src, addrspace_val, std.builtin.AddressSpace); |
| 37144 | const target = pt.zcu.getTarget(); | 37133 | const target = pt.zcu.getTarget(); |
| 37145 | const arch = target.cpu.arch; | 37134 | const arch = target.cpu.arch; |
| 37146 | 37135 | ||
| ... | @@ -37248,13 +37237,13 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type { | ... | @@ -37248,13 +37237,13 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type { |
| 37248 | const zcu = pt.zcu; | 37237 | const zcu = pt.zcu; |
| 37249 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { | 37238 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 37250 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 37239 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 37251 | .One, .Many, .C => ty, | 37240 | .one, .many, .c => ty, |
| 37252 | .Slice => null, | 37241 | .slice => null, |
| 37253 | }, | 37242 | }, |
| 37254 | .opt_type => |opt_child| switch (zcu.intern_pool.indexToKey(opt_child)) { | 37243 | .opt_type => |opt_child| switch (zcu.intern_pool.indexToKey(opt_child)) { |
| 37255 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 37244 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 37256 | .Slice, .C => null, | 37245 | .slice, .c => null, |
| 37257 | .Many, .One => { | 37246 | .many, .one => { |
| 37258 | if (ptr_type.flags.is_allowzero) return null; | 37247 | if (ptr_type.flags.is_allowzero) return null; |
| 37259 | 37248 | ||
| 37260 | // optionals of zero sized types behave like bools, not pointers | 37249 | // optionals of zero sized types behave like bools, not pointers |
| ... | @@ -38260,7 +38249,7 @@ fn maybeDerefSliceAsArray( | ... | @@ -38260,7 +38249,7 @@ fn maybeDerefSliceAsArray( |
| 38260 | }); | 38249 | }); |
| 38261 | const ptr_ty = try pt.ptrTypeSema(p: { | 38250 | const ptr_ty = try pt.ptrTypeSema(p: { |
| 38262 | var p = Type.fromInterned(slice.ty).ptrInfo(zcu); | 38251 | var p = Type.fromInterned(slice.ty).ptrInfo(zcu); |
| 38263 | p.flags.size = .One; | 38252 | p.flags.size = .one; |
| 38264 | p.child = array_ty.toIntern(); | 38253 | p.child = array_ty.toIntern(); |
| 38265 | p.sentinel = .none; | 38254 | p.sentinel = .none; |
| 38266 | break :p p; | 38255 | break :p p; |
src/Type.zig+32-32| ... | @@ -192,16 +192,16 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error | ... | @@ -192,16 +192,16 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error |
| 192 | const info = ty.ptrInfo(zcu); | 192 | const info = ty.ptrInfo(zcu); |
| 193 | 193 | ||
| 194 | if (info.sentinel != .none) switch (info.flags.size) { | 194 | if (info.sentinel != .none) switch (info.flags.size) { |
| 195 | .One, .C => unreachable, | 195 | .one, .c => unreachable, |
| 196 | .Many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}), | 196 | .many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}), |
| 197 | .Slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}), | 197 | .slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}), |
| 198 | } else switch (info.flags.size) { | 198 | } else switch (info.flags.size) { |
| 199 | .One => try writer.writeAll("*"), | 199 | .one => try writer.writeAll("*"), |
| 200 | .Many => try writer.writeAll("[*]"), | 200 | .many => try writer.writeAll("[*]"), |
| 201 | .C => try writer.writeAll("[*c]"), | 201 | .c => try writer.writeAll("[*c]"), |
| 202 | .Slice => try writer.writeAll("[]"), | 202 | .slice => try writer.writeAll("[]"), |
| 203 | } | 203 | } |
| 204 | if (info.flags.is_allowzero and info.flags.size != .C) try writer.writeAll("allowzero "); | 204 | if (info.flags.is_allowzero and info.flags.size != .c) try writer.writeAll("allowzero "); |
| 205 | if (info.flags.alignment != .none or | 205 | if (info.flags.alignment != .none or |
| 206 | info.packed_offset.host_size != 0 or | 206 | info.packed_offset.host_size != 0 or |
| 207 | info.flags.vector_index != .none) | 207 | info.flags.vector_index != .none) |
| ... | @@ -686,7 +686,7 @@ pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool { | ... | @@ -686,7 +686,7 @@ pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool { |
| 686 | 686 | ||
| 687 | .array_type => |array_type| Type.fromInterned(array_type.child).hasWellDefinedLayout(zcu), | 687 | .array_type => |array_type| Type.fromInterned(array_type.child).hasWellDefinedLayout(zcu), |
| 688 | .opt_type => ty.isPtrLikeOptional(zcu), | 688 | .opt_type => ty.isPtrLikeOptional(zcu), |
| 689 | .ptr_type => |ptr_type| ptr_type.flags.size != .Slice, | 689 | .ptr_type => |ptr_type| ptr_type.flags.size != .slice, |
| 690 | 690 | ||
| 691 | .simple_type => |t| switch (t) { | 691 | .simple_type => |t| switch (t) { |
| 692 | .f16, | 692 | .f16, |
| ... | @@ -1303,7 +1303,7 @@ pub fn abiSizeInner( | ... | @@ -1303,7 +1303,7 @@ pub fn abiSizeInner( |
| 1303 | return .{ .scalar = intAbiSize(int_type.bits, target, use_llvm) }; | 1303 | return .{ .scalar = intAbiSize(int_type.bits, target, use_llvm) }; |
| 1304 | }, | 1304 | }, |
| 1305 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 1305 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 1306 | .Slice => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 }, | 1306 | .slice => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 }, |
| 1307 | else => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) }, | 1307 | else => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 1308 | }, | 1308 | }, |
| 1309 | .anyframe_type => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) }, | 1309 | .anyframe_type => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| ... | @@ -1741,7 +1741,7 @@ pub fn bitSizeInner( | ... | @@ -1741,7 +1741,7 @@ pub fn bitSizeInner( |
| 1741 | switch (ip.indexToKey(ty.toIntern())) { | 1741 | switch (ip.indexToKey(ty.toIntern())) { |
| 1742 | .int_type => |int_type| return int_type.bits, | 1742 | .int_type => |int_type| return int_type.bits, |
| 1743 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 1743 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 1744 | .Slice => return target.ptrBitWidth() * 2, | 1744 | .slice => return target.ptrBitWidth() * 2, |
| 1745 | else => return target.ptrBitWidth(), | 1745 | else => return target.ptrBitWidth(), |
| 1746 | }, | 1746 | }, |
| 1747 | .anyframe_type => return target.ptrBitWidth(), | 1747 | .anyframe_type => return target.ptrBitWidth(), |
| ... | @@ -1903,7 +1903,7 @@ pub fn layoutIsResolved(ty: Type, zcu: *const Zcu) bool { | ... | @@ -1903,7 +1903,7 @@ pub fn layoutIsResolved(ty: Type, zcu: *const Zcu) bool { |
| 1903 | 1903 | ||
| 1904 | pub fn isSinglePointer(ty: Type, zcu: *const Zcu) bool { | 1904 | pub fn isSinglePointer(ty: Type, zcu: *const Zcu) bool { |
| 1905 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { | 1905 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 1906 | .ptr_type => |ptr_info| ptr_info.flags.size == .One, | 1906 | .ptr_type => |ptr_info| ptr_info.flags.size == .one, |
| 1907 | else => false, | 1907 | else => false, |
| 1908 | }; | 1908 | }; |
| 1909 | } | 1909 | } |
| ... | @@ -1923,7 +1923,7 @@ pub fn ptrSizeOrNull(ty: Type, zcu: *const Zcu) ?std.builtin.Type.Pointer.Size { | ... | @@ -1923,7 +1923,7 @@ pub fn ptrSizeOrNull(ty: Type, zcu: *const Zcu) ?std.builtin.Type.Pointer.Size { |
| 1923 | 1923 | ||
| 1924 | pub fn isSlice(ty: Type, zcu: *const Zcu) bool { | 1924 | pub fn isSlice(ty: Type, zcu: *const Zcu) bool { |
| 1925 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { | 1925 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 1926 | .ptr_type => |ptr_type| ptr_type.flags.size == .Slice, | 1926 | .ptr_type => |ptr_type| ptr_type.flags.size == .slice, |
| 1927 | else => false, | 1927 | else => false, |
| 1928 | }; | 1928 | }; |
| 1929 | } | 1929 | } |
| ... | @@ -1960,7 +1960,7 @@ pub fn isAllowzeroPtr(ty: Type, zcu: *const Zcu) bool { | ... | @@ -1960,7 +1960,7 @@ pub fn isAllowzeroPtr(ty: Type, zcu: *const Zcu) bool { |
| 1960 | 1960 | ||
| 1961 | pub fn isCPtr(ty: Type, zcu: *const Zcu) bool { | 1961 | pub fn isCPtr(ty: Type, zcu: *const Zcu) bool { |
| 1962 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { | 1962 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 1963 | .ptr_type => |ptr_type| ptr_type.flags.size == .C, | 1963 | .ptr_type => |ptr_type| ptr_type.flags.size == .c, |
| 1964 | else => false, | 1964 | else => false, |
| 1965 | }; | 1965 | }; |
| 1966 | } | 1966 | } |
| ... | @@ -1968,13 +1968,13 @@ pub fn isCPtr(ty: Type, zcu: *const Zcu) bool { | ... | @@ -1968,13 +1968,13 @@ pub fn isCPtr(ty: Type, zcu: *const Zcu) bool { |
| 1968 | pub fn isPtrAtRuntime(ty: Type, zcu: *const Zcu) bool { | 1968 | pub fn isPtrAtRuntime(ty: Type, zcu: *const Zcu) bool { |
| 1969 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { | 1969 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 1970 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 1970 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 1971 | .Slice => false, | 1971 | .slice => false, |
| 1972 | .One, .Many, .C => true, | 1972 | .one, .many, .c => true, |
| 1973 | }, | 1973 | }, |
| 1974 | .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) { | 1974 | .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) { |
| 1975 | .ptr_type => |p| switch (p.flags.size) { | 1975 | .ptr_type => |p| switch (p.flags.size) { |
| 1976 | .Slice, .C => false, | 1976 | .slice, .c => false, |
| 1977 | .Many, .One => !p.flags.is_allowzero, | 1977 | .many, .one => !p.flags.is_allowzero, |
| 1978 | }, | 1978 | }, |
| 1979 | else => false, | 1979 | else => false, |
| 1980 | }, | 1980 | }, |
| ... | @@ -1995,11 +1995,11 @@ pub fn ptrAllowsZero(ty: Type, zcu: *const Zcu) bool { | ... | @@ -1995,11 +1995,11 @@ pub fn ptrAllowsZero(ty: Type, zcu: *const Zcu) bool { |
| 1995 | pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool { | 1995 | pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool { |
| 1996 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { | 1996 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 1997 | .opt_type => |child_type| child_type == .anyerror_type or switch (zcu.intern_pool.indexToKey(child_type)) { | 1997 | .opt_type => |child_type| child_type == .anyerror_type or switch (zcu.intern_pool.indexToKey(child_type)) { |
| 1998 | .ptr_type => |ptr_type| ptr_type.flags.size != .C and !ptr_type.flags.is_allowzero, | 1998 | .ptr_type => |ptr_type| ptr_type.flags.size != .c and !ptr_type.flags.is_allowzero, |
| 1999 | .error_set_type, .inferred_error_set_type => true, | 1999 | .error_set_type, .inferred_error_set_type => true, |
| 2000 | else => false, | 2000 | else => false, |
| 2001 | }, | 2001 | }, |
| 2002 | .ptr_type => |ptr_type| ptr_type.flags.size == .C, | 2002 | .ptr_type => |ptr_type| ptr_type.flags.size == .c, |
| 2003 | else => false, | 2003 | else => false, |
| 2004 | }; | 2004 | }; |
| 2005 | } | 2005 | } |
| ... | @@ -2009,11 +2009,11 @@ pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool { | ... | @@ -2009,11 +2009,11 @@ pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool { |
| 2009 | /// This function must be kept in sync with `Sema.typePtrOrOptionalPtrTy`. | 2009 | /// This function must be kept in sync with `Sema.typePtrOrOptionalPtrTy`. |
| 2010 | pub fn isPtrLikeOptional(ty: Type, zcu: *const Zcu) bool { | 2010 | pub fn isPtrLikeOptional(ty: Type, zcu: *const Zcu) bool { |
| 2011 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { | 2011 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 2012 | .ptr_type => |ptr_type| ptr_type.flags.size == .C, | 2012 | .ptr_type => |ptr_type| ptr_type.flags.size == .c, |
| 2013 | .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) { | 2013 | .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) { |
| 2014 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 2014 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 2015 | .Slice, .C => false, | 2015 | .slice, .c => false, |
| 2016 | .Many, .One => !ptr_type.flags.is_allowzero, | 2016 | .many, .one => !ptr_type.flags.is_allowzero, |
| 2017 | }, | 2017 | }, |
| 2018 | else => false, | 2018 | else => false, |
| 2019 | }, | 2019 | }, |
| ... | @@ -2044,8 +2044,8 @@ pub fn childTypeIp(ty: Type, ip: *const InternPool) Type { | ... | @@ -2044,8 +2044,8 @@ pub fn childTypeIp(ty: Type, ip: *const InternPool) Type { |
| 2044 | pub fn elemType2(ty: Type, zcu: *const Zcu) Type { | 2044 | pub fn elemType2(ty: Type, zcu: *const Zcu) Type { |
| 2045 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { | 2045 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 2046 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 2046 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 2047 | .One => Type.fromInterned(ptr_type.child).shallowElemType(zcu), | 2047 | .one => Type.fromInterned(ptr_type.child).shallowElemType(zcu), |
| 2048 | .Many, .C, .Slice => Type.fromInterned(ptr_type.child), | 2048 | .many, .c, .slice => Type.fromInterned(ptr_type.child), |
| 2049 | }, | 2049 | }, |
| 2050 | .anyframe_type => |child| { | 2050 | .anyframe_type => |child| { |
| 2051 | assert(child != .none); | 2051 | assert(child != .none); |
| ... | @@ -2079,7 +2079,7 @@ pub fn optionalChild(ty: Type, zcu: *const Zcu) Type { | ... | @@ -2079,7 +2079,7 @@ pub fn optionalChild(ty: Type, zcu: *const Zcu) Type { |
| 2079 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { | 2079 | return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 2080 | .opt_type => |child| Type.fromInterned(child), | 2080 | .opt_type => |child| Type.fromInterned(child), |
| 2081 | .ptr_type => |ptr_type| b: { | 2081 | .ptr_type => |ptr_type| b: { |
| 2082 | assert(ptr_type.flags.size == .C); | 2082 | assert(ptr_type.flags.size == .c); |
| 2083 | break :b ty; | 2083 | break :b ty; |
| 2084 | }, | 2084 | }, |
| 2085 | else => unreachable, | 2085 | else => unreachable, |
| ... | @@ -2991,8 +2991,8 @@ pub fn isIndexable(ty: Type, zcu: *const Zcu) bool { | ... | @@ -2991,8 +2991,8 @@ pub fn isIndexable(ty: Type, zcu: *const Zcu) bool { |
| 2991 | return switch (ty.zigTypeTag(zcu)) { | 2991 | return switch (ty.zigTypeTag(zcu)) { |
| 2992 | .array, .vector => true, | 2992 | .array, .vector => true, |
| 2993 | .pointer => switch (ty.ptrSize(zcu)) { | 2993 | .pointer => switch (ty.ptrSize(zcu)) { |
| 2994 | .Slice, .Many, .C => true, | 2994 | .slice, .many, .c => true, |
| 2995 | .One => switch (ty.childType(zcu).zigTypeTag(zcu)) { | 2995 | .one => switch (ty.childType(zcu).zigTypeTag(zcu)) { |
| 2996 | .array, .vector => true, | 2996 | .array, .vector => true, |
| 2997 | .@"struct" => ty.childType(zcu).isTuple(zcu), | 2997 | .@"struct" => ty.childType(zcu).isTuple(zcu), |
| 2998 | else => false, | 2998 | else => false, |
| ... | @@ -3007,9 +3007,9 @@ pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool { | ... | @@ -3007,9 +3007,9 @@ pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool { |
| 3007 | return switch (ty.zigTypeTag(zcu)) { | 3007 | return switch (ty.zigTypeTag(zcu)) { |
| 3008 | .array, .vector => true, | 3008 | .array, .vector => true, |
| 3009 | .pointer => switch (ty.ptrSize(zcu)) { | 3009 | .pointer => switch (ty.ptrSize(zcu)) { |
| 3010 | .Many, .C => false, | 3010 | .many, .c => false, |
| 3011 | .Slice => true, | 3011 | .slice => true, |
| 3012 | .One => switch (ty.childType(zcu).zigTypeTag(zcu)) { | 3012 | .one => switch (ty.childType(zcu).zigTypeTag(zcu)) { |
| 3013 | .array, .vector => true, | 3013 | .array, .vector => true, |
| 3014 | .@"struct" => ty.childType(zcu).isTuple(zcu), | 3014 | .@"struct" => ty.childType(zcu).isTuple(zcu), |
| 3015 | else => false, | 3015 | else => false, |
| ... | @@ -4049,7 +4049,7 @@ pub fn elemPtrType(ptr_ty: Type, offset: ?usize, pt: Zcu.PerThread) !Type { | ... | @@ -4049,7 +4049,7 @@ pub fn elemPtrType(ptr_ty: Type, offset: ?usize, pt: Zcu.PerThread) !Type { |
| 4049 | host_size: u16 = 0, | 4049 | host_size: u16 = 0, |
| 4050 | alignment: Alignment = .none, | 4050 | alignment: Alignment = .none, |
| 4051 | vector_index: VI = .none, | 4051 | vector_index: VI = .none, |
| 4052 | } = if (parent_ty.isVector(zcu) and ptr_info.flags.size == .One) blk: { | 4052 | } = if (parent_ty.isVector(zcu) and ptr_info.flags.size == .one) blk: { |
| 4053 | const elem_bits = elem_ty.bitSize(zcu); | 4053 | const elem_bits = elem_ty.bitSize(zcu); |
| 4054 | if (elem_bits == 0) break :blk .{}; | 4054 | if (elem_bits == 0) break :blk .{}; |
| 4055 | const is_packed = elem_bits < 8 or !std.math.isPowerOfTwo(elem_bits); | 4055 | const is_packed = elem_bits < 8 or !std.math.isPowerOfTwo(elem_bits); |
src/Value.zig+113-39| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const build_options = @import("build_options"); | ||
| 3 | const Type = @import("Type.zig"); | 4 | const Type = @import("Type.zig"); |
| 4 | const assert = std.debug.assert; | 5 | const assert = std.debug.assert; |
| 5 | const BigIntConst = std.math.big.int.Const; | 6 | const BigIntConst = std.math.big.int.Const; |
| ... | @@ -3724,7 +3725,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { | ... | @@ -3724,7 +3725,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { |
| 3724 | const parent_ptr_ty = parent_ptr.typeOf(zcu); | 3725 | const parent_ptr_ty = parent_ptr.typeOf(zcu); |
| 3725 | const opt_ty = parent_ptr_ty.childType(zcu); | 3726 | const opt_ty = parent_ptr_ty.childType(zcu); |
| 3726 | 3727 | ||
| 3727 | assert(parent_ptr_ty.ptrSize(zcu) == .One); | 3728 | assert(parent_ptr_ty.ptrSize(zcu) == .one); |
| 3728 | assert(opt_ty.zigTypeTag(zcu) == .optional); | 3729 | assert(opt_ty.zigTypeTag(zcu) == .optional); |
| 3729 | 3730 | ||
| 3730 | const result_ty = try pt.ptrTypeSema(info: { | 3731 | const result_ty = try pt.ptrTypeSema(info: { |
| ... | @@ -3742,7 +3743,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { | ... | @@ -3742,7 +3743,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { |
| 3742 | return pt.getCoerced(parent_ptr, result_ty); | 3743 | return pt.getCoerced(parent_ptr, result_ty); |
| 3743 | } | 3744 | } |
| 3744 | 3745 | ||
| 3745 | const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, opt_ty, pt); | 3746 | const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, opt_ty, pt); |
| 3746 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ | 3747 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ |
| 3747 | .ty = result_ty.toIntern(), | 3748 | .ty = result_ty.toIntern(), |
| 3748 | .base_addr = .{ .opt_payload = base_ptr.toIntern() }, | 3749 | .base_addr = .{ .opt_payload = base_ptr.toIntern() }, |
| ... | @@ -3758,7 +3759,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { | ... | @@ -3758,7 +3759,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { |
| 3758 | const parent_ptr_ty = parent_ptr.typeOf(zcu); | 3759 | const parent_ptr_ty = parent_ptr.typeOf(zcu); |
| 3759 | const eu_ty = parent_ptr_ty.childType(zcu); | 3760 | const eu_ty = parent_ptr_ty.childType(zcu); |
| 3760 | 3761 | ||
| 3761 | assert(parent_ptr_ty.ptrSize(zcu) == .One); | 3762 | assert(parent_ptr_ty.ptrSize(zcu) == .one); |
| 3762 | assert(eu_ty.zigTypeTag(zcu) == .error_union); | 3763 | assert(eu_ty.zigTypeTag(zcu) == .error_union); |
| 3763 | 3764 | ||
| 3764 | const result_ty = try pt.ptrTypeSema(info: { | 3765 | const result_ty = try pt.ptrTypeSema(info: { |
| ... | @@ -3771,7 +3772,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { | ... | @@ -3771,7 +3772,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { |
| 3771 | 3772 | ||
| 3772 | if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty); | 3773 | if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty); |
| 3773 | 3774 | ||
| 3774 | const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, eu_ty, pt); | 3775 | const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, eu_ty, pt); |
| 3775 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ | 3776 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ |
| 3776 | .ty = result_ty.toIntern(), | 3777 | .ty = result_ty.toIntern(), |
| 3777 | .base_addr = .{ .eu_payload = base_ptr.toIntern() }, | 3778 | .base_addr = .{ .eu_payload = base_ptr.toIntern() }, |
| ... | @@ -3789,7 +3790,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { | ... | @@ -3789,7 +3790,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { |
| 3789 | const aggregate_ty = parent_ptr_ty.childType(zcu); | 3790 | const aggregate_ty = parent_ptr_ty.childType(zcu); |
| 3790 | 3791 | ||
| 3791 | const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu); | 3792 | const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu); |
| 3792 | assert(parent_ptr_info.flags.size == .One); | 3793 | assert(parent_ptr_info.flags.size == .one); |
| 3793 | 3794 | ||
| 3794 | // Exiting this `switch` indicates that the `field` pointer representation should be used. | 3795 | // Exiting this `switch` indicates that the `field` pointer representation should be used. |
| 3795 | // `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily. | 3796 | // `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily. |
| ... | @@ -3920,7 +3921,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { | ... | @@ -3920,7 +3921,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { |
| 3920 | 3921 | ||
| 3921 | if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty); | 3922 | if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty); |
| 3922 | 3923 | ||
| 3923 | const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, aggregate_ty, pt); | 3924 | const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, aggregate_ty, pt); |
| 3924 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ | 3925 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ |
| 3925 | .ty = result_ty.toIntern(), | 3926 | .ty = result_ty.toIntern(), |
| 3926 | .base_addr = .{ .field = .{ | 3927 | .base_addr = .{ .field = .{ |
| ... | @@ -3937,8 +3938,8 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { | ... | @@ -3937,8 +3938,8 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { |
| 3937 | pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value { | 3938 | pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value { |
| 3938 | const zcu = pt.zcu; | 3939 | const zcu = pt.zcu; |
| 3939 | const parent_ptr = switch (orig_parent_ptr.typeOf(zcu).ptrSize(zcu)) { | 3940 | const parent_ptr = switch (orig_parent_ptr.typeOf(zcu).ptrSize(zcu)) { |
| 3940 | .One, .Many, .C => orig_parent_ptr, | 3941 | .one, .many, .c => orig_parent_ptr, |
| 3941 | .Slice => orig_parent_ptr.slicePtr(zcu), | 3942 | .slice => orig_parent_ptr.slicePtr(zcu), |
| 3942 | }; | 3943 | }; |
| 3943 | 3944 | ||
| 3944 | const parent_ptr_ty = parent_ptr.typeOf(zcu); | 3945 | const parent_ptr_ty = parent_ptr.typeOf(zcu); |
| ... | @@ -3959,7 +3960,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value | ... | @@ -3959,7 +3960,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value |
| 3959 | }; | 3960 | }; |
| 3960 | 3961 | ||
| 3961 | const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) { | 3962 | const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) { |
| 3962 | .One => switch (elem_ty.zigTypeTag(zcu)) { | 3963 | .one => switch (elem_ty.zigTypeTag(zcu)) { |
| 3963 | .vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) }, | 3964 | .vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) }, |
| 3964 | .array => strat: { | 3965 | .array => strat: { |
| 3965 | const arr_elem_ty = elem_ty.childType(zcu); | 3966 | const arr_elem_ty = elem_ty.childType(zcu); |
| ... | @@ -3971,12 +3972,12 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value | ... | @@ -3971,12 +3972,12 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value |
| 3971 | else => unreachable, | 3972 | else => unreachable, |
| 3972 | }, | 3973 | }, |
| 3973 | 3974 | ||
| 3974 | .Many, .C => if (try elem_ty.comptimeOnlySema(pt)) | 3975 | .many, .c => if (try elem_ty.comptimeOnlySema(pt)) |
| 3975 | .{ .elem_ptr = elem_ty } | 3976 | .{ .elem_ptr = elem_ty } |
| 3976 | else | 3977 | else |
| 3977 | .{ .offset = field_idx * (try elem_ty.abiSizeInner(.sema, zcu, pt.tid)).scalar }, | 3978 | .{ .offset = field_idx * (try elem_ty.abiSizeInner(.sema, zcu, pt.tid)).scalar }, |
| 3978 | 3979 | ||
| 3979 | .Slice => unreachable, | 3980 | .slice => unreachable, |
| 3980 | }; | 3981 | }; |
| 3981 | 3982 | ||
| 3982 | switch (strat) { | 3983 | switch (strat) { |
| ... | @@ -4004,7 +4005,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value | ... | @@ -4004,7 +4005,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value |
| 4004 | }, | 4005 | }, |
| 4005 | else => {}, | 4006 | else => {}, |
| 4006 | } | 4007 | } |
| 4007 | const base_ptr = try parent_ptr.canonicalizeBasePtr(.Many, arr_base_ty, pt); | 4008 | const base_ptr = try parent_ptr.canonicalizeBasePtr(.many, arr_base_ty, pt); |
| 4008 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ | 4009 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ |
| 4009 | .ty = result_ty.toIntern(), | 4010 | .ty = result_ty.toIntern(), |
| 4010 | .base_addr = .{ .arr_elem = .{ | 4011 | .base_addr = .{ .arr_elem = .{ |
| ... | @@ -4234,7 +4235,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh | ... | @@ -4234,7 +4235,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh |
| 4234 | .child = parent_ptr_info.child, | 4235 | .child = parent_ptr_info.child, |
| 4235 | .flags = flags: { | 4236 | .flags = flags: { |
| 4236 | var flags = parent_ptr_info.flags; | 4237 | var flags = parent_ptr_info.flags; |
| 4237 | flags.size = .One; | 4238 | flags.size = .one; |
| 4238 | break :flags flags; | 4239 | break :flags flags; |
| 4239 | }, | 4240 | }, |
| 4240 | }); | 4241 | }); |
| ... | @@ -4304,8 +4305,8 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh | ... | @@ -4304,8 +4305,8 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh |
| 4304 | if (!cur_ty.isPtrLikeOptional(zcu)) break :ptr_opt; | 4305 | if (!cur_ty.isPtrLikeOptional(zcu)) break :ptr_opt; |
| 4305 | if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt; | 4306 | if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt; |
| 4306 | switch (need_child.ptrSize(zcu)) { | 4307 | switch (need_child.ptrSize(zcu)) { |
| 4307 | .One, .Many => {}, | 4308 | .one, .many => {}, |
| 4308 | .Slice, .C => break :ptr_opt, | 4309 | .slice, .c => break :ptr_opt, |
| 4309 | } | 4310 | } |
| 4310 | const parent = try arena.create(PointerDeriveStep); | 4311 | const parent = try arena.create(PointerDeriveStep); |
| 4311 | parent.* = cur_derive; | 4312 | parent.* = cur_derive; |
| ... | @@ -4323,7 +4324,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh | ... | @@ -4323,7 +4324,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh |
| 4323 | const elem_size = elem_ty.abiSize(zcu); | 4324 | const elem_size = elem_ty.abiSize(zcu); |
| 4324 | const start_idx = cur_offset / elem_size; | 4325 | const start_idx = cur_offset / elem_size; |
| 4325 | const end_idx = (cur_offset + need_bytes + elem_size - 1) / elem_size; | 4326 | const end_idx = (cur_offset + need_bytes + elem_size - 1) / elem_size; |
| 4326 | if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .One) { | 4327 | if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .one) { |
| 4327 | const parent = try arena.create(PointerDeriveStep); | 4328 | const parent = try arena.create(PointerDeriveStep); |
| 4328 | parent.* = cur_derive; | 4329 | parent.* = cur_derive; |
| 4329 | cur_derive = .{ .elem_ptr = .{ | 4330 | cur_derive = .{ .elem_ptr = .{ |
| ... | @@ -4531,6 +4532,20 @@ pub fn resolveLazy( | ... | @@ -4531,6 +4532,20 @@ pub fn resolveLazy( |
| 4531 | } | 4532 | } |
| 4532 | } | 4533 | } |
| 4533 | 4534 | ||
| 4535 | const InterpretMode = enum { | ||
| 4536 | /// In this mode, types are assumed to match what the compiler was built with in terms of field | ||
| 4537 | /// order, field types, etc. This improves compiler performance. However, it means that certain | ||
| 4538 | /// modifications to `std.builtin` will result in compiler crashes. | ||
| 4539 | direct, | ||
| 4540 | /// In this mode, various details of the type are allowed to differ from what the compiler was built | ||
| 4541 | /// with. Fields are matched by name rather than index; added struct fields are ignored, and removed | ||
| 4542 | /// struct fields use their default value if one exists. This is slower than `.direct`, but permits | ||
| 4543 | /// making certain changes to `std.builtin` (in particular reordering/adding/removing fields), so it | ||
| 4544 | /// is useful when applying breaking changes. | ||
| 4545 | by_name, | ||
| 4546 | }; | ||
| 4547 | const interpret_mode: InterpretMode = @field(InterpretMode, @tagName(build_options.value_interpret_mode)); | ||
| 4548 | |||
| 4534 | /// Given a `Value` representing a comptime-known value of type `T`, unwrap it into an actual `T` known to the compiler. | 4549 | /// Given a `Value` representing a comptime-known value of type `T`, unwrap it into an actual `T` known to the compiler. |
| 4535 | /// This is useful for accessing `std.builtin` structures received from comptime logic. | 4550 | /// This is useful for accessing `std.builtin` structures received from comptime logic. |
| 4536 | /// `val` must be fully resolved. | 4551 | /// `val` must be fully resolved. |
| ... | @@ -4583,11 +4598,20 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe | ... | @@ -4583,11 +4598,20 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe |
| 4583 | else | 4598 | else |
| 4584 | null, | 4599 | null, |
| 4585 | 4600 | ||
| 4586 | .@"enum" => zcu.toEnum(T, val), | 4601 | .@"enum" => switch (interpret_mode) { |
| 4602 | .direct => { | ||
| 4603 | const int = val.getUnsignedInt(zcu) orelse return error.TypeMismatch; | ||
| 4604 | return std.meta.intToEnum(T, int) catch error.TypeMismatch; | ||
| 4605 | }, | ||
| 4606 | .by_name => { | ||
| 4607 | const field_index = ty.enumTagFieldIndex(val, zcu) orelse return error.TypeMismatch; | ||
| 4608 | const field_name = ty.enumFieldName(field_index, zcu); | ||
| 4609 | return std.meta.stringToEnum(T, field_name.toSlice(ip)) orelse error.TypeMismatch; | ||
| 4610 | }, | ||
| 4611 | }, | ||
| 4587 | 4612 | ||
| 4588 | .@"union" => |@"union"| { | 4613 | .@"union" => |@"union"| { |
| 4589 | const union_obj = zcu.typeToUnion(ty) orelse return error.TypeMismatch; | 4614 | // No need to handle `interpret_mode`, because the `.@"enum"` handling already deals with it. |
| 4590 | if (union_obj.field_types.len != @"union".fields.len) return error.TypeMismatch; | ||
| 4591 | const tag_val = val.unionTag(zcu) orelse return error.TypeMismatch; | 4615 | const tag_val = val.unionTag(zcu) orelse return error.TypeMismatch; |
| 4592 | const tag = try tag_val.interpret(@"union".tag_type.?, pt); | 4616 | const tag = try tag_val.interpret(@"union".tag_type.?, pt); |
| 4593 | return switch (tag) { | 4617 | return switch (tag) { |
| ... | @@ -4599,14 +4623,28 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe | ... | @@ -4599,14 +4623,28 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe |
| 4599 | }; | 4623 | }; |
| 4600 | }, | 4624 | }, |
| 4601 | 4625 | ||
| 4602 | .@"struct" => |@"struct"| { | 4626 | .@"struct" => |@"struct"| switch (interpret_mode) { |
| 4603 | if (ty.structFieldCount(zcu) != @"struct".fields.len) return error.TypeMismatch; | 4627 | .direct => { |
| 4604 | var result: T = undefined; | 4628 | if (ty.structFieldCount(zcu) != @"struct".fields.len) return error.TypeMismatch; |
| 4605 | inline for (@"struct".fields, 0..) |field, field_idx| { | 4629 | var result: T = undefined; |
| 4606 | const field_val = try val.fieldValue(pt, field_idx); | 4630 | inline for (@"struct".fields, 0..) |field, field_idx| { |
| 4607 | @field(result, field.name) = try field_val.interpret(field.type, pt); | 4631 | const field_val = try val.fieldValue(pt, field_idx); |
| 4608 | } | 4632 | @field(result, field.name) = try field_val.interpret(field.type, pt); |
| 4609 | return result; | 4633 | } |
| 4634 | return result; | ||
| 4635 | }, | ||
| 4636 | .by_name => { | ||
| 4637 | const struct_obj = zcu.typeToStruct(ty) orelse return error.TypeMismatch; | ||
| 4638 | var result: T = undefined; | ||
| 4639 | inline for (@"struct".fields) |field| { | ||
| 4640 | const field_name_ip = try ip.getOrPutString(zcu.gpa, pt.tid, field.name, .no_embedded_nulls); | ||
| 4641 | @field(result, field.name) = if (struct_obj.nameIndex(ip, field_name_ip)) |field_idx| f: { | ||
| 4642 | const field_val = try val.fieldValue(pt, field_idx); | ||
| 4643 | break :f try field_val.interpret(field.type, pt); | ||
| 4644 | } else (field.defaultValue() orelse return error.TypeMismatch); | ||
| 4645 | } | ||
| 4646 | return result; | ||
| 4647 | }, | ||
| 4610 | }, | 4648 | }, |
| 4611 | }; | 4649 | }; |
| 4612 | } | 4650 | } |
| ... | @@ -4618,6 +4656,7 @@ pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory | ... | @@ -4618,6 +4656,7 @@ pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory |
| 4618 | const T = @TypeOf(val); | 4656 | const T = @TypeOf(val); |
| 4619 | 4657 | ||
| 4620 | const zcu = pt.zcu; | 4658 | const zcu = pt.zcu; |
| 4659 | const ip = &zcu.intern_pool; | ||
| 4621 | if (ty.zigTypeTag(zcu) != @typeInfo(T)) return error.TypeMismatch; | 4660 | if (ty.zigTypeTag(zcu) != @typeInfo(T)) return error.TypeMismatch; |
| 4622 | 4661 | ||
| 4623 | return switch (@typeInfo(T)) { | 4662 | return switch (@typeInfo(T)) { |
| ... | @@ -4657,9 +4696,17 @@ pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory | ... | @@ -4657,9 +4696,17 @@ pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory |
| 4657 | else | 4696 | else |
| 4658 | try pt.nullValue(ty), | 4697 | try pt.nullValue(ty), |
| 4659 | 4698 | ||
| 4660 | .@"enum" => try pt.enumValue(ty, (try uninterpret(@intFromEnum(val), ty.intTagType(zcu), pt)).toIntern()), | 4699 | .@"enum" => switch (interpret_mode) { |
| 4700 | .direct => try pt.enumValue(ty, (try uninterpret(@intFromEnum(val), ty.intTagType(zcu), pt)).toIntern()), | ||
| 4701 | .by_name => { | ||
| 4702 | const field_name_ip = try ip.getOrPutString(zcu.gpa, pt.tid, @tagName(val), .no_embedded_nulls); | ||
| 4703 | const field_idx = ty.enumFieldIndex(field_name_ip, zcu) orelse return error.TypeMismatch; | ||
| 4704 | return pt.enumValueFieldIndex(ty, field_idx); | ||
| 4705 | }, | ||
| 4706 | }, | ||
| 4661 | 4707 | ||
| 4662 | .@"union" => |@"union"| { | 4708 | .@"union" => |@"union"| { |
| 4709 | // No need to handle `interpret_mode`, because the `.@"enum"` handling already deals with it. | ||
| 4663 | const tag: @"union".tag_type.? = val; | 4710 | const tag: @"union".tag_type.? = val; |
| 4664 | const tag_val = try uninterpret(tag, ty.unionTagType(zcu).?, pt); | 4711 | const tag_val = try uninterpret(tag, ty.unionTagType(zcu).?, pt); |
| 4665 | const field_ty = ty.unionFieldType(tag_val, zcu) orelse return error.TypeMismatch; | 4712 | const field_ty = ty.unionFieldType(tag_val, zcu) orelse return error.TypeMismatch; |
| ... | @@ -4672,17 +4719,44 @@ pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory | ... | @@ -4672,17 +4719,44 @@ pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory |
| 4672 | }; | 4719 | }; |
| 4673 | }, | 4720 | }, |
| 4674 | 4721 | ||
| 4675 | .@"struct" => |@"struct"| { | 4722 | .@"struct" => |@"struct"| switch (interpret_mode) { |
| 4676 | if (ty.structFieldCount(zcu) != @"struct".fields.len) return error.TypeMismatch; | 4723 | .direct => { |
| 4677 | var field_vals: [@"struct".fields.len]InternPool.Index = undefined; | 4724 | if (ty.structFieldCount(zcu) != @"struct".fields.len) return error.TypeMismatch; |
| 4678 | inline for (&field_vals, @"struct".fields, 0..) |*field_val, field, field_idx| { | 4725 | var field_vals: [@"struct".fields.len]InternPool.Index = undefined; |
| 4679 | const field_ty = ty.fieldType(field_idx, zcu); | 4726 | inline for (&field_vals, @"struct".fields, 0..) |*field_val, field, field_idx| { |
| 4680 | field_val.* = (try uninterpret(@field(val, field.name), field_ty, pt)).toIntern(); | 4727 | const field_ty = ty.fieldType(field_idx, zcu); |
| 4681 | } | 4728 | field_val.* = (try uninterpret(@field(val, field.name), field_ty, pt)).toIntern(); |
| 4682 | return .fromInterned(try pt.intern(.{ .aggregate = .{ | 4729 | } |
| 4683 | .ty = ty.toIntern(), | 4730 | return .fromInterned(try pt.intern(.{ .aggregate = .{ |
| 4684 | .storage = .{ .elems = &field_vals }, | 4731 | .ty = ty.toIntern(), |
| 4685 | } })); | 4732 | .storage = .{ .elems = &field_vals }, |
| 4733 | } })); | ||
| 4734 | }, | ||
| 4735 | .by_name => { | ||
| 4736 | const struct_obj = zcu.typeToStruct(ty) orelse return error.TypeMismatch; | ||
| 4737 | const want_fields_len = struct_obj.field_types.len; | ||
| 4738 | const field_vals = try zcu.gpa.alloc(InternPool.Index, want_fields_len); | ||
| 4739 | defer zcu.gpa.free(field_vals); | ||
| 4740 | @memset(field_vals, .none); | ||
| 4741 | inline for (@"struct".fields) |field| { | ||
| 4742 | const field_name_ip = try ip.getOrPutString(zcu.gpa, pt.tid, field.name, .no_embedded_nulls); | ||
| 4743 | if (struct_obj.nameIndex(ip, field_name_ip)) |field_idx| { | ||
| 4744 | const field_ty = ty.fieldType(field_idx, zcu); | ||
| 4745 | field_vals[field_idx] = (try uninterpret(@field(val, field.name), field_ty, pt)).toIntern(); | ||
| 4746 | } | ||
| 4747 | } | ||
| 4748 | for (field_vals, 0..) |*field_val, field_idx| { | ||
| 4749 | if (field_val.* == .none) { | ||
| 4750 | const default_init = struct_obj.field_inits.get(ip)[field_idx]; | ||
| 4751 | if (default_init == .none) return error.TypeMismatch; | ||
| 4752 | field_val.* = default_init; | ||
| 4753 | } | ||
| 4754 | } | ||
| 4755 | return .fromInterned(try pt.intern(.{ .aggregate = .{ | ||
| 4756 | .ty = ty.toIntern(), | ||
| 4757 | .storage = .{ .elems = field_vals }, | ||
| 4758 | } })); | ||
| 4759 | }, | ||
| 4686 | }, | 4760 | }, |
| 4687 | }; | 4761 | }; |
| 4688 | } | 4762 | } |
src/Zcu.zig-4| ... | @@ -3486,10 +3486,6 @@ pub fn funcInfo(zcu: *const Zcu, func_index: InternPool.Index) InternPool.Key.Fu | ... | @@ -3486,10 +3486,6 @@ pub fn funcInfo(zcu: *const Zcu, func_index: InternPool.Index) InternPool.Key.Fu |
| 3486 | return zcu.intern_pool.toFunc(func_index); | 3486 | return zcu.intern_pool.toFunc(func_index); |
| 3487 | } | 3487 | } |
| 3488 | 3488 | ||
| 3489 | pub fn toEnum(zcu: *const Zcu, comptime E: type, val: Value) E { | ||
| 3490 | return zcu.intern_pool.toEnum(E, val.toIntern()); | ||
| 3491 | } | ||
| 3492 | |||
| 3493 | pub const UnionLayout = struct { | 3489 | pub const UnionLayout = struct { |
| 3494 | abi_size: u64, | 3490 | abi_size: u64, |
| 3495 | abi_align: Alignment, | 3491 | abi_align: Alignment, |
src/Zcu/PerThread.zig+3-3| ... | @@ -3068,7 +3068,7 @@ pub fn populateTestFunctions( | ... | @@ -3068,7 +3068,7 @@ pub fn populateTestFunctions( |
| 3068 | .child = test_fn_ty.toIntern(), | 3068 | .child = test_fn_ty.toIntern(), |
| 3069 | .flags = .{ | 3069 | .flags = .{ |
| 3070 | .is_const = true, | 3070 | .is_const = true, |
| 3071 | .size = .Slice, | 3071 | .size = .slice, |
| 3072 | }, | 3072 | }, |
| 3073 | }); | 3073 | }); |
| 3074 | const new_init = try pt.intern(.{ .slice = .{ | 3074 | const new_init = try pt.intern(.{ .slice = .{ |
| ... | @@ -3303,7 +3303,7 @@ pub fn optionalType(pt: Zcu.PerThread, child_type: InternPool.Index) Allocator.E | ... | @@ -3303,7 +3303,7 @@ pub fn optionalType(pt: Zcu.PerThread, child_type: InternPool.Index) Allocator.E |
| 3303 | pub fn ptrType(pt: Zcu.PerThread, info: InternPool.Key.PtrType) Allocator.Error!Type { | 3303 | pub fn ptrType(pt: Zcu.PerThread, info: InternPool.Key.PtrType) Allocator.Error!Type { |
| 3304 | var canon_info = info; | 3304 | var canon_info = info; |
| 3305 | 3305 | ||
| 3306 | if (info.flags.size == .C) canon_info.flags.is_allowzero = true; | 3306 | if (info.flags.size == .c) canon_info.flags.is_allowzero = true; |
| 3307 | 3307 | ||
| 3308 | // Canonicalize non-zero alignment. If it matches the ABI alignment of the pointee | 3308 | // Canonicalize non-zero alignment. If it matches the ABI alignment of the pointee |
| 3309 | // type, we change it to 0 here. If this causes an assertion trip because the | 3309 | // type, we change it to 0 here. If this causes an assertion trip because the |
| ... | @@ -3360,7 +3360,7 @@ pub fn manyConstPtrType(pt: Zcu.PerThread, child_type: Type) Allocator.Error!Typ | ... | @@ -3360,7 +3360,7 @@ pub fn manyConstPtrType(pt: Zcu.PerThread, child_type: Type) Allocator.Error!Typ |
| 3360 | return pt.ptrType(.{ | 3360 | return pt.ptrType(.{ |
| 3361 | .child = child_type.toIntern(), | 3361 | .child = child_type.toIntern(), |
| 3362 | .flags = .{ | 3362 | .flags = .{ |
| 3363 | .size = .Many, | 3363 | .size = .many, |
| 3364 | .is_const = true, | 3364 | .is_const = true, |
| 3365 | }, | 3365 | }, |
| 3366 | }); | 3366 | }); |
src/arch/aarch64/CodeGen.zig+1-1| ... | @@ -2398,7 +2398,7 @@ fn ptrArithmetic( | ... | @@ -2398,7 +2398,7 @@ fn ptrArithmetic( |
| 2398 | 2398 | ||
| 2399 | const ptr_ty = lhs_ty; | 2399 | const ptr_ty = lhs_ty; |
| 2400 | const elem_ty = switch (ptr_ty.ptrSize(zcu)) { | 2400 | const elem_ty = switch (ptr_ty.ptrSize(zcu)) { |
| 2401 | .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type | 2401 | .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type |
| 2402 | else => ptr_ty.childType(zcu), | 2402 | else => ptr_ty.childType(zcu), |
| 2403 | }; | 2403 | }; |
| 2404 | const elem_size = elem_ty.abiSize(zcu); | 2404 | const elem_size = elem_ty.abiSize(zcu); |
src/arch/arm/CodeGen.zig+1-1| ... | @@ -3919,7 +3919,7 @@ fn ptrArithmetic( | ... | @@ -3919,7 +3919,7 @@ fn ptrArithmetic( |
| 3919 | 3919 | ||
| 3920 | const ptr_ty = lhs_ty; | 3920 | const ptr_ty = lhs_ty; |
| 3921 | const elem_ty = switch (ptr_ty.ptrSize(zcu)) { | 3921 | const elem_ty = switch (ptr_ty.ptrSize(zcu)) { |
| 3922 | .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type | 3922 | .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type |
| 3923 | else => ptr_ty.childType(zcu), | 3923 | else => ptr_ty.childType(zcu), |
| 3924 | }; | 3924 | }; |
| 3925 | const elem_size: u32 = @intCast(elem_ty.abiSize(zcu)); | 3925 | const elem_size: u32 = @intCast(elem_ty.abiSize(zcu)); |
src/arch/riscv64/CodeGen.zig+11-11| ... | @@ -7843,15 +7843,15 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -7843,15 +7843,15 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void { |
| 7843 | if (elem_abi_size == 1) { | 7843 | if (elem_abi_size == 1) { |
| 7844 | const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { | 7844 | const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { |
| 7845 | // TODO: this only handles slices stored in the stack | 7845 | // TODO: this only handles slices stored in the stack |
| 7846 | .Slice => dst_ptr, | 7846 | .slice => dst_ptr, |
| 7847 | .One => dst_ptr, | 7847 | .one => dst_ptr, |
| 7848 | .C, .Many => unreachable, | 7848 | .c, .many => unreachable, |
| 7849 | }; | 7849 | }; |
| 7850 | const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { | 7850 | const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { |
| 7851 | // TODO: this only handles slices stored in the stack | 7851 | // TODO: this only handles slices stored in the stack |
| 7852 | .Slice => dst_ptr.address().offset(8).deref(), | 7852 | .slice => dst_ptr.address().offset(8).deref(), |
| 7853 | .One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) }, | 7853 | .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) }, |
| 7854 | .C, .Many => unreachable, | 7854 | .c, .many => unreachable, |
| 7855 | }; | 7855 | }; |
| 7856 | const len_lock: ?RegisterLock = switch (len) { | 7856 | const len_lock: ?RegisterLock = switch (len) { |
| 7857 | .register => |reg| func.register_manager.lockRegAssumeUnused(reg), | 7857 | .register => |reg| func.register_manager.lockRegAssumeUnused(reg), |
| ... | @@ -7867,8 +7867,8 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -7867,8 +7867,8 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void { |
| 7867 | // Length zero requires a runtime check - so we handle arrays specially | 7867 | // Length zero requires a runtime check - so we handle arrays specially |
| 7868 | // here to elide it. | 7868 | // here to elide it. |
| 7869 | switch (dst_ptr_ty.ptrSize(zcu)) { | 7869 | switch (dst_ptr_ty.ptrSize(zcu)) { |
| 7870 | .Slice => return func.fail("TODO: airMemset Slices", .{}), | 7870 | .slice => return func.fail("TODO: airMemset Slices", .{}), |
| 7871 | .One => { | 7871 | .one => { |
| 7872 | const elem_ptr_ty = try pt.singleMutPtrType(elem_ty); | 7872 | const elem_ptr_ty = try pt.singleMutPtrType(elem_ty); |
| 7873 | 7873 | ||
| 7874 | const len = dst_ptr_ty.childType(zcu).arrayLen(zcu); | 7874 | const len = dst_ptr_ty.childType(zcu).arrayLen(zcu); |
| ... | @@ -7889,7 +7889,7 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -7889,7 +7889,7 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void { |
| 7889 | const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) }; | 7889 | const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) }; |
| 7890 | try func.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy); | 7890 | try func.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy); |
| 7891 | }, | 7891 | }, |
| 7892 | .C, .Many => unreachable, | 7892 | .c, .many => unreachable, |
| 7893 | } | 7893 | } |
| 7894 | } | 7894 | } |
| 7895 | return func.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none }); | 7895 | return func.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none }); |
| ... | @@ -7906,7 +7906,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -7906,7 +7906,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void { |
| 7906 | const dst_ty = func.typeOf(bin_op.lhs); | 7906 | const dst_ty = func.typeOf(bin_op.lhs); |
| 7907 | 7907 | ||
| 7908 | const len_mcv: MCValue = switch (dst_ty.ptrSize(zcu)) { | 7908 | const len_mcv: MCValue = switch (dst_ty.ptrSize(zcu)) { |
| 7909 | .Slice => len: { | 7909 | .slice => len: { |
| 7910 | const len_reg, const len_lock = try func.allocReg(.int); | 7910 | const len_reg, const len_lock = try func.allocReg(.int); |
| 7911 | defer func.register_manager.unlockReg(len_lock); | 7911 | defer func.register_manager.unlockReg(len_lock); |
| 7912 | 7912 | ||
| ... | @@ -7921,7 +7921,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -7921,7 +7921,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void { |
| 7921 | ); | 7921 | ); |
| 7922 | break :len .{ .register = len_reg }; | 7922 | break :len .{ .register = len_reg }; |
| 7923 | }, | 7923 | }, |
| 7924 | .One => len: { | 7924 | .one => len: { |
| 7925 | const array_ty = dst_ty.childType(zcu); | 7925 | const array_ty = dst_ty.childType(zcu); |
| 7926 | break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) }; | 7926 | break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) }; |
| 7927 | }, | 7927 | }, |
src/arch/riscv64/abi.zig+1-1| ... | @@ -109,7 +109,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass { | ... | @@ -109,7 +109,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass { |
| 109 | return result; | 109 | return result; |
| 110 | }, | 110 | }, |
| 111 | .pointer => switch (ty.ptrSize(zcu)) { | 111 | .pointer => switch (ty.ptrSize(zcu)) { |
| 112 | .Slice => { | 112 | .slice => { |
| 113 | result[0] = .integer; | 113 | result[0] = .integer; |
| 114 | result[1] = .integer; | 114 | result[1] = .integer; |
| 115 | return result; | 115 | return result; |
src/arch/sparc64/CodeGen.zig+1-1| ... | @@ -2953,7 +2953,7 @@ fn binOp( | ... | @@ -2953,7 +2953,7 @@ fn binOp( |
| 2953 | .pointer => { | 2953 | .pointer => { |
| 2954 | const ptr_ty = lhs_ty; | 2954 | const ptr_ty = lhs_ty; |
| 2955 | const elem_ty = switch (ptr_ty.ptrSize(zcu)) { | 2955 | const elem_ty = switch (ptr_ty.ptrSize(zcu)) { |
| 2956 | .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type | 2956 | .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type |
| 2957 | else => ptr_ty.childType(zcu), | 2957 | else => ptr_ty.childType(zcu), |
| 2958 | }; | 2958 | }; |
| 2959 | const elem_size = elem_ty.abiSize(zcu); | 2959 | const elem_size = elem_ty.abiSize(zcu); |
src/arch/wasm/CodeGen.zig+8-8| ... | @@ -4726,7 +4726,7 @@ fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void { | ... | @@ -4726,7 +4726,7 @@ fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void { |
| 4726 | const offset = try cg.resolveInst(bin_op.rhs); | 4726 | const offset = try cg.resolveInst(bin_op.rhs); |
| 4727 | const ptr_ty = cg.typeOf(bin_op.lhs); | 4727 | const ptr_ty = cg.typeOf(bin_op.lhs); |
| 4728 | const pointee_ty = switch (ptr_ty.ptrSize(zcu)) { | 4728 | const pointee_ty = switch (ptr_ty.ptrSize(zcu)) { |
| 4729 | .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type | 4729 | .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type |
| 4730 | else => ptr_ty.childType(zcu), | 4730 | else => ptr_ty.childType(zcu), |
| 4731 | }; | 4731 | }; |
| 4732 | 4732 | ||
| ... | @@ -4756,12 +4756,12 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void { | ... | @@ -4756,12 +4756,12 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void { |
| 4756 | const ptr_ty = cg.typeOf(bin_op.lhs); | 4756 | const ptr_ty = cg.typeOf(bin_op.lhs); |
| 4757 | const value = try cg.resolveInst(bin_op.rhs); | 4757 | const value = try cg.resolveInst(bin_op.rhs); |
| 4758 | const len = switch (ptr_ty.ptrSize(zcu)) { | 4758 | const len = switch (ptr_ty.ptrSize(zcu)) { |
| 4759 | .Slice => try cg.sliceLen(ptr), | 4759 | .slice => try cg.sliceLen(ptr), |
| 4760 | .One => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }), | 4760 | .one => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }), |
| 4761 | .C, .Many => unreachable, | 4761 | .c, .many => unreachable, |
| 4762 | }; | 4762 | }; |
| 4763 | 4763 | ||
| 4764 | const elem_ty = if (ptr_ty.ptrSize(zcu) == .One) | 4764 | const elem_ty = if (ptr_ty.ptrSize(zcu) == .one) |
| 4765 | ptr_ty.childType(zcu).childType(zcu) | 4765 | ptr_ty.childType(zcu).childType(zcu) |
| 4766 | else | 4766 | else |
| 4767 | ptr_ty.childType(zcu); | 4767 | ptr_ty.childType(zcu); |
| ... | @@ -5688,7 +5688,7 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -5688,7 +5688,7 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5688 | const src = try cg.resolveInst(bin_op.rhs); | 5688 | const src = try cg.resolveInst(bin_op.rhs); |
| 5689 | const src_ty = cg.typeOf(bin_op.rhs); | 5689 | const src_ty = cg.typeOf(bin_op.rhs); |
| 5690 | const len = switch (dst_ty.ptrSize(zcu)) { | 5690 | const len = switch (dst_ty.ptrSize(zcu)) { |
| 5691 | .Slice => blk: { | 5691 | .slice => blk: { |
| 5692 | const slice_len = try cg.sliceLen(dst); | 5692 | const slice_len = try cg.sliceLen(dst); |
| 5693 | if (ptr_elem_ty.abiSize(zcu) != 1) { | 5693 | if (ptr_elem_ty.abiSize(zcu) != 1) { |
| 5694 | try cg.emitWValue(slice_len); | 5694 | try cg.emitWValue(slice_len); |
| ... | @@ -5698,10 +5698,10 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -5698,10 +5698,10 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5698 | } | 5698 | } |
| 5699 | break :blk slice_len; | 5699 | break :blk slice_len; |
| 5700 | }, | 5700 | }, |
| 5701 | .One => @as(WValue, .{ | 5701 | .one => @as(WValue, .{ |
| 5702 | .imm32 = @as(u32, @intCast(ptr_elem_ty.arrayLen(zcu) * ptr_elem_ty.childType(zcu).abiSize(zcu))), | 5702 | .imm32 = @as(u32, @intCast(ptr_elem_ty.arrayLen(zcu) * ptr_elem_ty.childType(zcu).abiSize(zcu))), |
| 5703 | }), | 5703 | }), |
| 5704 | .C, .Many => unreachable, | 5704 | .c, .many => unreachable, |
| 5705 | }; | 5705 | }; |
| 5706 | const dst_ptr = try cg.sliceOrArrayPtr(dst, dst_ty); | 5706 | const dst_ptr = try cg.sliceOrArrayPtr(dst, dst_ty); |
| 5707 | const src_ptr = try cg.sliceOrArrayPtr(src, src_ty); | 5707 | const src_ptr = try cg.sliceOrArrayPtr(src, src_ty); |
src/arch/x86_64/CodeGen.zig+14-14| ... | @@ -9607,13 +9607,13 @@ fn genMulDivBinOp( | ... | @@ -9607,13 +9607,13 @@ fn genMulDivBinOp( |
| 9607 | const manyptr_u32_ty = try pt.ptrType(.{ | 9607 | const manyptr_u32_ty = try pt.ptrType(.{ |
| 9608 | .child = .u32_type, | 9608 | .child = .u32_type, |
| 9609 | .flags = .{ | 9609 | .flags = .{ |
| 9610 | .size = .Many, | 9610 | .size = .many, |
| 9611 | }, | 9611 | }, |
| 9612 | }); | 9612 | }); |
| 9613 | const manyptr_const_u32_ty = try pt.ptrType(.{ | 9613 | const manyptr_const_u32_ty = try pt.ptrType(.{ |
| 9614 | .child = .u32_type, | 9614 | .child = .u32_type, |
| 9615 | .flags = .{ | 9615 | .flags = .{ |
| 9616 | .size = .Many, | 9616 | .size = .many, |
| 9617 | .is_const = true, | 9617 | .is_const = true, |
| 9618 | }, | 9618 | }, |
| 9619 | }); | 9619 | }); |
| ... | @@ -16614,15 +16614,15 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -16614,15 +16614,15 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void { |
| 16614 | if (elem_abi_size == 1) { | 16614 | if (elem_abi_size == 1) { |
| 16615 | const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { | 16615 | const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { |
| 16616 | // TODO: this only handles slices stored in the stack | 16616 | // TODO: this only handles slices stored in the stack |
| 16617 | .Slice => dst_ptr, | 16617 | .slice => dst_ptr, |
| 16618 | .One => dst_ptr, | 16618 | .one => dst_ptr, |
| 16619 | .C, .Many => unreachable, | 16619 | .c, .many => unreachable, |
| 16620 | }; | 16620 | }; |
| 16621 | const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { | 16621 | const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { |
| 16622 | // TODO: this only handles slices stored in the stack | 16622 | // TODO: this only handles slices stored in the stack |
| 16623 | .Slice => dst_ptr.address().offset(8).deref(), | 16623 | .slice => dst_ptr.address().offset(8).deref(), |
| 16624 | .One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) }, | 16624 | .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) }, |
| 16625 | .C, .Many => unreachable, | 16625 | .c, .many => unreachable, |
| 16626 | }; | 16626 | }; |
| 16627 | const len_lock: ?RegisterLock = switch (len) { | 16627 | const len_lock: ?RegisterLock = switch (len) { |
| 16628 | .register => |reg| self.register_manager.lockRegAssumeUnused(reg), | 16628 | .register => |reg| self.register_manager.lockRegAssumeUnused(reg), |
| ... | @@ -16638,7 +16638,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -16638,7 +16638,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void { |
| 16638 | // Length zero requires a runtime check - so we handle arrays specially | 16638 | // Length zero requires a runtime check - so we handle arrays specially |
| 16639 | // here to elide it. | 16639 | // here to elide it. |
| 16640 | switch (dst_ptr_ty.ptrSize(zcu)) { | 16640 | switch (dst_ptr_ty.ptrSize(zcu)) { |
| 16641 | .Slice => { | 16641 | .slice => { |
| 16642 | const slice_ptr_ty = dst_ptr_ty.slicePtrFieldType(zcu); | 16642 | const slice_ptr_ty = dst_ptr_ty.slicePtrFieldType(zcu); |
| 16643 | 16643 | ||
| 16644 | // TODO: this only handles slices stored in the stack | 16644 | // TODO: this only handles slices stored in the stack |
| ... | @@ -16681,7 +16681,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -16681,7 +16681,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void { |
| 16681 | 16681 | ||
| 16682 | self.performReloc(skip_reloc); | 16682 | self.performReloc(skip_reloc); |
| 16683 | }, | 16683 | }, |
| 16684 | .One => { | 16684 | .one => { |
| 16685 | const elem_ptr_ty = try pt.singleMutPtrType(elem_ty); | 16685 | const elem_ptr_ty = try pt.singleMutPtrType(elem_ty); |
| 16686 | 16686 | ||
| 16687 | const len = dst_ptr_ty.childType(zcu).arrayLen(zcu); | 16687 | const len = dst_ptr_ty.childType(zcu).arrayLen(zcu); |
| ... | @@ -16704,7 +16704,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -16704,7 +16704,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void { |
| 16704 | const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) }; | 16704 | const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) }; |
| 16705 | try self.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy); | 16705 | try self.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy); |
| 16706 | }, | 16706 | }, |
| 16707 | .C, .Many => unreachable, | 16707 | .c, .many => unreachable, |
| 16708 | } | 16708 | } |
| 16709 | } | 16709 | } |
| 16710 | return self.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none }); | 16710 | return self.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none }); |
| ... | @@ -16735,7 +16735,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -16735,7 +16735,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void { |
| 16735 | defer if (src_ptr_lock) |lock| self.register_manager.unlockReg(lock); | 16735 | defer if (src_ptr_lock) |lock| self.register_manager.unlockReg(lock); |
| 16736 | 16736 | ||
| 16737 | const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { | 16737 | const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { |
| 16738 | .Slice => len: { | 16738 | .slice => len: { |
| 16739 | const len_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp); | 16739 | const len_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp); |
| 16740 | const len_lock = self.register_manager.lockRegAssumeUnused(len_reg); | 16740 | const len_lock = self.register_manager.lockRegAssumeUnused(len_reg); |
| 16741 | defer self.register_manager.unlockReg(len_lock); | 16741 | defer self.register_manager.unlockReg(len_lock); |
| ... | @@ -16748,11 +16748,11 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -16748,11 +16748,11 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void { |
| 16748 | ); | 16748 | ); |
| 16749 | break :len .{ .register = len_reg }; | 16749 | break :len .{ .register = len_reg }; |
| 16750 | }, | 16750 | }, |
| 16751 | .One => len: { | 16751 | .one => len: { |
| 16752 | const array_ty = dst_ptr_ty.childType(zcu); | 16752 | const array_ty = dst_ptr_ty.childType(zcu); |
| 16753 | break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) }; | 16753 | break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) }; |
| 16754 | }, | 16754 | }, |
| 16755 | .C, .Many => unreachable, | 16755 | .c, .many => unreachable, |
| 16756 | }; | 16756 | }; |
| 16757 | const len_lock: ?RegisterLock = switch (len) { | 16757 | const len_lock: ?RegisterLock = switch (len) { |
| 16758 | .register => |reg| self.register_manager.lockRegAssumeUnused(reg), | 16758 | .register => |reg| self.register_manager.lockRegAssumeUnused(reg), |
src/arch/x86_64/abi.zig+1-1| ... | @@ -108,7 +108,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8 | ... | @@ -108,7 +108,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8 |
| 108 | var result = [1]Class{.none} ** 8; | 108 | var result = [1]Class{.none} ** 8; |
| 109 | switch (ty.zigTypeTag(zcu)) { | 109 | switch (ty.zigTypeTag(zcu)) { |
| 110 | .pointer => switch (ty.ptrSize(zcu)) { | 110 | .pointer => switch (ty.ptrSize(zcu)) { |
| 111 | .Slice => { | 111 | .slice => { |
| 112 | result[0] = .integer; | 112 | result[0] = .integer; |
| 113 | result[1] = .integer; | 113 | result[1] = .integer; |
| 114 | return result; | 114 | return result; |
src/clang.zig+1-1| ... | @@ -177,7 +177,7 @@ pub const ASTUnit = opaque { | ... | @@ -177,7 +177,7 @@ pub const ASTUnit = opaque { |
| 177 | extern fn ZigClangASTUnit_visitLocalTopLevelDecls( | 177 | extern fn ZigClangASTUnit_visitLocalTopLevelDecls( |
| 178 | *ASTUnit, | 178 | *ASTUnit, |
| 179 | context: ?*anyopaque, | 179 | context: ?*anyopaque, |
| 180 | Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.C) bool, | 180 | Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.c) bool, |
| 181 | ) bool; | 181 | ) bool; |
| 182 | 182 | ||
| 183 | pub const getLocalPreprocessingEntities_begin = ZigClangASTUnit_getLocalPreprocessingEntities_begin; | 183 | pub const getLocalPreprocessingEntities_begin = ZigClangASTUnit_getLocalPreprocessingEntities_begin; |
src/codegen.zig+1-1| ... | @@ -945,7 +945,7 @@ pub fn genTypedValue( | ... | @@ -945,7 +945,7 @@ pub fn genTypedValue( |
| 945 | switch (ty.zigTypeTag(zcu)) { | 945 | switch (ty.zigTypeTag(zcu)) { |
| 946 | .void => return .{ .mcv = .none }, | 946 | .void => return .{ .mcv = .none }, |
| 947 | .pointer => switch (ty.ptrSize(zcu)) { | 947 | .pointer => switch (ty.ptrSize(zcu)) { |
| 948 | .Slice => {}, | 948 | .slice => {}, |
| 949 | else => switch (val.toIntern()) { | 949 | else => switch (val.toIntern()) { |
| 950 | .null_value => { | 950 | .null_value => { |
| 951 | return .{ .mcv = .{ .immediate = 0 } }; | 951 | return .{ .mcv = .{ .immediate = 0 } }; |
src/codegen/c.zig+19-19| ... | @@ -1589,14 +1589,14 @@ pub const DeclGen = struct { | ... | @@ -1589,14 +1589,14 @@ pub const DeclGen = struct { |
| 1589 | try dg.fmtIntLiteral(try pt.undefValue(ty), location), | 1589 | try dg.fmtIntLiteral(try pt.undefValue(ty), location), |
| 1590 | }), | 1590 | }), |
| 1591 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 1591 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 1592 | .One, .Many, .C => { | 1592 | .one, .many, .c => { |
| 1593 | try writer.writeAll("(("); | 1593 | try writer.writeAll("(("); |
| 1594 | try dg.renderCType(writer, ctype); | 1594 | try dg.renderCType(writer, ctype); |
| 1595 | return writer.print("){x})", .{ | 1595 | return writer.print("){x})", .{ |
| 1596 | try dg.fmtIntLiteral(try pt.undefValue(Type.usize), .Other), | 1596 | try dg.fmtIntLiteral(try pt.undefValue(Type.usize), .Other), |
| 1597 | }); | 1597 | }); |
| 1598 | }, | 1598 | }, |
| 1599 | .Slice => { | 1599 | .slice => { |
| 1600 | if (!location.isInitializer()) { | 1600 | if (!location.isInitializer()) { |
| 1601 | try writer.writeByte('('); | 1601 | try writer.writeByte('('); |
| 1602 | try dg.renderCType(writer, ctype); | 1602 | try dg.renderCType(writer, ctype); |
| ... | @@ -3570,7 +3570,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3570,7 +3570,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3570 | try f.renderType(writer, inst_ty); | 3570 | try f.renderType(writer, inst_ty); |
| 3571 | try writer.writeByte(')'); | 3571 | try writer.writeByte(')'); |
| 3572 | if (elem_has_bits) try writer.writeByte('&'); | 3572 | if (elem_has_bits) try writer.writeByte('&'); |
| 3573 | if (elem_has_bits and ptr_ty.ptrSize(zcu) == .One) { | 3573 | if (elem_has_bits and ptr_ty.ptrSize(zcu) == .one) { |
| 3574 | // It's a pointer to an array, so we need to de-reference. | 3574 | // It's a pointer to an array, so we need to de-reference. |
| 3575 | try f.writeCValueDeref(writer, ptr); | 3575 | try f.writeCValueDeref(writer, ptr); |
| 3576 | } else try f.writeCValue(writer, ptr, .Other); | 3576 | } else try f.writeCValue(writer, ptr, .Other); |
| ... | @@ -5798,8 +5798,8 @@ fn fieldLocation( | ... | @@ -5798,8 +5798,8 @@ fn fieldLocation( |
| 5798 | } | 5798 | } |
| 5799 | }, | 5799 | }, |
| 5800 | .ptr_type => |ptr_info| switch (ptr_info.flags.size) { | 5800 | .ptr_type => |ptr_info| switch (ptr_info.flags.size) { |
| 5801 | .One, .Many, .C => unreachable, | 5801 | .one, .many, .c => unreachable, |
| 5802 | .Slice => switch (field_index) { | 5802 | .slice => switch (field_index) { |
| 5803 | 0 => return .{ .field = .{ .identifier = "ptr" } }, | 5803 | 0 => return .{ .field = .{ .identifier = "ptr" } }, |
| 5804 | 1 => return .{ .field = .{ .identifier = "len" } }, | 5804 | 1 => return .{ .field = .{ .identifier = "len" } }, |
| 5805 | else => unreachable, | 5805 | else => unreachable, |
| ... | @@ -6902,7 +6902,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { | ... | @@ -6902,7 +6902,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { |
| 6902 | 6902 | ||
| 6903 | try writer.writeAll("memset("); | 6903 | try writer.writeAll("memset("); |
| 6904 | switch (dest_ty.ptrSize(zcu)) { | 6904 | switch (dest_ty.ptrSize(zcu)) { |
| 6905 | .Slice => { | 6905 | .slice => { |
| 6906 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" }); | 6906 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" }); |
| 6907 | try writer.writeAll(", 0xaa, "); | 6907 | try writer.writeAll(", 0xaa, "); |
| 6908 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" }); | 6908 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" }); |
| ... | @@ -6912,14 +6912,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { | ... | @@ -6912,14 +6912,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { |
| 6912 | try writer.writeAll(");\n"); | 6912 | try writer.writeAll(");\n"); |
| 6913 | } | 6913 | } |
| 6914 | }, | 6914 | }, |
| 6915 | .One => { | 6915 | .one => { |
| 6916 | const array_ty = dest_ty.childType(zcu); | 6916 | const array_ty = dest_ty.childType(zcu); |
| 6917 | const len = array_ty.arrayLen(zcu) * elem_abi_size; | 6917 | const len = array_ty.arrayLen(zcu) * elem_abi_size; |
| 6918 | 6918 | ||
| 6919 | try f.writeCValue(writer, dest_slice, .FunctionArgument); | 6919 | try f.writeCValue(writer, dest_slice, .FunctionArgument); |
| 6920 | try writer.print(", 0xaa, {d});\n", .{len}); | 6920 | try writer.print(", 0xaa, {d});\n", .{len}); |
| 6921 | }, | 6921 | }, |
| 6922 | .Many, .C => unreachable, | 6922 | .many, .c => unreachable, |
| 6923 | } | 6923 | } |
| 6924 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 6924 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 6925 | return .none; | 6925 | return .none; |
| ... | @@ -6932,7 +6932,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { | ... | @@ -6932,7 +6932,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { |
| 6932 | const elem_ptr_ty = try pt.ptrType(.{ | 6932 | const elem_ptr_ty = try pt.ptrType(.{ |
| 6933 | .child = elem_ty.toIntern(), | 6933 | .child = elem_ty.toIntern(), |
| 6934 | .flags = .{ | 6934 | .flags = .{ |
| 6935 | .size = .C, | 6935 | .size = .c, |
| 6936 | }, | 6936 | }, |
| 6937 | }); | 6937 | }); |
| 6938 | 6938 | ||
| ... | @@ -6946,14 +6946,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { | ... | @@ -6946,14 +6946,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { |
| 6946 | try f.writeCValue(writer, index, .Other); | 6946 | try f.writeCValue(writer, index, .Other); |
| 6947 | try writer.writeAll(" != "); | 6947 | try writer.writeAll(" != "); |
| 6948 | switch (dest_ty.ptrSize(zcu)) { | 6948 | switch (dest_ty.ptrSize(zcu)) { |
| 6949 | .Slice => { | 6949 | .slice => { |
| 6950 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" }); | 6950 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" }); |
| 6951 | }, | 6951 | }, |
| 6952 | .One => { | 6952 | .one => { |
| 6953 | const array_ty = dest_ty.childType(zcu); | 6953 | const array_ty = dest_ty.childType(zcu); |
| 6954 | try writer.print("{d}", .{array_ty.arrayLen(zcu)}); | 6954 | try writer.print("{d}", .{array_ty.arrayLen(zcu)}); |
| 6955 | }, | 6955 | }, |
| 6956 | .Many, .C => unreachable, | 6956 | .many, .c => unreachable, |
| 6957 | } | 6957 | } |
| 6958 | try writer.writeAll("; ++"); | 6958 | try writer.writeAll("; ++"); |
| 6959 | try f.writeCValue(writer, index, .Other); | 6959 | try f.writeCValue(writer, index, .Other); |
| ... | @@ -6981,7 +6981,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { | ... | @@ -6981,7 +6981,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { |
| 6981 | 6981 | ||
| 6982 | try writer.writeAll("memset("); | 6982 | try writer.writeAll("memset("); |
| 6983 | switch (dest_ty.ptrSize(zcu)) { | 6983 | switch (dest_ty.ptrSize(zcu)) { |
| 6984 | .Slice => { | 6984 | .slice => { |
| 6985 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" }); | 6985 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" }); |
| 6986 | try writer.writeAll(", "); | 6986 | try writer.writeAll(", "); |
| 6987 | try f.writeCValue(writer, bitcasted, .FunctionArgument); | 6987 | try f.writeCValue(writer, bitcasted, .FunctionArgument); |
| ... | @@ -6989,7 +6989,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { | ... | @@ -6989,7 +6989,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { |
| 6989 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" }); | 6989 | try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" }); |
| 6990 | try writer.writeAll(");\n"); | 6990 | try writer.writeAll(");\n"); |
| 6991 | }, | 6991 | }, |
| 6992 | .One => { | 6992 | .one => { |
| 6993 | const array_ty = dest_ty.childType(zcu); | 6993 | const array_ty = dest_ty.childType(zcu); |
| 6994 | const len = array_ty.arrayLen(zcu) * elem_abi_size; | 6994 | const len = array_ty.arrayLen(zcu) * elem_abi_size; |
| 6995 | 6995 | ||
| ... | @@ -6998,7 +6998,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { | ... | @@ -6998,7 +6998,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { |
| 6998 | try f.writeCValue(writer, bitcasted, .FunctionArgument); | 6998 | try f.writeCValue(writer, bitcasted, .FunctionArgument); |
| 6999 | try writer.print(", {d});\n", .{len}); | 6999 | try writer.print(", {d});\n", .{len}); |
| 7000 | }, | 7000 | }, |
| 7001 | .Many, .C => unreachable, | 7001 | .many, .c => unreachable, |
| 7002 | } | 7002 | } |
| 7003 | try f.freeCValue(inst, bitcasted); | 7003 | try f.freeCValue(inst, bitcasted); |
| 7004 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 7004 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| ... | @@ -7015,7 +7015,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -7015,7 +7015,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7015 | const src_ty = f.typeOf(bin_op.rhs); | 7015 | const src_ty = f.typeOf(bin_op.rhs); |
| 7016 | const writer = f.object.writer(); | 7016 | const writer = f.object.writer(); |
| 7017 | 7017 | ||
| 7018 | if (dest_ty.ptrSize(zcu) != .One) { | 7018 | if (dest_ty.ptrSize(zcu) != .one) { |
| 7019 | try writer.writeAll("if ("); | 7019 | try writer.writeAll("if ("); |
| 7020 | try writeArrayLen(f, writer, dest_ptr, dest_ty); | 7020 | try writeArrayLen(f, writer, dest_ptr, dest_ty); |
| 7021 | try writer.writeAll(" != 0) "); | 7021 | try writer.writeAll(" != 0) "); |
| ... | @@ -7038,11 +7038,11 @@ fn writeArrayLen(f: *Function, writer: ArrayListWriter, dest_ptr: CValue, dest_t | ... | @@ -7038,11 +7038,11 @@ fn writeArrayLen(f: *Function, writer: ArrayListWriter, dest_ptr: CValue, dest_t |
| 7038 | const pt = f.object.dg.pt; | 7038 | const pt = f.object.dg.pt; |
| 7039 | const zcu = pt.zcu; | 7039 | const zcu = pt.zcu; |
| 7040 | switch (dest_ty.ptrSize(zcu)) { | 7040 | switch (dest_ty.ptrSize(zcu)) { |
| 7041 | .One => try writer.print("{}", .{ | 7041 | .one => try writer.print("{}", .{ |
| 7042 | try f.fmtIntLiteral(try pt.intValue(Type.usize, dest_ty.childType(zcu).arrayLen(zcu))), | 7042 | try f.fmtIntLiteral(try pt.intValue(Type.usize, dest_ty.childType(zcu).arrayLen(zcu))), |
| 7043 | }), | 7043 | }), |
| 7044 | .Many, .C => unreachable, | 7044 | .many, .c => unreachable, |
| 7045 | .Slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }), | 7045 | .slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }), |
| 7046 | } | 7046 | } |
| 7047 | } | 7047 | } |
| 7048 | 7048 |
src/codegen/c/Type.zig+3-3| ... | @@ -1458,7 +1458,7 @@ pub const Pool = struct { | ... | @@ -1458,7 +1458,7 @@ pub const Pool = struct { |
| 1458 | _ => |ip_index| switch (ip.indexToKey(ip_index)) { | 1458 | _ => |ip_index| switch (ip.indexToKey(ip_index)) { |
| 1459 | .int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind), | 1459 | .int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind), |
| 1460 | .ptr_type => |ptr_info| switch (ptr_info.flags.size) { | 1460 | .ptr_type => |ptr_info| switch (ptr_info.flags.size) { |
| 1461 | .One, .Many, .C => { | 1461 | .one, .many, .c => { |
| 1462 | const elem_ctype = elem_ctype: { | 1462 | const elem_ctype = elem_ctype: { |
| 1463 | if (ptr_info.packed_offset.host_size > 0 and | 1463 | if (ptr_info.packed_offset.host_size > 0 and |
| 1464 | ptr_info.flags.vector_index == .none) | 1464 | ptr_info.flags.vector_index == .none) |
| ... | @@ -1505,7 +1505,7 @@ pub const Pool = struct { | ... | @@ -1505,7 +1505,7 @@ pub const Pool = struct { |
| 1505 | .@"volatile" = ptr_info.flags.is_volatile, | 1505 | .@"volatile" = ptr_info.flags.is_volatile, |
| 1506 | }); | 1506 | }); |
| 1507 | }, | 1507 | }, |
| 1508 | .Slice => { | 1508 | .slice => { |
| 1509 | const target = &mod.resolved_target.result; | 1509 | const target = &mod.resolved_target.result; |
| 1510 | var fields = [_]Info.Field{ | 1510 | var fields = [_]Info.Field{ |
| 1511 | .{ | 1511 | .{ |
| ... | @@ -1598,7 +1598,7 @@ pub const Pool = struct { | ... | @@ -1598,7 +1598,7 @@ pub const Pool = struct { |
| 1598 | switch (payload_type) { | 1598 | switch (payload_type) { |
| 1599 | .anyerror_type => return payload_ctype, | 1599 | .anyerror_type => return payload_ctype, |
| 1600 | else => switch (ip.indexToKey(payload_type)) { | 1600 | else => switch (ip.indexToKey(payload_type)) { |
| 1601 | .ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .C and | 1601 | .ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .c and |
| 1602 | !payload_ptr_info.flags.is_allowzero) return payload_ctype, | 1602 | !payload_ptr_info.flags.is_allowzero) return payload_ctype, |
| 1603 | .error_set_type, .inferred_error_set_type => return payload_ctype, | 1603 | .error_set_type, .inferred_error_set_type => return payload_ctype, |
| 1604 | else => {}, | 1604 | else => {}, |
src/codegen/llvm.zig+17-17| ... | @@ -2109,7 +2109,7 @@ pub const Object = struct { | ... | @@ -2109,7 +2109,7 @@ pub const Object = struct { |
| 2109 | ptr_info.flags.is_allowzero or | 2109 | ptr_info.flags.is_allowzero or |
| 2110 | ptr_info.flags.is_const or | 2110 | ptr_info.flags.is_const or |
| 2111 | ptr_info.flags.is_volatile or | 2111 | ptr_info.flags.is_volatile or |
| 2112 | ptr_info.flags.size == .Many or ptr_info.flags.size == .C or | 2112 | ptr_info.flags.size == .many or ptr_info.flags.size == .c or |
| 2113 | !Type.fromInterned(ptr_info.child).hasRuntimeBitsIgnoreComptime(zcu)) | 2113 | !Type.fromInterned(ptr_info.child).hasRuntimeBitsIgnoreComptime(zcu)) |
| 2114 | { | 2114 | { |
| 2115 | const bland_ptr_ty = try pt.ptrType(.{ | 2115 | const bland_ptr_ty = try pt.ptrType(.{ |
| ... | @@ -2120,8 +2120,8 @@ pub const Object = struct { | ... | @@ -2120,8 +2120,8 @@ pub const Object = struct { |
| 2120 | .flags = .{ | 2120 | .flags = .{ |
| 2121 | .alignment = ptr_info.flags.alignment, | 2121 | .alignment = ptr_info.flags.alignment, |
| 2122 | .size = switch (ptr_info.flags.size) { | 2122 | .size = switch (ptr_info.flags.size) { |
| 2123 | .Many, .C, .One => .One, | 2123 | .many, .c, .one => .one, |
| 2124 | .Slice => .Slice, | 2124 | .slice => .slice, |
| 2125 | }, | 2125 | }, |
| 2126 | }, | 2126 | }, |
| 2127 | }); | 2127 | }); |
| ... | @@ -3382,8 +3382,8 @@ pub const Object = struct { | ... | @@ -3382,8 +3382,8 @@ pub const Object = struct { |
| 3382 | toLlvmAddressSpace(ptr_type.flags.address_space, target), | 3382 | toLlvmAddressSpace(ptr_type.flags.address_space, target), |
| 3383 | ); | 3383 | ); |
| 3384 | break :type switch (ptr_type.flags.size) { | 3384 | break :type switch (ptr_type.flags.size) { |
| 3385 | .One, .Many, .C => ptr_ty, | 3385 | .one, .many, .c => ptr_ty, |
| 3386 | .Slice => try o.builder.structType(.normal, &.{ | 3386 | .slice => try o.builder.structType(.normal, &.{ |
| 3387 | ptr_ty, | 3387 | ptr_ty, |
| 3388 | try o.lowerType(Type.usize), | 3388 | try o.lowerType(Type.usize), |
| 3389 | }), | 3389 | }), |
| ... | @@ -6988,7 +6988,7 @@ pub const FuncGen = struct { | ... | @@ -6988,7 +6988,7 @@ pub const FuncGen = struct { |
| 6988 | const zcu = pt.zcu; | 6988 | const zcu = pt.zcu; |
| 6989 | const llvm_usize = try o.lowerType(Type.usize); | 6989 | const llvm_usize = try o.lowerType(Type.usize); |
| 6990 | switch (ty.ptrSize(zcu)) { | 6990 | switch (ty.ptrSize(zcu)) { |
| 6991 | .Slice => { | 6991 | .slice => { |
| 6992 | const len = try fg.wip.extractValue(ptr, &.{1}, ""); | 6992 | const len = try fg.wip.extractValue(ptr, &.{1}, ""); |
| 6993 | const elem_ty = ty.childType(zcu); | 6993 | const elem_ty = ty.childType(zcu); |
| 6994 | const abi_size = elem_ty.abiSize(zcu); | 6994 | const abi_size = elem_ty.abiSize(zcu); |
| ... | @@ -6996,13 +6996,13 @@ pub const FuncGen = struct { | ... | @@ -6996,13 +6996,13 @@ pub const FuncGen = struct { |
| 6996 | const abi_size_llvm_val = try o.builder.intValue(llvm_usize, abi_size); | 6996 | const abi_size_llvm_val = try o.builder.intValue(llvm_usize, abi_size); |
| 6997 | return fg.wip.bin(.@"mul nuw", len, abi_size_llvm_val, ""); | 6997 | return fg.wip.bin(.@"mul nuw", len, abi_size_llvm_val, ""); |
| 6998 | }, | 6998 | }, |
| 6999 | .One => { | 6999 | .one => { |
| 7000 | const array_ty = ty.childType(zcu); | 7000 | const array_ty = ty.childType(zcu); |
| 7001 | const elem_ty = array_ty.childType(zcu); | 7001 | const elem_ty = array_ty.childType(zcu); |
| 7002 | const abi_size = elem_ty.abiSize(zcu); | 7002 | const abi_size = elem_ty.abiSize(zcu); |
| 7003 | return o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu) * abi_size); | 7003 | return o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu) * abi_size); |
| 7004 | }, | 7004 | }, |
| 7005 | .Many, .C => unreachable, | 7005 | .many, .c => unreachable, |
| 7006 | } | 7006 | } |
| 7007 | } | 7007 | } |
| 7008 | 7008 | ||
| ... | @@ -8670,11 +8670,11 @@ pub const FuncGen = struct { | ... | @@ -8670,11 +8670,11 @@ pub const FuncGen = struct { |
| 8670 | const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu)); | 8670 | const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu)); |
| 8671 | switch (ptr_ty.ptrSize(zcu)) { | 8671 | switch (ptr_ty.ptrSize(zcu)) { |
| 8672 | // It's a pointer to an array, so according to LLVM we need an extra GEP index. | 8672 | // It's a pointer to an array, so according to LLVM we need an extra GEP index. |
| 8673 | .One => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{ | 8673 | .one => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{ |
| 8674 | try o.builder.intValue(try o.lowerType(Type.usize), 0), offset, | 8674 | try o.builder.intValue(try o.lowerType(Type.usize), 0), offset, |
| 8675 | }, ""), | 8675 | }, ""), |
| 8676 | .C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""), | 8676 | .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""), |
| 8677 | .Slice => { | 8677 | .slice => { |
| 8678 | const base = try self.wip.extractValue(ptr, &.{0}, ""); | 8678 | const base = try self.wip.extractValue(ptr, &.{0}, ""); |
| 8679 | return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{offset}, ""); | 8679 | return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{offset}, ""); |
| 8680 | }, | 8680 | }, |
| ... | @@ -8693,11 +8693,11 @@ pub const FuncGen = struct { | ... | @@ -8693,11 +8693,11 @@ pub const FuncGen = struct { |
| 8693 | const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu)); | 8693 | const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu)); |
| 8694 | switch (ptr_ty.ptrSize(zcu)) { | 8694 | switch (ptr_ty.ptrSize(zcu)) { |
| 8695 | // It's a pointer to an array, so according to LLVM we need an extra GEP index. | 8695 | // It's a pointer to an array, so according to LLVM we need an extra GEP index. |
| 8696 | .One => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{ | 8696 | .one => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{ |
| 8697 | try o.builder.intValue(try o.lowerType(Type.usize), 0), negative_offset, | 8697 | try o.builder.intValue(try o.lowerType(Type.usize), 0), negative_offset, |
| 8698 | }, ""), | 8698 | }, ""), |
| 8699 | .C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""), | 8699 | .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""), |
| 8700 | .Slice => { | 8700 | .slice => { |
| 8701 | const base = try self.wip.extractValue(ptr, &.{0}, ""); | 8701 | const base = try self.wip.extractValue(ptr, &.{0}, ""); |
| 8702 | return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{negative_offset}, ""); | 8702 | return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{negative_offset}, ""); |
| 8703 | }, | 8703 | }, |
| ... | @@ -10034,9 +10034,9 @@ pub const FuncGen = struct { | ... | @@ -10034,9 +10034,9 @@ pub const FuncGen = struct { |
| 10034 | 10034 | ||
| 10035 | const llvm_usize_ty = try o.lowerType(Type.usize); | 10035 | const llvm_usize_ty = try o.lowerType(Type.usize); |
| 10036 | const len = switch (ptr_ty.ptrSize(zcu)) { | 10036 | const len = switch (ptr_ty.ptrSize(zcu)) { |
| 10037 | .Slice => try self.wip.extractValue(dest_slice, &.{1}, ""), | 10037 | .slice => try self.wip.extractValue(dest_slice, &.{1}, ""), |
| 10038 | .One => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)), | 10038 | .one => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)), |
| 10039 | .Many, .C => unreachable, | 10039 | .many, .c => unreachable, |
| 10040 | }; | 10040 | }; |
| 10041 | const elem_llvm_ty = try o.lowerType(elem_ty); | 10041 | const elem_llvm_ty = try o.lowerType(elem_ty); |
| 10042 | const end_ptr = try self.wip.gep(.inbounds, elem_llvm_ty, dest_ptr, &.{len}, ""); | 10042 | const end_ptr = try self.wip.gep(.inbounds, elem_llvm_ty, dest_ptr, &.{len}, ""); |
src/codegen/llvm/Builder.zig+2-2| ... | @@ -8463,7 +8463,7 @@ pub const Metadata = enum(u32) { | ... | @@ -8463,7 +8463,7 @@ pub const Metadata = enum(u32) { |
| 8463 | field.* = .{ | 8463 | field.* = .{ |
| 8464 | .name = name, | 8464 | .name = name, |
| 8465 | .type = []const u8, | 8465 | .type = []const u8, |
| 8466 | .default_value = null, | 8466 | .default_value_ptr = null, |
| 8467 | .is_comptime = false, | 8467 | .is_comptime = false, |
| 8468 | .alignment = 0, | 8468 | .alignment = 0, |
| 8469 | }; | 8469 | }; |
| ... | @@ -8474,7 +8474,7 @@ pub const Metadata = enum(u32) { | ... | @@ -8474,7 +8474,7 @@ pub const Metadata = enum(u32) { |
| 8474 | field.* = .{ | 8474 | field.* = .{ |
| 8475 | .name = name, | 8475 | .name = name, |
| 8476 | .type = std.fmt.Formatter(format), | 8476 | .type = std.fmt.Formatter(format), |
| 8477 | .default_value = null, | 8477 | .default_value_ptr = null, |
| 8478 | .is_comptime = false, | 8478 | .is_comptime = false, |
| 8479 | .alignment = 0, | 8479 | .alignment = 0, |
| 8480 | }; | 8480 | }; |
src/codegen/spirv.zig+8-8| ... | @@ -1705,13 +1705,13 @@ const NavGen = struct { | ... | @@ -1705,13 +1705,13 @@ const NavGen = struct { |
| 1705 | const storage_class = self.spvStorageClass(ptr_info.flags.address_space); | 1705 | const storage_class = self.spvStorageClass(ptr_info.flags.address_space); |
| 1706 | const ptr_ty_id = try self.ptrType(child_ty, storage_class); | 1706 | const ptr_ty_id = try self.ptrType(child_ty, storage_class); |
| 1707 | 1707 | ||
| 1708 | if (target.os.tag == .vulkan and ptr_info.flags.size == .Many) { | 1708 | if (target.os.tag == .vulkan and ptr_info.flags.size == .many) { |
| 1709 | try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{ | 1709 | try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{ |
| 1710 | .array_stride = @intCast(child_ty.abiSize(zcu)), | 1710 | .array_stride = @intCast(child_ty.abiSize(zcu)), |
| 1711 | } }); | 1711 | } }); |
| 1712 | } | 1712 | } |
| 1713 | 1713 | ||
| 1714 | if (ptr_info.flags.size != .Slice) { | 1714 | if (ptr_info.flags.size != .slice) { |
| 1715 | return ptr_ty_id; | 1715 | return ptr_ty_id; |
| 1716 | } | 1716 | } |
| 1717 | 1717 | ||
| ... | @@ -4399,15 +4399,15 @@ const NavGen = struct { | ... | @@ -4399,15 +4399,15 @@ const NavGen = struct { |
| 4399 | const result_ty_id = try self.resolveType(result_ty, .direct); | 4399 | const result_ty_id = try self.resolveType(result_ty, .direct); |
| 4400 | 4400 | ||
| 4401 | switch (ptr_ty.ptrSize(zcu)) { | 4401 | switch (ptr_ty.ptrSize(zcu)) { |
| 4402 | .One => { | 4402 | .one => { |
| 4403 | // Pointer to array | 4403 | // Pointer to array |
| 4404 | // TODO: Is this correct? | 4404 | // TODO: Is this correct? |
| 4405 | return try self.accessChainId(result_ty_id, ptr_id, &.{offset_id}); | 4405 | return try self.accessChainId(result_ty_id, ptr_id, &.{offset_id}); |
| 4406 | }, | 4406 | }, |
| 4407 | .C, .Many => { | 4407 | .c, .many => { |
| 4408 | return try self.ptrAccessChain(result_ty_id, ptr_id, offset_id, &.{}); | 4408 | return try self.ptrAccessChain(result_ty_id, ptr_id, offset_id, &.{}); |
| 4409 | }, | 4409 | }, |
| 4410 | .Slice => { | 4410 | .slice => { |
| 4411 | // TODO: This is probably incorrect. A slice should be returned here, though this is what llvm does. | 4411 | // TODO: This is probably incorrect. A slice should be returned here, though this is what llvm does. |
| 4412 | const slice_ptr_id = try self.extractField(result_ty, ptr_id, 0); | 4412 | const slice_ptr_id = try self.extractField(result_ty, ptr_id, 0); |
| 4413 | return try self.ptrAccessChain(result_ty_id, slice_ptr_id, offset_id, &.{}); | 4413 | return try self.ptrAccessChain(result_ty_id, slice_ptr_id, offset_id, &.{}); |
| ... | @@ -4989,15 +4989,15 @@ const NavGen = struct { | ... | @@ -4989,15 +4989,15 @@ const NavGen = struct { |
| 4989 | const pt = self.pt; | 4989 | const pt = self.pt; |
| 4990 | const zcu = pt.zcu; | 4990 | const zcu = pt.zcu; |
| 4991 | switch (ty.ptrSize(zcu)) { | 4991 | switch (ty.ptrSize(zcu)) { |
| 4992 | .Slice => return self.extractField(Type.usize, operand_id, 1), | 4992 | .slice => return self.extractField(Type.usize, operand_id, 1), |
| 4993 | .One => { | 4993 | .one => { |
| 4994 | const array_ty = ty.childType(zcu); | 4994 | const array_ty = ty.childType(zcu); |
| 4995 | const elem_ty = array_ty.childType(zcu); | 4995 | const elem_ty = array_ty.childType(zcu); |
| 4996 | const abi_size = elem_ty.abiSize(zcu); | 4996 | const abi_size = elem_ty.abiSize(zcu); |
| 4997 | const size = array_ty.arrayLenIncludingSentinel(zcu) * abi_size; | 4997 | const size = array_ty.arrayLenIncludingSentinel(zcu) * abi_size; |
| 4998 | return try self.constInt(Type.usize, size, .direct); | 4998 | return try self.constInt(Type.usize, size, .direct); |
| 4999 | }, | 4999 | }, |
| 5000 | .Many, .C => unreachable, | 5000 | .many, .c => unreachable, |
| 5001 | } | 5001 | } |
| 5002 | } | 5002 | } |
| 5003 | 5003 |
src/codegen/spirv/Section.zig+2-2| ... | @@ -159,7 +159,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand) | ... | @@ -159,7 +159,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand) |
| 159 | section.writeOperand(info.child, child); | 159 | section.writeOperand(info.child, child); |
| 160 | }, | 160 | }, |
| 161 | .pointer => |info| { | 161 | .pointer => |info| { |
| 162 | std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec. | 162 | std.debug.assert(info.size == .slice); // Should be no other pointer types in the spec. |
| 163 | for (operand) |item| { | 163 | for (operand) |item| { |
| 164 | section.writeOperand(info.child, item); | 164 | section.writeOperand(info.child, item); |
| 165 | } | 165 | } |
| ... | @@ -292,7 +292,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { | ... | @@ -292,7 +292,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { |
| 292 | .@"enum" => 1, | 292 | .@"enum" => 1, |
| 293 | .optional => |info| if (operand) |child| operandSize(info.child, child) else 0, | 293 | .optional => |info| if (operand) |child| operandSize(info.child, child) else 0, |
| 294 | .pointer => |info| blk: { | 294 | .pointer => |info| blk: { |
| 295 | std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec. | 295 | std.debug.assert(info.size == .slice); // Should be no other pointer types in the spec. |
| 296 | var total: usize = 0; | 296 | var total: usize = 0; |
| 297 | for (operand) |item| { | 297 | for (operand) |item| { |
| 298 | total += operandSize(info.child, item); | 298 | total += operandSize(info.child, item); |
src/crash_report.zig+1-1| ... | @@ -190,7 +190,7 @@ pub fn attachSegfaultHandler() void { | ... | @@ -190,7 +190,7 @@ pub fn attachSegfaultHandler() void { |
| 190 | debug.updateSegfaultHandler(&act); | 190 | debug.updateSegfaultHandler(&act); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) noreturn { | 193 | fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn { |
| 194 | // TODO: use alarm() here to prevent infinite loops | 194 | // TODO: use alarm() here to prevent infinite loops |
| 195 | PanicSwitch.preDispatch(); | 195 | PanicSwitch.preDispatch(); |
| 196 | 196 |
src/link/Dwarf.zig+2-2| ... | @@ -3182,7 +3182,7 @@ fn updateLazyType( | ... | @@ -3182,7 +3182,7 @@ fn updateLazyType( |
| 3182 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); | 3182 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| 3183 | }, | 3183 | }, |
| 3184 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 3184 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 3185 | .One, .Many, .C => { | 3185 | .one, .many, .c => { |
| 3186 | const ptr_child_type: Type = .fromInterned(ptr_type.child); | 3186 | const ptr_child_type: Type = .fromInterned(ptr_type.child); |
| 3187 | try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type); | 3187 | try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type); |
| 3188 | try wip_nav.strp(name); | 3188 | try wip_nav.strp(name); |
| ... | @@ -3210,7 +3210,7 @@ fn updateLazyType( | ... | @@ -3210,7 +3210,7 @@ fn updateLazyType( |
| 3210 | try wip_nav.refType(ptr_child_type); | 3210 | try wip_nav.refType(ptr_child_type); |
| 3211 | } | 3211 | } |
| 3212 | }, | 3212 | }, |
| 3213 | .Slice => { | 3213 | .slice => { |
| 3214 | try wip_nav.abbrevCode(.generated_struct_type); | 3214 | try wip_nav.abbrevCode(.generated_struct_type); |
| 3215 | try wip_nav.strp(name); | 3215 | try wip_nav.strp(name); |
| 3216 | try uleb128(diw, ty.abiSize(zcu)); | 3216 | try uleb128(diw, ty.abiSize(zcu)); |
src/link/tapi/yaml.zig+4-4| ... | @@ -248,7 +248,7 @@ pub const Value = union(enum) { | ... | @@ -248,7 +248,7 @@ pub const Value = union(enum) { |
| 248 | .array => return encode(arena, &input), | 248 | .array => return encode(arena, &input), |
| 249 | 249 | ||
| 250 | .pointer => |info| switch (info.size) { | 250 | .pointer => |info| switch (info.size) { |
| 251 | .One => switch (@typeInfo(info.child)) { | 251 | .one => switch (@typeInfo(info.child)) { |
| 252 | .array => |child_info| { | 252 | .array => |child_info| { |
| 253 | const Slice = []const child_info.child; | 253 | const Slice = []const child_info.child; |
| 254 | return encode(arena, @as(Slice, input)); | 254 | return encode(arena, @as(Slice, input)); |
| ... | @@ -257,7 +257,7 @@ pub const Value = union(enum) { | ... | @@ -257,7 +257,7 @@ pub const Value = union(enum) { |
| 257 | @compileError("Unhandled type: {s}" ++ @typeName(info.child)); | 257 | @compileError("Unhandled type: {s}" ++ @typeName(info.child)); |
| 258 | }, | 258 | }, |
| 259 | }, | 259 | }, |
| 260 | .Slice => { | 260 | .slice => { |
| 261 | if (info.child == u8) { | 261 | if (info.child == u8) { |
| 262 | return Value{ .string = try arena.dupe(u8, input) }; | 262 | return Value{ .string = try arena.dupe(u8, input) }; |
| 263 | } | 263 | } |
| ... | @@ -357,7 +357,7 @@ pub const Yaml = struct { | ... | @@ -357,7 +357,7 @@ pub const Yaml = struct { |
| 357 | }, | 357 | }, |
| 358 | .pointer => |info| { | 358 | .pointer => |info| { |
| 359 | switch (info.size) { | 359 | switch (info.size) { |
| 360 | .Slice => { | 360 | .slice => { |
| 361 | var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len); | 361 | var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len); |
| 362 | for (self.docs.items, 0..) |doc, i| { | 362 | for (self.docs.items, 0..) |doc, i| { |
| 363 | parsed[i] = try self.parseValue(info.child, doc); | 363 | parsed[i] = try self.parseValue(info.child, doc); |
| ... | @@ -446,7 +446,7 @@ pub const Yaml = struct { | ... | @@ -446,7 +446,7 @@ pub const Yaml = struct { |
| 446 | const arena = self.arena.allocator(); | 446 | const arena = self.arena.allocator(); |
| 447 | 447 | ||
| 448 | switch (ptr_info.size) { | 448 | switch (ptr_info.size) { |
| 449 | .Slice => { | 449 | .slice => { |
| 450 | if (ptr_info.child == u8) { | 450 | if (ptr_info.child == u8) { |
| 451 | return value.asString(); | 451 | return value.asString(); |
| 452 | } | 452 | } |
src/mutable_value.zig+1-1| ... | @@ -256,7 +256,7 @@ pub const MutableValue = union(enum) { | ... | @@ -256,7 +256,7 @@ pub const MutableValue = union(enum) { |
| 256 | }, | 256 | }, |
| 257 | .pointer => { | 257 | .pointer => { |
| 258 | const ptr_ty = ip.indexToKey(ty_ip).ptr_type; | 258 | const ptr_ty = ip.indexToKey(ty_ip).ptr_type; |
| 259 | if (ptr_ty.flags.size != .Slice) return; | 259 | if (ptr_ty.flags.size != .slice) return; |
| 260 | const ptr = try arena.create(MutableValue); | 260 | const ptr = try arena.create(MutableValue); |
| 261 | const len = try arena.create(MutableValue); | 261 | const len = try arena.create(MutableValue); |
| 262 | ptr.* = .{ .interned = try pt.intern(.{ .undef = ip.slicePtrType(ty_ip) }) }; | 262 | ptr.* = .{ .interned = try pt.intern(.{ .undef = ip.slicePtrType(ty_ip) }) }; |
src/translate_c.zig+2-2| ... | @@ -231,13 +231,13 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void { | ... | @@ -231,13 +231,13 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void { |
| 231 | } | 231 | } |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool { | 234 | fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool { |
| 235 | const c: *Context = @ptrCast(@alignCast(context)); | 235 | const c: *Context = @ptrCast(@alignCast(context)); |
| 236 | declVisitorNamesOnly(c, decl) catch return false; | 236 | declVisitorNamesOnly(c, decl) catch return false; |
| 237 | return true; | 237 | return true; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool { | 240 | fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool { |
| 241 | const c: *Context = @ptrCast(@alignCast(context)); | 241 | const c: *Context = @ptrCast(@alignCast(context)); |
| 242 | declVisitor(c, decl) catch return false; | 242 | declVisitor(c, decl) catch return false; |
| 243 | return true; | 243 | return true; |
stage1/config.zig.in+1| ... | @@ -13,3 +13,4 @@ pub const value_tracing = false; | ... | @@ -13,3 +13,4 @@ pub const value_tracing = false; |
| 13 | pub const skip_non_native = false; | 13 | pub const skip_non_native = false; |
| 14 | pub const force_gpa = false; | 14 | pub const force_gpa = false; |
| 15 | pub const dev = .core; | 15 | pub const dev = .core; |
| 16 | pub const value_interpret_mode = .direct; |
stage1/zig.h+304-143| ... | @@ -1,33 +1,143 @@ | ... | @@ -1,33 +1,143 @@ |
| 1 | #undef linux | 1 | #undef linux |
| 2 | 2 | ||
| 3 | #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ | ||
| 4 | #define __STDC_WANT_IEC_60559_TYPES_EXT__ | ||
| 5 | #endif | ||
| 6 | #include <float.h> | ||
| 7 | #include <limits.h> | ||
| 8 | #include <stdarg.h> | 3 | #include <stdarg.h> |
| 9 | #include <stddef.h> | 4 | #include <stddef.h> |
| 10 | #include <stdint.h> | ||
| 11 | |||
| 12 | #if _MSC_VER | ||
| 13 | #include <intrin.h> | ||
| 14 | #elif defined(__i386__) || defined(__x86_64__) | ||
| 15 | #include <cpuid.h> | ||
| 16 | #endif | ||
| 17 | 5 | ||
| 18 | #if !defined(__cplusplus) && __STDC_VERSION__ <= 201710L | 6 | #if defined(_MSC_VER) |
| 19 | #if __STDC_VERSION__ >= 199901L | 7 | #define zig_msvc |
| 20 | #include <stdbool.h> | 8 | #elif defined(__clang__) |
| 9 | #define zig_clang | ||
| 10 | #define zig_gnuc | ||
| 11 | #elif defined(__GNUC__) | ||
| 12 | #define zig_gnuc | ||
| 13 | #elif defined(__IBMC__) | ||
| 14 | #define zig_xlc | ||
| 15 | #elif defined(__TINYC__) | ||
| 16 | #define zig_tinyc | ||
| 17 | #elif defined(__slimcc__) | ||
| 18 | #define zig_slimcc | ||
| 19 | #endif | ||
| 20 | |||
| 21 | #if defined(__aarch64__) || (defined(zig_msvc) && defined(_M_ARM64)) | ||
| 22 | #define zig_aarch64 | ||
| 23 | #elif defined(__thumb__) || (defined(zig_msvc) && defined(_M_ARM)) | ||
| 24 | #define zig_thumb | ||
| 25 | #define zig_arm | ||
| 26 | #elif defined(__arm__) | ||
| 27 | #define zig_arm | ||
| 28 | #elif defined(__hexagon__) | ||
| 29 | #define zig_hexagon | ||
| 30 | #elif defined(__loongarch32) | ||
| 31 | #define zig_loongarch32 | ||
| 32 | #define zig_loongarch | ||
| 33 | #elif defined(__loongarch64) | ||
| 34 | #define zig_loongarch64 | ||
| 35 | #define zig_loongarch | ||
| 36 | #elif defined(__mips64) | ||
| 37 | #define zig_mips64 | ||
| 38 | #define zig_mips | ||
| 39 | #elif defined(__mips__) | ||
| 40 | #define zig_mips32 | ||
| 41 | #define zig_mips | ||
| 42 | #elif defined(__powerpc64__) | ||
| 43 | #define zig_powerpc64 | ||
| 44 | #define zig_powerpc | ||
| 45 | #elif defined(__powerpc__) | ||
| 46 | #define zig_powerpc32 | ||
| 47 | #define zig_powerpc | ||
| 48 | #elif defined(__riscv) && __riscv_xlen == 32 | ||
| 49 | #define zig_riscv32 | ||
| 50 | #define zig_riscv | ||
| 51 | #elif defined(__riscv) && __riscv_xlen == 64 | ||
| 52 | #define zig_riscv64 | ||
| 53 | #define zig_riscv | ||
| 54 | #elif defined(__s390x__) | ||
| 55 | #define zig_s390x | ||
| 56 | #elif defined(__sparc__) && defined(__arch64__) | ||
| 57 | #define zig_sparc64 | ||
| 58 | #define zig_sparc | ||
| 59 | #elif defined(__sparc__) | ||
| 60 | #define zig_sparc32 | ||
| 61 | #define zig_sparc | ||
| 62 | #elif defined(__wasm32__) | ||
| 63 | #define zig_wasm32 | ||
| 64 | #define zig_wasm | ||
| 65 | #elif defined(__wasm64__) | ||
| 66 | #define zig_wasm64 | ||
| 67 | #define zig_wasm | ||
| 68 | #elif defined(__i386__) || (defined(zig_msvc) && defined(_M_IX86)) | ||
| 69 | #define zig_x86_32 | ||
| 70 | #define zig_x86 | ||
| 71 | #elif defined (__x86_64__) || (defined(zig_msvc) && defined(_M_X64)) | ||
| 72 | #define zig_x86_64 | ||
| 73 | #define zig_x86 | ||
| 74 | #endif | ||
| 75 | |||
| 76 | #if defined(zig_msvc) || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
| 77 | #define zig_little_endian 1 | ||
| 78 | #define zig_big_endian 0 | ||
| 21 | #else | 79 | #else |
| 22 | typedef char bool; | 80 | #define zig_little_endian 0 |
| 23 | #define false 0 | 81 | #define zig_big_endian 1 |
| 24 | #define true 1 | ||
| 25 | #endif | 82 | #endif |
| 83 | |||
| 84 | #if defined(_AIX) | ||
| 85 | #define zig_aix | ||
| 86 | #elif defined(__MACH__) | ||
| 87 | #define zig_darwin | ||
| 88 | #elif defined(__DragonFly__) | ||
| 89 | #define zig_dragonfly | ||
| 90 | #define zig_bsd | ||
| 91 | #elif defined(__EMSCRIPTEN__) | ||
| 92 | #define zig_emscripten | ||
| 93 | #elif defined(__FreeBSD__) | ||
| 94 | #define zig_freebsd | ||
| 95 | #define zig_bsd | ||
| 96 | #elif defined(__Fuchsia__) | ||
| 97 | #define zig_fuchsia | ||
| 98 | #elif defined(__HAIKU__) | ||
| 99 | #define zig_haiku | ||
| 100 | #elif defined(__gnu_hurd__) | ||
| 101 | #define zig_hurd | ||
| 102 | #elif defined(__linux__) | ||
| 103 | #define zig_linux | ||
| 104 | #elif defined(__NetBSD__) | ||
| 105 | #define zig_netbsd | ||
| 106 | #define zig_bsd | ||
| 107 | #elif defined(__OpenBSD__) | ||
| 108 | #define zig_openbsd | ||
| 109 | #define zig_bsd | ||
| 110 | #elif defined(__SVR4) | ||
| 111 | #define zig_solaris | ||
| 112 | #elif defined(__wasi__) | ||
| 113 | #define zig_wasi | ||
| 114 | #elif defined(_WIN32) | ||
| 115 | #define zig_windows | ||
| 116 | #elif defined(__MVS__) | ||
| 117 | #define zig_zos | ||
| 118 | #endif | ||
| 119 | |||
| 120 | #if defined(zig_windows) | ||
| 121 | #define zig_coff | ||
| 122 | #elif defined(__ELF__) | ||
| 123 | #define zig_elf | ||
| 124 | #elif defined(zig_zos) | ||
| 125 | #define zig_goff | ||
| 126 | #elif defined(zig_darwin) | ||
| 127 | #define zig_macho | ||
| 128 | #elif defined(zig_aix) | ||
| 129 | #define zig_xcoff | ||
| 26 | #endif | 130 | #endif |
| 27 | 131 | ||
| 28 | #define zig_concat(lhs, rhs) lhs##rhs | 132 | #define zig_concat(lhs, rhs) lhs##rhs |
| 29 | #define zig_expand_concat(lhs, rhs) zig_concat(lhs, rhs) | 133 | #define zig_expand_concat(lhs, rhs) zig_concat(lhs, rhs) |
| 30 | 134 | ||
| 135 | #if defined(__has_include) | ||
| 136 | #define zig_has_include(include) __has_include(include) | ||
| 137 | #else | ||
| 138 | #define zig_has_include(include) 0 | ||
| 139 | #endif | ||
| 140 | |||
| 31 | #if defined(__has_builtin) | 141 | #if defined(__has_builtin) |
| 32 | #define zig_has_builtin(builtin) __has_builtin(__builtin_##builtin) | 142 | #define zig_has_builtin(builtin) __has_builtin(__builtin_##builtin) |
| 33 | #else | 143 | #else |
| ... | @@ -41,37 +151,19 @@ typedef char bool; | ... | @@ -41,37 +151,19 @@ typedef char bool; |
| 41 | #define zig_has_attribute(attribute) 0 | 151 | #define zig_has_attribute(attribute) 0 |
| 42 | #endif | 152 | #endif |
| 43 | 153 | ||
| 44 | #if __LITTLE_ENDIAN__ || _MSC_VER | 154 | #if __STDC_VERSION__ >= 202311L |
| 45 | #define zig_little_endian 1 | 155 | #define zig_threadlocal thread_local |
| 46 | #define zig_big_endian 0 | 156 | #elif __STDC_VERSION__ >= 201112L |
| 47 | #else | ||
| 48 | #define zig_little_endian 0 | ||
| 49 | #define zig_big_endian 1 | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #if __STDC_VERSION__ >= 201112L | ||
| 53 | #define zig_threadlocal _Thread_local | 157 | #define zig_threadlocal _Thread_local |
| 54 | #elif defined(__GNUC__) | 158 | #elif defined(zig_gnuc) || defined(zig_slimcc) |
| 55 | #define zig_threadlocal __thread | 159 | #define zig_threadlocal __thread |
| 56 | #elif _MSC_VER | 160 | #elif defined(zig_msvc) |
| 57 | #define zig_threadlocal __declspec(thread) | 161 | #define zig_threadlocal __declspec(thread) |
| 58 | #else | 162 | #else |
| 59 | #define zig_threadlocal zig_threadlocal_unavailable | 163 | #define zig_threadlocal zig_threadlocal_unavailable |
| 60 | #endif | 164 | #endif |
| 61 | 165 | ||
| 62 | #if defined(__clang__) | 166 | #if defined(zig_msvc) |
| 63 | #define zig_clang | ||
| 64 | #elif defined(__GNUC__) | ||
| 65 | #define zig_gnuc | ||
| 66 | #endif | ||
| 67 | |||
| 68 | #if defined(zig_gnuc) && (defined(__i386__) || defined(__x86_64__)) | ||
| 69 | #define zig_f128_has_miscompilations 1 | ||
| 70 | #else | ||
| 71 | #define zig_f128_has_miscompilations 0 | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if _MSC_VER | ||
| 75 | #define zig_const_arr | 167 | #define zig_const_arr |
| 76 | #define zig_callconv(c) __##c | 168 | #define zig_callconv(c) __##c |
| 77 | #else | 169 | #else |
| ... | @@ -82,7 +174,7 @@ typedef char bool; | ... | @@ -82,7 +174,7 @@ typedef char bool; |
| 82 | #if zig_has_attribute(naked) || defined(zig_gnuc) | 174 | #if zig_has_attribute(naked) || defined(zig_gnuc) |
| 83 | #define zig_naked_decl __attribute__((naked)) | 175 | #define zig_naked_decl __attribute__((naked)) |
| 84 | #define zig_naked __attribute__((naked)) | 176 | #define zig_naked __attribute__((naked)) |
| 85 | #elif defined(_MSC_VER) | 177 | #elif defined(zig_msvc) |
| 86 | #define zig_naked_decl | 178 | #define zig_naked_decl |
| 87 | #define zig_naked __declspec(naked) | 179 | #define zig_naked __declspec(naked) |
| 88 | #else | 180 | #else |
| ... | @@ -104,7 +196,7 @@ typedef char bool; | ... | @@ -104,7 +196,7 @@ typedef char bool; |
| 104 | 196 | ||
| 105 | #if zig_has_attribute(noinline) | 197 | #if zig_has_attribute(noinline) |
| 106 | #define zig_never_inline __attribute__((noinline)) zig_maybe_flatten | 198 | #define zig_never_inline __attribute__((noinline)) zig_maybe_flatten |
| 107 | #elif defined(_MSC_VER) | 199 | #elif defined(zig_msvc) |
| 108 | #define zig_never_inline __declspec(noinline) zig_maybe_flatten | 200 | #define zig_never_inline __declspec(noinline) zig_maybe_flatten |
| 109 | #else | 201 | #else |
| 110 | #define zig_never_inline zig_never_inline_unavailable | 202 | #define zig_never_inline zig_never_inline_unavailable |
| ... | @@ -124,46 +216,48 @@ typedef char bool; | ... | @@ -124,46 +216,48 @@ typedef char bool; |
| 124 | 216 | ||
| 125 | #if __STDC_VERSION__ >= 199901L | 217 | #if __STDC_VERSION__ >= 199901L |
| 126 | #define zig_restrict restrict | 218 | #define zig_restrict restrict |
| 127 | #elif defined(__GNUC__) | 219 | #elif defined(zig_gnuc) || defined(zig_tinyc) |
| 128 | #define zig_restrict __restrict | 220 | #define zig_restrict __restrict |
| 129 | #else | 221 | #else |
| 130 | #define zig_restrict | 222 | #define zig_restrict |
| 131 | #endif | 223 | #endif |
| 132 | 224 | ||
| 133 | #if zig_has_attribute(aligned) | 225 | #if zig_has_attribute(aligned) || defined(zig_tinyc) |
| 134 | #define zig_under_align(alignment) __attribute__((aligned(alignment))) | 226 | #define zig_under_align(alignment) __attribute__((aligned(alignment))) |
| 135 | #elif _MSC_VER | 227 | #elif defined(zig_msvc) |
| 136 | #define zig_under_align(alignment) __declspec(align(alignment)) | 228 | #define zig_under_align(alignment) __declspec(align(alignment)) |
| 137 | #else | 229 | #else |
| 138 | #define zig_under_align zig_align_unavailable | 230 | #define zig_under_align zig_align_unavailable |
| 139 | #endif | 231 | #endif |
| 140 | 232 | ||
| 141 | #if __STDC_VERSION__ >= 201112L | 233 | #if __STDC_VERSION__ >= 202311L |
| 234 | #define zig_align(alignment) alignas(alignment) | ||
| 235 | #elif __STDC_VERSION__ >= 201112L | ||
| 142 | #define zig_align(alignment) _Alignas(alignment) | 236 | #define zig_align(alignment) _Alignas(alignment) |
| 143 | #else | 237 | #else |
| 144 | #define zig_align(alignment) zig_under_align(alignment) | 238 | #define zig_align(alignment) zig_under_align(alignment) |
| 145 | #endif | 239 | #endif |
| 146 | 240 | ||
| 147 | #if zig_has_attribute(aligned) | 241 | #if zig_has_attribute(aligned) || defined(zig_tinyc) |
| 148 | #define zig_align_fn(alignment) __attribute__((aligned(alignment))) | 242 | #define zig_align_fn(alignment) __attribute__((aligned(alignment))) |
| 149 | #elif _MSC_VER | 243 | #elif defined(zig_msvc) |
| 150 | #define zig_align_fn(alignment) | 244 | #define zig_align_fn(alignment) |
| 151 | #else | 245 | #else |
| 152 | #define zig_align_fn zig_align_fn_unavailable | 246 | #define zig_align_fn zig_align_fn_unavailable |
| 153 | #endif | 247 | #endif |
| 154 | 248 | ||
| 155 | #if zig_has_attribute(packed) | 249 | #if zig_has_attribute(packed) || defined(zig_tinyc) |
| 156 | #define zig_packed(definition) __attribute__((packed)) definition | 250 | #define zig_packed(definition) __attribute__((packed)) definition |
| 157 | #elif _MSC_VER | 251 | #elif defined(zig_msvc) |
| 158 | #define zig_packed(definition) __pragma(pack(1)) definition __pragma(pack()) | 252 | #define zig_packed(definition) __pragma(pack(1)) definition __pragma(pack()) |
| 159 | #else | 253 | #else |
| 160 | #define zig_packed(definition) zig_packed_unavailable | 254 | #define zig_packed(definition) zig_packed_unavailable |
| 161 | #endif | 255 | #endif |
| 162 | 256 | ||
| 163 | #if zig_has_attribute(section) | 257 | #if zig_has_attribute(section) || defined(zig_tinyc) |
| 164 | #define zig_linksection(name) __attribute__((section(name))) | 258 | #define zig_linksection(name) __attribute__((section(name))) |
| 165 | #define zig_linksection_fn zig_linksection | 259 | #define zig_linksection_fn zig_linksection |
| 166 | #elif _MSC_VER | 260 | #elif defined(zig_msvc) |
| 167 | #define zig_linksection(name) __pragma(section(name, read, write)) __declspec(allocate(name)) | 261 | #define zig_linksection(name) __pragma(section(name, read, write)) __declspec(allocate(name)) |
| 168 | #define zig_linksection_fn(name) __pragma(section(name, read, execute)) __declspec(code_seg(name)) | 262 | #define zig_linksection_fn(name) __pragma(section(name, read, execute)) __declspec(code_seg(name)) |
| 169 | #else | 263 | #else |
| ... | @@ -171,8 +265,10 @@ typedef char bool; | ... | @@ -171,8 +265,10 @@ typedef char bool; |
| 171 | #define zig_linksection_fn zig_linksection | 265 | #define zig_linksection_fn zig_linksection |
| 172 | #endif | 266 | #endif |
| 173 | 267 | ||
| 174 | #if zig_has_builtin(unreachable) || defined(zig_gnuc) | 268 | #if zig_has_builtin(unreachable) || defined(zig_gnuc) || defined(zig_tinyc) |
| 175 | #define zig_unreachable() __builtin_unreachable() | 269 | #define zig_unreachable() __builtin_unreachable() |
| 270 | #elif defined(zig_msvc) | ||
| 271 | #define zig_unreachable() __assume(0) | ||
| 176 | #else | 272 | #else |
| 177 | #define zig_unreachable() | 273 | #define zig_unreachable() |
| 178 | #endif | 274 | #endif |
| ... | @@ -183,23 +279,23 @@ typedef char bool; | ... | @@ -183,23 +279,23 @@ typedef char bool; |
| 183 | #define zig_extern extern | 279 | #define zig_extern extern |
| 184 | #endif | 280 | #endif |
| 185 | 281 | ||
| 186 | #if _MSC_VER | 282 | #if defined(zig_msvc) |
| 187 | #if _M_X64 | 283 | #if defined(zig_x86_64) |
| 188 | #define zig_mangle_c(symbol) symbol | 284 | #define zig_mangle_c(symbol) symbol |
| 189 | #else /*_M_X64 */ | 285 | #else /* zig_x86_64 */ |
| 190 | #define zig_mangle_c(symbol) "_" symbol | 286 | #define zig_mangle_c(symbol) "_" symbol |
| 191 | #endif /*_M_X64 */ | 287 | #endif /* zig_x86_64 */ |
| 192 | #else /* _MSC_VER */ | 288 | #else /* zig_msvc */ |
| 193 | #if __APPLE__ | 289 | #if defined(zig_macho) |
| 194 | #define zig_mangle_c(symbol) "_" symbol | 290 | #define zig_mangle_c(symbol) "_" symbol |
| 195 | #else /* __APPLE__ */ | 291 | #else /* zig_macho */ |
| 196 | #define zig_mangle_c(symbol) symbol | 292 | #define zig_mangle_c(symbol) symbol |
| 197 | #endif /* __APPLE__ */ | 293 | #endif /* zig_macho */ |
| 198 | #endif /* _MSC_VER */ | 294 | #endif /* zig_msvc */ |
| 199 | 295 | ||
| 200 | #if zig_has_attribute(alias) && !__APPLE__ | 296 | #if (zig_has_attribute(alias) || defined(zig_tinyc)) && !defined(zig_macho) |
| 201 | #define zig_export(symbol, name) __attribute__((alias(symbol))) | 297 | #define zig_export(symbol, name) __attribute__((alias(symbol))) |
| 202 | #elif _MSC_VER | 298 | #elif defined(zig_msvc) |
| 203 | #define zig_export(symbol, name) ; \ | 299 | #define zig_export(symbol, name) ; \ |
| 204 | __pragma(comment(linker, "/alternatename:" zig_mangle_c(name) "=" zig_mangle_c(symbol))) | 300 | __pragma(comment(linker, "/alternatename:" zig_mangle_c(name) "=" zig_mangle_c(symbol))) |
| 205 | #else | 301 | #else |
| ... | @@ -209,24 +305,24 @@ typedef char bool; | ... | @@ -209,24 +305,24 @@ typedef char bool; |
| 209 | 305 | ||
| 210 | #define zig_mangled_tentative zig_mangled | 306 | #define zig_mangled_tentative zig_mangled |
| 211 | #define zig_mangled_final zig_mangled | 307 | #define zig_mangled_final zig_mangled |
| 212 | #if _MSC_VER | 308 | #if defined(zig_msvc) |
| 213 | #define zig_mangled(mangled, unmangled) ; \ | 309 | #define zig_mangled(mangled, unmangled) ; \ |
| 214 | zig_export(#mangled, unmangled) | 310 | zig_export(#mangled, unmangled) |
| 215 | #define zig_mangled_export(mangled, unmangled, symbol) \ | 311 | #define zig_mangled_export(mangled, unmangled, symbol) \ |
| 216 | zig_export(unmangled, #mangled) \ | 312 | zig_export(unmangled, #mangled) \ |
| 217 | zig_export(symbol, unmangled) | 313 | zig_export(symbol, unmangled) |
| 218 | #else /* _MSC_VER */ | 314 | #else /* zig_msvc */ |
| 219 | #define zig_mangled(mangled, unmangled) __asm(zig_mangle_c(unmangled)) | 315 | #define zig_mangled(mangled, unmangled) __asm(zig_mangle_c(unmangled)) |
| 220 | #define zig_mangled_export(mangled, unmangled, symbol) \ | 316 | #define zig_mangled_export(mangled, unmangled, symbol) \ |
| 221 | zig_mangled_final(mangled, unmangled) \ | 317 | zig_mangled_final(mangled, unmangled) \ |
| 222 | zig_export(symbol, unmangled) | 318 | zig_export(symbol, unmangled) |
| 223 | #endif /* _MSC_VER */ | 319 | #endif /* zig_msvc */ |
| 224 | 320 | ||
| 225 | #if _MSC_VER | 321 | #if defined(zig_msvc) |
| 226 | #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args;\ | 322 | #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args;\ |
| 227 | __pragma(comment(linker, "/alternatename:" zig_mangle_c(#fn_name) "=" zig_mangle_c(#libc_name))); | 323 | __pragma(comment(linker, "/alternatename:" zig_mangle_c(#fn_name) "=" zig_mangle_c(#libc_name))); |
| 228 | #define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, sig_args, call_args) | 324 | #define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, sig_args, call_args) |
| 229 | #else /* _MSC_VER */ | 325 | #else /* zig_msvc */ |
| 230 | #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args __asm(zig_mangle_c(#libc_name)); | 326 | #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args __asm(zig_mangle_c(#libc_name)); |
| 231 | #define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type libc_name sig_args; \ | 327 | #define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type libc_name sig_args; \ |
| 232 | static inline Type fn_name sig_args { return libc_name call_args; } | 328 | static inline Type fn_name sig_args { return libc_name call_args; } |
| ... | @@ -235,10 +331,10 @@ typedef char bool; | ... | @@ -235,10 +331,10 @@ typedef char bool; |
| 235 | #define zig_expand_import_0(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, libc_name, sig_args, call_args) | 331 | #define zig_expand_import_0(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, libc_name, sig_args, call_args) |
| 236 | #define zig_expand_import_1(Type, fn_name, libc_name, sig_args, call_args) zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) | 332 | #define zig_expand_import_1(Type, fn_name, libc_name, sig_args, call_args) zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) |
| 237 | 333 | ||
| 238 | #if zig_has_attribute(weak) || defined(zig_gnuc) | 334 | #if zig_has_attribute(weak) || defined(zig_gnuc) || defined(zig_tinyc) |
| 239 | #define zig_weak_linkage __attribute__((weak)) | 335 | #define zig_weak_linkage __attribute__((weak)) |
| 240 | #define zig_weak_linkage_fn __attribute__((weak)) | 336 | #define zig_weak_linkage_fn __attribute__((weak)) |
| 241 | #elif _MSC_VER | 337 | #elif defined(zig_msvc) |
| 242 | #define zig_weak_linkage __declspec(selectany) | 338 | #define zig_weak_linkage __declspec(selectany) |
| 243 | #define zig_weak_linkage_fn | 339 | #define zig_weak_linkage_fn |
| 244 | #else | 340 | #else |
| ... | @@ -246,68 +342,94 @@ typedef char bool; | ... | @@ -246,68 +342,94 @@ typedef char bool; |
| 246 | #define zig_weak_linkage_fn zig_weak_linkage_unavailable | 342 | #define zig_weak_linkage_fn zig_weak_linkage_unavailable |
| 247 | #endif | 343 | #endif |
| 248 | 344 | ||
| 345 | #if defined(zig_gnuc) || defined(zig_tinyc) || defined(zig_slimcc) | ||
| 346 | #define zig_gnuc_asm | ||
| 347 | #endif | ||
| 348 | |||
| 249 | #if zig_has_builtin(trap) | 349 | #if zig_has_builtin(trap) |
| 250 | #define zig_trap() __builtin_trap() | 350 | #define zig_trap() __builtin_trap() |
| 251 | #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) | 351 | #elif defined(zig_msvc) |
| 352 | |||
| 353 | #if defined(zig_x86) | ||
| 252 | #define zig_trap() __ud2() | 354 | #define zig_trap() __ud2() |
| 253 | #elif defined(_MSC_VER) | 355 | #else |
| 254 | #define zig_trap() __fastfail(7) | 356 | #define zig_trap() __fastfail(7) |
| 255 | #elif defined(__thumb__) | 357 | #endif |
| 358 | |||
| 359 | #elif defined(zig_gnuc_asm) | ||
| 360 | |||
| 361 | #if defined(zig_thumb) | ||
| 256 | #define zig_trap() __asm__ volatile("udf #0xfe") | 362 | #define zig_trap() __asm__ volatile("udf #0xfe") |
| 257 | #elif defined(__arm__) || defined(__aarch64__) | 363 | #elif defined(zig_arm) || defined(zig_aarch64) |
| 258 | #define zig_trap() __asm__ volatile("udf #0xfdee") | 364 | #define zig_trap() __asm__ volatile("udf #0xfdee") |
| 259 | #elif defined(__loongarch__) || defined(__powerpc__) | 365 | #elif defined(zig_hexagon) |
| 366 | #define zig_trap() __asm__ volatile("r27:26 = memd(#0xbadc0fee)") | ||
| 367 | #elif defined(zig_loongarch) || defined(zig_powerpc) | ||
| 260 | #define zig_trap() __asm__ volatile(".word 0x0") | 368 | #define zig_trap() __asm__ volatile(".word 0x0") |
| 261 | #elif defined(__mips__) | 369 | #elif defined(zig_mips) |
| 262 | #define zig_trap() __asm__ volatile(".word 0x3d") | 370 | #define zig_trap() __asm__ volatile(".word 0x3d") |
| 263 | #elif defined(__riscv) | 371 | #elif defined(zig_riscv) |
| 264 | #define zig_trap() __asm__ volatile("unimp") | 372 | #define zig_trap() __asm__ volatile("unimp") |
| 265 | #elif defined(__s390__) | 373 | #elif defined(zig_s390x) |
| 266 | #define zig_trap() __asm__ volatile("j 0x2") | 374 | #define zig_trap() __asm__ volatile("j 0x2") |
| 267 | #elif defined(__sparc__) | 375 | #elif defined(zig_sparc) |
| 268 | #define zig_trap() __asm__ volatile("illtrap") | 376 | #define zig_trap() __asm__ volatile("illtrap") |
| 269 | #elif defined(__i386__) || defined(__x86_64__) | 377 | #elif defined(zig_x86) |
| 270 | #define zig_trap() __asm__ volatile("ud2") | 378 | #define zig_trap() __asm__ volatile("ud2") |
| 271 | #else | 379 | #else |
| 272 | #define zig_trap() zig_trap_unavailable | 380 | #define zig_trap() zig_trap_unavailable |
| 273 | #endif | 381 | #endif |
| 274 | 382 | ||
| 383 | #else | ||
| 384 | #define zig_trap() zig_trap_unavailable | ||
| 385 | #endif | ||
| 386 | |||
| 275 | #if zig_has_builtin(debugtrap) | 387 | #if zig_has_builtin(debugtrap) |
| 276 | #define zig_breakpoint() __builtin_debugtrap() | 388 | #define zig_breakpoint() __builtin_debugtrap() |
| 277 | #elif defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) | 389 | #elif defined(zig_msvc) |
| 278 | #define zig_breakpoint() __debugbreak() | 390 | #define zig_breakpoint() __debugbreak() |
| 279 | #elif defined(__arm__) | 391 | #elif defined(zig_gnuc_asm) |
| 392 | |||
| 393 | #if defined(zig_arm) | ||
| 280 | #define zig_breakpoint() __asm__ volatile("bkpt #0x0") | 394 | #define zig_breakpoint() __asm__ volatile("bkpt #0x0") |
| 281 | #elif defined(__aarch64__) | 395 | #elif defined(zig_aarch64) |
| 282 | #define zig_breakpoint() __asm__ volatile("brk #0xf000") | 396 | #define zig_breakpoint() __asm__ volatile("brk #0xf000") |
| 283 | #elif defined(__loongarch__) | 397 | #elif defined(zig_hexagon) |
| 398 | #define zig_breakpoint() __asm__ volatile("brkpt") | ||
| 399 | #elif defined(zig_loongarch) | ||
| 284 | #define zig_breakpoint() __asm__ volatile("break 0x0") | 400 | #define zig_breakpoint() __asm__ volatile("break 0x0") |
| 285 | #elif defined(__mips__) | 401 | #elif defined(zig_mips) |
| 286 | #define zig_breakpoint() __asm__ volatile("break") | 402 | #define zig_breakpoint() __asm__ volatile("break") |
| 287 | #elif defined(__powerpc__) | 403 | #elif defined(zig_powerpc) |
| 288 | #define zig_breakpoint() __asm__ volatile("trap") | 404 | #define zig_breakpoint() __asm__ volatile("trap") |
| 289 | #elif defined(__riscv) | 405 | #elif defined(zig_riscv) |
| 290 | #define zig_breakpoint() __asm__ volatile("ebreak") | 406 | #define zig_breakpoint() __asm__ volatile("ebreak") |
| 291 | #elif defined(__s390__) | 407 | #elif defined(zig_s390x) |
| 292 | #define zig_breakpoint() __asm__ volatile("j 0x6") | 408 | #define zig_breakpoint() __asm__ volatile("j 0x6") |
| 293 | #elif defined(__sparc__) | 409 | #elif defined(zig_sparc) |
| 294 | #define zig_breakpoint() __asm__ volatile("ta 0x1") | 410 | #define zig_breakpoint() __asm__ volatile("ta 0x1") |
| 295 | #elif defined(__i386__) || defined(__x86_64__) | 411 | #elif defined(zig_x86) |
| 296 | #define zig_breakpoint() __asm__ volatile("int $0x3") | 412 | #define zig_breakpoint() __asm__ volatile("int $0x3") |
| 297 | #else | 413 | #else |
| 298 | #define zig_breakpoint() zig_breakpoint_unavailable | 414 | #define zig_breakpoint() zig_breakpoint_unavailable |
| 299 | #endif | 415 | #endif |
| 300 | 416 | ||
| 301 | #if zig_has_builtin(return_address) || defined(zig_gnuc) | 417 | #else |
| 418 | #define zig_breakpoint() zig_breakpoint_unavailable | ||
| 419 | #endif | ||
| 420 | |||
| 421 | #if zig_has_builtin(return_address) || defined(zig_gnuc) || defined(zig_tinyc) | ||
| 302 | #define zig_return_address() __builtin_extract_return_addr(__builtin_return_address(0)) | 422 | #define zig_return_address() __builtin_extract_return_addr(__builtin_return_address(0)) |
| 303 | #elif defined(_MSC_VER) | 423 | #elif defined(zig_msvc) |
| 304 | #define zig_return_address() _ReturnAddress() | 424 | #define zig_return_address() _ReturnAddress() |
| 305 | #else | 425 | #else |
| 306 | #define zig_return_address() 0 | 426 | #define zig_return_address() 0 |
| 307 | #endif | 427 | #endif |
| 308 | 428 | ||
| 309 | #if zig_has_builtin(frame_address) || defined(zig_gnuc) | 429 | #if zig_has_builtin(frame_address) || defined(zig_gnuc) || defined(zig_tinyc) |
| 310 | #define zig_frame_address() __builtin_frame_address(0) | 430 | #define zig_frame_address() __builtin_frame_address(0) |
| 431 | #elif defined(zig_msvc) | ||
| 432 | #define zig_frame_address() _AddressOfReturnAddress() | ||
| 311 | #else | 433 | #else |
| 312 | #define zig_frame_address() 0 | 434 | #define zig_frame_address() 0 |
| 313 | #endif | 435 | #endif |
| ... | @@ -326,18 +448,18 @@ typedef char bool; | ... | @@ -326,18 +448,18 @@ typedef char bool; |
| 326 | #define zig_wasm_memory_grow(index, delta) zig_unimplemented() | 448 | #define zig_wasm_memory_grow(index, delta) zig_unimplemented() |
| 327 | #endif | 449 | #endif |
| 328 | 450 | ||
| 329 | #if __STDC_VERSION__ >= 201112L | 451 | #if __STDC_VERSION__ >= 202311L |
| 452 | #define zig_noreturn [[noreturn]] | ||
| 453 | #elif __STDC_VERSION__ >= 201112L | ||
| 330 | #define zig_noreturn _Noreturn | 454 | #define zig_noreturn _Noreturn |
| 331 | #elif zig_has_attribute(noreturn) || defined(zig_gnuc) | 455 | #elif zig_has_attribute(noreturn) || defined(zig_gnuc) || defined(zig_tinyc) |
| 332 | #define zig_noreturn __attribute__((noreturn)) | 456 | #define zig_noreturn __attribute__((noreturn)) |
| 333 | #elif _MSC_VER | 457 | #elif defined(zig_msvc) |
| 334 | #define zig_noreturn __declspec(noreturn) | 458 | #define zig_noreturn __declspec(noreturn) |
| 335 | #else | 459 | #else |
| 336 | #define zig_noreturn | 460 | #define zig_noreturn |
| 337 | #endif | 461 | #endif |
| 338 | 462 | ||
| 339 | #define zig_bitSizeOf(T) (CHAR_BIT * sizeof(T)) | ||
| 340 | |||
| 341 | #define zig_compiler_rt_abbrev_uint32_t si | 463 | #define zig_compiler_rt_abbrev_uint32_t si |
| 342 | #define zig_compiler_rt_abbrev_int32_t si | 464 | #define zig_compiler_rt_abbrev_int32_t si |
| 343 | #define zig_compiler_rt_abbrev_uint64_t di | 465 | #define zig_compiler_rt_abbrev_uint64_t di |
| ... | @@ -353,12 +475,25 @@ typedef char bool; | ... | @@ -353,12 +475,25 @@ typedef char bool; |
| 353 | zig_extern void *memcpy (void *zig_restrict, void const *zig_restrict, size_t); | 475 | zig_extern void *memcpy (void *zig_restrict, void const *zig_restrict, size_t); |
| 354 | zig_extern void *memset (void *, int, size_t); | 476 | zig_extern void *memset (void *, int, size_t); |
| 355 | 477 | ||
| 356 | /* ===================== 8/16/32/64-bit Integer Support ===================== */ | 478 | /* ================ Bool and 8/16/32/64-bit Integer Support ================= */ |
| 357 | 479 | ||
| 358 | #if __STDC_VERSION__ >= 199901L || _MSC_VER | 480 | #include <limits.h> |
| 359 | #include <stdint.h> | 481 | |
| 482 | #define zig_bitSizeOf(T) (CHAR_BIT * sizeof(T)) | ||
| 483 | |||
| 484 | #if __STDC_VERSION__ >= 202311L | ||
| 485 | /* bool, true, and false are provided by the language. */ | ||
| 486 | #elif __STDC_VERSION__ >= 199901L || zig_has_include(<stdbool.h>) | ||
| 487 | #include <stdbool.h> | ||
| 360 | #else | 488 | #else |
| 489 | typedef char bool; | ||
| 490 | #define false 0 | ||
| 491 | #define true 1 | ||
| 492 | #endif | ||
| 361 | 493 | ||
| 494 | #if __STDC_VERSION__ >= 199901L || defined(zig_msvc) || zig_has_include(<stdint.h>) | ||
| 495 | #include <stdint.h> | ||
| 496 | #else | ||
| 362 | #if SCHAR_MIN == ~0x7F && SCHAR_MAX == 0x7F && UCHAR_MAX == 0xFF | 497 | #if SCHAR_MIN == ~0x7F && SCHAR_MAX == 0x7F && UCHAR_MAX == 0xFF |
| 363 | typedef unsigned char uint8_t; | 498 | typedef unsigned char uint8_t; |
| 364 | typedef signed char int8_t; | 499 | typedef signed char int8_t; |
| ... | @@ -1132,7 +1267,7 @@ static inline int64_t zig_bit_reverse_i64(int64_t val, uint8_t bits) { | ... | @@ -1132,7 +1267,7 @@ static inline int64_t zig_bit_reverse_i64(int64_t val, uint8_t bits) { |
| 1132 | static inline uint8_t zig_popcount_i##w(int##w##_t val, uint8_t bits) { \ | 1267 | static inline uint8_t zig_popcount_i##w(int##w##_t val, uint8_t bits) { \ |
| 1133 | return zig_popcount_u##w((uint##w##_t)val, bits); \ | 1268 | return zig_popcount_u##w((uint##w##_t)val, bits); \ |
| 1134 | } | 1269 | } |
| 1135 | #if zig_has_builtin(popcount) || defined(zig_gnuc) | 1270 | #if zig_has_builtin(popcount) || defined(zig_gnuc) || defined(zig_tinyc) |
| 1136 | #define zig_builtin_popcount(w) \ | 1271 | #define zig_builtin_popcount(w) \ |
| 1137 | static inline uint8_t zig_popcount_u##w(uint##w##_t val, uint8_t bits) { \ | 1272 | static inline uint8_t zig_popcount_u##w(uint##w##_t val, uint8_t bits) { \ |
| 1138 | (void)bits; \ | 1273 | (void)bits; \ |
| ... | @@ -1161,7 +1296,7 @@ zig_builtin_popcount(64) | ... | @@ -1161,7 +1296,7 @@ zig_builtin_popcount(64) |
| 1161 | static inline uint8_t zig_ctz_i##w(int##w##_t val, uint8_t bits) { \ | 1296 | static inline uint8_t zig_ctz_i##w(int##w##_t val, uint8_t bits) { \ |
| 1162 | return zig_ctz_u##w((uint##w##_t)val, bits); \ | 1297 | return zig_ctz_u##w((uint##w##_t)val, bits); \ |
| 1163 | } | 1298 | } |
| 1164 | #if zig_has_builtin(ctz) || defined(zig_gnuc) | 1299 | #if zig_has_builtin(ctz) || defined(zig_gnuc) || defined(zig_tinyc) |
| 1165 | #define zig_builtin_ctz(w) \ | 1300 | #define zig_builtin_ctz(w) \ |
| 1166 | static inline uint8_t zig_ctz_u##w(uint##w##_t val, uint8_t bits) { \ | 1301 | static inline uint8_t zig_ctz_u##w(uint##w##_t val, uint8_t bits) { \ |
| 1167 | if (val == 0) return bits; \ | 1302 | if (val == 0) return bits; \ |
| ... | @@ -1186,7 +1321,7 @@ zig_builtin_ctz(64) | ... | @@ -1186,7 +1321,7 @@ zig_builtin_ctz(64) |
| 1186 | static inline uint8_t zig_clz_i##w(int##w##_t val, uint8_t bits) { \ | 1321 | static inline uint8_t zig_clz_i##w(int##w##_t val, uint8_t bits) { \ |
| 1187 | return zig_clz_u##w((uint##w##_t)val, bits); \ | 1322 | return zig_clz_u##w((uint##w##_t)val, bits); \ |
| 1188 | } | 1323 | } |
| 1189 | #if zig_has_builtin(clz) || defined(zig_gnuc) | 1324 | #if zig_has_builtin(clz) || defined(zig_gnuc) || defined(zig_tinyc) |
| 1190 | #define zig_builtin_clz(w) \ | 1325 | #define zig_builtin_clz(w) \ |
| 1191 | static inline uint8_t zig_clz_u##w(uint##w##_t val, uint8_t bits) { \ | 1326 | static inline uint8_t zig_clz_u##w(uint##w##_t val, uint8_t bits) { \ |
| 1192 | if (val == 0) return bits; \ | 1327 | if (val == 0) return bits; \ |
| ... | @@ -1254,7 +1389,7 @@ typedef struct { zig_align(16) int64_t hi; uint64_t lo; } zig_i128; | ... | @@ -1254,7 +1389,7 @@ typedef struct { zig_align(16) int64_t hi; uint64_t lo; } zig_i128; |
| 1254 | #define zig_make_u128(hi, lo) ((zig_u128){ .h##i = (hi), .l##o = (lo) }) | 1389 | #define zig_make_u128(hi, lo) ((zig_u128){ .h##i = (hi), .l##o = (lo) }) |
| 1255 | #define zig_make_i128(hi, lo) ((zig_i128){ .h##i = (hi), .l##o = (lo) }) | 1390 | #define zig_make_i128(hi, lo) ((zig_i128){ .h##i = (hi), .l##o = (lo) }) |
| 1256 | 1391 | ||
| 1257 | #if _MSC_VER /* MSVC doesn't allow struct literals in constant expressions */ | 1392 | #if defined(zig_msvc) /* MSVC doesn't allow struct literals in constant expressions */ |
| 1258 | #define zig_init_u128(hi, lo) { .h##i = (hi), .l##o = (lo) } | 1393 | #define zig_init_u128(hi, lo) { .h##i = (hi), .l##o = (lo) } |
| 1259 | #define zig_init_i128(hi, lo) { .h##i = (hi), .l##o = (lo) } | 1394 | #define zig_init_i128(hi, lo) { .h##i = (hi), .l##o = (lo) } |
| 1260 | #else /* But non-MSVC doesn't like the unprotected commas */ | 1395 | #else /* But non-MSVC doesn't like the unprotected commas */ |
| ... | @@ -3016,7 +3151,13 @@ static inline uint16_t zig_popcount_big(const void *val, bool is_signed, uint16_ | ... | @@ -3016,7 +3151,13 @@ static inline uint16_t zig_popcount_big(const void *val, bool is_signed, uint16_ |
| 3016 | 3151 | ||
| 3017 | /* ========================= Floating Point Support ========================= */ | 3152 | /* ========================= Floating Point Support ========================= */ |
| 3018 | 3153 | ||
| 3019 | #if _MSC_VER | 3154 | #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ |
| 3155 | #define __STDC_WANT_IEC_60559_TYPES_EXT__ | ||
| 3156 | #endif | ||
| 3157 | |||
| 3158 | #include <float.h> | ||
| 3159 | |||
| 3160 | #if defined(zig_msvc) | ||
| 3020 | float __cdecl nanf(char const* input); | 3161 | float __cdecl nanf(char const* input); |
| 3021 | double __cdecl nan(char const* input); | 3162 | double __cdecl nan(char const* input); |
| 3022 | long double __cdecl nanl(char const* input); | 3163 | long double __cdecl nanl(char const* input); |
| ... | @@ -3078,7 +3219,7 @@ typedef uint16_t zig_f16; | ... | @@ -3078,7 +3219,7 @@ typedef uint16_t zig_f16; |
| 3078 | #undef zig_init_special_f16 | 3219 | #undef zig_init_special_f16 |
| 3079 | #define zig_init_special_f16(sign, name, arg, repr) repr | 3220 | #define zig_init_special_f16(sign, name, arg, repr) repr |
| 3080 | #endif | 3221 | #endif |
| 3081 | #if __APPLE__ && (defined(__i386__) || defined(__x86_64__)) | 3222 | #if defined(zig_darwin) && defined(zig_x86) |
| 3082 | typedef uint16_t zig_compiler_rt_f16; | 3223 | typedef uint16_t zig_compiler_rt_f16; |
| 3083 | #else | 3224 | #else |
| 3084 | typedef zig_f16 zig_compiler_rt_f16; | 3225 | typedef zig_f16 zig_compiler_rt_f16; |
| ... | @@ -3086,7 +3227,7 @@ typedef zig_f16 zig_compiler_rt_f16; | ... | @@ -3086,7 +3227,7 @@ typedef zig_f16 zig_compiler_rt_f16; |
| 3086 | 3227 | ||
| 3087 | #define zig_has_f32 1 | 3228 | #define zig_has_f32 1 |
| 3088 | #define zig_libc_name_f32(name) name##f | 3229 | #define zig_libc_name_f32(name) name##f |
| 3089 | #if _MSC_VER | 3230 | #if defined(zig_msvc) |
| 3090 | #define zig_init_special_f32(sign, name, arg, repr) sign zig_make_f32(zig_msvc_flt_##name, ) | 3231 | #define zig_init_special_f32(sign, name, arg, repr) sign zig_make_f32(zig_msvc_flt_##name, ) |
| 3091 | #else | 3232 | #else |
| 3092 | #define zig_init_special_f32(sign, name, arg, repr) zig_make_special_f32(sign, name, arg, repr) | 3233 | #define zig_init_special_f32(sign, name, arg, repr) zig_make_special_f32(sign, name, arg, repr) |
| ... | @@ -3118,7 +3259,7 @@ typedef uint32_t zig_f32; | ... | @@ -3118,7 +3259,7 @@ typedef uint32_t zig_f32; |
| 3118 | #define zig_has_f64 1 | 3259 | #define zig_has_f64 1 |
| 3119 | #define zig_libc_name_f64(name) name | 3260 | #define zig_libc_name_f64(name) name |
| 3120 | 3261 | ||
| 3121 | #if _MSC_VER | 3262 | #if defined(zig_msvc) |
| 3122 | #define zig_init_special_f64(sign, name, arg, repr) sign zig_make_f64(zig_msvc_flt_##name, ) | 3263 | #define zig_init_special_f64(sign, name, arg, repr) sign zig_make_f64(zig_msvc_flt_##name, ) |
| 3123 | #else | 3264 | #else |
| 3124 | #define zig_init_special_f64(sign, name, arg, repr) zig_make_special_f64(sign, name, arg, repr) | 3265 | #define zig_init_special_f64(sign, name, arg, repr) zig_make_special_f64(sign, name, arg, repr) |
| ... | @@ -3183,6 +3324,12 @@ typedef zig_u128 zig_f80; | ... | @@ -3183,6 +3324,12 @@ typedef zig_u128 zig_f80; |
| 3183 | #define zig_init_special_f80(sign, name, arg, repr) repr | 3324 | #define zig_init_special_f80(sign, name, arg, repr) repr |
| 3184 | #endif | 3325 | #endif |
| 3185 | 3326 | ||
| 3327 | #if !defined(zig_clang) && defined(zig_gnuc) && defined(zig_x86) | ||
| 3328 | #define zig_f128_has_miscompilations 1 | ||
| 3329 | #else | ||
| 3330 | #define zig_f128_has_miscompilations 0 | ||
| 3331 | #endif | ||
| 3332 | |||
| 3186 | #define zig_has_f128 1 | 3333 | #define zig_has_f128 1 |
| 3187 | #define zig_libc_name_f128(name) name##q | 3334 | #define zig_libc_name_f128(name) name##q |
| 3188 | #define zig_init_special_f128(sign, name, arg, repr) zig_make_special_f128(sign, name, arg, repr) | 3335 | #define zig_init_special_f128(sign, name, arg, repr) zig_make_special_f128(sign, name, arg, repr) |
| ... | @@ -3211,7 +3358,7 @@ typedef __float128 zig_f128; | ... | @@ -3211,7 +3358,7 @@ typedef __float128 zig_f128; |
| 3211 | #define zig_has_f128 0 | 3358 | #define zig_has_f128 0 |
| 3212 | #undef zig_make_special_f128 | 3359 | #undef zig_make_special_f128 |
| 3213 | #undef zig_init_special_f128 | 3360 | #undef zig_init_special_f128 |
| 3214 | #if __APPLE__ || defined(__aarch64__) | 3361 | #if defined(zig_darwin) || defined(zig_aarch64) |
| 3215 | typedef __attribute__((__vector_size__(2 * sizeof(uint64_t)))) uint64_t zig_v2u64; | 3362 | typedef __attribute__((__vector_size__(2 * sizeof(uint64_t)))) uint64_t zig_v2u64; |
| 3216 | zig_basic_operator(zig_v2u64, xor_v2u64, ^) | 3363 | zig_basic_operator(zig_v2u64, xor_v2u64, ^) |
| 3217 | #define zig_repr_f128 v2u64 | 3364 | #define zig_repr_f128 v2u64 |
| ... | @@ -3230,10 +3377,10 @@ typedef zig_u128 zig_f128; | ... | @@ -3230,10 +3377,10 @@ typedef zig_u128 zig_f128; |
| 3230 | #endif | 3377 | #endif |
| 3231 | #endif | 3378 | #endif |
| 3232 | 3379 | ||
| 3233 | #if !_MSC_VER && defined(ZIG_TARGET_ABI_MSVC) | 3380 | #if !defined(zig_msvc) && defined(ZIG_TARGET_ABI_MSVC) |
| 3234 | /* Emulate msvc abi on a gnu compiler */ | 3381 | /* Emulate msvc abi on a gnu compiler */ |
| 3235 | typedef zig_f64 zig_c_longdouble; | 3382 | typedef zig_f64 zig_c_longdouble; |
| 3236 | #elif _MSC_VER && !defined(ZIG_TARGET_ABI_MSVC) | 3383 | #elif defined(zig_msvc) && !defined(ZIG_TARGET_ABI_MSVC) |
| 3237 | /* Emulate gnu abi on an msvc compiler */ | 3384 | /* Emulate gnu abi on an msvc compiler */ |
| 3238 | typedef zig_f128 zig_c_longdouble; | 3385 | typedef zig_f128 zig_c_longdouble; |
| 3239 | #else | 3386 | #else |
| ... | @@ -3582,7 +3729,7 @@ zig_float_builtins(64) | ... | @@ -3582,7 +3729,7 @@ zig_float_builtins(64) |
| 3582 | res = zig_atomicrmw_expected; \ | 3729 | res = zig_atomicrmw_expected; \ |
| 3583 | } while (0) | 3730 | } while (0) |
| 3584 | 3731 | ||
| 3585 | #if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__) | 3732 | #if (__STDC_VERSION__ >= 201112L || (zig_has_include(<stdatomic.h>) && !defined(zig_msvc))) && !defined(__STDC_NO_ATOMICS__) |
| 3586 | #include <stdatomic.h> | 3733 | #include <stdatomic.h> |
| 3587 | typedef enum memory_order zig_memory_order; | 3734 | typedef enum memory_order zig_memory_order; |
| 3588 | #define zig_memory_order_relaxed memory_order_relaxed | 3735 | #define zig_memory_order_relaxed memory_order_relaxed |
| ... | @@ -3610,7 +3757,7 @@ typedef enum memory_order zig_memory_order; | ... | @@ -3610,7 +3757,7 @@ typedef enum memory_order zig_memory_order; |
| 3610 | #define zig_atomicrmw_add_float zig_atomicrmw_add | 3757 | #define zig_atomicrmw_add_float zig_atomicrmw_add |
| 3611 | #undef zig_atomicrmw_sub_float | 3758 | #undef zig_atomicrmw_sub_float |
| 3612 | #define zig_atomicrmw_sub_float zig_atomicrmw_sub | 3759 | #define zig_atomicrmw_sub_float zig_atomicrmw_sub |
| 3613 | #elif defined(__GNUC__) | 3760 | #elif defined(zig_gnuc) |
| 3614 | typedef int zig_memory_order; | 3761 | typedef int zig_memory_order; |
| 3615 | #define zig_memory_order_relaxed __ATOMIC_RELAXED | 3762 | #define zig_memory_order_relaxed __ATOMIC_RELAXED |
| 3616 | #define zig_memory_order_acquire __ATOMIC_ACQUIRE | 3763 | #define zig_memory_order_acquire __ATOMIC_ACQUIRE |
| ... | @@ -3633,7 +3780,7 @@ typedef int zig_memory_order; | ... | @@ -3633,7 +3780,7 @@ typedef int zig_memory_order; |
| 3633 | #define zig_atomic_load(res, obj, order, Type, ReprType) __atomic_load (obj, &(res), order) | 3780 | #define zig_atomic_load(res, obj, order, Type, ReprType) __atomic_load (obj, &(res), order) |
| 3634 | #undef zig_atomicrmw_xchg_float | 3781 | #undef zig_atomicrmw_xchg_float |
| 3635 | #define zig_atomicrmw_xchg_float zig_atomicrmw_xchg | 3782 | #define zig_atomicrmw_xchg_float zig_atomicrmw_xchg |
| 3636 | #elif _MSC_VER && (_M_IX86 || _M_X64) | 3783 | #elif defined(zig_msvc) && defined(zig_x86) |
| 3637 | #define zig_memory_order_relaxed 0 | 3784 | #define zig_memory_order_relaxed 0 |
| 3638 | #define zig_memory_order_acquire 2 | 3785 | #define zig_memory_order_acquire 2 |
| 3639 | #define zig_memory_order_release 3 | 3786 | #define zig_memory_order_release 3 |
| ... | @@ -3653,7 +3800,7 @@ typedef int zig_memory_order; | ... | @@ -3653,7 +3800,7 @@ typedef int zig_memory_order; |
| 3653 | #define zig_atomicrmw_max(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_max_ ##Type(obj, arg) | 3800 | #define zig_atomicrmw_max(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_max_ ##Type(obj, arg) |
| 3654 | #define zig_atomic_store( obj, arg, order, Type, ReprType) zig_msvc_atomic_store_ ##Type(obj, arg) | 3801 | #define zig_atomic_store( obj, arg, order, Type, ReprType) zig_msvc_atomic_store_ ##Type(obj, arg) |
| 3655 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##order##_##Type(obj) | 3802 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##order##_##Type(obj) |
| 3656 | /* TODO: _MSC_VER && (_M_ARM || _M_ARM64) */ | 3803 | /* TODO: zig_msvc && (zig_thumb || zig_aarch64) */ |
| 3657 | #else | 3804 | #else |
| 3658 | #define zig_memory_order_relaxed 0 | 3805 | #define zig_memory_order_relaxed 0 |
| 3659 | #define zig_memory_order_acquire 2 | 3806 | #define zig_memory_order_acquire 2 |
| ... | @@ -3676,7 +3823,7 @@ typedef int zig_memory_order; | ... | @@ -3676,7 +3823,7 @@ typedef int zig_memory_order; |
| 3676 | #define zig_atomic_load(res, obj, order, Type, ReprType) zig_atomics_unavailable | 3823 | #define zig_atomic_load(res, obj, order, Type, ReprType) zig_atomics_unavailable |
| 3677 | #endif | 3824 | #endif |
| 3678 | 3825 | ||
| 3679 | #if _MSC_VER && (_M_IX86 || _M_X64) | 3826 | #if defined(zig_msvc) && defined(zig_x86) |
| 3680 | 3827 | ||
| 3681 | /* TODO: zig_msvc_atomic_load should load 32 bit without interlocked on x86, and load 64 bit without interlocked on x64 */ | 3828 | /* TODO: zig_msvc_atomic_load should load 32 bit without interlocked on x86, and load 64 bit without interlocked on x64 */ |
| 3682 | 3829 | ||
| ... | @@ -3773,7 +3920,7 @@ zig_msvc_atomics(i16, int16_t, short, 16, 16) | ... | @@ -3773,7 +3920,7 @@ zig_msvc_atomics(i16, int16_t, short, 16, 16) |
| 3773 | zig_msvc_atomics(u32, uint32_t, long, , 32) | 3920 | zig_msvc_atomics(u32, uint32_t, long, , 32) |
| 3774 | zig_msvc_atomics(i32, int32_t, long, , 32) | 3921 | zig_msvc_atomics(i32, int32_t, long, , 32) |
| 3775 | 3922 | ||
| 3776 | #if _M_X64 | 3923 | #if defined(zig_x86_64) |
| 3777 | zig_msvc_atomics(u64, uint64_t, __int64, 64, 64) | 3924 | zig_msvc_atomics(u64, uint64_t, __int64, 64, 64) |
| 3778 | zig_msvc_atomics(i64, int64_t, __int64, 64, 64) | 3925 | zig_msvc_atomics(i64, int64_t, __int64, 64, 64) |
| 3779 | #endif | 3926 | #endif |
| ... | @@ -3818,11 +3965,11 @@ zig_msvc_atomics(i64, int64_t, __int64, 64, 64) | ... | @@ -3818,11 +3965,11 @@ zig_msvc_atomics(i64, int64_t, __int64, 64, 64) |
| 3818 | } | 3965 | } |
| 3819 | 3966 | ||
| 3820 | zig_msvc_flt_atomics(f32, long, , 32) | 3967 | zig_msvc_flt_atomics(f32, long, , 32) |
| 3821 | #if _M_X64 | 3968 | #if defined(zig_x86_64) |
| 3822 | zig_msvc_flt_atomics(f64, int64_t, 64, 64) | 3969 | zig_msvc_flt_atomics(f64, int64_t, 64, 64) |
| 3823 | #endif | 3970 | #endif |
| 3824 | 3971 | ||
| 3825 | #if _M_IX86 | 3972 | #if defined(zig_x86_32) |
| 3826 | static inline void zig_msvc_atomic_barrier() { | 3973 | static inline void zig_msvc_atomic_barrier() { |
| 3827 | int32_t barrier; | 3974 | int32_t barrier; |
| 3828 | __asm { | 3975 | __asm { |
| ... | @@ -3859,7 +4006,7 @@ static inline bool zig_msvc_cmpxchg_p32(void volatile* obj, void* expected, void | ... | @@ -3859,7 +4006,7 @@ static inline bool zig_msvc_cmpxchg_p32(void volatile* obj, void* expected, void |
| 3859 | if (!success) *(void**)expected = initial; | 4006 | if (!success) *(void**)expected = initial; |
| 3860 | return success; | 4007 | return success; |
| 3861 | } | 4008 | } |
| 3862 | #else /* _M_IX86 */ | 4009 | #else /* zig_x86_32 */ |
| 3863 | static inline void* zig_msvc_atomicrmw_xchg_p64(void volatile* obj, void* arg) { | 4010 | static inline void* zig_msvc_atomicrmw_xchg_p64(void volatile* obj, void* arg) { |
| 3864 | return _InterlockedExchangePointer(obj, arg); | 4011 | return _InterlockedExchangePointer(obj, arg); |
| 3865 | } | 4012 | } |
| ... | @@ -3920,55 +4067,59 @@ static inline void zig_msvc_atomic_store_i128(zig_i128 volatile* obj, zig_i128 a | ... | @@ -3920,55 +4067,59 @@ static inline void zig_msvc_atomic_store_i128(zig_i128 volatile* obj, zig_i128 a |
| 3920 | while (!zig_cmpxchg_weak(obj, expected, arg, zig_memory_order_seq_cst, zig_memory_order_seq_cst, i128, zig_i128)); | 4067 | while (!zig_cmpxchg_weak(obj, expected, arg, zig_memory_order_seq_cst, zig_memory_order_seq_cst, i128, zig_i128)); |
| 3921 | } | 4068 | } |
| 3922 | 4069 | ||
| 3923 | #endif /* _M_IX86 */ | 4070 | #endif /* zig_x86_32 */ |
| 3924 | 4071 | ||
| 3925 | #endif /* _MSC_VER && (_M_IX86 || _M_X64) */ | 4072 | #endif /* zig_msvc && zig_x86 */ |
| 3926 | 4073 | ||
| 3927 | /* ======================== Special Case Intrinsics ========================= */ | 4074 | /* ======================== Special Case Intrinsics ========================= */ |
| 3928 | 4075 | ||
| 3929 | #if defined(_M_ARM) || defined(__thumb__) | 4076 | #if defined(zig_msvc) |
| 4077 | #include <intrin.h> | ||
| 4078 | #endif | ||
| 4079 | |||
| 4080 | #if defined(zig_thumb) | ||
| 3930 | 4081 | ||
| 3931 | static inline void* zig_thumb_windows_teb(void) { | 4082 | static inline void* zig_thumb_windows_teb(void) { |
| 3932 | void* teb = 0; | 4083 | void* teb = 0; |
| 3933 | #if defined(_MSC_VER) | 4084 | #if defined(zig_msvc) |
| 3934 | teb = (void*)_MoveFromCoprocessor(15, 0, 13, 0, 2); | 4085 | teb = (void*)_MoveFromCoprocessor(15, 0, 13, 0, 2); |
| 3935 | #elif defined(__GNUC__) | 4086 | #elif defined(zig_gnuc_asm) |
| 3936 | __asm__ ("mrc p15, 0, %[ptr], c13, c0, 2" : [ptr] "=r" (teb)); | 4087 | __asm__ ("mrc p15, 0, %[ptr], c13, c0, 2" : [ptr] "=r" (teb)); |
| 3937 | #endif | 4088 | #endif |
| 3938 | return teb; | 4089 | return teb; |
| 3939 | } | 4090 | } |
| 3940 | 4091 | ||
| 3941 | #elif defined(_M_ARM64) || defined(__arch64__) | 4092 | #elif defined(zig_aarch64) |
| 3942 | 4093 | ||
| 3943 | static inline void* zig_aarch64_windows_teb(void) { | 4094 | static inline void* zig_aarch64_windows_teb(void) { |
| 3944 | void* teb = 0; | 4095 | void* teb = 0; |
| 3945 | #if defined(_MSC_VER) | 4096 | #if defined(zig_msvc) |
| 3946 | teb = (void*)__readx18qword(0x0); | 4097 | teb = (void*)__readx18qword(0x0); |
| 3947 | #elif defined(__GNUC__) | 4098 | #elif defined(zig_gnuc_asm) |
| 3948 | __asm__ ("mov %[ptr], x18" : [ptr] "=r" (teb)); | 4099 | __asm__ ("mov %[ptr], x18" : [ptr] "=r" (teb)); |
| 3949 | #endif | 4100 | #endif |
| 3950 | return teb; | 4101 | return teb; |
| 3951 | } | 4102 | } |
| 3952 | 4103 | ||
| 3953 | #elif defined(_M_IX86) || defined(__i386__) | 4104 | #elif defined(zig_x86_32) |
| 3954 | 4105 | ||
| 3955 | static inline void* zig_x86_windows_teb(void) { | 4106 | static inline void* zig_x86_windows_teb(void) { |
| 3956 | void* teb = 0; | 4107 | void* teb = 0; |
| 3957 | #if defined(_MSC_VER) | 4108 | #if defined(zig_msvc) |
| 3958 | teb = (void*)__readfsdword(0x18); | 4109 | teb = (void*)__readfsdword(0x18); |
| 3959 | #elif defined(__GNUC__) | 4110 | #elif defined(zig_gnuc_asm) |
| 3960 | __asm__ ("movl %%fs:0x18, %[ptr]" : [ptr] "=r" (teb)); | 4111 | __asm__ ("movl %%fs:0x18, %[ptr]" : [ptr] "=r" (teb)); |
| 3961 | #endif | 4112 | #endif |
| 3962 | return teb; | 4113 | return teb; |
| 3963 | } | 4114 | } |
| 3964 | 4115 | ||
| 3965 | #elif defined(_M_X64) || defined(__x86_64__) | 4116 | #elif defined(zig_x86_64) |
| 3966 | 4117 | ||
| 3967 | static inline void* zig_x86_64_windows_teb(void) { | 4118 | static inline void* zig_x86_64_windows_teb(void) { |
| 3968 | void* teb = 0; | 4119 | void* teb = 0; |
| 3969 | #if defined(_MSC_VER) | 4120 | #if defined(zig_msvc) |
| 3970 | teb = (void*)__readgsqword(0x30); | 4121 | teb = (void*)__readgsqword(0x30); |
| 3971 | #elif defined(__GNUC__) | 4122 | #elif defined(zig_gnuc_asm) |
| 3972 | __asm__ ("movq %%gs:0x30, %[ptr]" : [ptr] "=r" (teb)); | 4123 | __asm__ ("movq %%gs:0x30, %[ptr]" : [ptr] "=r" (teb)); |
| 3973 | #endif | 4124 | #endif |
| 3974 | return teb; | 4125 | return teb; |
| ... | @@ -3976,29 +4127,39 @@ static inline void* zig_x86_64_windows_teb(void) { | ... | @@ -3976,29 +4127,39 @@ static inline void* zig_x86_64_windows_teb(void) { |
| 3976 | 4127 | ||
| 3977 | #endif | 4128 | #endif |
| 3978 | 4129 | ||
| 3979 | #if (_MSC_VER && (_M_IX86 || _M_X64)) || defined(__i386__) || defined(__x86_64__) | 4130 | #if defined(zig_x86) |
| 3980 | 4131 | ||
| 3981 | static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) { | 4132 | static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) { |
| 3982 | #if _MSC_VER | 4133 | #if defined(zig_msvc) |
| 3983 | int cpu_info[4]; | 4134 | int cpu_info[4]; |
| 3984 | __cpuidex(cpu_info, leaf_id, subid); | 4135 | __cpuidex(cpu_info, leaf_id, subid); |
| 3985 | *eax = (uint32_t)cpu_info[0]; | 4136 | *eax = (uint32_t)cpu_info[0]; |
| 3986 | *ebx = (uint32_t)cpu_info[1]; | 4137 | *ebx = (uint32_t)cpu_info[1]; |
| 3987 | *ecx = (uint32_t)cpu_info[2]; | 4138 | *ecx = (uint32_t)cpu_info[2]; |
| 3988 | *edx = (uint32_t)cpu_info[3]; | 4139 | *edx = (uint32_t)cpu_info[3]; |
| 4140 | #elif defined(zig_gnuc_asm) | ||
| 4141 | __asm__("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "a"(leaf_id), "c"(subid)); | ||
| 3989 | #else | 4142 | #else |
| 3990 | __cpuid_count(leaf_id, subid, *eax, *ebx, *ecx, *edx); | 4143 | *eax = 0; |
| 4144 | *ebx = 0; | ||
| 4145 | *ecx = 0; | ||
| 4146 | *edx = 0; | ||
| 3991 | #endif | 4147 | #endif |
| 3992 | } | 4148 | } |
| 3993 | 4149 | ||
| 3994 | static inline uint32_t zig_x86_get_xcr0(void) { | 4150 | static inline uint32_t zig_x86_get_xcr0(void) { |
| 3995 | #if _MSC_VER | 4151 | #if defined(zig_msvc) |
| 3996 | return (uint32_t)_xgetbv(0); | 4152 | return (uint32_t)_xgetbv(0); |
| 3997 | #else | 4153 | #elif defined(zig_gnuc_asm) |
| 3998 | uint32_t eax; | 4154 | uint32_t eax; |
| 3999 | uint32_t edx; | 4155 | uint32_t edx; |
| 4000 | __asm__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(0)); | 4156 | __asm__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(0)); |
| 4001 | return eax; | 4157 | return eax; |
| 4158 | #else | ||
| 4159 | *eax = 0; | ||
| 4160 | *ebx = 0; | ||
| 4161 | *ecx = 0; | ||
| 4162 | *edx = 0; | ||
| 4002 | #endif | 4163 | #endif |
| 4003 | } | 4164 | } |
| 4004 | 4165 |
stage1/zig1.wasm| Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ | |||
test/behavior/align.zig+2-2| ... | @@ -410,11 +410,11 @@ test "alignment of function with c calling convention" { | ... | @@ -410,11 +410,11 @@ test "alignment of function with c calling convention" { |
| 410 | var runtime_nothing = &nothing; | 410 | var runtime_nothing = &nothing; |
| 411 | _ = &runtime_nothing; | 411 | _ = &runtime_nothing; |
| 412 | const casted1: *align(a) const u8 = @ptrCast(runtime_nothing); | 412 | const casted1: *align(a) const u8 = @ptrCast(runtime_nothing); |
| 413 | const casted2: *const fn () callconv(.C) void = @ptrCast(casted1); | 413 | const casted2: *const fn () callconv(.c) void = @ptrCast(casted1); |
| 414 | casted2(); | 414 | casted2(); |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | fn nothing() callconv(.C) void {} | 417 | fn nothing() callconv(.c) void {} |
| 418 | 418 | ||
| 419 | const DefaultAligned = struct { | 419 | const DefaultAligned = struct { |
| 420 | nevermind: u32, | 420 | nevermind: u32, |
test/behavior/cast.zig+5-5| ... | @@ -1118,7 +1118,7 @@ test "compile time int to ptr of function" { | ... | @@ -1118,7 +1118,7 @@ test "compile time int to ptr of function" { |
| 1118 | // On some architectures function pointers must be aligned. | 1118 | // On some architectures function pointers must be aligned. |
| 1119 | const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf); | 1119 | const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf); |
| 1120 | pub const FUNCTION_CONSTANT = @as(PFN_void, @ptrFromInt(hardcoded_fn_addr)); | 1120 | pub const FUNCTION_CONSTANT = @as(PFN_void, @ptrFromInt(hardcoded_fn_addr)); |
| 1121 | pub const PFN_void = *const fn (*anyopaque) callconv(.C) void; | 1121 | pub const PFN_void = *const fn (*anyopaque) callconv(.c) void; |
| 1122 | 1122 | ||
| 1123 | fn foobar(func: PFN_void) !void { | 1123 | fn foobar(func: PFN_void) !void { |
| 1124 | try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr); | 1124 | try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr); |
| ... | @@ -1281,11 +1281,11 @@ test "implicit cast *[0]T to E![]const u8" { | ... | @@ -1281,11 +1281,11 @@ test "implicit cast *[0]T to E![]const u8" { |
| 1281 | 1281 | ||
| 1282 | var global_array: [4]u8 = undefined; | 1282 | var global_array: [4]u8 = undefined; |
| 1283 | test "cast from array reference to fn: comptime fn ptr" { | 1283 | test "cast from array reference to fn: comptime fn ptr" { |
| 1284 | const f = @as(*align(1) const fn () callconv(.C) void, @ptrCast(&global_array)); | 1284 | const f = @as(*align(1) const fn () callconv(.c) void, @ptrCast(&global_array)); |
| 1285 | try expect(@intFromPtr(f) == @intFromPtr(&global_array)); | 1285 | try expect(@intFromPtr(f) == @intFromPtr(&global_array)); |
| 1286 | } | 1286 | } |
| 1287 | test "cast from array reference to fn: runtime fn ptr" { | 1287 | test "cast from array reference to fn: runtime fn ptr" { |
| 1288 | var f = @as(*align(1) const fn () callconv(.C) void, @ptrCast(&global_array)); | 1288 | var f = @as(*align(1) const fn () callconv(.c) void, @ptrCast(&global_array)); |
| 1289 | _ = &f; | 1289 | _ = &f; |
| 1290 | try expect(@intFromPtr(f) == @intFromPtr(&global_array)); | 1290 | try expect(@intFromPtr(f) == @intFromPtr(&global_array)); |
| 1291 | } | 1291 | } |
| ... | @@ -1309,12 +1309,12 @@ test "*const [N]null u8 to ?[]const u8" { | ... | @@ -1309,12 +1309,12 @@ test "*const [N]null u8 to ?[]const u8" { |
| 1309 | 1309 | ||
| 1310 | test "cast between [*c]T and ?[*:0]T on fn parameter" { | 1310 | test "cast between [*c]T and ?[*:0]T on fn parameter" { |
| 1311 | const S = struct { | 1311 | const S = struct { |
| 1312 | const Handler = ?fn ([*c]const u8) callconv(.C) void; | 1312 | const Handler = ?fn ([*c]const u8) callconv(.c) void; |
| 1313 | fn addCallback(comptime handler: Handler) void { | 1313 | fn addCallback(comptime handler: Handler) void { |
| 1314 | _ = handler; | 1314 | _ = handler; |
| 1315 | } | 1315 | } |
| 1316 | 1316 | ||
| 1317 | fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void { | 1317 | fn myCallback(cstr: ?[*:0]const u8) callconv(.c) void { |
| 1318 | _ = cstr; | 1318 | _ = cstr; |
| 1319 | } | 1319 | } |
| 1320 | 1320 |
test/behavior/export_builtin.zig+1-1| ... | @@ -26,7 +26,7 @@ test "exporting with internal linkage" { | ... | @@ -26,7 +26,7 @@ test "exporting with internal linkage" { |
| 26 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 26 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 27 | 27 | ||
| 28 | const S = struct { | 28 | const S = struct { |
| 29 | fn foo() callconv(.C) void {} | 29 | fn foo() callconv(.c) void {} |
| 30 | comptime { | 30 | comptime { |
| 31 | @export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal }); | 31 | @export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal }); |
| 32 | } | 32 | } |
test/behavior/export_keyword.zig+1-1| ... | @@ -44,7 +44,7 @@ test "export function alias" { | ... | @@ -44,7 +44,7 @@ test "export function alias" { |
| 44 | if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest; | 44 | if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest; |
| 45 | 45 | ||
| 46 | _ = struct { | 46 | _ = struct { |
| 47 | fn foo_internal() callconv(.C) u32 { | 47 | fn foo_internal() callconv(.c) u32 { |
| 48 | return 123; | 48 | return 123; |
| 49 | } | 49 | } |
| 50 | export const foo_exported = foo_internal; | 50 | export const foo_exported = foo_internal; |
test/behavior/extern.zig+3-3| ... | @@ -20,7 +20,7 @@ test "function extern symbol" { | ... | @@ -20,7 +20,7 @@ test "function extern symbol" { |
| 20 | if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest; | 20 | if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest; |
| 21 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | 21 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 22 | 22 | ||
| 23 | const a = @extern(*const fn () callconv(.C) i32, .{ .name = "a_mystery_function" }); | 23 | const a = @extern(*const fn () callconv(.c) i32, .{ .name = "a_mystery_function" }); |
| 24 | try expect(a() == 4567); | 24 | try expect(a() == 4567); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| ... | @@ -35,7 +35,7 @@ test "function extern symbol matches extern decl" { | ... | @@ -35,7 +35,7 @@ test "function extern symbol matches extern decl" { |
| 35 | 35 | ||
| 36 | const S = struct { | 36 | const S = struct { |
| 37 | extern fn another_mystery_function() u32; | 37 | extern fn another_mystery_function() u32; |
| 38 | const same_thing = @extern(*const fn () callconv(.C) u32, .{ .name = "another_mystery_function" }); | 38 | const same_thing = @extern(*const fn () callconv(.c) u32, .{ .name = "another_mystery_function" }); |
| 39 | }; | 39 | }; |
| 40 | try expect(S.another_mystery_function() == 12345); | 40 | try expect(S.another_mystery_function() == 12345); |
| 41 | try expect(S.same_thing() == 12345); | 41 | try expect(S.same_thing() == 12345); |
| ... | @@ -55,5 +55,5 @@ test "coerce extern function types" { | ... | @@ -55,5 +55,5 @@ test "coerce extern function types" { |
| 55 | }; | 55 | }; |
| 56 | _ = S; | 56 | _ = S; |
| 57 | 57 | ||
| 58 | _ = @as(fn () callconv(.C) ?*u32, c_extern_function); | 58 | _ = @as(fn () callconv(.c) ?*u32, c_extern_function); |
| 59 | } | 59 | } |
test/behavior/fn.zig+5-5| ... | @@ -153,9 +153,9 @@ test "extern struct with stdcallcc fn pointer" { | ... | @@ -153,9 +153,9 @@ test "extern struct with stdcallcc fn pointer" { |
| 153 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | 153 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 154 | 154 | ||
| 155 | const S = extern struct { | 155 | const S = extern struct { |
| 156 | ptr: *const fn () callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .C) i32, | 156 | ptr: *const fn () callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .c) i32, |
| 157 | 157 | ||
| 158 | fn foo() callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .C) i32 { | 158 | fn foo() callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .c) i32 { |
| 159 | return 1234; | 159 | return 1234; |
| 160 | } | 160 | } |
| 161 | }; | 161 | }; |
| ... | @@ -169,7 +169,7 @@ const nComplexCallconv = 100; | ... | @@ -169,7 +169,7 @@ const nComplexCallconv = 100; |
| 169 | fn fComplexCallconvRet(x: u32) callconv(blk: { | 169 | fn fComplexCallconvRet(x: u32) callconv(blk: { |
| 170 | const s: struct { n: u32 } = .{ .n = nComplexCallconv }; | 170 | const s: struct { n: u32 } = .{ .n = nComplexCallconv }; |
| 171 | break :blk switch (s.n) { | 171 | break :blk switch (s.n) { |
| 172 | 0 => .C, | 172 | 0 => .c, |
| 173 | 1 => .Inline, | 173 | 1 => .Inline, |
| 174 | else => .Unspecified, | 174 | else => .Unspecified, |
| 175 | }; | 175 | }; |
| ... | @@ -435,13 +435,13 @@ test "implicit cast function to function ptr" { | ... | @@ -435,13 +435,13 @@ test "implicit cast function to function ptr" { |
| 435 | return 123; | 435 | return 123; |
| 436 | } | 436 | } |
| 437 | }; | 437 | }; |
| 438 | var fnPtr1: *const fn () callconv(.C) c_int = S1.someFunctionThatReturnsAValue; | 438 | var fnPtr1: *const fn () callconv(.c) c_int = S1.someFunctionThatReturnsAValue; |
| 439 | _ = &fnPtr1; | 439 | _ = &fnPtr1; |
| 440 | try expect(fnPtr1() == 123); | 440 | try expect(fnPtr1() == 123); |
| 441 | const S2 = struct { | 441 | const S2 = struct { |
| 442 | extern fn someFunctionThatReturnsAValue() c_int; | 442 | extern fn someFunctionThatReturnsAValue() c_int; |
| 443 | }; | 443 | }; |
| 444 | var fnPtr2: *const fn () callconv(.C) c_int = S2.someFunctionThatReturnsAValue; | 444 | var fnPtr2: *const fn () callconv(.c) c_int = S2.someFunctionThatReturnsAValue; |
| 445 | _ = &fnPtr2; | 445 | _ = &fnPtr2; |
| 446 | try expect(fnPtr2() == 123); | 446 | try expect(fnPtr2() == 123); |
| 447 | } | 447 | } |
test/behavior/generics.zig+6-6| ... | @@ -324,7 +324,7 @@ test "generic function instantiation non-duplicates" { | ... | @@ -324,7 +324,7 @@ test "generic function instantiation non-duplicates" { |
| 324 | for (source, 0..) |s, i| dest[i] = s; | 324 | for (source, 0..) |s, i| dest[i] = s; |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | fn foo() callconv(.C) void {} | 327 | fn foo() callconv(.c) void {} |
| 328 | }; | 328 | }; |
| 329 | var buffer: [100]u8 = undefined; | 329 | var buffer: [100]u8 = undefined; |
| 330 | S.copy(u8, &buffer, "hello"); | 330 | S.copy(u8, &buffer, "hello"); |
| ... | @@ -471,13 +471,13 @@ test "coerced function body has inequal value with its uncoerced body" { | ... | @@ -471,13 +471,13 @@ test "coerced function body has inequal value with its uncoerced body" { |
| 471 | try expect(S.A.do() == 1234); | 471 | try expect(S.A.do() == 1234); |
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | test "generic function returns value from callconv(.C) function" { | 474 | test "generic function returns value from callconv(.c) function" { |
| 475 | const S = struct { | 475 | const S = struct { |
| 476 | fn getU8() callconv(.C) u8 { | 476 | fn getU8() callconv(.c) u8 { |
| 477 | return 123; | 477 | return 123; |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | fn getGeneric(comptime T: type, supplier: fn () callconv(.C) T) T { | 480 | fn getGeneric(comptime T: type, supplier: fn () callconv(.c) T) T { |
| 481 | return supplier(); | 481 | return supplier(); |
| 482 | } | 482 | } |
| 483 | }; | 483 | }; |
| ... | @@ -521,11 +521,11 @@ test "function argument tuple used as struct field" { | ... | @@ -521,11 +521,11 @@ test "function argument tuple used as struct field" { |
| 521 | try expect(c.t[0] == null); | 521 | try expect(c.t[0] == null); |
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | test "comptime callconv(.C) function ptr uses comptime type argument" { | 524 | test "comptime callconv(.c) function ptr uses comptime type argument" { |
| 525 | const S = struct { | 525 | const S = struct { |
| 526 | fn A( | 526 | fn A( |
| 527 | comptime T: type, | 527 | comptime T: type, |
| 528 | comptime destroycb: ?*const fn (?*T) callconv(.C) void, | 528 | comptime destroycb: ?*const fn (?*T) callconv(.c) void, |
| 529 | ) !void { | 529 | ) !void { |
| 530 | try expect(destroycb == null); | 530 | try expect(destroycb == null); |
| 531 | } | 531 | } |
test/behavior/import_c_keywords.zig+1-1| ... | @@ -80,7 +80,7 @@ test "import c keywords" { | ... | @@ -80,7 +80,7 @@ test "import c keywords" { |
| 80 | try std.testing.expect(ptr_id == &some_non_c_keyword_constant); | 80 | try std.testing.expect(ptr_id == &some_non_c_keyword_constant); |
| 81 | 81 | ||
| 82 | if (builtin.target.ofmt != .coff and builtin.target.os.tag != .windows) { | 82 | if (builtin.target.ofmt != .coff and builtin.target.os.tag != .windows) { |
| 83 | var ptr_fn: *const fn () callconv(.C) Id = &double; | 83 | var ptr_fn: *const fn () callconv(.c) Id = &double; |
| 84 | try std.testing.expect(ptr_fn == &float); | 84 | try std.testing.expect(ptr_fn == &float); |
| 85 | ptr_fn = &an_alias_of_float; | 85 | ptr_fn = &an_alias_of_float; |
| 86 | try std.testing.expect(ptr_fn == &float); | 86 | try std.testing.expect(ptr_fn == &float); |
test/behavior/packed-struct.zig+3-3| ... | @@ -891,7 +891,7 @@ test "runtime init of unnamed packed struct type" { | ... | @@ -891,7 +891,7 @@ test "runtime init of unnamed packed struct type" { |
| 891 | }{ .x = z }).m(); | 891 | }{ .x = z }).m(); |
| 892 | } | 892 | } |
| 893 | 893 | ||
| 894 | test "packed struct passed to callconv(.C) function" { | 894 | test "packed struct passed to callconv(.c) function" { |
| 895 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 895 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 896 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 896 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 897 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 897 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| ... | @@ -906,7 +906,7 @@ test "packed struct passed to callconv(.C) function" { | ... | @@ -906,7 +906,7 @@ test "packed struct passed to callconv(.C) function" { |
| 906 | d: u46 = 0, | 906 | d: u46 = 0, |
| 907 | }; | 907 | }; |
| 908 | 908 | ||
| 909 | fn foo(p: Packed, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64) callconv(.C) bool { | 909 | fn foo(p: Packed, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64) callconv(.c) bool { |
| 910 | return p.a == 12345 and p.b == true and p.c == true and p.d == 0 and a1 == 5 and a2 == 4 and a3 == 3 and a4 == 2 and a5 == 1; | 910 | return p.a == 12345 and p.b == true and p.c == true and p.d == 0 and a1 == 5 and a2 == 4 and a3 == 3 and a4 == 2 and a5 == 1; |
| 911 | } | 911 | } |
| 912 | }; | 912 | }; |
| ... | @@ -1270,7 +1270,7 @@ test "2-byte packed struct argument in C calling convention" { | ... | @@ -1270,7 +1270,7 @@ test "2-byte packed struct argument in C calling convention" { |
| 1270 | x: u15 = 0, | 1270 | x: u15 = 0, |
| 1271 | y: u1 = 0, | 1271 | y: u1 = 0, |
| 1272 | 1272 | ||
| 1273 | fn foo(s: @This()) callconv(.C) i32 { | 1273 | fn foo(s: @This()) callconv(.c) i32 { |
| 1274 | return s.x; | 1274 | return s.x; |
| 1275 | } | 1275 | } |
| 1276 | fn bar(s: @This()) !void { | 1276 | fn bar(s: @This()) !void { |
test/behavior/struct.zig+1-1| ... | @@ -803,7 +803,7 @@ test "fn with C calling convention returns struct by value" { | ... | @@ -803,7 +803,7 @@ test "fn with C calling convention returns struct by value" { |
| 803 | handle: i32, | 803 | handle: i32, |
| 804 | }; | 804 | }; |
| 805 | 805 | ||
| 806 | fn makeBar(t: i32) callconv(.C) ExternBar { | 806 | fn makeBar(t: i32) callconv(.c) ExternBar { |
| 807 | return ExternBar{ | 807 | return ExternBar{ |
| 808 | .handle = t, | 808 | .handle = t, |
| 809 | }; | 809 | }; |
test/behavior/tuple.zig+3-3| ... | @@ -141,14 +141,14 @@ test "array-like initializer for tuple types" { | ... | @@ -141,14 +141,14 @@ test "array-like initializer for tuple types" { |
| 141 | .{ | 141 | .{ |
| 142 | .name = "0", | 142 | .name = "0", |
| 143 | .type = i32, | 143 | .type = i32, |
| 144 | .default_value = null, | 144 | .default_value_ptr = null, |
| 145 | .is_comptime = false, | 145 | .is_comptime = false, |
| 146 | .alignment = @alignOf(i32), | 146 | .alignment = @alignOf(i32), |
| 147 | }, | 147 | }, |
| 148 | .{ | 148 | .{ |
| 149 | .name = "1", | 149 | .name = "1", |
| 150 | .type = u8, | 150 | .type = u8, |
| 151 | .default_value = null, | 151 | .default_value_ptr = null, |
| 152 | .is_comptime = false, | 152 | .is_comptime = false, |
| 153 | .alignment = @alignOf(u8), | 153 | .alignment = @alignOf(u8), |
| 154 | }, | 154 | }, |
| ... | @@ -330,7 +330,7 @@ test "zero sized struct in tuple handled correctly" { | ... | @@ -330,7 +330,7 @@ test "zero sized struct in tuple handled correctly" { |
| 330 | .fields = &.{.{ | 330 | .fields = &.{.{ |
| 331 | .name = "0", | 331 | .name = "0", |
| 332 | .type = struct {}, | 332 | .type = struct {}, |
| 333 | .default_value = null, | 333 | .default_value_ptr = null, |
| 334 | .is_comptime = false, | 334 | .is_comptime = false, |
| 335 | .alignment = 0, | 335 | .alignment = 0, |
| 336 | }}, | 336 | }}, |
test/behavior/tuple_declarations.zig+2-2| ... | @@ -20,13 +20,13 @@ test "tuple declaration type info" { | ... | @@ -20,13 +20,13 @@ test "tuple declaration type info" { |
| 20 | 20 | ||
| 21 | try expectEqualStrings(info.fields[0].name, "0"); | 21 | try expectEqualStrings(info.fields[0].name, "0"); |
| 22 | try expect(info.fields[0].type == u32); | 22 | try expect(info.fields[0].type == u32); |
| 23 | try expect(@as(*const u32, @ptrCast(@alignCast(info.fields[0].default_value))).* == 1); | 23 | try expect(info.fields[0].defaultValue() == 1); |
| 24 | try expect(info.fields[0].is_comptime); | 24 | try expect(info.fields[0].is_comptime); |
| 25 | try expect(info.fields[0].alignment == @alignOf(u32)); | 25 | try expect(info.fields[0].alignment == @alignOf(u32)); |
| 26 | 26 | ||
| 27 | try expectEqualStrings(info.fields[1].name, "1"); | 27 | try expectEqualStrings(info.fields[1].name, "1"); |
| 28 | try expect(info.fields[1].type == []const u8); | 28 | try expect(info.fields[1].type == []const u8); |
| 29 | try expect(info.fields[1].default_value == null); | 29 | try expect(info.fields[1].defaultValue() == null); |
| 30 | try expect(!info.fields[1].is_comptime); | 30 | try expect(!info.fields[1].is_comptime); |
| 31 | try expect(info.fields[1].alignment == @alignOf([]const u8)); | 31 | try expect(info.fields[1].alignment == @alignOf([]const u8)); |
| 32 | } | 32 | } |
test/behavior/type.zig+21-21| ... | @@ -118,21 +118,21 @@ test "Type.Array" { | ... | @@ -118,21 +118,21 @@ test "Type.Array" { |
| 118 | .array = .{ | 118 | .array = .{ |
| 119 | .len = 123, | 119 | .len = 123, |
| 120 | .child = u8, | 120 | .child = u8, |
| 121 | .sentinel = null, | 121 | .sentinel_ptr = null, |
| 122 | }, | 122 | }, |
| 123 | })); | 123 | })); |
| 124 | try testing.expect([2]u32 == @Type(.{ | 124 | try testing.expect([2]u32 == @Type(.{ |
| 125 | .array = .{ | 125 | .array = .{ |
| 126 | .len = 2, | 126 | .len = 2, |
| 127 | .child = u32, | 127 | .child = u32, |
| 128 | .sentinel = null, | 128 | .sentinel_ptr = null, |
| 129 | }, | 129 | }, |
| 130 | })); | 130 | })); |
| 131 | try testing.expect([2:0]u32 == @Type(.{ | 131 | try testing.expect([2:0]u32 == @Type(.{ |
| 132 | .array = .{ | 132 | .array = .{ |
| 133 | .len = 2, | 133 | .len = 2, |
| 134 | .child = u32, | 134 | .child = u32, |
| 135 | .sentinel = &@as(u32, 0), | 135 | .sentinel_ptr = &@as(u32, 0), |
| 136 | }, | 136 | }, |
| 137 | })); | 137 | })); |
| 138 | try testTypes(&[_]type{ [1]u8, [30]usize, [7]bool }); | 138 | try testTypes(&[_]type{ [1]u8, [30]usize, [7]bool }); |
| ... | @@ -141,14 +141,14 @@ test "Type.Array" { | ... | @@ -141,14 +141,14 @@ test "Type.Array" { |
| 141 | test "@Type create slice with null sentinel" { | 141 | test "@Type create slice with null sentinel" { |
| 142 | const Slice = @Type(.{ | 142 | const Slice = @Type(.{ |
| 143 | .pointer = .{ | 143 | .pointer = .{ |
| 144 | .size = .Slice, | 144 | .size = .slice, |
| 145 | .is_const = true, | 145 | .is_const = true, |
| 146 | .is_volatile = false, | 146 | .is_volatile = false, |
| 147 | .is_allowzero = false, | 147 | .is_allowzero = false, |
| 148 | .alignment = 8, | 148 | .alignment = 8, |
| 149 | .address_space = .generic, | 149 | .address_space = .generic, |
| 150 | .child = *i32, | 150 | .child = *i32, |
| 151 | .sentinel = null, | 151 | .sentinel_ptr = null, |
| 152 | }, | 152 | }, |
| 153 | }); | 153 | }); |
| 154 | try testing.expect(Slice == []align(8) const *i32); | 154 | try testing.expect(Slice == []align(8) const *i32); |
| ... | @@ -266,10 +266,10 @@ test "Type.Struct" { | ... | @@ -266,10 +266,10 @@ test "Type.Struct" { |
| 266 | try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout); | 266 | try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout); |
| 267 | try testing.expectEqualSlices(u8, "x", infoA.fields[0].name); | 267 | try testing.expectEqualSlices(u8, "x", infoA.fields[0].name); |
| 268 | try testing.expectEqual(u8, infoA.fields[0].type); | 268 | try testing.expectEqual(u8, infoA.fields[0].type); |
| 269 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value); | 269 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value_ptr); |
| 270 | try testing.expectEqualSlices(u8, "y", infoA.fields[1].name); | 270 | try testing.expectEqualSlices(u8, "y", infoA.fields[1].name); |
| 271 | try testing.expectEqual(u32, infoA.fields[1].type); | 271 | try testing.expectEqual(u32, infoA.fields[1].type); |
| 272 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value); | 272 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value_ptr); |
| 273 | try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls); | 273 | try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls); |
| 274 | try testing.expectEqual(@as(bool, false), infoA.is_tuple); | 274 | try testing.expectEqual(@as(bool, false), infoA.is_tuple); |
| 275 | 275 | ||
| ... | @@ -284,10 +284,10 @@ test "Type.Struct" { | ... | @@ -284,10 +284,10 @@ test "Type.Struct" { |
| 284 | try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout); | 284 | try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout); |
| 285 | try testing.expectEqualSlices(u8, "x", infoB.fields[0].name); | 285 | try testing.expectEqualSlices(u8, "x", infoB.fields[0].name); |
| 286 | try testing.expectEqual(u8, infoB.fields[0].type); | 286 | try testing.expectEqual(u8, infoB.fields[0].type); |
| 287 | try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value); | 287 | try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value_ptr); |
| 288 | try testing.expectEqualSlices(u8, "y", infoB.fields[1].name); | 288 | try testing.expectEqualSlices(u8, "y", infoB.fields[1].name); |
| 289 | try testing.expectEqual(u32, infoB.fields[1].type); | 289 | try testing.expectEqual(u32, infoB.fields[1].type); |
| 290 | try testing.expectEqual(@as(u32, 5), @as(*align(1) const u32, @ptrCast(infoB.fields[1].default_value.?)).*); | 290 | try testing.expectEqual(@as(u32, 5), infoB.fields[1].defaultValue().?); |
| 291 | try testing.expectEqual(@as(usize, 0), infoB.decls.len); | 291 | try testing.expectEqual(@as(usize, 0), infoB.decls.len); |
| 292 | try testing.expectEqual(@as(bool, false), infoB.is_tuple); | 292 | try testing.expectEqual(@as(bool, false), infoB.is_tuple); |
| 293 | 293 | ||
| ... | @@ -296,10 +296,10 @@ test "Type.Struct" { | ... | @@ -296,10 +296,10 @@ test "Type.Struct" { |
| 296 | try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout); | 296 | try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout); |
| 297 | try testing.expectEqualSlices(u8, "x", infoC.fields[0].name); | 297 | try testing.expectEqualSlices(u8, "x", infoC.fields[0].name); |
| 298 | try testing.expectEqual(u8, infoC.fields[0].type); | 298 | try testing.expectEqual(u8, infoC.fields[0].type); |
| 299 | try testing.expectEqual(@as(u8, 3), @as(*const u8, @ptrCast(infoC.fields[0].default_value.?)).*); | 299 | try testing.expectEqual(@as(u8, 3), infoC.fields[0].defaultValue().?); |
| 300 | try testing.expectEqualSlices(u8, "y", infoC.fields[1].name); | 300 | try testing.expectEqualSlices(u8, "y", infoC.fields[1].name); |
| 301 | try testing.expectEqual(u32, infoC.fields[1].type); | 301 | try testing.expectEqual(u32, infoC.fields[1].type); |
| 302 | try testing.expectEqual(@as(u32, 5), @as(*align(1) const u32, @ptrCast(infoC.fields[1].default_value.?)).*); | 302 | try testing.expectEqual(@as(u32, 5), infoC.fields[1].defaultValue().?); |
| 303 | try testing.expectEqual(@as(usize, 0), infoC.decls.len); | 303 | try testing.expectEqual(@as(usize, 0), infoC.decls.len); |
| 304 | try testing.expectEqual(@as(bool, false), infoC.is_tuple); | 304 | try testing.expectEqual(@as(bool, false), infoC.is_tuple); |
| 305 | 305 | ||
| ... | @@ -309,10 +309,10 @@ test "Type.Struct" { | ... | @@ -309,10 +309,10 @@ test "Type.Struct" { |
| 309 | try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout); | 309 | try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout); |
| 310 | try testing.expectEqualSlices(u8, "x", infoD.fields[0].name); | 310 | try testing.expectEqualSlices(u8, "x", infoD.fields[0].name); |
| 311 | try testing.expectEqual(comptime_int, infoD.fields[0].type); | 311 | try testing.expectEqual(comptime_int, infoD.fields[0].type); |
| 312 | try testing.expectEqual(@as(comptime_int, 3), @as(*const comptime_int, @ptrCast(infoD.fields[0].default_value.?)).*); | 312 | try testing.expectEqual(@as(comptime_int, 3), infoD.fields[0].defaultValue().?); |
| 313 | try testing.expectEqualSlices(u8, "y", infoD.fields[1].name); | 313 | try testing.expectEqualSlices(u8, "y", infoD.fields[1].name); |
| 314 | try testing.expectEqual(comptime_int, infoD.fields[1].type); | 314 | try testing.expectEqual(comptime_int, infoD.fields[1].type); |
| 315 | try testing.expectEqual(@as(comptime_int, 5), @as(*const comptime_int, @ptrCast(infoD.fields[1].default_value.?)).*); | 315 | try testing.expectEqual(@as(comptime_int, 5), infoD.fields[1].defaultValue().?); |
| 316 | try testing.expectEqual(@as(usize, 0), infoD.decls.len); | 316 | try testing.expectEqual(@as(usize, 0), infoD.decls.len); |
| 317 | try testing.expectEqual(@as(bool, false), infoD.is_tuple); | 317 | try testing.expectEqual(@as(bool, false), infoD.is_tuple); |
| 318 | 318 | ||
| ... | @@ -322,10 +322,10 @@ test "Type.Struct" { | ... | @@ -322,10 +322,10 @@ test "Type.Struct" { |
| 322 | try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout); | 322 | try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout); |
| 323 | try testing.expectEqualSlices(u8, "0", infoE.fields[0].name); | 323 | try testing.expectEqualSlices(u8, "0", infoE.fields[0].name); |
| 324 | try testing.expectEqual(comptime_int, infoE.fields[0].type); | 324 | try testing.expectEqual(comptime_int, infoE.fields[0].type); |
| 325 | try testing.expectEqual(@as(comptime_int, 1), @as(*const comptime_int, @ptrCast(infoE.fields[0].default_value.?)).*); | 325 | try testing.expectEqual(@as(comptime_int, 1), infoE.fields[0].defaultValue().?); |
| 326 | try testing.expectEqualSlices(u8, "1", infoE.fields[1].name); | 326 | try testing.expectEqualSlices(u8, "1", infoE.fields[1].name); |
| 327 | try testing.expectEqual(comptime_int, infoE.fields[1].type); | 327 | try testing.expectEqual(comptime_int, infoE.fields[1].type); |
| 328 | try testing.expectEqual(@as(comptime_int, 2), @as(*const comptime_int, @ptrCast(infoE.fields[1].default_value.?)).*); | 328 | try testing.expectEqual(@as(comptime_int, 2), infoE.fields[1].defaultValue().?); |
| 329 | try testing.expectEqual(@as(usize, 0), infoE.decls.len); | 329 | try testing.expectEqual(@as(usize, 0), infoE.decls.len); |
| 330 | try testing.expectEqual(@as(bool, true), infoE.is_tuple); | 330 | try testing.expectEqual(@as(bool, true), infoE.is_tuple); |
| 331 | 331 | ||
| ... | @@ -548,11 +548,11 @@ test "Type.Fn" { | ... | @@ -548,11 +548,11 @@ test "Type.Fn" { |
| 548 | 548 | ||
| 549 | const some_opaque = opaque {}; | 549 | const some_opaque = opaque {}; |
| 550 | const some_ptr = *some_opaque; | 550 | const some_ptr = *some_opaque; |
| 551 | const T = fn (c_int, some_ptr) callconv(.C) void; | 551 | const T = fn (c_int, some_ptr) callconv(.c) void; |
| 552 | 552 | ||
| 553 | { | 553 | { |
| 554 | const fn_info = std.builtin.Type{ .@"fn" = .{ | 554 | const fn_info = std.builtin.Type{ .@"fn" = .{ |
| 555 | .calling_convention = .C, | 555 | .calling_convention = .c, |
| 556 | .is_generic = false, | 556 | .is_generic = false, |
| 557 | .is_var_args = false, | 557 | .is_var_args = false, |
| 558 | .return_type = void, | 558 | .return_type = void, |
| ... | @@ -582,7 +582,7 @@ test "reified struct field name from optional payload" { | ... | @@ -582,7 +582,7 @@ test "reified struct field name from optional payload" { |
| 582 | .fields = &.{.{ | 582 | .fields = &.{.{ |
| 583 | .name = name, | 583 | .name = name, |
| 584 | .type = u8, | 584 | .type = u8, |
| 585 | .default_value = null, | 585 | .default_value_ptr = null, |
| 586 | .is_comptime = false, | 586 | .is_comptime = false, |
| 587 | .alignment = 1, | 587 | .alignment = 1, |
| 588 | }}, | 588 | }}, |
| ... | @@ -628,7 +628,7 @@ test "reified struct uses @alignOf" { | ... | @@ -628,7 +628,7 @@ test "reified struct uses @alignOf" { |
| 628 | .{ | 628 | .{ |
| 629 | .name = "globals", | 629 | .name = "globals", |
| 630 | .type = modules.mach.globals, | 630 | .type = modules.mach.globals, |
| 631 | .default_value = null, | 631 | .default_value_ptr = null, |
| 632 | .is_comptime = false, | 632 | .is_comptime = false, |
| 633 | .alignment = @alignOf(modules.mach.globals), | 633 | .alignment = @alignOf(modules.mach.globals), |
| 634 | }, | 634 | }, |
| ... | @@ -688,7 +688,7 @@ test "empty struct assigned to reified struct field" { | ... | @@ -688,7 +688,7 @@ test "empty struct assigned to reified struct field" { |
| 688 | .fields = &.{.{ | 688 | .fields = &.{.{ |
| 689 | .name = "components", | 689 | .name = "components", |
| 690 | .type = @TypeOf(modules.components), | 690 | .type = @TypeOf(modules.components), |
| 691 | .default_value = null, | 691 | .default_value_ptr = null, |
| 692 | .is_comptime = false, | 692 | .is_comptime = false, |
| 693 | .alignment = @alignOf(@TypeOf(modules.components)), | 693 | .alignment = @alignOf(@TypeOf(modules.components)), |
| 694 | }}, | 694 | }}, |
| ... | @@ -738,7 +738,7 @@ test "struct field names sliced at comptime from larger string" { | ... | @@ -738,7 +738,7 @@ test "struct field names sliced at comptime from larger string" { |
| 738 | .alignment = 0, | 738 | .alignment = 0, |
| 739 | .name = name ++ "", | 739 | .name = name ++ "", |
| 740 | .type = usize, | 740 | .type = usize, |
| 741 | .default_value = null, | 741 | .default_value_ptr = null, |
| 742 | .is_comptime = false, | 742 | .is_comptime = false, |
| 743 | }}; | 743 | }}; |
| 744 | } | 744 | } |
test/behavior/type_info.zig+25-25| ... | @@ -44,7 +44,7 @@ test "type info: C pointer type info" { | ... | @@ -44,7 +44,7 @@ test "type info: C pointer type info" { |
| 44 | fn testCPtr() !void { | 44 | fn testCPtr() !void { |
| 45 | const ptr_info = @typeInfo([*c]align(4) const i8); | 45 | const ptr_info = @typeInfo([*c]align(4) const i8); |
| 46 | try expect(ptr_info == .pointer); | 46 | try expect(ptr_info == .pointer); |
| 47 | try expect(ptr_info.pointer.size == .C); | 47 | try expect(ptr_info.pointer.size == .c); |
| 48 | try expect(ptr_info.pointer.is_const); | 48 | try expect(ptr_info.pointer.is_const); |
| 49 | try expect(!ptr_info.pointer.is_volatile); | 49 | try expect(!ptr_info.pointer.is_volatile); |
| 50 | try expect(ptr_info.pointer.alignment == 4); | 50 | try expect(ptr_info.pointer.alignment == 4); |
| ... | @@ -54,8 +54,8 @@ fn testCPtr() !void { | ... | @@ -54,8 +54,8 @@ fn testCPtr() !void { |
| 54 | test "type info: value is correctly copied" { | 54 | test "type info: value is correctly copied" { |
| 55 | comptime { | 55 | comptime { |
| 56 | var ptrInfo = @typeInfo([]u32); | 56 | var ptrInfo = @typeInfo([]u32); |
| 57 | ptrInfo.pointer.size = .One; | 57 | ptrInfo.pointer.size = .one; |
| 58 | try expect(@typeInfo([]u32).pointer.size == .Slice); | 58 | try expect(@typeInfo([]u32).pointer.size == .slice); |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| 61 | 61 | ||
| ... | @@ -79,12 +79,12 @@ test "type info: pointer type info" { | ... | @@ -79,12 +79,12 @@ test "type info: pointer type info" { |
| 79 | fn testPointer() !void { | 79 | fn testPointer() !void { |
| 80 | const u32_ptr_info = @typeInfo(*u32); | 80 | const u32_ptr_info = @typeInfo(*u32); |
| 81 | try expect(u32_ptr_info == .pointer); | 81 | try expect(u32_ptr_info == .pointer); |
| 82 | try expect(u32_ptr_info.pointer.size == .One); | 82 | try expect(u32_ptr_info.pointer.size == .one); |
| 83 | try expect(u32_ptr_info.pointer.is_const == false); | 83 | try expect(u32_ptr_info.pointer.is_const == false); |
| 84 | try expect(u32_ptr_info.pointer.is_volatile == false); | 84 | try expect(u32_ptr_info.pointer.is_volatile == false); |
| 85 | try expect(u32_ptr_info.pointer.alignment == @alignOf(u32)); | 85 | try expect(u32_ptr_info.pointer.alignment == @alignOf(u32)); |
| 86 | try expect(u32_ptr_info.pointer.child == u32); | 86 | try expect(u32_ptr_info.pointer.child == u32); |
| 87 | try expect(u32_ptr_info.pointer.sentinel == null); | 87 | try expect(u32_ptr_info.pointer.sentinel() == null); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | test "type info: unknown length pointer type info" { | 90 | test "type info: unknown length pointer type info" { |
| ... | @@ -95,10 +95,10 @@ test "type info: unknown length pointer type info" { | ... | @@ -95,10 +95,10 @@ test "type info: unknown length pointer type info" { |
| 95 | fn testUnknownLenPtr() !void { | 95 | fn testUnknownLenPtr() !void { |
| 96 | const u32_ptr_info = @typeInfo([*]const volatile f64); | 96 | const u32_ptr_info = @typeInfo([*]const volatile f64); |
| 97 | try expect(u32_ptr_info == .pointer); | 97 | try expect(u32_ptr_info == .pointer); |
| 98 | try expect(u32_ptr_info.pointer.size == .Many); | 98 | try expect(u32_ptr_info.pointer.size == .many); |
| 99 | try expect(u32_ptr_info.pointer.is_const == true); | 99 | try expect(u32_ptr_info.pointer.is_const == true); |
| 100 | try expect(u32_ptr_info.pointer.is_volatile == true); | 100 | try expect(u32_ptr_info.pointer.is_volatile == true); |
| 101 | try expect(u32_ptr_info.pointer.sentinel == null); | 101 | try expect(u32_ptr_info.pointer.sentinel() == null); |
| 102 | try expect(u32_ptr_info.pointer.alignment == @alignOf(f64)); | 102 | try expect(u32_ptr_info.pointer.alignment == @alignOf(f64)); |
| 103 | try expect(u32_ptr_info.pointer.child == f64); | 103 | try expect(u32_ptr_info.pointer.child == f64); |
| 104 | } | 104 | } |
| ... | @@ -111,12 +111,12 @@ test "type info: null terminated pointer type info" { | ... | @@ -111,12 +111,12 @@ test "type info: null terminated pointer type info" { |
| 111 | fn testNullTerminatedPtr() !void { | 111 | fn testNullTerminatedPtr() !void { |
| 112 | const ptr_info = @typeInfo([*:0]u8); | 112 | const ptr_info = @typeInfo([*:0]u8); |
| 113 | try expect(ptr_info == .pointer); | 113 | try expect(ptr_info == .pointer); |
| 114 | try expect(ptr_info.pointer.size == .Many); | 114 | try expect(ptr_info.pointer.size == .many); |
| 115 | try expect(ptr_info.pointer.is_const == false); | 115 | try expect(ptr_info.pointer.is_const == false); |
| 116 | try expect(ptr_info.pointer.is_volatile == false); | 116 | try expect(ptr_info.pointer.is_volatile == false); |
| 117 | try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0); | 117 | try expect(ptr_info.pointer.sentinel().? == 0); |
| 118 | 118 | ||
| 119 | try expect(@typeInfo([:0]u8).pointer.sentinel != null); | 119 | try expect(@typeInfo([:0]u8).pointer.sentinel() != null); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | test "type info: slice type info" { | 122 | test "type info: slice type info" { |
| ... | @@ -127,7 +127,7 @@ test "type info: slice type info" { | ... | @@ -127,7 +127,7 @@ test "type info: slice type info" { |
| 127 | fn testSlice() !void { | 127 | fn testSlice() !void { |
| 128 | const u32_slice_info = @typeInfo([]u32); | 128 | const u32_slice_info = @typeInfo([]u32); |
| 129 | try expect(u32_slice_info == .pointer); | 129 | try expect(u32_slice_info == .pointer); |
| 130 | try expect(u32_slice_info.pointer.size == .Slice); | 130 | try expect(u32_slice_info.pointer.size == .slice); |
| 131 | try expect(u32_slice_info.pointer.is_const == false); | 131 | try expect(u32_slice_info.pointer.is_const == false); |
| 132 | try expect(u32_slice_info.pointer.is_volatile == false); | 132 | try expect(u32_slice_info.pointer.is_volatile == false); |
| 133 | try expect(u32_slice_info.pointer.alignment == 4); | 133 | try expect(u32_slice_info.pointer.alignment == 4); |
| ... | @@ -145,14 +145,14 @@ fn testArray() !void { | ... | @@ -145,14 +145,14 @@ fn testArray() !void { |
| 145 | try expect(info == .array); | 145 | try expect(info == .array); |
| 146 | try expect(info.array.len == 42); | 146 | try expect(info.array.len == 42); |
| 147 | try expect(info.array.child == u8); | 147 | try expect(info.array.child == u8); |
| 148 | try expect(info.array.sentinel == null); | 148 | try expect(info.array.sentinel() == null); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | { | 151 | { |
| 152 | const info = @typeInfo([10:0]u8); | 152 | const info = @typeInfo([10:0]u8); |
| 153 | try expect(info.array.len == 10); | 153 | try expect(info.array.len == 10); |
| 154 | try expect(info.array.child == u8); | 154 | try expect(info.array.child == u8); |
| 155 | try expect(@as(*const u8, @ptrCast(info.array.sentinel.?)).* == @as(u8, 0)); | 155 | try expect(info.array.sentinel().? == @as(u8, 0)); |
| 156 | try expect(@sizeOf([10:0]u8) == info.array.len + 1); | 156 | try expect(@sizeOf([10:0]u8) == info.array.len + 1); |
| 157 | } | 157 | } |
| 158 | } | 158 | } |
| ... | @@ -292,8 +292,8 @@ fn testStruct() !void { | ... | @@ -292,8 +292,8 @@ fn testStruct() !void { |
| 292 | try expect(unpacked_struct_info.@"struct".is_tuple == false); | 292 | try expect(unpacked_struct_info.@"struct".is_tuple == false); |
| 293 | try expect(unpacked_struct_info.@"struct".backing_integer == null); | 293 | try expect(unpacked_struct_info.@"struct".backing_integer == null); |
| 294 | try expect(unpacked_struct_info.@"struct".fields[0].alignment == @alignOf(u32)); | 294 | try expect(unpacked_struct_info.@"struct".fields[0].alignment == @alignOf(u32)); |
| 295 | try expect(@as(*align(1) const u32, @ptrCast(unpacked_struct_info.@"struct".fields[0].default_value.?)).* == 4); | 295 | try expect(unpacked_struct_info.@"struct".fields[0].defaultValue().? == 4); |
| 296 | try expect(mem.eql(u8, "foobar", @as(*align(1) const *const [6:0]u8, @ptrCast(unpacked_struct_info.@"struct".fields[1].default_value.?)).*)); | 296 | try expect(mem.eql(u8, "foobar", unpacked_struct_info.@"struct".fields[1].defaultValue().?)); |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | const TestStruct = struct { | 299 | const TestStruct = struct { |
| ... | @@ -315,8 +315,8 @@ fn testPackedStruct() !void { | ... | @@ -315,8 +315,8 @@ fn testPackedStruct() !void { |
| 315 | try expect(struct_info.@"struct".fields.len == 4); | 315 | try expect(struct_info.@"struct".fields.len == 4); |
| 316 | try expect(struct_info.@"struct".fields[0].alignment == 0); | 316 | try expect(struct_info.@"struct".fields[0].alignment == 0); |
| 317 | try expect(struct_info.@"struct".fields[2].type == f32); | 317 | try expect(struct_info.@"struct".fields[2].type == f32); |
| 318 | try expect(struct_info.@"struct".fields[2].default_value == null); | 318 | try expect(struct_info.@"struct".fields[2].defaultValue() == null); |
| 319 | try expect(@as(*align(1) const u32, @ptrCast(struct_info.@"struct".fields[3].default_value.?)).* == 4); | 319 | try expect(struct_info.@"struct".fields[3].defaultValue().? == 4); |
| 320 | try expect(struct_info.@"struct".fields[3].alignment == 0); | 320 | try expect(struct_info.@"struct".fields[3].alignment == 0); |
| 321 | try expect(struct_info.@"struct".decls.len == 1); | 321 | try expect(struct_info.@"struct".decls.len == 1); |
| 322 | } | 322 | } |
| ... | @@ -374,13 +374,13 @@ fn testFunction() !void { | ... | @@ -374,13 +374,13 @@ fn testFunction() !void { |
| 374 | try expect(foo_fn_info.@"fn".is_var_args); | 374 | try expect(foo_fn_info.@"fn".is_var_args); |
| 375 | try expect(foo_fn_info.@"fn".return_type.? == usize); | 375 | try expect(foo_fn_info.@"fn".return_type.? == usize); |
| 376 | const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo)); | 376 | const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo)); |
| 377 | try expect(foo_ptr_fn_info.pointer.size == .One); | 377 | try expect(foo_ptr_fn_info.pointer.size == .one); |
| 378 | try expect(foo_ptr_fn_info.pointer.is_const); | 378 | try expect(foo_ptr_fn_info.pointer.is_const); |
| 379 | try expect(!foo_ptr_fn_info.pointer.is_volatile); | 379 | try expect(!foo_ptr_fn_info.pointer.is_volatile); |
| 380 | try expect(foo_ptr_fn_info.pointer.address_space == .generic); | 380 | try expect(foo_ptr_fn_info.pointer.address_space == .generic); |
| 381 | try expect(foo_ptr_fn_info.pointer.child == foo_fn_type); | 381 | try expect(foo_ptr_fn_info.pointer.child == foo_fn_type); |
| 382 | try expect(!foo_ptr_fn_info.pointer.is_allowzero); | 382 | try expect(!foo_ptr_fn_info.pointer.is_allowzero); |
| 383 | try expect(foo_ptr_fn_info.pointer.sentinel == null); | 383 | try expect(foo_ptr_fn_info.pointer.sentinel() == null); |
| 384 | 384 | ||
| 385 | // Avoid looking at `typeInfoFooAligned` on targets which don't support function alignment. | 385 | // Avoid looking at `typeInfoFooAligned` on targets which don't support function alignment. |
| 386 | switch (builtin.target.cpu.arch) { | 386 | switch (builtin.target.cpu.arch) { |
| ... | @@ -401,14 +401,14 @@ fn testFunction() !void { | ... | @@ -401,14 +401,14 @@ fn testFunction() !void { |
| 401 | try expect(aligned_foo_fn_info.@"fn".is_var_args); | 401 | try expect(aligned_foo_fn_info.@"fn".is_var_args); |
| 402 | try expect(aligned_foo_fn_info.@"fn".return_type.? == usize); | 402 | try expect(aligned_foo_fn_info.@"fn".return_type.? == usize); |
| 403 | const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned)); | 403 | const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned)); |
| 404 | try expect(aligned_foo_ptr_fn_info.pointer.size == .One); | 404 | try expect(aligned_foo_ptr_fn_info.pointer.size == .one); |
| 405 | try expect(aligned_foo_ptr_fn_info.pointer.is_const); | 405 | try expect(aligned_foo_ptr_fn_info.pointer.is_const); |
| 406 | try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile); | 406 | try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile); |
| 407 | try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4); | 407 | try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4); |
| 408 | try expect(aligned_foo_ptr_fn_info.pointer.address_space == .generic); | 408 | try expect(aligned_foo_ptr_fn_info.pointer.address_space == .generic); |
| 409 | try expect(aligned_foo_ptr_fn_info.pointer.child == aligned_foo_fn_type); | 409 | try expect(aligned_foo_ptr_fn_info.pointer.child == aligned_foo_fn_type); |
| 410 | try expect(!aligned_foo_ptr_fn_info.pointer.is_allowzero); | 410 | try expect(!aligned_foo_ptr_fn_info.pointer.is_allowzero); |
| 411 | try expect(aligned_foo_ptr_fn_info.pointer.sentinel == null); | 411 | try expect(aligned_foo_ptr_fn_info.pointer.sentinel() == null); |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.c) usize; | 414 | extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.c) usize; |
| ... | @@ -517,7 +517,7 @@ test "type info: TypeId -> Type impl cast" { | ... | @@ -517,7 +517,7 @@ test "type info: TypeId -> Type impl cast" { |
| 517 | 517 | ||
| 518 | test "sentinel of opaque pointer type" { | 518 | test "sentinel of opaque pointer type" { |
| 519 | const c_void_info = @typeInfo(*anyopaque); | 519 | const c_void_info = @typeInfo(*anyopaque); |
| 520 | try expect(c_void_info.pointer.sentinel == null); | 520 | try expect(c_void_info.pointer.sentinel_ptr == null); |
| 521 | } | 521 | } |
| 522 | 522 | ||
| 523 | test "@typeInfo does not force declarations into existence" { | 523 | test "@typeInfo does not force declarations into existence" { |
| ... | @@ -601,9 +601,9 @@ test "typeInfo resolves usingnamespace declarations" { | ... | @@ -601,9 +601,9 @@ test "typeInfo resolves usingnamespace declarations" { |
| 601 | try expectEqualStrings(decls[1].name, "f1"); | 601 | try expectEqualStrings(decls[1].name, "f1"); |
| 602 | } | 602 | } |
| 603 | 603 | ||
| 604 | test "value from struct @typeInfo default_value can be loaded at comptime" { | 604 | test "value from struct @typeInfo default_value_ptr can be loaded at comptime" { |
| 605 | comptime { | 605 | comptime { |
| 606 | const a = @typeInfo(@TypeOf(.{ .foo = @as(u8, 1) })).@"struct".fields[0].default_value; | 606 | const a = @typeInfo(@TypeOf(.{ .foo = @as(u8, 1) })).@"struct".fields[0].default_value_ptr; |
| 607 | try expect(@as(*const u8, @ptrCast(a)).* == 1); | 607 | try expect(@as(*const u8, @ptrCast(a)).* == 1); |
| 608 | } | 608 | } |
| 609 | } | 609 | } |
| ... | @@ -646,7 +646,7 @@ test "@typeInfo decls ignore dependency loops" { | ... | @@ -646,7 +646,7 @@ test "@typeInfo decls ignore dependency loops" { |
| 646 | 646 | ||
| 647 | test "type info of tuple of string literal default value" { | 647 | test "type info of tuple of string literal default value" { |
| 648 | const struct_field = @typeInfo(@TypeOf(.{"hi"})).@"struct".fields[0]; | 648 | const struct_field = @typeInfo(@TypeOf(.{"hi"})).@"struct".fields[0]; |
| 649 | const value = @as(*align(1) const *const [2:0]u8, @ptrCast(struct_field.default_value.?)).*; | 649 | const value = struct_field.defaultValue().?; |
| 650 | comptime std.debug.assert(value[0] == 'h'); | 650 | comptime std.debug.assert(value[0] == 'h'); |
| 651 | } | 651 | } |
| 652 | 652 |
test/behavior/union.zig+1-1| ... | @@ -1229,7 +1229,7 @@ test "return an extern union from C calling convention" { | ... | @@ -1229,7 +1229,7 @@ test "return an extern union from C calling convention" { |
| 1229 | s: S, | 1229 | s: S, |
| 1230 | }; | 1230 | }; |
| 1231 | 1231 | ||
| 1232 | fn bar(arg_u: U) callconv(.C) U { | 1232 | fn bar(arg_u: U) callconv(.c) U { |
| 1233 | var u = arg_u; | 1233 | var u = arg_u; |
| 1234 | _ = &u; | 1234 | _ = &u; |
| 1235 | return u; | 1235 | return u; |
test/behavior/var_args.zig+8-8| ... | @@ -108,19 +108,19 @@ test "simple variadic function" { | ... | @@ -108,19 +108,19 @@ test "simple variadic function" { |
| 108 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 | 108 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 |
| 109 | 109 | ||
| 110 | const S = struct { | 110 | const S = struct { |
| 111 | fn simple(...) callconv(.C) c_int { | 111 | fn simple(...) callconv(.c) c_int { |
| 112 | var ap = @cVaStart(); | 112 | var ap = @cVaStart(); |
| 113 | defer @cVaEnd(&ap); | 113 | defer @cVaEnd(&ap); |
| 114 | return @cVaArg(&ap, c_int); | 114 | return @cVaArg(&ap, c_int); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | fn compatible(_: c_int, ...) callconv(.C) c_int { | 117 | fn compatible(_: c_int, ...) callconv(.c) c_int { |
| 118 | var ap = @cVaStart(); | 118 | var ap = @cVaStart(); |
| 119 | defer @cVaEnd(&ap); | 119 | defer @cVaEnd(&ap); |
| 120 | return @cVaArg(&ap, c_int); | 120 | return @cVaArg(&ap, c_int); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | fn add(count: c_int, ...) callconv(.C) c_int { | 123 | fn add(count: c_int, ...) callconv(.c) c_int { |
| 124 | var ap = @cVaStart(); | 124 | var ap = @cVaStart(); |
| 125 | defer @cVaEnd(&ap); | 125 | defer @cVaEnd(&ap); |
| 126 | var i: usize = 0; | 126 | var i: usize = 0; |
| ... | @@ -169,7 +169,7 @@ test "coerce reference to var arg" { | ... | @@ -169,7 +169,7 @@ test "coerce reference to var arg" { |
| 169 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 | 169 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 |
| 170 | 170 | ||
| 171 | const S = struct { | 171 | const S = struct { |
| 172 | fn addPtr(count: c_int, ...) callconv(.C) c_int { | 172 | fn addPtr(count: c_int, ...) callconv(.c) c_int { |
| 173 | var ap = @cVaStart(); | 173 | var ap = @cVaStart(); |
| 174 | defer @cVaEnd(&ap); | 174 | defer @cVaEnd(&ap); |
| 175 | var i: usize = 0; | 175 | var i: usize = 0; |
| ... | @@ -202,7 +202,7 @@ test "variadic functions" { | ... | @@ -202,7 +202,7 @@ test "variadic functions" { |
| 202 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 | 202 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 |
| 203 | 203 | ||
| 204 | const S = struct { | 204 | const S = struct { |
| 205 | fn printf(list_ptr: *std.ArrayList(u8), format: [*:0]const u8, ...) callconv(.C) void { | 205 | fn printf(list_ptr: *std.ArrayList(u8), format: [*:0]const u8, ...) callconv(.c) void { |
| 206 | var ap = @cVaStart(); | 206 | var ap = @cVaStart(); |
| 207 | defer @cVaEnd(&ap); | 207 | defer @cVaEnd(&ap); |
| 208 | vprintf(list_ptr, format, &ap); | 208 | vprintf(list_ptr, format, &ap); |
| ... | @@ -212,7 +212,7 @@ test "variadic functions" { | ... | @@ -212,7 +212,7 @@ test "variadic functions" { |
| 212 | list: *std.ArrayList(u8), | 212 | list: *std.ArrayList(u8), |
| 213 | format: [*:0]const u8, | 213 | format: [*:0]const u8, |
| 214 | ap: *std.builtin.VaList, | 214 | ap: *std.builtin.VaList, |
| 215 | ) callconv(.C) void { | 215 | ) callconv(.c) void { |
| 216 | for (std.mem.span(format)) |c| switch (c) { | 216 | for (std.mem.span(format)) |c| switch (c) { |
| 217 | 's' => { | 217 | 's' => { |
| 218 | const arg = @cVaArg(ap, [*:0]const u8); | 218 | const arg = @cVaArg(ap, [*:0]const u8); |
| ... | @@ -247,7 +247,7 @@ test "copy VaList" { | ... | @@ -247,7 +247,7 @@ test "copy VaList" { |
| 247 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 | 247 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 |
| 248 | 248 | ||
| 249 | const S = struct { | 249 | const S = struct { |
| 250 | fn add(count: c_int, ...) callconv(.C) c_int { | 250 | fn add(count: c_int, ...) callconv(.c) c_int { |
| 251 | var ap = @cVaStart(); | 251 | var ap = @cVaStart(); |
| 252 | defer @cVaEnd(&ap); | 252 | defer @cVaEnd(&ap); |
| 253 | var copy = @cVaCopy(&ap); | 253 | var copy = @cVaCopy(&ap); |
| ... | @@ -284,7 +284,7 @@ test "unused VaList arg" { | ... | @@ -284,7 +284,7 @@ test "unused VaList arg" { |
| 284 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 | 284 | if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350 |
| 285 | 285 | ||
| 286 | const S = struct { | 286 | const S = struct { |
| 287 | fn thirdArg(dummy: c_int, ...) callconv(.C) c_int { | 287 | fn thirdArg(dummy: c_int, ...) callconv(.c) c_int { |
| 288 | _ = dummy; | 288 | _ = dummy; |
| 289 | 289 | ||
| 290 | var ap = @cVaStart(); | 290 | var ap = @cVaStart(); |
test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig+1-1| ... | @@ -21,7 +21,7 @@ pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn { | ... | @@ -21,7 +21,7 @@ pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn { |
| 21 | 21 | ||
| 22 | pub fn isSingleItemPtr(comptime T: type) bool { | 22 | pub fn isSingleItemPtr(comptime T: type) bool { |
| 23 | if (comptime is(.pointer)(T)) { | 23 | if (comptime is(.pointer)(T)) { |
| 24 | return @typeInfo(T).pointer.size == .One; | 24 | return @typeInfo(T).pointer.size == .one; |
| 25 | } | 25 | } |
| 26 | return false; | 26 | return false; |
| 27 | } | 27 | } |
test/cases/compile_errors/invalid_pointer_with_reify_type.zig+2-4| ... | @@ -1,18 +1,16 @@ | ... | @@ -1,18 +1,16 @@ |
| 1 | export fn entry() void { | 1 | export fn entry() void { |
| 2 | _ = @Type(.{ .pointer = .{ | 2 | _ = @Type(.{ .pointer = .{ |
| 3 | .size = .One, | 3 | .size = .one, |
| 4 | .is_const = false, | 4 | .is_const = false, |
| 5 | .is_volatile = false, | 5 | .is_volatile = false, |
| 6 | .alignment = 1, | 6 | .alignment = 1, |
| 7 | .address_space = .generic, | 7 | .address_space = .generic, |
| 8 | .child = u8, | 8 | .child = u8, |
| 9 | .is_allowzero = false, | 9 | .is_allowzero = false, |
| 10 | .sentinel = &@as(u8, 0), | 10 | .sentinel_ptr = &@as(u8, 0), |
| 11 | } }); | 11 | } }); |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | // error | 14 | // error |
| 15 | // backend=stage2 | ||
| 16 | // target=native | ||
| 17 | // | 15 | // |
| 18 | // :2:9: error: sentinels are only allowed on slices and unknown-length pointers | 16 | // :2:9: error: sentinels are only allowed on slices and unknown-length pointers |
test/cases/compile_errors/non_scalar_sentinel.zig+5-5| ... | @@ -12,30 +12,30 @@ comptime { | ... | @@ -12,30 +12,30 @@ comptime { |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | comptime { | 14 | comptime { |
| 15 | _ = @Type(.{ .array = .{ .child = S, .len = 0, .sentinel = &sentinel } }); | 15 | _ = @Type(.{ .array = .{ .child = S, .len = 0, .sentinel_ptr = &sentinel } }); |
| 16 | } | 16 | } |
| 17 | comptime { | 17 | comptime { |
| 18 | _ = @Type(.{ .pointer = .{ | 18 | _ = @Type(.{ .pointer = .{ |
| 19 | .size = .Many, | 19 | .size = .slice, |
| 20 | .is_const = false, | 20 | .is_const = false, |
| 21 | .is_volatile = false, | 21 | .is_volatile = false, |
| 22 | .alignment = @alignOf(S), | 22 | .alignment = @alignOf(S), |
| 23 | .address_space = .generic, | 23 | .address_space = .generic, |
| 24 | .child = S, | 24 | .child = S, |
| 25 | .is_allowzero = false, | 25 | .is_allowzero = false, |
| 26 | .sentinel = &sentinel, | 26 | .sentinel_ptr = &sentinel, |
| 27 | } }); | 27 | } }); |
| 28 | } | 28 | } |
| 29 | comptime { | 29 | comptime { |
| 30 | _ = @Type(.{ .pointer = .{ | 30 | _ = @Type(.{ .pointer = .{ |
| 31 | .size = .Many, | 31 | .size = .many, |
| 32 | .is_const = false, | 32 | .is_const = false, |
| 33 | .is_volatile = false, | 33 | .is_volatile = false, |
| 34 | .alignment = @alignOf(S), | 34 | .alignment = @alignOf(S), |
| 35 | .address_space = .generic, | 35 | .address_space = .generic, |
| 36 | .child = S, | 36 | .child = S, |
| 37 | .is_allowzero = false, | 37 | .is_allowzero = false, |
| 38 | .sentinel = &sentinel, | 38 | .sentinel_ptr = &sentinel, |
| 39 | } }); | 39 | } }); |
| 40 | } | 40 | } |
| 41 | 41 |
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-3| ... | @@ -1,11 +1,9 @@ | ... | @@ -1,11 +1,9 @@ |
| 1 | export fn entry() void { | 1 | export fn entry() void { |
| 2 | _ = @Type(.{ .@"struct" = .{ .layout = .@"packed", .fields = &.{ | 2 | _ = @Type(.{ .@"struct" = .{ .layout = .@"packed", .fields = &.{ |
| 3 | .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 }, | 3 | .{ .name = "one", .type = u4, .default_value_ptr = null, .is_comptime = false, .alignment = 2 }, |
| 4 | }, .decls = &.{}, .is_tuple = false } }); | 4 | }, .decls = &.{}, .is_tuple = false } }); |
| 5 | } | 5 | } |
| 6 | 6 | ||
| 7 | // error | 7 | // error |
| 8 | // backend=stage2 | ||
| 9 | // target=native | ||
| 10 | // | 8 | // |
| 11 | // :2:9: error: alignment in a packed struct field must be set to 0 | 9 | // :2:9: error: alignment in a packed struct field must be set to 0 |
test/cases/compile_errors/reify_struct.zig+5-7| ... | @@ -4,7 +4,7 @@ comptime { | ... | @@ -4,7 +4,7 @@ comptime { |
| 4 | .fields = &.{.{ | 4 | .fields = &.{.{ |
| 5 | .name = "foo", | 5 | .name = "foo", |
| 6 | .type = u32, | 6 | .type = u32, |
| 7 | .default_value = null, | 7 | .default_value_ptr = null, |
| 8 | .is_comptime = false, | 8 | .is_comptime = false, |
| 9 | .alignment = 4, | 9 | .alignment = 4, |
| 10 | }}, | 10 | }}, |
| ... | @@ -18,7 +18,7 @@ comptime { | ... | @@ -18,7 +18,7 @@ comptime { |
| 18 | .fields = &.{.{ | 18 | .fields = &.{.{ |
| 19 | .name = "3", | 19 | .name = "3", |
| 20 | .type = u32, | 20 | .type = u32, |
| 21 | .default_value = null, | 21 | .default_value_ptr = null, |
| 22 | .is_comptime = false, | 22 | .is_comptime = false, |
| 23 | .alignment = 4, | 23 | .alignment = 4, |
| 24 | }}, | 24 | }}, |
| ... | @@ -32,7 +32,7 @@ comptime { | ... | @@ -32,7 +32,7 @@ comptime { |
| 32 | .fields = &.{.{ | 32 | .fields = &.{.{ |
| 33 | .name = "0", | 33 | .name = "0", |
| 34 | .type = u32, | 34 | .type = u32, |
| 35 | .default_value = null, | 35 | .default_value_ptr = null, |
| 36 | .is_comptime = true, | 36 | .is_comptime = true, |
| 37 | .alignment = 4, | 37 | .alignment = 4, |
| 38 | }}, | 38 | }}, |
| ... | @@ -46,7 +46,7 @@ comptime { | ... | @@ -46,7 +46,7 @@ comptime { |
| 46 | .fields = &.{.{ | 46 | .fields = &.{.{ |
| 47 | .name = "0", | 47 | .name = "0", |
| 48 | .type = u32, | 48 | .type = u32, |
| 49 | .default_value = null, | 49 | .default_value_ptr = null, |
| 50 | .is_comptime = true, | 50 | .is_comptime = true, |
| 51 | .alignment = 4, | 51 | .alignment = 4, |
| 52 | }}, | 52 | }}, |
| ... | @@ -60,7 +60,7 @@ comptime { | ... | @@ -60,7 +60,7 @@ comptime { |
| 60 | .fields = &.{.{ | 60 | .fields = &.{.{ |
| 61 | .name = "0", | 61 | .name = "0", |
| 62 | .type = u32, | 62 | .type = u32, |
| 63 | .default_value = null, | 63 | .default_value_ptr = null, |
| 64 | .is_comptime = true, | 64 | .is_comptime = true, |
| 65 | .alignment = 4, | 65 | .alignment = 4, |
| 66 | }}, | 66 | }}, |
| ... | @@ -70,8 +70,6 @@ comptime { | ... | @@ -70,8 +70,6 @@ comptime { |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | // error | 72 | // error |
| 73 | // backend=stage2 | ||
| 74 | // target=native | ||
| 75 | // | 73 | // |
| 76 | // :2:5: error: tuple cannot have non-numeric field 'foo' | 74 | // :2:5: error: tuple cannot have non-numeric field 'foo' |
| 77 | // :16:5: error: tuple field name '3' does not match field index 0 | 75 | // :16:5: error: tuple field name '3' does not match field index 0 |
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig+3-5| ... | @@ -17,7 +17,7 @@ comptime { | ... | @@ -17,7 +17,7 @@ comptime { |
| 17 | .fields = &.{.{ | 17 | .fields = &.{.{ |
| 18 | .name = "0", | 18 | .name = "0", |
| 19 | .type = u32, | 19 | .type = u32, |
| 20 | .default_value = null, | 20 | .default_value_ptr = null, |
| 21 | .is_comptime = true, | 21 | .is_comptime = true, |
| 22 | .alignment = 5, | 22 | .alignment = 5, |
| 23 | }}, | 23 | }}, |
| ... | @@ -29,21 +29,19 @@ comptime { | ... | @@ -29,21 +29,19 @@ comptime { |
| 29 | comptime { | 29 | comptime { |
| 30 | _ = @Type(.{ | 30 | _ = @Type(.{ |
| 31 | .pointer = .{ | 31 | .pointer = .{ |
| 32 | .size = .Many, | 32 | .size = .many, |
| 33 | .is_const = true, | 33 | .is_const = true, |
| 34 | .is_volatile = false, | 34 | .is_volatile = false, |
| 35 | .alignment = 7, | 35 | .alignment = 7, |
| 36 | .address_space = .generic, | 36 | .address_space = .generic, |
| 37 | .child = u8, | 37 | .child = u8, |
| 38 | .is_allowzero = false, | 38 | .is_allowzero = false, |
| 39 | .sentinel = null, | 39 | .sentinel_ptr = null, |
| 40 | }, | 40 | }, |
| 41 | }); | 41 | }); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | // error | 44 | // error |
| 45 | // backend=stage2 | ||
| 46 | // target=native | ||
| 47 | // | 45 | // |
| 48 | // :2:9: error: alignment value '3' is not a power of two or zero | 46 | // :2:9: error: alignment value '3' is not a power of two or zero |
| 49 | // :14:9: error: alignment value '5' is not a power of two or zero | 47 | // :14:9: error: alignment value '5' is not a power of two or zero |
test/cases/compile_errors/reify_type_with_undefined.zig+1-1| ... | @@ -1,5 +1,5 @@ | ... | @@ -1,5 +1,5 @@ |
| 1 | comptime { | 1 | comptime { |
| 2 | _ = @Type(.{ .array = .{ .len = 0, .child = u8, .sentinel = undefined } }); | 2 | _ = @Type(.{ .array = .{ .len = 0, .child = u8, .sentinel_ptr = undefined } }); |
| 3 | } | 3 | } |
| 4 | comptime { | 4 | comptime { |
| 5 | _ = @Type(.{ | 5 | _ = @Type(.{ |