| author | |
| committer | |
| log | 63604024f47767b7b0c0deba5c9647cd6c040931 |
| tree | 1233623946564f1cc87d34705f9fa02d1e2c8014 |
| parent | 2afc689060e1d14e039f3c439d42f22ba09768a3 |
6 files changed, 28 insertions(+), 24 deletions(-)
src/InternPool.zig+6-6| ... | ... | @@ -3824,13 +3824,13 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { |
| 3824 | 3824 | assert(child == .u8_type); |
| 3825 | 3825 | if (bytes.len != len) { |
| 3826 | 3826 | assert(bytes.len == len_including_sentinel); |
| 3827 | assert(bytes[len] == ip.indexToKey(sentinel).int.storage.u64); | |
| 3827 | assert(bytes[@intCast(usize, len)] == ip.indexToKey(sentinel).int.storage.u64); | |
| 3828 | 3828 | } |
| 3829 | 3829 | }, |
| 3830 | 3830 | .elems => |elems| { |
| 3831 | 3831 | if (elems.len != len) { |
| 3832 | 3832 | assert(elems.len == len_including_sentinel); |
| 3833 | assert(elems[len] == sentinel); | |
| 3833 | assert(elems[@intCast(usize, len)] == sentinel); | |
| 3834 | 3834 | } |
| 3835 | 3835 | }, |
| 3836 | 3836 | .repeated_elem => |elem| { |
| ... | ... | @@ -3936,7 +3936,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { |
| 3936 | 3936 | |
| 3937 | 3937 | if (child == .u8_type) bytes: { |
| 3938 | 3938 | const string_bytes_index = ip.string_bytes.items.len; |
| 3939 | try ip.string_bytes.ensureUnusedCapacity(gpa, len_including_sentinel + 1); | |
| 3939 | try ip.string_bytes.ensureUnusedCapacity(gpa, @intCast(usize, len_including_sentinel + 1)); | |
| 3940 | 3940 | try ip.extra.ensureUnusedCapacity(gpa, @typeInfo(Bytes).Struct.fields.len); |
| 3941 | 3941 | switch (aggregate.storage) { |
| 3942 | 3942 | .bytes => |bytes| ip.string_bytes.appendSliceAssumeCapacity(bytes), |
| ... | ... | @@ -3953,7 +3953,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { |
| 3953 | 3953 | .repeated_elem => |elem| switch (ip.indexToKey(elem)) { |
| 3954 | 3954 | .undef => break :bytes, |
| 3955 | 3955 | .int => |int| @memset( |
| 3956 | ip.string_bytes.addManyAsSliceAssumeCapacity(len), | |
| 3956 | ip.string_bytes.addManyAsSliceAssumeCapacity(@intCast(usize, len)), | |
| 3957 | 3957 | @intCast(u8, int.storage.u64), |
| 3958 | 3958 | ), |
| 3959 | 3959 | else => unreachable, |
| ... | ... | @@ -3967,7 +3967,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { |
| 3967 | 3967 | const string = if (has_internal_null) |
| 3968 | 3968 | @intToEnum(String, string_bytes_index) |
| 3969 | 3969 | else |
| 3970 | (try ip.getOrPutTrailingString(gpa, len_including_sentinel)).toString(); | |
| 3970 | (try ip.getOrPutTrailingString(gpa, @intCast(usize, len_including_sentinel))).toString(); | |
| 3971 | 3971 | ip.items.appendAssumeCapacity(.{ |
| 3972 | 3972 | .tag = .bytes, |
| 3973 | 3973 | .data = ip.addExtraAssumeCapacity(Bytes{ |
| ... | ... | @@ -3980,7 +3980,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { |
| 3980 | 3980 | |
| 3981 | 3981 | try ip.extra.ensureUnusedCapacity( |
| 3982 | 3982 | gpa, |
| 3983 | @typeInfo(Tag.Aggregate).Struct.fields.len + len_including_sentinel, | |
| 3983 | @typeInfo(Tag.Aggregate).Struct.fields.len + @intCast(usize, len_including_sentinel), | |
| 3984 | 3984 | ); |
| 3985 | 3985 | ip.items.appendAssumeCapacity(.{ |
| 3986 | 3986 | .tag = .aggregate, |
src/Sema.zig+11-8| ... | ... | @@ -28186,11 +28186,12 @@ fn beginComptimePtrMutation( |
| 28186 | 28186 | const elem_abi_size_u64 = try sema.typeAbiSize(base_elem_ty); |
| 28187 | 28187 | if (elem_abi_size_u64 < try sema.typeAbiSize(ptr_elem_ty)) { |
| 28188 | 28188 | const elem_abi_size = try sema.usizeCast(block, src, elem_abi_size_u64); |
| 28189 | const elem_idx = try sema.usizeCast(block, src, elem_ptr.index); | |
| 28189 | 28190 | return .{ |
| 28190 | 28191 | .mut_decl = parent.mut_decl, |
| 28191 | 28192 | .pointee = .{ .reinterpret = .{ |
| 28192 | 28193 | .val_ptr = val_ptr, |
| 28193 | .byte_offset = elem_abi_size * elem_ptr.index, | |
| 28194 | .byte_offset = elem_abi_size * elem_idx, | |
| 28194 | 28195 | } }, |
| 28195 | 28196 | .ty = parent.ty, |
| 28196 | 28197 | }; |
| ... | ... | @@ -28223,7 +28224,7 @@ fn beginComptimePtrMutation( |
| 28223 | 28224 | block, |
| 28224 | 28225 | src, |
| 28225 | 28226 | elem_ty, |
| 28226 | &elems[elem_ptr.index], | |
| 28227 | &elems[@intCast(usize, elem_ptr.index)], | |
| 28227 | 28228 | ptr_elem_ty, |
| 28228 | 28229 | parent.mut_decl, |
| 28229 | 28230 | ); |
| ... | ... | @@ -28254,7 +28255,7 @@ fn beginComptimePtrMutation( |
| 28254 | 28255 | block, |
| 28255 | 28256 | src, |
| 28256 | 28257 | elem_ty, |
| 28257 | &elems[elem_ptr.index], | |
| 28258 | &elems[@intCast(usize, elem_ptr.index)], | |
| 28258 | 28259 | ptr_elem_ty, |
| 28259 | 28260 | parent.mut_decl, |
| 28260 | 28261 | ); |
| ... | ... | @@ -28265,7 +28266,7 @@ fn beginComptimePtrMutation( |
| 28265 | 28266 | block, |
| 28266 | 28267 | src, |
| 28267 | 28268 | elem_ty, |
| 28268 | &val_ptr.castTag(.aggregate).?.data[elem_ptr.index], | |
| 28269 | &val_ptr.castTag(.aggregate).?.data[@intCast(usize, elem_ptr.index)], | |
| 28269 | 28270 | ptr_elem_ty, |
| 28270 | 28271 | parent.mut_decl, |
| 28271 | 28272 | ), |
| ... | ... | @@ -28291,7 +28292,7 @@ fn beginComptimePtrMutation( |
| 28291 | 28292 | block, |
| 28292 | 28293 | src, |
| 28293 | 28294 | elem_ty, |
| 28294 | &elems[elem_ptr.index], | |
| 28295 | &elems[@intCast(usize, elem_ptr.index)], | |
| 28295 | 28296 | ptr_elem_ty, |
| 28296 | 28297 | parent.mut_decl, |
| 28297 | 28298 | ); |
| ... | ... | @@ -28331,11 +28332,12 @@ fn beginComptimePtrMutation( |
| 28331 | 28332 | |
| 28332 | 28333 | const elem_abi_size_u64 = try sema.typeAbiSize(base_elem_ty); |
| 28333 | 28334 | const elem_abi_size = try sema.usizeCast(block, src, elem_abi_size_u64); |
| 28335 | const elem_idx = try sema.usizeCast(block, src, elem_ptr.index); | |
| 28334 | 28336 | return ComptimePtrMutationKit{ |
| 28335 | 28337 | .mut_decl = parent.mut_decl, |
| 28336 | 28338 | .pointee = .{ .reinterpret = .{ |
| 28337 | 28339 | .val_ptr = reinterpret.val_ptr, |
| 28338 | .byte_offset = reinterpret.byte_offset + elem_abi_size * elem_ptr.index, | |
| 28340 | .byte_offset = reinterpret.byte_offset + elem_abi_size * elem_idx, | |
| 28339 | 28341 | } }, |
| 28340 | 28342 | .ty = parent.ty, |
| 28341 | 28343 | }; |
| ... | ... | @@ -28750,9 +28752,10 @@ fn beginComptimePtrLoad( |
| 28750 | 28752 | // the pointee array directly from our parent array. |
| 28751 | 28753 | if (load_ty.isArrayOrVector(mod) and load_ty.childType(mod).eql(elem_ty, mod)) { |
| 28752 | 28754 | const N = try sema.usizeCast(block, src, load_ty.arrayLenIncludingSentinel(mod)); |
| 28755 | const elem_idx = try sema.usizeCast(block, src, elem_ptr.index); | |
| 28753 | 28756 | deref.pointee = if (elem_ptr.index + N <= check_len) TypedValue{ |
| 28754 | 28757 | .ty = try Type.array(sema.arena, N, null, elem_ty, mod), |
| 28755 | .val = try array_tv.val.sliceArray(mod, sema.arena, elem_ptr.index, elem_ptr.index + N), | |
| 28758 | .val = try array_tv.val.sliceArray(mod, sema.arena, elem_idx, elem_idx + N), | |
| 28756 | 28759 | } else null; |
| 28757 | 28760 | break :blk deref; |
| 28758 | 28761 | } |
| ... | ... | @@ -28773,7 +28776,7 @@ fn beginComptimePtrLoad( |
| 28773 | 28776 | } |
| 28774 | 28777 | deref.pointee = TypedValue{ |
| 28775 | 28778 | .ty = elem_ty, |
| 28776 | .val = try array_tv.val.elemValue(mod, elem_ptr.index), | |
| 28779 | .val = try array_tv.val.elemValue(mod, @intCast(usize, elem_ptr.index)), | |
| 28777 | 28780 | }; |
| 28778 | 28781 | break :blk deref; |
| 28779 | 28782 | }, |
src/TypedValue.zig+2-2| ... | ... | @@ -356,12 +356,12 @@ pub fn print( |
| 356 | 356 | if (container_ty.isTuple(mod)) { |
| 357 | 357 | try writer.print("[{d}]", .{field.index}); |
| 358 | 358 | } |
| 359 | const field_name_ip = container_ty.structFieldName(field.index, mod); | |
| 359 | const field_name_ip = container_ty.structFieldName(@intCast(usize, field.index), mod); | |
| 360 | 360 | const field_name = mod.intern_pool.stringToSlice(field_name_ip); |
| 361 | 361 | try writer.print(".{}", .{std.zig.fmtId(field_name)}); |
| 362 | 362 | }, |
| 363 | 363 | .Union => { |
| 364 | const field_name_ip = container_ty.unionFields(mod).keys()[field.index]; | |
| 364 | const field_name_ip = container_ty.unionFields(mod).keys()[@intCast(usize, field.index)]; | |
| 365 | 365 | const field_name = mod.intern_pool.stringToSlice(field_name_ip); |
| 366 | 366 | try writer.print(".{}", .{std.zig.fmtId(field_name)}); |
| 367 | 367 | }, |
src/arch/wasm/CodeGen.zig+2-2| ... | ... | @@ -2982,8 +2982,8 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value) InnerError!WValue { |
| 2982 | 2982 | |
| 2983 | 2983 | const offset = switch (parent_ty.zigTypeTag(mod)) { |
| 2984 | 2984 | .Struct => switch (parent_ty.containerLayout(mod)) { |
| 2985 | .Packed => parent_ty.packedStructFieldByteOffset(field.index, mod), | |
| 2986 | else => parent_ty.structFieldOffset(field.index, mod), | |
| 2985 | .Packed => parent_ty.packedStructFieldByteOffset(@intCast(usize, field.index), mod), | |
| 2986 | else => parent_ty.structFieldOffset(@intCast(usize, field.index), mod), | |
| 2987 | 2987 | }, |
| 2988 | 2988 | .Union => switch (parent_ty.containerLayout(mod)) { |
| 2989 | 2989 | .Packed => 0, |
src/codegen/c.zig+1-1| ... | ... | @@ -642,7 +642,7 @@ pub const DeclGen = struct { |
| 642 | 642 | // Ensure complete type definition is visible before accessing fields. |
| 643 | 643 | _ = try dg.typeToIndex(base_ty, .complete); |
| 644 | 644 | const field_ty = switch (mod.intern_pool.indexToKey(base_ty.toIntern())) { |
| 645 | .anon_struct_type, .struct_type, .union_type => base_ty.structFieldType(field.index, mod), | |
| 645 | .anon_struct_type, .struct_type, .union_type => base_ty.structFieldType(@intCast(usize, field.index), mod), | |
| 646 | 646 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 647 | 647 | .One, .Many, .C => unreachable, |
| 648 | 648 | .Slice => switch (field.index) { |
src/value.zig+6-5| ... | ... | @@ -395,7 +395,8 @@ pub const Value = struct { |
| 395 | 395 | } }); |
| 396 | 396 | }, |
| 397 | 397 | .aggregate => { |
| 398 | const old_elems = val.castTag(.aggregate).?.data[0..ty.arrayLen(mod)]; | |
| 398 | const len = @intCast(usize, ty.arrayLen(mod)); | |
| 399 | const old_elems = val.castTag(.aggregate).?.data[0..len]; | |
| 399 | 400 | const new_elems = try mod.gpa.alloc(InternPool.Index, old_elems.len); |
| 400 | 401 | defer mod.gpa.free(new_elems); |
| 401 | 402 | const ty_key = mod.intern_pool.indexToKey(ty.toIntern()); |
| ... | ... | @@ -642,7 +643,7 @@ pub const Value = struct { |
| 642 | 643 | const base_addr = (try field.base.toValue().getUnsignedIntAdvanced(mod, opt_sema)) orelse return null; |
| 643 | 644 | const struct_ty = mod.intern_pool.typeOf(field.base).toType().childType(mod); |
| 644 | 645 | if (opt_sema) |sema| try sema.resolveTypeLayout(struct_ty); |
| 645 | return base_addr + struct_ty.structFieldOffset(field.index, mod); | |
| 646 | return base_addr + struct_ty.structFieldOffset(@intCast(usize, field.index), mod); | |
| 646 | 647 | }, |
| 647 | 648 | else => null, |
| 648 | 649 | }, |
| ... | ... | @@ -1798,10 +1799,10 @@ pub const Value = struct { |
| 1798 | 1799 | .int, .eu_payload => unreachable, |
| 1799 | 1800 | .opt_payload => |base| base.toValue().elemValue(mod, index), |
| 1800 | 1801 | .comptime_field => |field_val| field_val.toValue().elemValue(mod, index), |
| 1801 | .elem => |elem| elem.base.toValue().elemValue(mod, index + elem.index), | |
| 1802 | .elem => |elem| elem.base.toValue().elemValue(mod, index + @intCast(usize, elem.index)), | |
| 1802 | 1803 | .field => |field| if (field.base.toValue().pointerDecl(mod)) |decl_index| { |
| 1803 | 1804 | const base_decl = mod.declPtr(decl_index); |
| 1804 | const field_val = try base_decl.val.fieldValue(mod, field.index); | |
| 1805 | const field_val = try base_decl.val.fieldValue(mod, @intCast(usize, field.index)); | |
| 1805 | 1806 | return field_val.elemValue(mod, index); |
| 1806 | 1807 | } else unreachable, |
| 1807 | 1808 | }, |
| ... | ... | @@ -1921,7 +1922,7 @@ pub const Value = struct { |
| 1921 | 1922 | .comptime_field => |comptime_field| comptime_field.toValue() |
| 1922 | 1923 | .sliceArray(mod, arena, start, end), |
| 1923 | 1924 | .elem => |elem| elem.base.toValue() |
| 1924 | .sliceArray(mod, arena, start + elem.index, end + elem.index), | |
| 1925 | .sliceArray(mod, arena, start + @intCast(usize, elem.index), end + @intCast(usize, elem.index)), | |
| 1925 | 1926 | else => unreachable, |
| 1926 | 1927 | }, |
| 1927 | 1928 | .aggregate => |aggregate| (try mod.intern(.{ .aggregate = .{ |