diff options
| author | Tristan Ross <tristan.ross@midstall.com> | 2024-02-18 18:28:39 -0800 |
|---|---|---|
| committer | Tristan Ross <tristan.ross@midstall.com> | 2024-03-11 07:09:07 -0700 |
| commit | 099f3c4039d5702b073639ef8b55881973b71c80 (patch) | |
| tree | 2be1bb7abc86fb4c9148b82314718eac6a01e895 /src/Value.zig | |
| parent | d0c06ca7127110a8afeb0ef524a197049892db21 (diff) | |
| download | zig-099f3c4039d5702b073639ef8b55881973b71c80.tar.gz zig-099f3c4039d5702b073639ef8b55881973b71c80.zip | |
std.builtin: make container layout fields lowercase
Diffstat (limited to 'src/Value.zig')
| -rw-r--r-- | src/Value.zig | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/Value.zig b/src/Value.zig index 3468ae4f10..a9f80635c7 100644 --- a/src/Value.zig +++ b/src/Value.zig @@ -676,8 +676,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ .Struct => { const struct_type = mod.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout; switch (struct_type.layout) { - .Auto => return error.IllDefinedMemoryLayout, - .Extern => for (0..struct_type.field_types.len) |i| { + .auto => return error.IllDefinedMemoryLayout, + .@"extern" => for (0..struct_type.field_types.len) |i| { const off: usize = @intCast(ty.structFieldOffset(i, mod)); const field_val = switch (val.ip_index) { .none => switch (val.tag()) { @@ -701,7 +701,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); try writeToMemory(field_val, field_ty, mod, buffer[off..]); }, - .Packed => { + .@"packed" => { const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0); }, @@ -724,8 +724,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ bigint.writeTwosComplement(buffer[0..byte_count], endian); }, .Union => switch (ty.containerLayout(mod)) { - .Auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already - .Extern => { + .auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already + .@"extern" => { if (val.unionTag(mod)) |union_tag| { const union_obj = mod.typeToUnion(ty).?; const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?; @@ -739,7 +739,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ return writeToMemory(val.unionValue(mod), backing_ty, mod, buffer[0..byte_count]); } }, - .Packed => { + .@"packed" => { const backing_ty = try ty.unionBackingType(mod); const byte_count: usize = @intCast(backing_ty.abiSize(mod)); return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0); @@ -841,7 +841,7 @@ pub fn writeToPackedMemory( const struct_type = ip.loadStructType(ty.toIntern()); // Sema is supposed to have emitted a compile error already in the case of Auto, // and Extern is handled in non-packed writeToMemory. - assert(struct_type.layout == .Packed); + assert(struct_type.layout == .@"packed"); var bits: u16 = 0; for (0..struct_type.field_types.len) |i| { const field_val = switch (val.ip_index) { @@ -866,8 +866,8 @@ pub fn writeToPackedMemory( .Union => { const union_obj = mod.typeToUnion(ty).?; switch (union_obj.getLayout(ip)) { - .Auto, .Extern => unreachable, // Handled in non-packed writeToMemory - .Packed => { + .auto, .@"extern" => unreachable, // Handled in non-packed writeToMemory + .@"packed" => { if (val.unionTag(mod)) |union_tag| { const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?; const field_type = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); @@ -991,8 +991,8 @@ pub fn readFromMemory( .Struct => { const struct_type = mod.typeToStruct(ty).?; switch (struct_type.layout) { - .Auto => unreachable, // Sema is supposed to have emitted a compile error already - .Extern => { + .auto => unreachable, // Sema is supposed to have emitted a compile error already + .@"extern" => { const field_types = struct_type.field_types; const field_vals = try arena.alloc(InternPool.Index, field_types.len); for (field_vals, 0..) |*field_val, i| { @@ -1006,7 +1006,7 @@ pub fn readFromMemory( .storage = .{ .elems = field_vals }, } }))); }, - .Packed => { + .@"packed" => { const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena); }, @@ -1025,8 +1025,8 @@ pub fn readFromMemory( } }))); }, .Union => switch (ty.containerLayout(mod)) { - .Auto => return error.IllDefinedMemoryLayout, - .Extern => { + .auto => return error.IllDefinedMemoryLayout, + .@"extern" => { const union_size = ty.abiSize(mod); const array_ty = try mod.arrayType(.{ .len = union_size, .child = .u8_type }); const val = try (try readFromMemory(array_ty, mod, buffer, arena)).intern(array_ty, mod); @@ -1036,7 +1036,7 @@ pub fn readFromMemory( .val = val, } }))); }, - .Packed => { + .@"packed" => { const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena); }, @@ -1177,8 +1177,8 @@ pub fn readFromPackedMemory( } }))); }, .Union => switch (ty.containerLayout(mod)) { - .Auto, .Extern => unreachable, // Handled by non-packed readFromMemory - .Packed => { + .auto, .@"extern" => unreachable, // Handled by non-packed readFromMemory + .@"packed" => { const backing_ty = try ty.unionBackingType(mod); const val = (try readFromPackedMemory(backing_ty, mod, buffer, bit_offset, arena)).toIntern(); return Value.fromInterned((try mod.intern(.{ .un = .{ @@ -4064,7 +4064,7 @@ fn dbHelper(self: *Value, tag_to_payload_map: *map: { .alignment = 0, }; break :map @Type(.{ .Struct = .{ - .layout = .Extern, + .layout = .@"extern", .fields = &fields, .decls = &.{}, .is_tuple = false, |
