@@ -2992,7 +2992,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
2992
2992
};
2993
2993
}
2994
2994
2995
- fn indexToKeyFuncType (ip : InternPool , data : u32 ) Key.FuncType {
2995
+ fn indexToKeyFuncType (ip : * const InternPool , data : u32 ) Key.FuncType {
2996
2996
const type_function = ip .extraDataTrail (TypeFunction , data );
2997
2997
const param_types = @ptrCast (
2998
2998
[]Index ,
@@ -3015,7 +3015,7 @@ fn indexToKeyFuncType(ip: InternPool, data: u32) Key.FuncType {
3015
3015
};
3016
3016
}
3017
3017
3018
- fn indexToKeyEnum (ip : InternPool , data : u32 , tag_mode : Key.EnumType.TagMode ) Key {
3018
+ fn indexToKeyEnum (ip : * const InternPool , data : u32 , tag_mode : Key.EnumType.TagMode ) Key {
3019
3019
const enum_explicit = ip .extraDataTrail (EnumExplicit , data );
3020
3020
const names = @ptrCast (
3021
3021
[]const NullTerminatedString ,
@@ -3038,7 +3038,7 @@ fn indexToKeyEnum(ip: InternPool, data: u32, tag_mode: Key.EnumType.TagMode) Key
3038
3038
} };
3039
3039
}
3040
3040
3041
- fn indexToKeyBigInt (ip : InternPool , limb_index : u32 , positive : bool ) Key {
3041
+ fn indexToKeyBigInt (ip : * const InternPool , limb_index : u32 , positive : bool ) Key {
3042
3042
const int_info = ip .limbData (Int , limb_index );
3043
3043
return .{ .int = .{
3044
3044
.ty = int_info .ty ,
@@ -4351,7 +4351,7 @@ fn addLimbsAssumeCapacity(ip: *InternPool, limbs: []const Limb) void {
4351
4351
}
4352
4352
}
4353
4353
4354
- fn extraDataTrail (ip : InternPool , comptime T : type , index : usize ) struct { data : T , end : usize } {
4354
+ fn extraDataTrail (ip : * const InternPool , comptime T : type , index : usize ) struct { data : T , end : usize } {
4355
4355
var result : T = undefined ;
4356
4356
const fields = @typeInfo (T ).Struct .fields ;
4357
4357
inline for (fields , 0.. ) | field , i | {
@@ -4384,12 +4384,12 @@ fn extraDataTrail(ip: InternPool, comptime T: type, index: usize) struct { data:
4384
4384
};
4385
4385
}
4386
4386
4387
- fn extraData (ip : InternPool , comptime T : type , index : usize ) T {
4387
+ fn extraData (ip : * const InternPool , comptime T : type , index : usize ) T {
4388
4388
return extraDataTrail (ip , T , index ).data ;
4389
4389
}
4390
4390
4391
4391
/// Asserts the struct has 32-bit fields and the number of fields is evenly divisible by 2.
4392
- fn limbData (ip : InternPool , comptime T : type , index : usize ) T {
4392
+ fn limbData (ip : * const InternPool , comptime T : type , index : usize ) T {
4393
4393
switch (@sizeOf (Limb )) {
4394
4394
@sizeOf (u32 ) = > return extraData (ip , T , index ),
4395
4395
@sizeOf (u64 ) = > {},
@@ -4413,7 +4413,7 @@ fn limbData(ip: InternPool, comptime T: type, index: usize) T {
4413
4413
}
4414
4414
4415
4415
/// This function returns the Limb slice that is trailing data after a payload.
4416
- fn limbSlice (ip : InternPool , comptime S : type , limb_index : u32 , len : u32 ) []const Limb {
4416
+ fn limbSlice (ip : * const InternPool , comptime S : type , limb_index : u32 , len : u32 ) []const Limb {
4417
4417
const field_count = @typeInfo (S ).Struct .fields .len ;
4418
4418
switch (@sizeOf (Limb )) {
4419
4419
@sizeOf (u32 ) = > {
@@ -4433,7 +4433,7 @@ const LimbsAsIndexes = struct {
4433
4433
len : u32 ,
4434
4434
};
4435
4435
4436
- fn limbsSliceToIndex (ip : InternPool , limbs : []const Limb ) LimbsAsIndexes {
4436
+ fn limbsSliceToIndex (ip : * const InternPool , limbs : []const Limb ) LimbsAsIndexes {
4437
4437
const host_slice = switch (@sizeOf (Limb )) {
4438
4438
@sizeOf (u32 ) = > ip .extra .items ,
4439
4439
@sizeOf (u64 ) = > ip .limbs .items ,
@@ -4447,7 +4447,7 @@ fn limbsSliceToIndex(ip: InternPool, limbs: []const Limb) LimbsAsIndexes {
4447
4447
}
4448
4448
4449
4449
/// This function converts Limb array indexes to a primitive slice type.
4450
- fn limbsIndexToSlice (ip : InternPool , limbs : LimbsAsIndexes ) []const Limb {
4450
+ fn limbsIndexToSlice (ip : * const InternPool , limbs : LimbsAsIndexes ) []const Limb {
4451
4451
return switch (@sizeOf (Limb )) {
4452
4452
@sizeOf (u32 ) = > ip .extra .items [limbs .start .. ][0.. limbs .len ],
4453
4453
@sizeOf (u64 ) = > ip .limbs .items [limbs .start .. ][0.. limbs .len ],
@@ -4485,7 +4485,7 @@ test "basic usage" {
4485
4485
try std .testing .expect (another_array_i32 == array_i32 );
4486
4486
}
4487
4487
4488
- pub fn childType (ip : InternPool , i : Index ) Index {
4488
+ pub fn childType (ip : * const InternPool , i : Index ) Index {
4489
4489
return switch (ip .indexToKey (i )) {
4490
4490
.ptr_type = > | ptr_type | ptr_type .elem_type ,
4491
4491
.vector_type = > | vector_type | vector_type .child ,
@@ -4496,7 +4496,7 @@ pub fn childType(ip: InternPool, i: Index) Index {
4496
4496
}
4497
4497
4498
4498
/// Given a slice type, returns the type of the ptr field.
4499
- pub fn slicePtrType (ip : InternPool , i : Index ) Index {
4499
+ pub fn slicePtrType (ip : * const InternPool , i : Index ) Index {
4500
4500
switch (i ) {
4501
4501
.slice_const_u8_type = > return .manyptr_const_u8_type ,
4502
4502
.slice_const_u8_sentinel_0_type = > return .manyptr_const_u8_sentinel_0_type ,
@@ -4510,7 +4510,7 @@ pub fn slicePtrType(ip: InternPool, i: Index) Index {
4510
4510
}
4511
4511
4512
4512
/// Given a slice value, returns the value of the ptr field.
4513
- pub fn slicePtr (ip : InternPool , i : Index ) Index {
4513
+ pub fn slicePtr (ip : * const InternPool , i : Index ) Index {
4514
4514
const item = ip .items .get (@enumToInt (i ));
4515
4515
switch (item .tag ) {
4516
4516
.ptr_slice = > return ip .extraData (PtrSlice , item .data ).ptr ,
@@ -4519,7 +4519,7 @@ pub fn slicePtr(ip: InternPool, i: Index) Index {
4519
4519
}
4520
4520
4521
4521
/// Given a slice value, returns the value of the len field.
4522
- pub fn sliceLen (ip : InternPool , i : Index ) Index {
4522
+ pub fn sliceLen (ip : * const InternPool , i : Index ) Index {
4523
4523
const item = ip .items .get (@enumToInt (i ));
4524
4524
switch (item .tag ) {
4525
4525
.ptr_slice = > return ip .extraData (PtrSlice , item .data ).len ,
@@ -4702,15 +4702,15 @@ pub fn getCoercedInts(ip: *InternPool, gpa: Allocator, int: Key.Int, new_ty: Ind
4702
4702
} });
4703
4703
}
4704
4704
4705
- pub fn indexToStructType (ip : InternPool , val : Index ) Module.Struct.OptionalIndex {
4705
+ pub fn indexToStructType (ip : * const InternPool , val : Index ) Module.Struct.OptionalIndex {
4706
4706
assert (val != .none );
4707
4707
const tags = ip .items .items (.tag );
4708
4708
if (tags [@enumToInt (val )] != .type_struct ) return .none ;
4709
4709
const datas = ip .items .items (.data );
4710
4710
return @intToEnum (Module .Struct .Index , datas [@enumToInt (val )]).toOptional ();
4711
4711
}
4712
4712
4713
- pub fn indexToUnionType (ip : InternPool , val : Index ) Module.Union.OptionalIndex {
4713
+ pub fn indexToUnionType (ip : * const InternPool , val : Index ) Module.Union.OptionalIndex {
4714
4714
assert (val != .none );
4715
4715
const tags = ip .items .items (.tag );
4716
4716
switch (tags [@enumToInt (val )]) {
@@ -4721,7 +4721,7 @@ pub fn indexToUnionType(ip: InternPool, val: Index) Module.Union.OptionalIndex {
4721
4721
return @intToEnum (Module .Union .Index , datas [@enumToInt (val )]).toOptional ();
4722
4722
}
4723
4723
4724
- pub fn indexToFuncType (ip : InternPool , val : Index ) ? Key.FuncType {
4724
+ pub fn indexToFuncType (ip : * const InternPool , val : Index ) ? Key.FuncType {
4725
4725
assert (val != .none );
4726
4726
const tags = ip .items .items (.tag );
4727
4727
const datas = ip .items .items (.data );
@@ -4731,15 +4731,15 @@ pub fn indexToFuncType(ip: InternPool, val: Index) ?Key.FuncType {
4731
4731
}
4732
4732
}
4733
4733
4734
- pub fn indexToFunc (ip : InternPool , val : Index ) Module.Fn.OptionalIndex {
4734
+ pub fn indexToFunc (ip : * const InternPool , val : Index ) Module.Fn.OptionalIndex {
4735
4735
assert (val != .none );
4736
4736
const tags = ip .items .items (.tag );
4737
4737
if (tags [@enumToInt (val )] != .func ) return .none ;
4738
4738
const datas = ip .items .items (.data );
4739
4739
return ip .extraData (Key .Func , datas [@enumToInt (val )]).index .toOptional ();
4740
4740
}
4741
4741
4742
- pub fn indexToInferredErrorSetType (ip : InternPool , val : Index ) Module.Fn.InferredErrorSet.OptionalIndex {
4742
+ pub fn indexToInferredErrorSetType (ip : * const InternPool , val : Index ) Module.Fn.InferredErrorSet.OptionalIndex {
4743
4743
assert (val != .none );
4744
4744
const tags = ip .items .items (.tag );
4745
4745
if (tags [@enumToInt (val )] != .type_inferred_error_set ) return .none ;
@@ -4748,7 +4748,7 @@ pub fn indexToInferredErrorSetType(ip: InternPool, val: Index) Module.Fn.Inferre
4748
4748
}
4749
4749
4750
4750
/// includes .comptime_int_type
4751
- pub fn isIntegerType (ip : InternPool , ty : Index ) bool {
4751
+ pub fn isIntegerType (ip : * const InternPool , ty : Index ) bool {
4752
4752
return switch (ty ) {
4753
4753
.usize_type ,
4754
4754
.isize_type ,
@@ -4769,7 +4769,7 @@ pub fn isIntegerType(ip: InternPool, ty: Index) bool {
4769
4769
}
4770
4770
4771
4771
/// does not include .enum_literal_type
4772
- pub fn isEnumType (ip : InternPool , ty : Index ) bool {
4772
+ pub fn isEnumType (ip : * const InternPool , ty : Index ) bool {
4773
4773
return switch (ty ) {
4774
4774
.atomic_order_type ,
4775
4775
.atomic_rmw_op_type ,
@@ -4783,35 +4783,35 @@ pub fn isEnumType(ip: InternPool, ty: Index) bool {
4783
4783
};
4784
4784
}
4785
4785
4786
- pub fn isFunctionType (ip : InternPool , ty : Index ) bool {
4786
+ pub fn isFunctionType (ip : * const InternPool , ty : Index ) bool {
4787
4787
return ip .indexToKey (ty ) == .func_type ;
4788
4788
}
4789
4789
4790
- pub fn isPointerType (ip : InternPool , ty : Index ) bool {
4790
+ pub fn isPointerType (ip : * const InternPool , ty : Index ) bool {
4791
4791
return ip .indexToKey (ty ) == .ptr_type ;
4792
4792
}
4793
4793
4794
- pub fn isOptionalType (ip : InternPool , ty : Index ) bool {
4794
+ pub fn isOptionalType (ip : * const InternPool , ty : Index ) bool {
4795
4795
return ip .indexToKey (ty ) == .opt_type ;
4796
4796
}
4797
4797
4798
4798
/// includes .inferred_error_set_type
4799
- pub fn isErrorSetType (ip : InternPool , ty : Index ) bool {
4799
+ pub fn isErrorSetType (ip : * const InternPool , ty : Index ) bool {
4800
4800
return ty == .anyerror_type or switch (ip .indexToKey (ty )) {
4801
4801
.error_set_type , .inferred_error_set_type = > true ,
4802
4802
else = > false ,
4803
4803
};
4804
4804
}
4805
4805
4806
- pub fn isInferredErrorSetType (ip : InternPool , ty : Index ) bool {
4806
+ pub fn isInferredErrorSetType (ip : * const InternPool , ty : Index ) bool {
4807
4807
return ip .indexToKey (ty ) == .inferred_error_set_type ;
4808
4808
}
4809
4809
4810
- pub fn isErrorUnionType (ip : InternPool , ty : Index ) bool {
4810
+ pub fn isErrorUnionType (ip : * const InternPool , ty : Index ) bool {
4811
4811
return ip .indexToKey (ty ) == .error_union_type ;
4812
4812
}
4813
4813
4814
- pub fn isAggregateType (ip : InternPool , ty : Index ) bool {
4814
+ pub fn isAggregateType (ip : * const InternPool , ty : Index ) bool {
4815
4815
return switch (ip .indexToKey (ty )) {
4816
4816
.array_type , .vector_type , .anon_struct_type , .struct_type = > true ,
4817
4817
else = > false ,
@@ -4827,11 +4827,11 @@ pub fn mutateVarInit(ip: *InternPool, index: Index, init_index: Index) void {
4827
4827
ip .extra .items [ip .items .items (.data )[@enumToInt (index )] + field_index ] = @enumToInt (init_index );
4828
4828
}
4829
4829
4830
- pub fn dump (ip : InternPool ) void {
4830
+ pub fn dump (ip : * const InternPool ) void {
4831
4831
dumpFallible (ip , std .heap .page_allocator ) catch return ;
4832
4832
}
4833
4833
4834
- fn dumpFallible (ip : InternPool , arena : Allocator ) anyerror ! void {
4834
+ fn dumpFallible (ip : * const InternPool , arena : Allocator ) anyerror ! void {
4835
4835
const items_size = (1 + 4 ) * ip .items .len ;
4836
4836
const extra_size = 4 * ip .extra .items .len ;
4837
4837
const limbs_size = 8 * ip .limbs .items .len ;
@@ -5023,35 +5023,35 @@ pub fn structPtr(ip: *InternPool, index: Module.Struct.Index) *Module.Struct {
5023
5023
return ip .allocated_structs .at (@enumToInt (index ));
5024
5024
}
5025
5025
5026
- pub fn structPtrConst (ip : InternPool , index : Module.Struct.Index ) * const Module.Struct {
5026
+ pub fn structPtrConst (ip : * const InternPool , index : Module.Struct.Index ) * const Module.Struct {
5027
5027
return ip .allocated_structs .at (@enumToInt (index ));
5028
5028
}
5029
5029
5030
- pub fn structPtrUnwrapConst (ip : InternPool , index : Module.Struct.OptionalIndex ) ? * const Module.Struct {
5030
+ pub fn structPtrUnwrapConst (ip : * const InternPool , index : Module.Struct.OptionalIndex ) ? * const Module.Struct {
5031
5031
return structPtrConst (ip , index .unwrap () orelse return null );
5032
5032
}
5033
5033
5034
5034
pub fn unionPtr (ip : * InternPool , index : Module.Union.Index ) * Module.Union {
5035
5035
return ip .allocated_unions .at (@enumToInt (index ));
5036
5036
}
5037
5037
5038
- pub fn unionPtrConst (ip : InternPool , index : Module.Union.Index ) * const Module.Union {
5038
+ pub fn unionPtrConst (ip : * const InternPool , index : Module.Union.Index ) * const Module.Union {
5039
5039
return ip .allocated_unions .at (@enumToInt (index ));
5040
5040
}
5041
5041
5042
5042
pub fn funcPtr (ip : * InternPool , index : Module.Fn.Index ) * Module.Fn {
5043
5043
return ip .allocated_funcs .at (@enumToInt (index ));
5044
5044
}
5045
5045
5046
- pub fn funcPtrConst (ip : InternPool , index : Module.Fn.Index ) * const Module.Fn {
5046
+ pub fn funcPtrConst (ip : * const InternPool , index : Module.Fn.Index ) * const Module.Fn {
5047
5047
return ip .allocated_funcs .at (@enumToInt (index ));
5048
5048
}
5049
5049
5050
5050
pub fn inferredErrorSetPtr (ip : * InternPool , index : Module.Fn.InferredErrorSet.Index ) * Module.Fn.InferredErrorSet {
5051
5051
return ip .allocated_inferred_error_sets .at (@enumToInt (index ));
5052
5052
}
5053
5053
5054
- pub fn inferredErrorSetPtrConst (ip : InternPool , index : Module.Fn.InferredErrorSet.Index ) * const Module.Fn.InferredErrorSet {
5054
+ pub fn inferredErrorSetPtrConst (ip : * const InternPool , index : Module.Fn.InferredErrorSet.Index ) * const Module.Fn.InferredErrorSet {
5055
5055
return ip .allocated_inferred_error_sets .at (@enumToInt (index ));
5056
5056
}
5057
5057
@@ -5182,19 +5182,19 @@ pub fn getString(ip: *InternPool, s: []const u8) OptionalNullTerminatedString {
5182
5182
}
5183
5183
}
5184
5184
5185
- pub fn stringToSlice (ip : InternPool , s : NullTerminatedString ) [:0 ]const u8 {
5185
+ pub fn stringToSlice (ip : * const InternPool , s : NullTerminatedString ) [:0 ]const u8 {
5186
5186
const string_bytes = ip .string_bytes .items ;
5187
5187
const start = @enumToInt (s );
5188
5188
var end : usize = start ;
5189
5189
while (string_bytes [end ] != 0 ) end += 1 ;
5190
5190
return string_bytes [start .. end :0 ];
5191
5191
}
5192
5192
5193
- pub fn stringToSliceUnwrap (ip : InternPool , s : OptionalNullTerminatedString ) ? [:0 ]const u8 {
5193
+ pub fn stringToSliceUnwrap (ip : * const InternPool , s : OptionalNullTerminatedString ) ? [:0 ]const u8 {
5194
5194
return ip .stringToSlice (s .unwrap () orelse return null );
5195
5195
}
5196
5196
5197
- pub fn typeOf (ip : InternPool , index : Index ) Index {
5197
+ pub fn typeOf (ip : * const InternPool , index : Index ) Index {
5198
5198
// This optimization of static keys is required so that typeOf can be called
5199
5199
// on static keys that haven't been added yet during static key initialization.
5200
5200
// An alternative would be to topological sort the static keys, but this would
@@ -5382,12 +5382,12 @@ pub fn typeOf(ip: InternPool, index: Index) Index {
5382
5382
}
5383
5383
5384
5384
/// Assumes that the enum's field indexes equal its value tags.
5385
- pub fn toEnum (ip : InternPool , comptime E : type , i : Index ) E {
5385
+ pub fn toEnum (ip : * const InternPool , comptime E : type , i : Index ) E {
5386
5386
const int = ip .indexToKey (i ).enum_tag .int ;
5387
5387
return @intToEnum (E , ip .indexToKey (int ).int .storage .u64 );
5388
5388
}
5389
5389
5390
- pub fn aggregateTypeLen (ip : InternPool , ty : Index ) u64 {
5390
+ pub fn aggregateTypeLen (ip : * const InternPool , ty : Index ) u64 {
5391
5391
return switch (ip .indexToKey (ty )) {
5392
5392
.struct_type = > | struct_type | ip .structPtrConst (struct_type .index .unwrap () orelse return 0 ).fields .count (),
5393
5393
.anon_struct_type = > | anon_struct_type | anon_struct_type .types .len ,
@@ -5397,7 +5397,7 @@ pub fn aggregateTypeLen(ip: InternPool, ty: Index) u64 {
5397
5397
};
5398
5398
}
5399
5399
5400
- pub fn aggregateTypeLenIncludingSentinel (ip : InternPool , ty : Index ) u64 {
5400
+ pub fn aggregateTypeLenIncludingSentinel (ip : * const InternPool , ty : Index ) u64 {
5401
5401
return switch (ip .indexToKey (ty )) {
5402
5402
.struct_type = > | struct_type | ip .structPtrConst (struct_type .index .unwrap () orelse return 0 ).fields .count (),
5403
5403
.anon_struct_type = > | anon_struct_type | anon_struct_type .types .len ,
@@ -5407,7 +5407,7 @@ pub fn aggregateTypeLenIncludingSentinel(ip: InternPool, ty: Index) u64 {
5407
5407
};
5408
5408
}
5409
5409
5410
- pub fn isNoReturn (ip : InternPool , ty : Index ) bool {
5410
+ pub fn isNoReturn (ip : * const InternPool , ty : Index ) bool {
5411
5411
return switch (ty ) {
5412
5412
.noreturn_type = > true ,
5413
5413
else = > switch (ip .indexToKey (ty )) {
@@ -5420,7 +5420,7 @@ pub fn isNoReturn(ip: InternPool, ty: Index) bool {
5420
5420
5421
5421
/// This is a particularly hot function, so we operate directly on encodings
5422
5422
/// rather than the more straightforward implementation of calling `indexToKey`.
5423
- pub fn zigTypeTagOrPoison (ip : InternPool , index : Index ) error {GenericPoison }! std.builtin.TypeId {
5423
+ pub fn zigTypeTagOrPoison (ip : * const InternPool , index : Index ) error {GenericPoison }! std.builtin.TypeId {
5424
5424
return switch (index ) {
5425
5425
.u1_type ,
5426
5426
.u8_type ,
0 commit comments