| author | |
| committer | |
| log | 20ae15917c5cded10a01b85c2cba77041dacef1c |
| tree | 583b4b57b3f0329b73e8198efbe4a797b0486005 |
| parent | fe117d9961c3622fda5c359733d01de686509af0 |
| signature | Commit is signed but in an unrecognized format. |
6 files changed, 70 insertions(+), 0 deletions(-)
src/Module.zig+5| ... | @@ -2381,6 +2381,11 @@ pub fn analyzeSlice(self: *Module, scope: *Scope, src: usize, array_ptr: *Inst, | ... | @@ -2381,6 +2381,11 @@ pub fn analyzeSlice(self: *Module, scope: *Scope, src: usize, array_ptr: *Inst, |
| 2381 | return self.fail(scope, src, "TODO implement analysis of slice", .{}); | 2381 | return self.fail(scope, src, "TODO implement analysis of slice", .{}); |
| 2382 | } | 2382 | } |
| 2383 | 2383 | ||
| 2384 | pub fn analyzeImport(self: *Module, scope: *Scope, src: usize, target_string: []const u8) InnerError!*Inst { | ||
| 2385 | // TODO actually try to import | ||
| 2386 | return self.constType(scope, src, Type.initTag(.empty_struct)); | ||
| 2387 | } | ||
| 2388 | |||
| 2384 | /// Asserts that lhs and rhs types are both numeric. | 2389 | /// Asserts that lhs and rhs types are both numeric. |
| 2385 | pub fn cmpNumeric( | 2390 | pub fn cmpNumeric( |
| 2386 | self: *Module, | 2391 | self: *Module, |
src/astgen.zig+11| ... | @@ -1973,6 +1973,15 @@ fn bitCast(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.BuiltinCa | ... | @@ -1973,6 +1973,15 @@ fn bitCast(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.BuiltinCa |
| 1973 | } | 1973 | } |
| 1974 | } | 1974 | } |
| 1975 | 1975 | ||
| 1976 | fn import(mod: *Module, scope: *Scope, call: *ast.Node.BuiltinCall) InnerError!*zir.Inst { | ||
| 1977 | try ensureBuiltinParamCount(mod, scope, call, 1); | ||
| 1978 | const tree = scope.tree(); | ||
| 1979 | const src = tree.token_locs[call.builtin_token].start; | ||
| 1980 | const params = call.params(); | ||
| 1981 | const target = try expr(mod, scope, .none, params[0]); | ||
| 1982 | return addZIRUnOp(mod, scope, src, .import, target); | ||
| 1983 | } | ||
| 1984 | |||
| 1976 | fn builtinCall(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.BuiltinCall) InnerError!*zir.Inst { | 1985 | fn builtinCall(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.BuiltinCall) InnerError!*zir.Inst { |
| 1977 | const tree = scope.tree(); | 1986 | const tree = scope.tree(); |
| 1978 | const builtin_name = tree.tokenSlice(call.builtin_token); | 1987 | const builtin_name = tree.tokenSlice(call.builtin_token); |
| ... | @@ -1995,6 +2004,8 @@ fn builtinCall(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.Built | ... | @@ -1995,6 +2004,8 @@ fn builtinCall(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.Built |
| 1995 | } else if (mem.eql(u8, builtin_name, "@breakpoint")) { | 2004 | } else if (mem.eql(u8, builtin_name, "@breakpoint")) { |
| 1996 | const src = tree.token_locs[call.builtin_token].start; | 2005 | const src = tree.token_locs[call.builtin_token].start; |
| 1997 | return rlWrap(mod, scope, rl, try addZIRNoOp(mod, scope, src, .breakpoint)); | 2006 | return rlWrap(mod, scope, rl, try addZIRNoOp(mod, scope, src, .breakpoint)); |
| 2007 | } else if (mem.eql(u8, builtin_name, "@import")) { | ||
| 2008 | return rlWrap(mod, scope, rl, try import(mod, scope, call)); | ||
| 1998 | } else { | 2009 | } else { |
| 1999 | return mod.failTok(scope, call.builtin_token, "invalid builtin function: '{}'", .{builtin_name}); | 2010 | return mod.failTok(scope, call.builtin_token, "invalid builtin function: '{}'", .{builtin_name}); |
| 2000 | } | 2011 | } |
src/type.zig+29| ... | @@ -89,6 +89,8 @@ pub const Type = extern union { | ... | @@ -89,6 +89,8 @@ pub const Type = extern union { |
| 89 | .anyerror_void_error_union, .error_union => return .ErrorUnion, | 89 | .anyerror_void_error_union, .error_union => return .ErrorUnion, |
| 90 | 90 | ||
| 91 | .anyframe_T, .@"anyframe" => return .AnyFrame, | 91 | .anyframe_T, .@"anyframe" => return .AnyFrame, |
| 92 | |||
| 93 | .empty_struct => return .Struct, | ||
| 92 | } | 94 | } |
| 93 | } | 95 | } |
| 94 | 96 | ||
| ... | @@ -352,6 +354,7 @@ pub const Type = extern union { | ... | @@ -352,6 +354,7 @@ pub const Type = extern union { |
| 352 | .enum_literal, | 354 | .enum_literal, |
| 353 | .anyerror_void_error_union, | 355 | .anyerror_void_error_union, |
| 354 | .@"anyframe", | 356 | .@"anyframe", |
| 357 | .empty_struct, | ||
| 355 | => unreachable, | 358 | => unreachable, |
| 356 | 359 | ||
| 357 | .array_u8_sentinel_0 => return self.copyPayloadShallow(allocator, Payload.Array_u8_Sentinel0), | 360 | .array_u8_sentinel_0 => return self.copyPayloadShallow(allocator, Payload.Array_u8_Sentinel0), |
| ... | @@ -505,6 +508,7 @@ pub const Type = extern union { | ... | @@ -505,6 +508,7 @@ pub const Type = extern union { |
| 505 | .@"null" => return out_stream.writeAll("@Type(.Null)"), | 508 | .@"null" => return out_stream.writeAll("@Type(.Null)"), |
| 506 | .@"undefined" => return out_stream.writeAll("@Type(.Undefined)"), | 509 | .@"undefined" => return out_stream.writeAll("@Type(.Undefined)"), |
| 507 | 510 | ||
| 511 | .empty_struct => return out_stream.writeAll("struct {}"), | ||
| 508 | .@"anyframe" => return out_stream.writeAll("anyframe"), | 512 | .@"anyframe" => return out_stream.writeAll("anyframe"), |
| 509 | .anyerror_void_error_union => return out_stream.writeAll("anyerror!void"), | 513 | .anyerror_void_error_union => return out_stream.writeAll("anyerror!void"), |
| 510 | .const_slice_u8 => return out_stream.writeAll("[]const u8"), | 514 | .const_slice_u8 => return out_stream.writeAll("[]const u8"), |
| ... | @@ -788,6 +792,7 @@ pub const Type = extern union { | ... | @@ -788,6 +792,7 @@ pub const Type = extern union { |
| 788 | .@"null", | 792 | .@"null", |
| 789 | .@"undefined", | 793 | .@"undefined", |
| 790 | .enum_literal, | 794 | .enum_literal, |
| 795 | .empty_struct, | ||
| 791 | => false, | 796 | => false, |
| 792 | }; | 797 | }; |
| 793 | } | 798 | } |
| ... | @@ -910,6 +915,7 @@ pub const Type = extern union { | ... | @@ -910,6 +915,7 @@ pub const Type = extern union { |
| 910 | .@"null", | 915 | .@"null", |
| 911 | .@"undefined", | 916 | .@"undefined", |
| 912 | .enum_literal, | 917 | .enum_literal, |
| 918 | .empty_struct, | ||
| 913 | => unreachable, | 919 | => unreachable, |
| 914 | }; | 920 | }; |
| 915 | } | 921 | } |
| ... | @@ -932,6 +938,7 @@ pub const Type = extern union { | ... | @@ -932,6 +938,7 @@ pub const Type = extern union { |
| 932 | .@"undefined" => unreachable, | 938 | .@"undefined" => unreachable, |
| 933 | .enum_literal => unreachable, | 939 | .enum_literal => unreachable, |
| 934 | .single_const_pointer_to_comptime_int => unreachable, | 940 | .single_const_pointer_to_comptime_int => unreachable, |
| 941 | .empty_struct => unreachable, | ||
| 935 | 942 | ||
| 936 | .u8, | 943 | .u8, |
| 937 | .i8, | 944 | .i8, |
| ... | @@ -1107,6 +1114,7 @@ pub const Type = extern union { | ... | @@ -1107,6 +1114,7 @@ pub const Type = extern union { |
| 1107 | .anyerror_void_error_union, | 1114 | .anyerror_void_error_union, |
| 1108 | .error_set, | 1115 | .error_set, |
| 1109 | .error_set_single, | 1116 | .error_set_single, |
| 1117 | .empty_struct, | ||
| 1110 | => false, | 1118 | => false, |
| 1111 | 1119 | ||
| 1112 | .single_const_pointer, | 1120 | .single_const_pointer, |
| ... | @@ -1181,6 +1189,7 @@ pub const Type = extern union { | ... | @@ -1181,6 +1189,7 @@ pub const Type = extern union { |
| 1181 | .anyerror_void_error_union, | 1189 | .anyerror_void_error_union, |
| 1182 | .error_set, | 1190 | .error_set, |
| 1183 | .error_set_single, | 1191 | .error_set_single, |
| 1192 | .empty_struct, | ||
| 1184 | => false, | 1193 | => false, |
| 1185 | 1194 | ||
| 1186 | .const_slice, | 1195 | .const_slice, |
| ... | @@ -1252,6 +1261,7 @@ pub const Type = extern union { | ... | @@ -1252,6 +1261,7 @@ pub const Type = extern union { |
| 1252 | .anyerror_void_error_union, | 1261 | .anyerror_void_error_union, |
| 1253 | .error_set, | 1262 | .error_set, |
| 1254 | .error_set_single, | 1263 | .error_set_single, |
| 1264 | .empty_struct, | ||
| 1255 | => false, | 1265 | => false, |
| 1256 | 1266 | ||
| 1257 | .single_const_pointer, | 1267 | .single_const_pointer, |
| ... | @@ -1332,6 +1342,7 @@ pub const Type = extern union { | ... | @@ -1332,6 +1342,7 @@ pub const Type = extern union { |
| 1332 | .anyerror_void_error_union, | 1342 | .anyerror_void_error_union, |
| 1333 | .error_set, | 1343 | .error_set, |
| 1334 | .error_set_single, | 1344 | .error_set_single, |
| 1345 | .empty_struct, | ||
| 1335 | => false, | 1346 | => false, |
| 1336 | 1347 | ||
| 1337 | .pointer => { | 1348 | .pointer => { |
| ... | @@ -1407,6 +1418,7 @@ pub const Type = extern union { | ... | @@ -1407,6 +1418,7 @@ pub const Type = extern union { |
| 1407 | .anyerror_void_error_union, | 1418 | .anyerror_void_error_union, |
| 1408 | .error_set, | 1419 | .error_set, |
| 1409 | .error_set_single, | 1420 | .error_set_single, |
| 1421 | .empty_struct, | ||
| 1410 | => false, | 1422 | => false, |
| 1411 | 1423 | ||
| 1412 | .pointer => { | 1424 | .pointer => { |
| ... | @@ -1524,6 +1536,7 @@ pub const Type = extern union { | ... | @@ -1524,6 +1536,7 @@ pub const Type = extern union { |
| 1524 | .anyerror_void_error_union, | 1536 | .anyerror_void_error_union, |
| 1525 | .error_set, | 1537 | .error_set, |
| 1526 | .error_set_single, | 1538 | .error_set_single, |
| 1539 | .empty_struct, | ||
| 1527 | => unreachable, | 1540 | => unreachable, |
| 1528 | 1541 | ||
| 1529 | .array => self.cast(Payload.Array).?.elem_type, | 1542 | .array => self.cast(Payload.Array).?.elem_type, |
| ... | @@ -1651,6 +1664,7 @@ pub const Type = extern union { | ... | @@ -1651,6 +1664,7 @@ pub const Type = extern union { |
| 1651 | .anyerror_void_error_union, | 1664 | .anyerror_void_error_union, |
| 1652 | .error_set, | 1665 | .error_set, |
| 1653 | .error_set_single, | 1666 | .error_set_single, |
| 1667 | .empty_struct, | ||
| 1654 | => unreachable, | 1668 | => unreachable, |
| 1655 | 1669 | ||
| 1656 | .array => self.cast(Payload.Array).?.len, | 1670 | .array => self.cast(Payload.Array).?.len, |
| ... | @@ -1716,6 +1730,7 @@ pub const Type = extern union { | ... | @@ -1716,6 +1730,7 @@ pub const Type = extern union { |
| 1716 | .anyerror_void_error_union, | 1730 | .anyerror_void_error_union, |
| 1717 | .error_set, | 1731 | .error_set, |
| 1718 | .error_set_single, | 1732 | .error_set_single, |
| 1733 | .empty_struct, | ||
| 1719 | => unreachable, | 1734 | => unreachable, |
| 1720 | 1735 | ||
| 1721 | .single_const_pointer, | 1736 | .single_const_pointer, |
| ... | @@ -1798,6 +1813,7 @@ pub const Type = extern union { | ... | @@ -1798,6 +1813,7 @@ pub const Type = extern union { |
| 1798 | .anyerror_void_error_union, | 1813 | .anyerror_void_error_union, |
| 1799 | .error_set, | 1814 | .error_set, |
| 1800 | .error_set_single, | 1815 | .error_set_single, |
| 1816 | .empty_struct, | ||
| 1801 | => false, | 1817 | => false, |
| 1802 | 1818 | ||
| 1803 | .int_signed, | 1819 | .int_signed, |
| ... | @@ -1872,6 +1888,7 @@ pub const Type = extern union { | ... | @@ -1872,6 +1888,7 @@ pub const Type = extern union { |
| 1872 | .anyerror_void_error_union, | 1888 | .anyerror_void_error_union, |
| 1873 | .error_set, | 1889 | .error_set, |
| 1874 | .error_set_single, | 1890 | .error_set_single, |
| 1891 | .empty_struct, | ||
| 1875 | => false, | 1892 | => false, |
| 1876 | 1893 | ||
| 1877 | .int_unsigned, | 1894 | .int_unsigned, |
| ... | @@ -1936,6 +1953,7 @@ pub const Type = extern union { | ... | @@ -1936,6 +1953,7 @@ pub const Type = extern union { |
| 1936 | .anyerror_void_error_union, | 1953 | .anyerror_void_error_union, |
| 1937 | .error_set, | 1954 | .error_set, |
| 1938 | .error_set_single, | 1955 | .error_set_single, |
| 1956 | .empty_struct, | ||
| 1939 | => unreachable, | 1957 | => unreachable, |
| 1940 | 1958 | ||
| 1941 | .int_unsigned => .{ .signed = false, .bits = self.cast(Payload.IntUnsigned).?.bits }, | 1959 | .int_unsigned => .{ .signed = false, .bits = self.cast(Payload.IntUnsigned).?.bits }, |
| ... | @@ -2018,6 +2036,7 @@ pub const Type = extern union { | ... | @@ -2018,6 +2036,7 @@ pub const Type = extern union { |
| 2018 | .anyerror_void_error_union, | 2036 | .anyerror_void_error_union, |
| 2019 | .error_set, | 2037 | .error_set, |
| 2020 | .error_set_single, | 2038 | .error_set_single, |
| 2039 | .empty_struct, | ||
| 2021 | => false, | 2040 | => false, |
| 2022 | 2041 | ||
| 2023 | .usize, | 2042 | .usize, |
| ... | @@ -2129,6 +2148,7 @@ pub const Type = extern union { | ... | @@ -2129,6 +2148,7 @@ pub const Type = extern union { |
| 2129 | .anyerror_void_error_union, | 2148 | .anyerror_void_error_union, |
| 2130 | .error_set, | 2149 | .error_set, |
| 2131 | .error_set_single, | 2150 | .error_set_single, |
| 2151 | .empty_struct, | ||
| 2132 | => unreachable, | 2152 | => unreachable, |
| 2133 | }; | 2153 | }; |
| 2134 | } | 2154 | } |
| ... | @@ -2206,6 +2226,7 @@ pub const Type = extern union { | ... | @@ -2206,6 +2226,7 @@ pub const Type = extern union { |
| 2206 | .anyerror_void_error_union, | 2226 | .anyerror_void_error_union, |
| 2207 | .error_set, | 2227 | .error_set, |
| 2208 | .error_set_single, | 2228 | .error_set_single, |
| 2229 | .empty_struct, | ||
| 2209 | => unreachable, | 2230 | => unreachable, |
| 2210 | } | 2231 | } |
| 2211 | } | 2232 | } |
| ... | @@ -2282,6 +2303,7 @@ pub const Type = extern union { | ... | @@ -2282,6 +2303,7 @@ pub const Type = extern union { |
| 2282 | .anyerror_void_error_union, | 2303 | .anyerror_void_error_union, |
| 2283 | .error_set, | 2304 | .error_set, |
| 2284 | .error_set_single, | 2305 | .error_set_single, |
| 2306 | .empty_struct, | ||
| 2285 | => unreachable, | 2307 | => unreachable, |
| 2286 | } | 2308 | } |
| 2287 | } | 2309 | } |
| ... | @@ -2358,6 +2380,7 @@ pub const Type = extern union { | ... | @@ -2358,6 +2380,7 @@ pub const Type = extern union { |
| 2358 | .anyerror_void_error_union, | 2380 | .anyerror_void_error_union, |
| 2359 | .error_set, | 2381 | .error_set, |
| 2360 | .error_set_single, | 2382 | .error_set_single, |
| 2383 | .empty_struct, | ||
| 2361 | => unreachable, | 2384 | => unreachable, |
| 2362 | }; | 2385 | }; |
| 2363 | } | 2386 | } |
| ... | @@ -2431,6 +2454,7 @@ pub const Type = extern union { | ... | @@ -2431,6 +2454,7 @@ pub const Type = extern union { |
| 2431 | .anyerror_void_error_union, | 2454 | .anyerror_void_error_union, |
| 2432 | .error_set, | 2455 | .error_set, |
| 2433 | .error_set_single, | 2456 | .error_set_single, |
| 2457 | .empty_struct, | ||
| 2434 | => unreachable, | 2458 | => unreachable, |
| 2435 | }; | 2459 | }; |
| 2436 | } | 2460 | } |
| ... | @@ -2504,6 +2528,7 @@ pub const Type = extern union { | ... | @@ -2504,6 +2528,7 @@ pub const Type = extern union { |
| 2504 | .anyerror_void_error_union, | 2528 | .anyerror_void_error_union, |
| 2505 | .error_set, | 2529 | .error_set, |
| 2506 | .error_set_single, | 2530 | .error_set_single, |
| 2531 | .empty_struct, | ||
| 2507 | => unreachable, | 2532 | => unreachable, |
| 2508 | }; | 2533 | }; |
| 2509 | } | 2534 | } |
| ... | @@ -2577,6 +2602,7 @@ pub const Type = extern union { | ... | @@ -2577,6 +2602,7 @@ pub const Type = extern union { |
| 2577 | .anyerror_void_error_union, | 2602 | .anyerror_void_error_union, |
| 2578 | .error_set, | 2603 | .error_set, |
| 2579 | .error_set_single, | 2604 | .error_set_single, |
| 2605 | .empty_struct, | ||
| 2580 | => false, | 2606 | => false, |
| 2581 | }; | 2607 | }; |
| 2582 | } | 2608 | } |
| ... | @@ -2636,6 +2662,7 @@ pub const Type = extern union { | ... | @@ -2636,6 +2662,7 @@ pub const Type = extern union { |
| 2636 | .error_set_single, | 2662 | .error_set_single, |
| 2637 | => return null, | 2663 | => return null, |
| 2638 | 2664 | ||
| 2665 | .empty_struct => return Value.initTag(.empty_struct_value), | ||
| 2639 | .void => return Value.initTag(.void_value), | 2666 | .void => return Value.initTag(.void_value), |
| 2640 | .noreturn => return Value.initTag(.unreachable_value), | 2667 | .noreturn => return Value.initTag(.unreachable_value), |
| 2641 | .@"null" => return Value.initTag(.null_value), | 2668 | .@"null" => return Value.initTag(.null_value), |
| ... | @@ -2743,6 +2770,7 @@ pub const Type = extern union { | ... | @@ -2743,6 +2770,7 @@ pub const Type = extern union { |
| 2743 | .anyerror_void_error_union, | 2770 | .anyerror_void_error_union, |
| 2744 | .error_set, | 2771 | .error_set, |
| 2745 | .error_set_single, | 2772 | .error_set_single, |
| 2773 | .empty_struct, | ||
| 2746 | => return false, | 2774 | => return false, |
| 2747 | 2775 | ||
| 2748 | .c_const_pointer, | 2776 | .c_const_pointer, |
| ... | @@ -2809,6 +2837,7 @@ pub const Type = extern union { | ... | @@ -2809,6 +2837,7 @@ pub const Type = extern union { |
| 2809 | single_const_pointer_to_comptime_int, | 2837 | single_const_pointer_to_comptime_int, |
| 2810 | anyerror_void_error_union, | 2838 | anyerror_void_error_union, |
| 2811 | @"anyframe", | 2839 | @"anyframe", |
| 2840 | empty_struct, | ||
| 2812 | const_slice_u8, // See last_no_payload_tag below. | 2841 | const_slice_u8, // See last_no_payload_tag below. |
| 2813 | // After this, the tag requires a payload. | 2842 | // After this, the tag requires a payload. |
| 2814 | 2843 |
src/value.zig+14| ... | @@ -68,6 +68,7 @@ pub const Value = extern union { | ... | @@ -68,6 +68,7 @@ pub const Value = extern union { |
| 68 | one, | 68 | one, |
| 69 | void_value, | 69 | void_value, |
| 70 | unreachable_value, | 70 | unreachable_value, |
| 71 | empty_struct_value, | ||
| 71 | empty_array, | 72 | empty_array, |
| 72 | null_value, | 73 | null_value, |
| 73 | bool_true, | 74 | bool_true, |
| ... | @@ -182,6 +183,7 @@ pub const Value = extern union { | ... | @@ -182,6 +183,7 @@ pub const Value = extern union { |
| 182 | .null_value, | 183 | .null_value, |
| 183 | .bool_true, | 184 | .bool_true, |
| 184 | .bool_false, | 185 | .bool_false, |
| 186 | .empty_struct_value, | ||
| 185 | => unreachable, | 187 | => unreachable, |
| 186 | 188 | ||
| 187 | .ty => { | 189 | .ty => { |
| ... | @@ -312,6 +314,7 @@ pub const Value = extern union { | ... | @@ -312,6 +314,7 @@ pub const Value = extern union { |
| 312 | .enum_literal_type => return out_stream.writeAll("@Type(.EnumLiteral)"), | 314 | .enum_literal_type => return out_stream.writeAll("@Type(.EnumLiteral)"), |
| 313 | .anyframe_type => return out_stream.writeAll("anyframe"), | 315 | .anyframe_type => return out_stream.writeAll("anyframe"), |
| 314 | 316 | ||
| 317 | .empty_struct_value => return out_stream.writeAll("struct {}{}"), | ||
| 315 | .null_value => return out_stream.writeAll("null"), | 318 | .null_value => return out_stream.writeAll("null"), |
| 316 | .undef => return out_stream.writeAll("undefined"), | 319 | .undef => return out_stream.writeAll("undefined"), |
| 317 | .zero => return out_stream.writeAll("0"), | 320 | .zero => return out_stream.writeAll("0"), |
| ... | @@ -475,6 +478,7 @@ pub const Value = extern union { | ... | @@ -475,6 +478,7 @@ pub const Value = extern union { |
| 475 | .float_128, | 478 | .float_128, |
| 476 | .enum_literal, | 479 | .enum_literal, |
| 477 | .@"error", | 480 | .@"error", |
| 481 | .empty_struct_value, | ||
| 478 | => unreachable, | 482 | => unreachable, |
| 479 | }; | 483 | }; |
| 480 | } | 484 | } |
| ... | @@ -543,6 +547,7 @@ pub const Value = extern union { | ... | @@ -543,6 +547,7 @@ pub const Value = extern union { |
| 543 | .enum_literal, | 547 | .enum_literal, |
| 544 | .error_set, | 548 | .error_set, |
| 545 | .@"error", | 549 | .@"error", |
| 550 | .empty_struct_value, | ||
| 546 | => unreachable, | 551 | => unreachable, |
| 547 | 552 | ||
| 548 | .undef => unreachable, | 553 | .undef => unreachable, |
| ... | @@ -626,6 +631,7 @@ pub const Value = extern union { | ... | @@ -626,6 +631,7 @@ pub const Value = extern union { |
| 626 | .enum_literal, | 631 | .enum_literal, |
| 627 | .error_set, | 632 | .error_set, |
| 628 | .@"error", | 633 | .@"error", |
| 634 | .empty_struct_value, | ||
| 629 | => unreachable, | 635 | => unreachable, |
| 630 | 636 | ||
| 631 | .undef => unreachable, | 637 | .undef => unreachable, |
| ... | @@ -709,6 +715,7 @@ pub const Value = extern union { | ... | @@ -709,6 +715,7 @@ pub const Value = extern union { |
| 709 | .enum_literal, | 715 | .enum_literal, |
| 710 | .error_set, | 716 | .error_set, |
| 711 | .@"error", | 717 | .@"error", |
| 718 | .empty_struct_value, | ||
| 712 | => unreachable, | 719 | => unreachable, |
| 713 | 720 | ||
| 714 | .undef => unreachable, | 721 | .undef => unreachable, |
| ... | @@ -820,6 +827,7 @@ pub const Value = extern union { | ... | @@ -820,6 +827,7 @@ pub const Value = extern union { |
| 820 | .enum_literal, | 827 | .enum_literal, |
| 821 | .error_set, | 828 | .error_set, |
| 822 | .@"error", | 829 | .@"error", |
| 830 | .empty_struct_value, | ||
| 823 | => unreachable, | 831 | => unreachable, |
| 824 | 832 | ||
| 825 | .zero, | 833 | .zero, |
| ... | @@ -907,6 +915,7 @@ pub const Value = extern union { | ... | @@ -907,6 +915,7 @@ pub const Value = extern union { |
| 907 | .enum_literal, | 915 | .enum_literal, |
| 908 | .error_set, | 916 | .error_set, |
| 909 | .@"error", | 917 | .@"error", |
| 918 | .empty_struct_value, | ||
| 910 | => unreachable, | 919 | => unreachable, |
| 911 | 920 | ||
| 912 | .zero, | 921 | .zero, |
| ... | @@ -1078,6 +1087,7 @@ pub const Value = extern union { | ... | @@ -1078,6 +1087,7 @@ pub const Value = extern union { |
| 1078 | .enum_literal, | 1087 | .enum_literal, |
| 1079 | .error_set, | 1088 | .error_set, |
| 1080 | .@"error", | 1089 | .@"error", |
| 1090 | .empty_struct_value, | ||
| 1081 | => unreachable, | 1091 | => unreachable, |
| 1082 | 1092 | ||
| 1083 | .zero, | 1093 | .zero, |
| ... | @@ -1152,6 +1162,7 @@ pub const Value = extern union { | ... | @@ -1152,6 +1162,7 @@ pub const Value = extern union { |
| 1152 | .enum_literal, | 1162 | .enum_literal, |
| 1153 | .error_set, | 1163 | .error_set, |
| 1154 | .@"error", | 1164 | .@"error", |
| 1165 | .empty_struct_value, | ||
| 1155 | => unreachable, | 1166 | => unreachable, |
| 1156 | 1167 | ||
| 1157 | .zero, | 1168 | .zero, |
| ... | @@ -1300,6 +1311,7 @@ pub const Value = extern union { | ... | @@ -1300,6 +1311,7 @@ pub const Value = extern union { |
| 1300 | .enum_literal, | 1311 | .enum_literal, |
| 1301 | .error_set, | 1312 | .error_set, |
| 1302 | .@"error", | 1313 | .@"error", |
| 1314 | .empty_struct_value, | ||
| 1303 | => unreachable, | 1315 | => unreachable, |
| 1304 | 1316 | ||
| 1305 | .ref_val => self.cast(Payload.RefVal).?.val, | 1317 | .ref_val => self.cast(Payload.RefVal).?.val, |
| ... | @@ -1383,6 +1395,7 @@ pub const Value = extern union { | ... | @@ -1383,6 +1395,7 @@ pub const Value = extern union { |
| 1383 | .enum_literal, | 1395 | .enum_literal, |
| 1384 | .error_set, | 1396 | .error_set, |
| 1385 | .@"error", | 1397 | .@"error", |
| 1398 | .empty_struct_value, | ||
| 1386 | => unreachable, | 1399 | => unreachable, |
| 1387 | 1400 | ||
| 1388 | .empty_array => unreachable, // out of bounds array index | 1401 | .empty_array => unreachable, // out of bounds array index |
| ... | @@ -1483,6 +1496,7 @@ pub const Value = extern union { | ... | @@ -1483,6 +1496,7 @@ pub const Value = extern union { |
| 1483 | .enum_literal, | 1496 | .enum_literal, |
| 1484 | .error_set, | 1497 | .error_set, |
| 1485 | .@"error", | 1498 | .@"error", |
| 1499 | .empty_struct_value, | ||
| 1486 | => false, | 1500 | => false, |
| 1487 | 1501 | ||
| 1488 | .undef => unreachable, | 1502 | .undef => unreachable, |
src/zir.zig+4| ... | @@ -161,6 +161,8 @@ pub const Inst = struct { | ... | @@ -161,6 +161,8 @@ pub const Inst = struct { |
| 161 | @"fn", | 161 | @"fn", |
| 162 | /// Returns a function type. | 162 | /// Returns a function type. |
| 163 | fntype, | 163 | fntype, |
| 164 | /// @import(operand) | ||
| 165 | import, | ||
| 164 | /// Integer literal. | 166 | /// Integer literal. |
| 165 | int, | 167 | int, |
| 166 | /// Convert an integer value to another integer type, asserting that the destination type | 168 | /// Convert an integer value to another integer type, asserting that the destination type |
| ... | @@ -315,6 +317,7 @@ pub const Inst = struct { | ... | @@ -315,6 +317,7 @@ pub const Inst = struct { |
| 315 | .ensure_err_payload_void, | 317 | .ensure_err_payload_void, |
| 316 | .anyframe_type, | 318 | .anyframe_type, |
| 317 | .bitnot, | 319 | .bitnot, |
| 320 | .import, | ||
| 318 | => UnOp, | 321 | => UnOp, |
| 319 | 322 | ||
| 320 | .add, | 323 | .add, |
| ... | @@ -489,6 +492,7 @@ pub const Inst = struct { | ... | @@ -489,6 +492,7 @@ pub const Inst = struct { |
| 489 | .error_set, | 492 | .error_set, |
| 490 | .slice, | 493 | .slice, |
| 491 | .slice_start, | 494 | .slice_start, |
| 495 | .import, | ||
| 492 | => false, | 496 | => false, |
| 493 | 497 | ||
| 494 | .@"break", | 498 | .@"break", |
src/zir_sema.zig+7| ... | @@ -134,6 +134,7 @@ pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError! | ... | @@ -134,6 +134,7 @@ pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError! |
| 134 | .error_set => return analyzeInstErrorSet(mod, scope, old_inst.castTag(.error_set).?), | 134 | .error_set => return analyzeInstErrorSet(mod, scope, old_inst.castTag(.error_set).?), |
| 135 | .slice => return analyzeInstSlice(mod, scope, old_inst.castTag(.slice).?), | 135 | .slice => return analyzeInstSlice(mod, scope, old_inst.castTag(.slice).?), |
| 136 | .slice_start => return analyzeInstSliceStart(mod, scope, old_inst.castTag(.slice_start).?), | 136 | .slice_start => return analyzeInstSliceStart(mod, scope, old_inst.castTag(.slice_start).?), |
| 137 | .import => return analyzeInstImport(mod, scope, old_inst.castTag(.import).?), | ||
| 137 | } | 138 | } |
| 138 | } | 139 | } |
| 139 | 140 | ||
| ... | @@ -1190,6 +1191,12 @@ fn analyzeInstSliceStart(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn | ... | @@ -1190,6 +1191,12 @@ fn analyzeInstSliceStart(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn |
| 1190 | return mod.analyzeSlice(scope, inst.base.src, array_ptr, start, null, null); | 1191 | return mod.analyzeSlice(scope, inst.base.src, array_ptr, start, null, null); |
| 1191 | } | 1192 | } |
| 1192 | 1193 | ||
| 1194 | fn analyzeInstImport(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | ||
| 1195 | const operand = try resolveConstString(mod, scope, inst.positionals.operand); | ||
| 1196 | |||
| 1197 | return mod.analyzeImport(scope, inst.base.src, operand); | ||
| 1198 | } | ||
| 1199 | |||
| 1193 | fn analyzeInstShl(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1200 | fn analyzeInstShl(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1194 | return mod.fail(scope, inst.base.src, "TODO implement analyzeInstShl", .{}); | 1201 | return mod.fail(scope, inst.base.src, "TODO implement analyzeInstShl", .{}); |
| 1195 | } | 1202 | } |