| ... | ... | @@ -50,21 +50,20 @@ pub const Type = struct { |
| 50 | 50 | .optional => return .Optional, |
| 51 | 51 | |
| 52 | 52 | .error_union => return .ErrorUnion, |
| 53 | | |
| 54 | | .anyframe_T => return .AnyFrame, |
| 55 | 53 | }, |
| 56 | | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { |
| 57 | | .int_type => return .Int, |
| 58 | | .ptr_type => return .Pointer, |
| 59 | | .array_type => return .Array, |
| 60 | | .vector_type => return .Vector, |
| 61 | | .opt_type => return .Optional, |
| 62 | | .error_union_type => return .ErrorUnion, |
| 63 | | .struct_type, .anon_struct_type => return .Struct, |
| 64 | | .union_type => return .Union, |
| 65 | | .opaque_type => return .Opaque, |
| 66 | | .enum_type => return .Enum, |
| 67 | | .func_type => return .Fn, |
| 54 | else => return switch (mod.intern_pool.indexToKey(ty.ip_index)) { |
| 55 | .int_type => .Int, |
| 56 | .ptr_type => .Pointer, |
| 57 | .array_type => .Array, |
| 58 | .vector_type => .Vector, |
| 59 | .opt_type => .Optional, |
| 60 | .error_union_type => .ErrorUnion, |
| 61 | .struct_type, .anon_struct_type => .Struct, |
| 62 | .union_type => .Union, |
| 63 | .opaque_type => .Opaque, |
| 64 | .enum_type => .Enum, |
| 65 | .func_type => .Fn, |
| 66 | .anyframe_type => .AnyFrame, |
| 68 | 67 | .simple_type => |s| switch (s) { |
| 69 | 68 | .f16, |
| 70 | 69 | .f32, |
| ... | ... | @@ -72,7 +71,7 @@ pub const Type = struct { |
| 72 | 71 | .f80, |
| 73 | 72 | .f128, |
| 74 | 73 | .c_longdouble, |
| 75 | | => return .Float, |
| 74 | => .Float, |
| 76 | 75 | |
| 77 | 76 | .usize, |
| 78 | 77 | .isize, |
| ... | ... | @@ -85,20 +84,19 @@ pub const Type = struct { |
| 85 | 84 | .c_ulong, |
| 86 | 85 | .c_longlong, |
| 87 | 86 | .c_ulonglong, |
| 88 | | => return .Int, |
| 89 | | |
| 90 | | .anyopaque => return .Opaque, |
| 91 | | .bool => return .Bool, |
| 92 | | .void => return .Void, |
| 93 | | .type => return .Type, |
| 94 | | .anyerror => return .ErrorSet, |
| 95 | | .comptime_int => return .ComptimeInt, |
| 96 | | .comptime_float => return .ComptimeFloat, |
| 97 | | .noreturn => return .NoReturn, |
| 98 | | .@"anyframe" => return .AnyFrame, |
| 99 | | .null => return .Null, |
| 100 | | .undefined => return .Undefined, |
| 101 | | .enum_literal => return .EnumLiteral, |
| 87 | => .Int, |
| 88 | |
| 89 | .anyopaque => .Opaque, |
| 90 | .bool => .Bool, |
| 91 | .void => .Void, |
| 92 | .type => .Type, |
| 93 | .anyerror => .ErrorSet, |
| 94 | .comptime_int => .ComptimeInt, |
| 95 | .comptime_float => .ComptimeFloat, |
| 96 | .noreturn => .NoReturn, |
| 97 | .null => .Null, |
| 98 | .undefined => .Undefined, |
| 99 | .enum_literal => .EnumLiteral, |
| 102 | 100 | |
| 103 | 101 | .atomic_order, |
| 104 | 102 | .atomic_rmw_op, |
| ... | ... | @@ -107,14 +105,14 @@ pub const Type = struct { |
| 107 | 105 | .float_mode, |
| 108 | 106 | .reduce_op, |
| 109 | 107 | .call_modifier, |
| 110 | | => return .Enum, |
| 108 | => .Enum, |
| 111 | 109 | |
| 112 | 110 | .prefetch_options, |
| 113 | 111 | .export_options, |
| 114 | 112 | .extern_options, |
| 115 | | => return .Struct, |
| 113 | => .Struct, |
| 116 | 114 | |
| 117 | | .type_info => return .Union, |
| 115 | .type_info => .Union, |
| 118 | 116 | |
| 119 | 117 | .generic_poison => return error.GenericPoison, |
| 120 | 118 | .var_args_param => unreachable, |
| ... | ... | @@ -408,11 +406,6 @@ pub const Type = struct { |
| 408 | 406 | |
| 409 | 407 | return true; |
| 410 | 408 | }, |
| 411 | | |
| 412 | | .anyframe_T => { |
| 413 | | if (b.zigTypeTag(mod) != .AnyFrame) return false; |
| 414 | | return a.elemType2(mod).eql(b.elemType2(mod), mod); |
| 415 | | }, |
| 416 | 409 | } |
| 417 | 410 | } |
| 418 | 411 | |
| ... | ... | @@ -488,11 +481,6 @@ pub const Type = struct { |
| 488 | 481 | const payload_ty = ty.errorUnionPayload(); |
| 489 | 482 | hashWithHasher(payload_ty, hasher, mod); |
| 490 | 483 | }, |
| 491 | | |
| 492 | | .anyframe_T => { |
| 493 | | std.hash.autoHash(hasher, std.builtin.TypeId.AnyFrame); |
| 494 | | hashWithHasher(ty.childType(mod), hasher, mod); |
| 495 | | }, |
| 496 | 484 | } |
| 497 | 485 | } |
| 498 | 486 | |
| ... | ... | @@ -542,9 +530,7 @@ pub const Type = struct { |
| 542 | 530 | .inferred_alloc_mut, |
| 543 | 531 | => unreachable, |
| 544 | 532 | |
| 545 | | .optional, |
| 546 | | .anyframe_T, |
| 547 | | => { |
| 533 | .optional => { |
| 548 | 534 | const payload = self.cast(Payload.ElemType).?; |
| 549 | 535 | const new_payload = try allocator.create(Payload.ElemType); |
| 550 | 536 | new_payload.* = .{ |
| ... | ... | @@ -668,12 +654,6 @@ pub const Type = struct { |
| 668 | 654 | while (true) { |
| 669 | 655 | const t = ty.tag(); |
| 670 | 656 | switch (t) { |
| 671 | | .anyframe_T => { |
| 672 | | const return_type = ty.castTag(.anyframe_T).?.data; |
| 673 | | try writer.print("anyframe->", .{}); |
| 674 | | ty = return_type; |
| 675 | | continue; |
| 676 | | }, |
| 677 | 657 | .optional => { |
| 678 | 658 | const child_type = ty.castTag(.optional).?.data; |
| 679 | 659 | try writer.writeByte('?'); |
| ... | ... | @@ -838,11 +818,6 @@ pub const Type = struct { |
| 838 | 818 | try writer.writeByte('?'); |
| 839 | 819 | try print(child_type, writer, mod); |
| 840 | 820 | }, |
| 841 | | .anyframe_T => { |
| 842 | | const return_type = ty.castTag(.anyframe_T).?.data; |
| 843 | | try writer.print("anyframe->", .{}); |
| 844 | | try print(return_type, writer, mod); |
| 845 | | }, |
| 846 | 821 | .error_set => { |
| 847 | 822 | const names = ty.castTag(.error_set).?.data.names.keys(); |
| 848 | 823 | try writer.writeAll("error{"); |
| ... | ... | @@ -1034,6 +1009,11 @@ pub const Type = struct { |
| 1034 | 1009 | try print(fn_info.return_type.toType(), writer, mod); |
| 1035 | 1010 | } |
| 1036 | 1011 | }, |
| 1012 | .anyframe_type => |child| { |
| 1013 | if (child == .none) return writer.writeAll("anyframe"); |
| 1014 | try writer.writeAll("anyframe->"); |
| 1015 | return print(child.toType(), writer, mod); |
| 1016 | }, |
| 1037 | 1017 | |
| 1038 | 1018 | // values, not types |
| 1039 | 1019 | .undef => unreachable, |
| ... | ... | @@ -1098,9 +1078,7 @@ pub const Type = struct { |
| 1098 | 1078 | |
| 1099 | 1079 | // Pointers to zero-bit types still have a runtime address; however, pointers |
| 1100 | 1080 | // to comptime-only types do not, with the exception of function pointers. |
| 1101 | | .anyframe_T, |
| 1102 | | .pointer, |
| 1103 | | => { |
| 1081 | .pointer => { |
| 1104 | 1082 | if (ignore_comptime_only) { |
| 1105 | 1083 | return true; |
| 1106 | 1084 | } else if (ty.childType(mod).zigTypeTag(mod) == .Fn) { |
| ... | ... | @@ -1141,6 +1119,7 @@ pub const Type = struct { |
| 1141 | 1119 | if (strat == .sema) return !(try strat.sema.typeRequiresComptime(ty)); |
| 1142 | 1120 | return !comptimeOnly(ty, mod); |
| 1143 | 1121 | }, |
| 1122 | .anyframe_type => true, |
| 1144 | 1123 | .array_type => |array_type| { |
| 1145 | 1124 | if (array_type.sentinel != .none) { |
| 1146 | 1125 | return array_type.child.toType().hasRuntimeBitsAdvanced(mod, ignore_comptime_only, strat); |
| ... | ... | @@ -1195,7 +1174,6 @@ pub const Type = struct { |
| 1195 | 1174 | .c_longdouble, |
| 1196 | 1175 | .bool, |
| 1197 | 1176 | .anyerror, |
| 1198 | | .@"anyframe", |
| 1199 | 1177 | .anyopaque, |
| 1200 | 1178 | .atomic_order, |
| 1201 | 1179 | .atomic_rmw_op, |
| ... | ... | @@ -1319,7 +1297,6 @@ pub const Type = struct { |
| 1319 | 1297 | .error_set_inferred, |
| 1320 | 1298 | .error_set_merged, |
| 1321 | 1299 | .error_union, |
| 1322 | | .anyframe_T, |
| 1323 | 1300 | => false, |
| 1324 | 1301 | |
| 1325 | 1302 | .inferred_alloc_mut => unreachable, |
| ... | ... | @@ -1336,6 +1313,7 @@ pub const Type = struct { |
| 1336 | 1313 | .error_union_type, |
| 1337 | 1314 | .anon_struct_type, |
| 1338 | 1315 | .opaque_type, |
| 1316 | .anyframe_type, |
| 1339 | 1317 | // These are function bodies, not function pointers. |
| 1340 | 1318 | .func_type, |
| 1341 | 1319 | => false, |
| ... | ... | @@ -1366,7 +1344,6 @@ pub const Type = struct { |
| 1366 | 1344 | => true, |
| 1367 | 1345 | |
| 1368 | 1346 | .anyerror, |
| 1369 | | .@"anyframe", |
| 1370 | 1347 | .anyopaque, |
| 1371 | 1348 | .atomic_order, |
| 1372 | 1349 | .atomic_rmw_op, |
| ... | ... | @@ -1594,9 +1571,7 @@ pub const Type = struct { |
| 1594 | 1571 | switch (ty.ip_index) { |
| 1595 | 1572 | .empty_struct_type => return AbiAlignmentAdvanced{ .scalar = 0 }, |
| 1596 | 1573 | .none => switch (ty.tag()) { |
| 1597 | | .pointer, |
| 1598 | | .anyframe_T, |
| 1599 | | => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 1574 | .pointer => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 1600 | 1575 | |
| 1601 | 1576 | // TODO revisit this when we have the concept of the error tag type |
| 1602 | 1577 | .error_set_inferred, |
| ... | ... | @@ -1617,7 +1592,7 @@ pub const Type = struct { |
| 1617 | 1592 | if (int_type.bits == 0) return AbiAlignmentAdvanced{ .scalar = 0 }; |
| 1618 | 1593 | return AbiAlignmentAdvanced{ .scalar = intAbiAlignment(int_type.bits, target) }; |
| 1619 | 1594 | }, |
| 1620 | | .ptr_type => { |
| 1595 | .ptr_type, .anyframe_type => { |
| 1621 | 1596 | return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }; |
| 1622 | 1597 | }, |
| 1623 | 1598 | .array_type => |array_type| { |
| ... | ... | @@ -1657,7 +1632,6 @@ pub const Type = struct { |
| 1657 | 1632 | .isize, |
| 1658 | 1633 | .export_options, |
| 1659 | 1634 | .extern_options, |
| 1660 | | .@"anyframe", |
| 1661 | 1635 | => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 1662 | 1636 | |
| 1663 | 1637 | .c_char => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.char) }, |
| ... | ... | @@ -1976,8 +1950,6 @@ pub const Type = struct { |
| 1976 | 1950 | .inferred_alloc_const => unreachable, |
| 1977 | 1951 | .inferred_alloc_mut => unreachable, |
| 1978 | 1952 | |
| 1979 | | .anyframe_T => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 1980 | | |
| 1981 | 1953 | .pointer => switch (ty.castTag(.pointer).?.data.size) { |
| 1982 | 1954 | .Slice => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 }, |
| 1983 | 1955 | else => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| ... | ... | @@ -2039,6 +2011,8 @@ pub const Type = struct { |
| 2039 | 2011 | .Slice => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 }, |
| 2040 | 2012 | else => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 2041 | 2013 | }, |
| 2014 | .anyframe_type => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 2015 | |
| 2042 | 2016 | .array_type => |array_type| { |
| 2043 | 2017 | const len = array_type.len + @boolToInt(array_type.sentinel != .none); |
| 2044 | 2018 | switch (try array_type.child.toType().abiSizeAdvanced(mod, strat)) { |
| ... | ... | @@ -2102,7 +2076,6 @@ pub const Type = struct { |
| 2102 | 2076 | |
| 2103 | 2077 | .usize, |
| 2104 | 2078 | .isize, |
| 2105 | | .@"anyframe", |
| 2106 | 2079 | => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 2107 | 2080 | |
| 2108 | 2081 | .c_char => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.char) }, |
| ... | ... | @@ -2298,8 +2271,6 @@ pub const Type = struct { |
| 2298 | 2271 | .inferred_alloc_const => unreachable, |
| 2299 | 2272 | .inferred_alloc_mut => unreachable, |
| 2300 | 2273 | |
| 2301 | | .anyframe_T => return target.ptrBitWidth(), |
| 2302 | | |
| 2303 | 2274 | .pointer => switch (ty.castTag(.pointer).?.data.size) { |
| 2304 | 2275 | .Slice => return target.ptrBitWidth() * 2, |
| 2305 | 2276 | else => return target.ptrBitWidth(), |
| ... | ... | @@ -2323,6 +2294,8 @@ pub const Type = struct { |
| 2323 | 2294 | .Slice => return target.ptrBitWidth() * 2, |
| 2324 | 2295 | else => return target.ptrBitWidth() * 2, |
| 2325 | 2296 | }, |
| 2297 | .anyframe_type => return target.ptrBitWidth(), |
| 2298 | |
| 2326 | 2299 | .array_type => |array_type| { |
| 2327 | 2300 | const len = array_type.len + @boolToInt(array_type.sentinel != .none); |
| 2328 | 2301 | if (len == 0) return 0; |
| ... | ... | @@ -2349,7 +2322,6 @@ pub const Type = struct { |
| 2349 | 2322 | |
| 2350 | 2323 | .usize, |
| 2351 | 2324 | .isize, |
| 2352 | | .@"anyframe", |
| 2353 | 2325 | => return target.ptrBitWidth(), |
| 2354 | 2326 | |
| 2355 | 2327 | .c_char => return target.c_type_bit_size(.char), |
| ... | ... | @@ -2777,8 +2749,6 @@ pub const Type = struct { |
| 2777 | 2749 | }, |
| 2778 | 2750 | .optional => ty.castTag(.optional).?.data.childType(mod), |
| 2779 | 2751 | |
| 2780 | | .anyframe_T => ty.castTag(.anyframe_T).?.data, |
| 2781 | | |
| 2782 | 2752 | else => unreachable, |
| 2783 | 2753 | }, |
| 2784 | 2754 | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { |
| ... | ... | @@ -2786,6 +2756,10 @@ pub const Type = struct { |
| 2786 | 2756 | .One => ptr_type.elem_type.toType().shallowElemType(mod), |
| 2787 | 2757 | .Many, .C, .Slice => ptr_type.elem_type.toType(), |
| 2788 | 2758 | }, |
| 2759 | .anyframe_type => |child| { |
| 2760 | assert(child != .none); |
| 2761 | return child.toType(); |
| 2762 | }, |
| 2789 | 2763 | .vector_type => |vector_type| vector_type.child.toType(), |
| 2790 | 2764 | .array_type => |array_type| array_type.child.toType(), |
| 2791 | 2765 | .opt_type => |child| mod.intern_pool.childType(child).toType(), |
| ... | ... | @@ -3154,6 +3128,7 @@ pub const Type = struct { |
| 3154 | 3128 | .anon_struct_type => unreachable, |
| 3155 | 3129 | |
| 3156 | 3130 | .ptr_type => unreachable, |
| 3131 | .anyframe_type => unreachable, |
| 3157 | 3132 | .array_type => unreachable, |
| 3158 | 3133 | |
| 3159 | 3134 | .opt_type => unreachable, |
| ... | ... | @@ -3327,7 +3302,6 @@ pub const Type = struct { |
| 3327 | 3302 | .error_set, |
| 3328 | 3303 | .error_set_merged, |
| 3329 | 3304 | .error_set_inferred, |
| 3330 | | .anyframe_T, |
| 3331 | 3305 | .pointer, |
| 3332 | 3306 | => return null, |
| 3333 | 3307 | |
| ... | ... | @@ -3355,6 +3329,7 @@ pub const Type = struct { |
| 3355 | 3329 | .ptr_type, |
| 3356 | 3330 | .error_union_type, |
| 3357 | 3331 | .func_type, |
| 3332 | .anyframe_type, |
| 3358 | 3333 | => return null, |
| 3359 | 3334 | |
| 3360 | 3335 | .array_type => |array_type| { |
| ... | ... | @@ -3401,7 +3376,6 @@ pub const Type = struct { |
| 3401 | 3376 | .anyerror, |
| 3402 | 3377 | .comptime_int, |
| 3403 | 3378 | .comptime_float, |
| 3404 | | .@"anyframe", |
| 3405 | 3379 | .enum_literal, |
| 3406 | 3380 | .atomic_order, |
| 3407 | 3381 | .atomic_rmw_op, |
| ... | ... | @@ -3555,10 +3529,6 @@ pub const Type = struct { |
| 3555 | 3529 | }, |
| 3556 | 3530 | |
| 3557 | 3531 | .error_union => return ty.errorUnionPayload().comptimeOnly(mod), |
| 3558 | | .anyframe_T => { |
| 3559 | | const child_ty = ty.castTag(.anyframe_T).?.data; |
| 3560 | | return child_ty.comptimeOnly(mod); |
| 3561 | | }, |
| 3562 | 3532 | }, |
| 3563 | 3533 | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { |
| 3564 | 3534 | .int_type => false, |
| ... | ... | @@ -3570,6 +3540,10 @@ pub const Type = struct { |
| 3570 | 3540 | return child_ty.comptimeOnly(mod); |
| 3571 | 3541 | } |
| 3572 | 3542 | }, |
| 3543 | .anyframe_type => |child| { |
| 3544 | if (child == .none) return false; |
| 3545 | return child.toType().comptimeOnly(mod); |
| 3546 | }, |
| 3573 | 3547 | .array_type => |array_type| array_type.child.toType().comptimeOnly(mod), |
| 3574 | 3548 | .vector_type => |vector_type| vector_type.child.toType().comptimeOnly(mod), |
| 3575 | 3549 | .opt_type => |child| child.toType().comptimeOnly(mod), |
| ... | ... | @@ -3599,7 +3573,6 @@ pub const Type = struct { |
| 3599 | 3573 | .bool, |
| 3600 | 3574 | .void, |
| 3601 | 3575 | .anyerror, |
| 3602 | | .@"anyframe", |
| 3603 | 3576 | .noreturn, |
| 3604 | 3577 | .generic_poison, |
| 3605 | 3578 | .atomic_order, |
| ... | ... | @@ -4245,7 +4218,6 @@ pub const Type = struct { |
| 4245 | 4218 | pointer, |
| 4246 | 4219 | optional, |
| 4247 | 4220 | error_union, |
| 4248 | | anyframe_T, |
| 4249 | 4221 | error_set, |
| 4250 | 4222 | error_set_single, |
| 4251 | 4223 | /// The type is the inferred error set of a specific function. |
| ... | ... | @@ -4261,9 +4233,7 @@ pub const Type = struct { |
| 4261 | 4233 | .inferred_alloc_mut, |
| 4262 | 4234 | => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"), |
| 4263 | 4235 | |
| 4264 | | .optional, |
| 4265 | | .anyframe_T, |
| 4266 | | => Payload.ElemType, |
| 4236 | .optional => Payload.ElemType, |
| 4267 | 4237 | |
| 4268 | 4238 | .error_set => Payload.ErrorSet, |
| 4269 | 4239 | .error_set_inferred => Payload.ErrorSetInferred, |