| author | |
| committer | |
| log | 242bb4469547c322081ad15a84019486aedbc74d |
| tree | 0b416f181051c9d842b7a33e9eba137b5225d17c |
| parent | f857bf72e2239718bbbe4cba08d6961ad77fc69a |
| signature | Commit is signed but in an unrecognized format. |
Just a small refactor.3 files changed, 13 insertions(+), 17 deletions(-)
src/InternPool.zig-12| ... | ... | @@ -1462,16 +1462,6 @@ pub const MapIndex = enum(u32) { |
| 1462 | 1462 | } |
| 1463 | 1463 | }; |
| 1464 | 1464 | |
| 1465 | pub const RuntimeIndex = enum(u32) { | |
| 1466 | zero = 0, | |
| 1467 | comptime_field_ptr = std.math.maxInt(u32), | |
| 1468 | _, | |
| 1469 | ||
| 1470 | pub fn increment(ri: *RuntimeIndex) void { | |
| 1471 | ri.* = @enumFromInt(@intFromEnum(ri.*) + 1); | |
| 1472 | } | |
| 1473 | }; | |
| 1474 | ||
| 1475 | 1465 | pub const ComptimeAllocIndex = enum(u32) { _ }; |
| 1476 | 1466 | |
| 1477 | 1467 | pub const NamespaceIndex = enum(u32) { |
| ... | ... | @@ -9788,7 +9778,6 @@ fn addExtraAssumeCapacity(extra: Local.Extra.Mutable, item: anytype) u32 { |
| 9788 | 9778 | OptionalNamespaceIndex, |
| 9789 | 9779 | MapIndex, |
| 9790 | 9780 | OptionalMapIndex, |
| 9791 | RuntimeIndex, | |
| 9792 | 9781 | String, |
| 9793 | 9782 | NullTerminatedString, |
| 9794 | 9783 | OptionalNullTerminatedString, |
| ... | ... | @@ -9852,7 +9841,6 @@ fn extraDataTrail(extra: Local.Extra, comptime T: type, index: u32) struct { dat |
| 9852 | 9841 | OptionalNamespaceIndex, |
| 9853 | 9842 | MapIndex, |
| 9854 | 9843 | OptionalMapIndex, |
| 9855 | RuntimeIndex, | |
| 9856 | 9844 | String, |
| 9857 | 9845 | NullTerminatedString, |
| 9858 | 9846 | OptionalNullTerminatedString, |
src/Sema.zig+13-3| ... | ... | @@ -122,9 +122,19 @@ allow_memoize: bool = true, |
| 122 | 122 | /// This state is on `Sema` so that `cold` hints can be propagated up through blocks with less special handling. |
| 123 | 123 | branch_hint: ?std.builtin.BranchHint = null, |
| 124 | 124 | |
| 125 | const RuntimeIndex = enum(u32) { | |
| 126 | zero = 0, | |
| 127 | comptime_field_ptr = std.math.maxInt(u32), | |
| 128 | _, | |
| 129 | ||
| 130 | pub fn increment(ri: *RuntimeIndex) void { | |
| 131 | ri.* = @enumFromInt(@intFromEnum(ri.*) + 1); | |
| 132 | } | |
| 133 | }; | |
| 134 | ||
| 125 | 135 | const MaybeComptimeAlloc = struct { |
| 126 | 136 | /// The runtime index of the `alloc` instruction. |
| 127 | runtime_index: Value.RuntimeIndex, | |
| 137 | runtime_index: RuntimeIndex, | |
| 128 | 138 | /// Backed by sema.arena. Tracks all comptime-known stores to this `alloc`. Due to |
| 129 | 139 | /// RLS, a single comptime-known allocation may have arbitrarily many stores. |
| 130 | 140 | /// This list also contains `set_union_tag`, `optional_payload_ptr_set`, and |
| ... | ... | @@ -144,7 +154,7 @@ const ComptimeAlloc = struct { |
| 144 | 154 | /// This is the `runtime_index` at the point of this allocation. If an store |
| 145 | 155 | /// to this alloc ever occurs with a runtime index greater than this one, it |
| 146 | 156 | /// is behind a runtime condition, so a compile error will be emitted. |
| 147 | runtime_index: Value.RuntimeIndex, | |
| 157 | runtime_index: RuntimeIndex, | |
| 148 | 158 | }; |
| 149 | 159 | |
| 150 | 160 | fn newComptimeAlloc(sema: *Sema, block: *Block, ty: Type, alignment: Alignment) !ComptimeAllocIndex { |
| ... | ... | @@ -364,7 +374,7 @@ pub const Block = struct { |
| 364 | 374 | runtime_loop: ?LazySrcLoc = null, |
| 365 | 375 | /// Non zero if a non-inline loop or a runtime conditional have been encountered. |
| 366 | 376 | /// Stores to comptime variables are only allowed when var.runtime_index <= runtime_index. |
| 367 | runtime_index: Value.RuntimeIndex = .zero, | |
| 377 | runtime_index: RuntimeIndex = .zero, | |
| 368 | 378 | inline_block: Zir.Inst.OptionalIndex = .none, |
| 369 | 379 | |
| 370 | 380 | comptime_reason: ?*const ComptimeReason = null, |
src/Value.zig-2| ... | ... | @@ -3710,8 +3710,6 @@ pub fn makeBool(x: bool) Value { |
| 3710 | 3710 | return if (x) Value.true else Value.false; |
| 3711 | 3711 | } |
| 3712 | 3712 | |
| 3713 | pub const RuntimeIndex = InternPool.RuntimeIndex; | |
| 3714 | ||
| 3715 | 3713 | /// `parent_ptr` must be a single-pointer to some optional. |
| 3716 | 3714 | /// Returns a pointer to the payload of the optional. |
| 3717 | 3715 | /// May perform type resolution. |