aboutsummaryrefslogtreecommitdiff
path: root/src/Sema
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-08-28 02:35:53 +0100
committermlugg <mlugg@mlugg.co.uk>2024-08-28 08:39:59 +0100
commit0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9 (patch)
tree2c07fddf2b6230360fe618c4de192bc2d24eeaf7 /src/Sema
parent1a178d499537b922ff05c5d0186ed5a00dbb1a9b (diff)
downloadzig-0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9.tar.gz
zig-0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9.zip
std: update `std.builtin.Type` fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
Diffstat (limited to 'src/Sema')
-rw-r--r--src/Sema/bitcast.zig14
-rw-r--r--src/Sema/comptime_ptr_access.zig128
2 files changed, 71 insertions, 71 deletions
diff --git a/src/Sema/bitcast.zig b/src/Sema/bitcast.zig
index 04229532fc..d3adbe7eb8 100644
--- a/src/Sema/bitcast.zig
+++ b/src/Sema/bitcast.zig
@@ -274,7 +274,7 @@ const UnpackValueBits = struct {
=> try unpack.primitive(val),
.aggregate => switch (ty.zigTypeTag(zcu)) {
- .Vector => {
+ .vector => {
const len: usize = @intCast(ty.arrayLen(zcu));
for (0..len) |i| {
// We reverse vector elements in packed memory on BE targets.
@@ -286,7 +286,7 @@ const UnpackValueBits = struct {
try unpack.add(elem_val);
}
},
- .Array => {
+ .array => {
// Each element is padded up to its ABI size. Padding bits are undefined.
// The final element does not have trailing padding.
// Elements are reversed in packed memory on BE targets.
@@ -316,7 +316,7 @@ const UnpackValueBits = struct {
try unpack.add(s);
};
},
- .Struct => switch (ty.containerLayout(zcu)) {
+ .@"struct" => switch (ty.containerLayout(zcu)) {
.auto => unreachable, // ill-defined layout
.@"extern" => switch (endian) {
.little => {
@@ -473,7 +473,7 @@ const PackValueBits = struct {
const ip = &zcu.intern_pool;
const arena = pack.arena;
switch (ty.zigTypeTag(zcu)) {
- .Vector => {
+ .vector => {
// Elements are bit-packed.
const len = ty.arrayLen(zcu);
const elem_ty = ty.childType(zcu);
@@ -496,7 +496,7 @@ const PackValueBits = struct {
.storage = .{ .elems = elems },
} }));
},
- .Array => {
+ .array => {
// Each element is padded up to its ABI size. The final element does not have trailing padding.
const len = ty.arrayLen(zcu);
const elem_ty = ty.childType(zcu);
@@ -530,7 +530,7 @@ const PackValueBits = struct {
.storage = .{ .elems = elems },
} }));
},
- .Struct => switch (ty.containerLayout(zcu)) {
+ .@"struct" => switch (ty.containerLayout(zcu)) {
.auto => unreachable, // ill-defined layout
.@"extern" => {
const elems = try arena.alloc(InternPool.Index, ty.structFieldCount(zcu));
@@ -587,7 +587,7 @@ const PackValueBits = struct {
} }));
},
},
- .Union => {
+ .@"union" => {
// We will attempt to read as the backing representation. If this emits
// `error.ReinterpretDeclRef`, we will try each union field, preferring larger ones.
// We will also attempt smaller fields when we get `undefined`, as if some bits are
diff --git a/src/Sema/comptime_ptr_access.zig b/src/Sema/comptime_ptr_access.zig
index 893ea6db36..10e81d7a9e 100644
--- a/src/Sema/comptime_ptr_access.zig
+++ b/src/Sema/comptime_ptr_access.zig
@@ -226,7 +226,7 @@ fn loadComptimePtrInner(
.variable => return .runtime_load,
// We let `.@"extern"` through here if it's a function.
// This allows you to alias `extern fn`s.
- .@"extern" => |e| if (Type.fromInterned(e.ty).zigTypeTag(zcu) == .Fn)
+ .@"extern" => |e| if (Type.fromInterned(e.ty).zigTypeTag(zcu) == .@"fn")
break :val .{ .interned = val }
else
return .runtime_load,
@@ -296,8 +296,8 @@ fn loadComptimePtrInner(
const agg_ty = agg_val.typeOf(zcu);
switch (agg_ty.zigTypeTag(zcu)) {
- .Struct, .Pointer => break :val try agg_val.getElem(sema.pt, @intCast(base_index.index)),
- .Union => {
+ .@"struct", .pointer => break :val try agg_val.getElem(sema.pt, @intCast(base_index.index)),
+ .@"union" => {
const tag_val: Value, const payload_mv: MutableValue = switch (agg_val) {
.un => |un| .{ Value.fromInterned(un.tag), un.payload.* },
.interned => |ip_index| switch (ip.indexToKey(ip_index)) {
@@ -321,7 +321,7 @@ fn loadComptimePtrInner(
};
if (ptr.byte_offset == 0 and host_bits == 0) {
- if (load_ty.zigTypeTag(zcu) != .Array or array_offset == 0) {
+ if (load_ty.zigTypeTag(zcu) != .array or array_offset == 0) {
if (.ok == try sema.coerceInMemoryAllowed(
block,
load_ty,
@@ -366,7 +366,7 @@ fn loadComptimePtrInner(
null,
)) {
// Changing the length of an array.
- const skip_base: u64 = extra_base_index + if (load_ty.zigTypeTag(zcu) == .Array) skip: {
+ const skip_base: u64 = extra_base_index + if (load_ty.zigTypeTag(zcu) == .array) skip: {
break :skip load_ty.childType(zcu).arrayBase(zcu)[1] * array_offset;
} else 0;
if (skip_base + load_count > val_count) return .{ .out_of_bounds = base_val.typeOf(zcu) };
@@ -394,7 +394,7 @@ fn loadComptimePtrInner(
var cur_val = base_val;
var cur_offset = ptr.byte_offset;
- if (load_ty.zigTypeTag(zcu) == .Array and array_offset > 0) {
+ if (load_ty.zigTypeTag(zcu) == .array and array_offset > 0) {
cur_offset += try load_ty.childType(zcu).abiSizeSema(pt) * array_offset;
}
@@ -410,30 +410,30 @@ fn loadComptimePtrInner(
while (true) {
const cur_ty = cur_val.typeOf(zcu);
switch (cur_ty.zigTypeTag(zcu)) {
- .NoReturn,
- .Type,
- .ComptimeInt,
- .ComptimeFloat,
- .Null,
- .Undefined,
- .EnumLiteral,
- .Opaque,
- .Fn,
- .ErrorUnion,
+ .noreturn,
+ .type,
+ .comptime_int,
+ .comptime_float,
+ .null,
+ .undefined,
+ .enum_literal,
+ .@"opaque",
+ .@"fn",
+ .error_union,
=> unreachable, // ill-defined layout
- .Int,
- .Float,
- .Bool,
- .Void,
- .Pointer,
- .ErrorSet,
- .AnyFrame,
- .Frame,
- .Enum,
- .Vector,
+ .int,
+ .float,
+ .bool,
+ .void,
+ .pointer,
+ .error_set,
+ .@"anyframe",
+ .frame,
+ .@"enum",
+ .vector,
=> break, // terminal types (no sub-values)
- .Optional => break, // this can only be a pointer-like optional so is terminal
- .Array => {
+ .optional => break, // this can only be a pointer-like optional so is terminal
+ .array => {
const elem_ty = cur_ty.childType(zcu);
const elem_size = try elem_ty.abiSizeSema(pt);
const elem_idx = cur_offset / elem_size;
@@ -446,7 +446,7 @@ fn loadComptimePtrInner(
break;
}
},
- .Struct => switch (cur_ty.containerLayout(zcu)) {
+ .@"struct" => switch (cur_ty.containerLayout(zcu)) {
.auto => unreachable, // ill-defined layout
.@"packed" => break, // let the bitcast logic handle this
.@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| {
@@ -459,7 +459,7 @@ fn loadComptimePtrInner(
}
} else break, // pointer spans multiple fields
},
- .Union => switch (cur_ty.containerLayout(zcu)) {
+ .@"union" => switch (cur_ty.containerLayout(zcu)) {
.auto => unreachable, // ill-defined layout
.@"packed" => break, // let the bitcast logic handle this
.@"extern" => {
@@ -692,11 +692,11 @@ fn prepareComptimePtrStore(
const agg_ty = agg_val.typeOf(zcu);
switch (agg_ty.zigTypeTag(zcu)) {
- .Struct, .Pointer => break :strat .{ .direct = .{
+ .@"struct", .pointer => break :strat .{ .direct = .{
.val = try agg_val.elem(pt, sema.arena, @intCast(base_index.index)),
.alloc = alloc,
} },
- .Union => {
+ .@"union" => {
if (agg_val.* == .interned and Value.fromInterned(agg_val.interned).isUndef(zcu)) {
return .undef;
}
@@ -717,7 +717,7 @@ fn prepareComptimePtrStore(
};
if (ptr.byte_offset == 0) {
- if (store_ty.zigTypeTag(zcu) != .Array or array_offset == 0) direct: {
+ if (store_ty.zigTypeTag(zcu) != .array or array_offset == 0) direct: {
const base_val_ty = switch (base_strat) {
.direct => |direct| direct.val.typeOf(zcu),
.index => |index| index.val.typeOf(zcu).childType(zcu),
@@ -770,7 +770,7 @@ fn prepareComptimePtrStore(
}
if (base_elem_offset + extra_base_index + store_count > val_count) return .{ .out_of_bounds = oob_ty };
- if (store_ty.zigTypeTag(zcu) == .Array) {
+ if (store_ty.zigTypeTag(zcu) == .array) {
const skip = store_ty.childType(zcu).arrayBase(zcu)[1] * array_offset;
return .{ .flat_index = .{
.alloc = base_strat.alloc(),
@@ -780,7 +780,7 @@ fn prepareComptimePtrStore(
}
// `base_val` must be an array, since otherwise the "direct reinterpret" logic above noticed it.
- assert(base_val.typeOf(zcu).zigTypeTag(zcu) == .Array);
+ assert(base_val.typeOf(zcu).zigTypeTag(zcu) == .array);
var index: u64 = base_elem_offset + extra_base_index;
const arr_val, const arr_index = (try recursiveIndex(sema, base_val, &index)).?;
@@ -816,7 +816,7 @@ fn prepareComptimePtrStore(
return .{ .needed_well_defined = cur_val.typeOf(zcu) };
}
- if (store_ty.zigTypeTag(zcu) == .Array and array_offset > 0) {
+ if (store_ty.zigTypeTag(zcu) == .array and array_offset > 0) {
cur_offset += try store_ty.childType(zcu).abiSizeSema(pt) * array_offset;
}
@@ -832,30 +832,30 @@ fn prepareComptimePtrStore(
while (true) {
const cur_ty = cur_val.typeOf(zcu);
switch (cur_ty.zigTypeTag(zcu)) {
- .NoReturn,
- .Type,
- .ComptimeInt,
- .ComptimeFloat,
- .Null,
- .Undefined,
- .EnumLiteral,
- .Opaque,
- .Fn,
- .ErrorUnion,
+ .noreturn,
+ .type,
+ .comptime_int,
+ .comptime_float,
+ .null,
+ .undefined,
+ .enum_literal,
+ .@"opaque",
+ .@"fn",
+ .error_union,
=> unreachable, // ill-defined layout
- .Int,
- .Float,
- .Bool,
- .Void,
- .Pointer,
- .ErrorSet,
- .AnyFrame,
- .Frame,
- .Enum,
- .Vector,
+ .int,
+ .float,
+ .bool,
+ .void,
+ .pointer,
+ .error_set,
+ .@"anyframe",
+ .frame,
+ .@"enum",
+ .vector,
=> break, // terminal types (no sub-values)
- .Optional => break, // this can only be a pointer-like optional so is terminal
- .Array => {
+ .optional => break, // this can only be a pointer-like optional so is terminal
+ .array => {
const elem_ty = cur_ty.childType(zcu);
const elem_size = try elem_ty.abiSizeSema(pt);
const elem_idx = cur_offset / elem_size;
@@ -868,7 +868,7 @@ fn prepareComptimePtrStore(
break;
}
},
- .Struct => switch (cur_ty.containerLayout(zcu)) {
+ .@"struct" => switch (cur_ty.containerLayout(zcu)) {
.auto => unreachable, // ill-defined layout
.@"packed" => break, // let the bitcast logic handle this
.@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| {
@@ -881,7 +881,7 @@ fn prepareComptimePtrStore(
}
} else break, // pointer spans multiple fields
},
- .Union => switch (cur_ty.containerLayout(zcu)) {
+ .@"union" => switch (cur_ty.containerLayout(zcu)) {
.auto => unreachable, // ill-defined layout
.@"packed" => break, // let the bitcast logic handle this
.@"extern" => {
@@ -942,7 +942,7 @@ fn flattenArray(
return;
}
- if (ty.zigTypeTag(zcu) != .Array) {
+ if (ty.zigTypeTag(zcu) != .array) {
out[@intCast(next_idx.*)] = (try val.intern(sema.pt, sema.arena)).toIntern();
next_idx.* += 1;
return;
@@ -975,7 +975,7 @@ fn unflattenArray(
const zcu = sema.pt.zcu;
const arena = sema.arena;
- if (ty.zigTypeTag(zcu) != .Array) {
+ if (ty.zigTypeTag(zcu) != .array) {
const val = Value.fromInterned(elems[@intCast(next_idx.*)]);
next_idx.* += 1;
return sema.pt.getCoerced(val, ty);
@@ -1008,7 +1008,7 @@ fn recursiveIndex(
const pt = sema.pt;
const ty = mv.typeOf(pt.zcu);
- assert(ty.zigTypeTag(pt.zcu) == .Array);
+ assert(ty.zigTypeTag(pt.zcu) == .array);
const ty_base_elems = ty.arrayBase(pt.zcu)[1];
if (index.* >= ty_base_elems) {
@@ -1017,7 +1017,7 @@ fn recursiveIndex(
}
const elem_ty = ty.childType(pt.zcu);
- if (elem_ty.zigTypeTag(pt.zcu) != .Array) {
+ if (elem_ty.zigTypeTag(pt.zcu) != .array) {
assert(index.* < ty.arrayLenIncludingSentinel(pt.zcu)); // should be handled by initial check
return .{ mv, index.* };
}