| author | |
| committer | |
| log | cb20093614efecb341f8b3260bf9f91bb10556e6 |
| tree | acbc8f6fae9e00bf79223162d5c5ca747540456c |
| parent | b06e5b8c6862ce77dab314c7817709f0832799df |
| signature |
9 files changed, 151 insertions(+), 192 deletions(-)
src-self-hosted/codegen.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code) |
| 17 | 17 | defer fn_val.base.deref(comp); |
| 18 | 18 | defer code.destroy(comp.gpa()); |
| 19 | 19 | |
| 20 | var output_path = try await (async comp.createRandomOutputPath(comp.target.objFileExt()) catch unreachable); | |
| 20 | var output_path = try comp.createRandomOutputPath(comp.target.objFileExt()); | |
| 21 | 21 | errdefer output_path.deinit(); |
| 22 | 22 | |
| 23 | 23 | const llvm_handle = try comp.zig_compiler.getAnyLlvmContext(); |
src-self-hosted/compilation.zig+63-81| ... | ... | @@ -93,8 +93,8 @@ pub const ZigCompiler = struct { |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | pub async fn getNativeLibC(self: *ZigCompiler) !*LibCInstallation { |
| 96 | if (await (async self.native_libc.start() catch unreachable)) |ptr| return ptr; | |
| 97 | try await (async self.native_libc.data.findNative(self.loop) catch unreachable); | |
| 96 | if (self.native_libc.start()) |ptr| return ptr; | |
| 97 | try self.native_libc.data.findNative(self.loop); | |
| 98 | 98 | self.native_libc.resolve(); |
| 99 | 99 | return &self.native_libc.data; |
| 100 | 100 | } |
| ... | ... | @@ -227,8 +227,8 @@ pub const Compilation = struct { |
| 227 | 227 | /// need to wait on this group before deinitializing |
| 228 | 228 | deinit_group: event.Group(void), |
| 229 | 229 | |
| 230 | destroy_handle: promise, | |
| 231 | main_loop_handle: promise, | |
| 230 | // destroy_frame: @Frame(createAsync), | |
| 231 | main_loop_frame: @Frame(Compilation.mainLoop), | |
| 232 | 232 | main_loop_future: event.Future(void), |
| 233 | 233 | |
| 234 | 234 | have_err_ret_tracing: bool, |
| ... | ... | @@ -348,7 +348,7 @@ pub const Compilation = struct { |
| 348 | 348 | zig_lib_dir: []const u8, |
| 349 | 349 | ) !*Compilation { |
| 350 | 350 | var optional_comp: ?*Compilation = null; |
| 351 | const handle = try async<zig_compiler.loop.allocator> createAsync( | |
| 351 | const frame = async createAsync( | |
| 352 | 352 | &optional_comp, |
| 353 | 353 | zig_compiler, |
| 354 | 354 | name, |
| ... | ... | @@ -359,10 +359,7 @@ pub const Compilation = struct { |
| 359 | 359 | is_static, |
| 360 | 360 | zig_lib_dir, |
| 361 | 361 | ); |
| 362 | return optional_comp orelse if (getAwaitResult( | |
| 363 | zig_compiler.loop.allocator, | |
| 364 | handle, | |
| 365 | )) |_| unreachable else |err| err; | |
| 362 | return optional_comp orelse await frame; | |
| 366 | 363 | } |
| 367 | 364 | |
| 368 | 365 | async fn createAsync( |
| ... | ... | @@ -376,10 +373,6 @@ pub const Compilation = struct { |
| 376 | 373 | is_static: bool, |
| 377 | 374 | zig_lib_dir: []const u8, |
| 378 | 375 | ) !void { |
| 379 | // workaround for https://github.com/ziglang/zig/issues/1194 | |
| 380 | suspend { | |
| 381 | resume @handle(); | |
| 382 | } | |
| 383 | 376 | |
| 384 | 377 | const loop = zig_compiler.loop; |
| 385 | 378 | var comp = Compilation{ |
| ... | ... | @@ -395,8 +388,8 @@ pub const Compilation = struct { |
| 395 | 388 | .zig_lib_dir = zig_lib_dir, |
| 396 | 389 | .zig_std_dir = undefined, |
| 397 | 390 | .tmp_dir = event.Future(BuildError![]u8).init(loop), |
| 398 | .destroy_handle = @handle(), | |
| 399 | .main_loop_handle = undefined, | |
| 391 | .destroy_frame = @frame(), | |
| 392 | .main_loop_frame = undefined, | |
| 400 | 393 | .main_loop_future = event.Future(void).init(loop), |
| 401 | 394 | |
| 402 | 395 | .name = undefined, |
| ... | ... | @@ -546,7 +539,7 @@ pub const Compilation = struct { |
| 546 | 539 | try comp.initTypes(); |
| 547 | 540 | defer comp.primitive_type_table.deinit(); |
| 548 | 541 | |
| 549 | comp.main_loop_handle = async comp.mainLoop() catch unreachable; | |
| 542 | comp.main_loop_frame = async comp.mainLoop() catch unreachable; | |
| 550 | 543 | // Set this to indicate that initialization completed successfully. |
| 551 | 544 | // from here on out we must not return an error. |
| 552 | 545 | // This must occur before the first suspend/await. |
| ... | ... | @@ -555,7 +548,7 @@ pub const Compilation = struct { |
| 555 | 548 | suspend; |
| 556 | 549 | // From here on is cleanup. |
| 557 | 550 | |
| 558 | await (async comp.deinit_group.wait() catch unreachable); | |
| 551 | comp.deinit_group.wait(); | |
| 559 | 552 | |
| 560 | 553 | if (comp.tmp_dir.getOrNull()) |tmp_dir_result| if (tmp_dir_result.*) |tmp_dir| { |
| 561 | 554 | // TODO evented I/O? |
| ... | ... | @@ -578,10 +571,10 @@ pub const Compilation = struct { |
| 578 | 571 | error.Overflow => return error.Overflow, |
| 579 | 572 | error.InvalidCharacter => unreachable, // we just checked the characters above |
| 580 | 573 | }; |
| 581 | const int_type = try await (async Type.Int.get(comp, Type.Int.Key{ | |
| 574 | const int_type = try Type.Int.get(comp, Type.Int.Key{ | |
| 582 | 575 | .bit_count = bit_count, |
| 583 | 576 | .is_signed = is_signed, |
| 584 | }) catch unreachable); | |
| 577 | }); | |
| 585 | 578 | errdefer int_type.base.base.deref(); |
| 586 | 579 | return &int_type.base; |
| 587 | 580 | }, |
| ... | ... | @@ -758,8 +751,8 @@ pub const Compilation = struct { |
| 758 | 751 | } |
| 759 | 752 | |
| 760 | 753 | pub fn destroy(self: *Compilation) void { |
| 761 | cancel self.main_loop_handle; | |
| 762 | resume self.destroy_handle; | |
| 754 | await self.main_loop_frame; | |
| 755 | resume self.destroy_frame; | |
| 763 | 756 | } |
| 764 | 757 | |
| 765 | 758 | fn start(self: *Compilation) void { |
| ... | ... | @@ -768,13 +761,13 @@ pub const Compilation = struct { |
| 768 | 761 | |
| 769 | 762 | async fn mainLoop(self: *Compilation) void { |
| 770 | 763 | // wait until start() is called |
| 771 | _ = await (async self.main_loop_future.get() catch unreachable); | |
| 764 | _ = self.main_loop_future.get(); | |
| 772 | 765 | |
| 773 | var build_result = await (async self.initialCompile() catch unreachable); | |
| 766 | var build_result = self.initialCompile(); | |
| 774 | 767 | |
| 775 | 768 | while (true) { |
| 776 | 769 | const link_result = if (build_result) blk: { |
| 777 | break :blk await (async self.maybeLink() catch unreachable); | |
| 770 | break :blk self.maybeLink(); | |
| 778 | 771 | } else |err| err; |
| 779 | 772 | // this makes a handy error return trace and stack trace in debug mode |
| 780 | 773 | if (std.debug.runtime_safety) { |
| ... | ... | @@ -782,28 +775,28 @@ pub const Compilation = struct { |
| 782 | 775 | } |
| 783 | 776 | |
| 784 | 777 | const compile_errors = blk: { |
| 785 | const held = await (async self.compile_errors.acquire() catch unreachable); | |
| 778 | const held = self.compile_errors.acquire(); | |
| 786 | 779 | defer held.release(); |
| 787 | 780 | break :blk held.value.toOwnedSlice(); |
| 788 | 781 | }; |
| 789 | 782 | |
| 790 | 783 | if (link_result) |_| { |
| 791 | 784 | if (compile_errors.len == 0) { |
| 792 | await (async self.events.put(Event.Ok) catch unreachable); | |
| 785 | self.events.put(Event.Ok); | |
| 793 | 786 | } else { |
| 794 | await (async self.events.put(Event{ .Fail = compile_errors }) catch unreachable); | |
| 787 | self.events.put(Event{ .Fail = compile_errors }); | |
| 795 | 788 | } |
| 796 | 789 | } else |err| { |
| 797 | 790 | // if there's an error then the compile errors have dangling references |
| 798 | 791 | self.gpa().free(compile_errors); |
| 799 | 792 | |
| 800 | await (async self.events.put(Event{ .Error = err }) catch unreachable); | |
| 793 | self.events.put(Event{ .Error = err }); | |
| 801 | 794 | } |
| 802 | 795 | |
| 803 | 796 | // First, get an item from the watch channel, waiting on the channel. |
| 804 | 797 | var group = event.Group(BuildError!void).init(self.loop); |
| 805 | 798 | { |
| 806 | const ev = (await (async self.fs_watch.channel.get() catch unreachable)) catch |err| { | |
| 799 | const ev = (self.fs_watch.channel.get()) catch |err| { | |
| 807 | 800 | build_result = err; |
| 808 | 801 | continue; |
| 809 | 802 | }; |
| ... | ... | @@ -814,7 +807,7 @@ pub const Compilation = struct { |
| 814 | 807 | }; |
| 815 | 808 | } |
| 816 | 809 | // Next, get all the items from the channel that are buffered up. |
| 817 | while (await (async self.fs_watch.channel.getOrNull() catch unreachable)) |ev_or_err| { | |
| 810 | while (self.fs_watch.channel.getOrNull()) |ev_or_err| { | |
| 818 | 811 | if (ev_or_err) |ev| { |
| 819 | 812 | const root_scope = ev.data; |
| 820 | 813 | group.call(rebuildFile, self, root_scope) catch |err| { |
| ... | ... | @@ -826,17 +819,17 @@ pub const Compilation = struct { |
| 826 | 819 | continue; |
| 827 | 820 | } |
| 828 | 821 | } |
| 829 | build_result = await (async group.wait() catch unreachable); | |
| 822 | build_result = group.wait(); | |
| 830 | 823 | } |
| 831 | 824 | } |
| 832 | 825 | |
| 833 | 826 | async fn rebuildFile(self: *Compilation, root_scope: *Scope.Root) !void { |
| 834 | 827 | const tree_scope = blk: { |
| 835 | const source_code = (await (async fs.readFile( | |
| 828 | const source_code = fs.readFile( | |
| 836 | 829 | self.loop, |
| 837 | 830 | root_scope.realpath, |
| 838 | 831 | max_src_size, |
| 839 | ) catch unreachable)) catch |err| { | |
| 832 | ) catch |err| { | |
| 840 | 833 | try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", @errorName(err)); |
| 841 | 834 | return; |
| 842 | 835 | }; |
| ... | ... | @@ -856,13 +849,13 @@ pub const Compilation = struct { |
| 856 | 849 | const msg = try Msg.createFromParseErrorAndScope(self, tree_scope, parse_error); |
| 857 | 850 | errdefer msg.destroy(); |
| 858 | 851 | |
| 859 | try await (async self.addCompileErrorAsync(msg) catch unreachable); | |
| 852 | try self.addCompileErrorAsync(msg); | |
| 860 | 853 | } |
| 861 | 854 | if (tree_scope.tree.errors.len != 0) { |
| 862 | 855 | return; |
| 863 | 856 | } |
| 864 | 857 | |
| 865 | const locked_table = await (async root_scope.decls.table.acquireWrite() catch unreachable); | |
| 858 | const locked_table = root_scope.decls.table.acquireWrite(); | |
| 866 | 859 | defer locked_table.release(); |
| 867 | 860 | |
| 868 | 861 | var decl_group = event.Group(BuildError!void).init(self.loop); |
| ... | ... | @@ -876,7 +869,7 @@ pub const Compilation = struct { |
| 876 | 869 | tree_scope, |
| 877 | 870 | ); |
| 878 | 871 | |
| 879 | try await (async decl_group.wait() catch unreachable); | |
| 872 | try decl_group.wait(); | |
| 880 | 873 | } |
| 881 | 874 | |
| 882 | 875 | async fn rebuildChangedDecls( |
| ... | ... | @@ -988,20 +981,20 @@ pub const Compilation = struct { |
| 988 | 981 | } |
| 989 | 982 | |
| 990 | 983 | async fn maybeLink(self: *Compilation) !void { |
| 991 | (await (async self.prelink_group.wait() catch unreachable)) catch |err| switch (err) { | |
| 984 | (self.prelink_group.wait()) catch |err| switch (err) { | |
| 992 | 985 | error.SemanticAnalysisFailed => {}, |
| 993 | 986 | else => return err, |
| 994 | 987 | }; |
| 995 | 988 | |
| 996 | 989 | const any_prelink_errors = blk: { |
| 997 | const compile_errors = await (async self.compile_errors.acquire() catch unreachable); | |
| 990 | const compile_errors = self.compile_errors.acquire(); | |
| 998 | 991 | defer compile_errors.release(); |
| 999 | 992 | |
| 1000 | 993 | break :blk compile_errors.value.len != 0; |
| 1001 | 994 | }; |
| 1002 | 995 | |
| 1003 | 996 | if (!any_prelink_errors) { |
| 1004 | try await (async link(self) catch unreachable); | |
| 997 | try link(self); | |
| 1005 | 998 | } |
| 1006 | 999 | } |
| 1007 | 1000 | |
| ... | ... | @@ -1013,12 +1006,12 @@ pub const Compilation = struct { |
| 1013 | 1006 | node: *ast.Node, |
| 1014 | 1007 | expected_type: ?*Type, |
| 1015 | 1008 | ) !*ir.Code { |
| 1016 | const unanalyzed_code = try await (async ir.gen( | |
| 1009 | const unanalyzed_code = try ir.gen( | |
| 1017 | 1010 | comp, |
| 1018 | 1011 | node, |
| 1019 | 1012 | tree_scope, |
| 1020 | 1013 | scope, |
| 1021 | ) catch unreachable); | |
| 1014 | ); | |
| 1022 | 1015 | defer unanalyzed_code.destroy(comp.gpa()); |
| 1023 | 1016 | |
| 1024 | 1017 | if (comp.verbose_ir) { |
| ... | ... | @@ -1026,11 +1019,11 @@ pub const Compilation = struct { |
| 1026 | 1019 | unanalyzed_code.dump(); |
| 1027 | 1020 | } |
| 1028 | 1021 | |
| 1029 | const analyzed_code = try await (async ir.analyze( | |
| 1022 | const analyzed_code = try ir.analyze( | |
| 1030 | 1023 | comp, |
| 1031 | 1024 | unanalyzed_code, |
| 1032 | 1025 | expected_type, |
| 1033 | ) catch unreachable); | |
| 1026 | ); | |
| 1034 | 1027 | errdefer analyzed_code.destroy(comp.gpa()); |
| 1035 | 1028 | |
| 1036 | 1029 | if (comp.verbose_ir) { |
| ... | ... | @@ -1050,13 +1043,13 @@ pub const Compilation = struct { |
| 1050 | 1043 | const void_type = Type.Void.get(comp); |
| 1051 | 1044 | defer void_type.base.base.deref(comp); |
| 1052 | 1045 | |
| 1053 | const analyzed_code = (await (async genAndAnalyzeCode( | |
| 1046 | const analyzed_code = genAndAnalyzeCode( | |
| 1054 | 1047 | comp, |
| 1055 | 1048 | tree_scope, |
| 1056 | 1049 | scope, |
| 1057 | 1050 | comptime_node.expr, |
| 1058 | 1051 | &void_type.base, |
| 1059 | ) catch unreachable)) catch |err| switch (err) { | |
| 1052 | ) catch |err| switch (err) { | |
| 1060 | 1053 | // This poison value should not cause the errdefers to run. It simply means |
| 1061 | 1054 | // that comp.compile_errors is populated. |
| 1062 | 1055 | error.SemanticAnalysisFailed => return {}, |
| ... | ... | @@ -1112,14 +1105,14 @@ pub const Compilation = struct { |
| 1112 | 1105 | ) !void { |
| 1113 | 1106 | errdefer msg.destroy(); |
| 1114 | 1107 | |
| 1115 | const compile_errors = await (async self.compile_errors.acquire() catch unreachable); | |
| 1108 | const compile_errors = self.compile_errors.acquire(); | |
| 1116 | 1109 | defer compile_errors.release(); |
| 1117 | 1110 | |
| 1118 | 1111 | try compile_errors.value.append(msg); |
| 1119 | 1112 | } |
| 1120 | 1113 | |
| 1121 | 1114 | async fn verifyUniqueSymbol(self: *Compilation, decl: *Decl) !void { |
| 1122 | const exported_symbol_names = await (async self.exported_symbol_names.acquire() catch unreachable); | |
| 1115 | const exported_symbol_names = self.exported_symbol_names.acquire(); | |
| 1123 | 1116 | defer exported_symbol_names.release(); |
| 1124 | 1117 | |
| 1125 | 1118 | if (try exported_symbol_names.value.put(decl.name, decl)) |other_decl| { |
| ... | ... | @@ -1173,9 +1166,9 @@ pub const Compilation = struct { |
| 1173 | 1166 | |
| 1174 | 1167 | /// cancels itself so no need to await or cancel the promise. |
| 1175 | 1168 | async fn startFindingNativeLibC(self: *Compilation) void { |
| 1176 | await (async self.loop.yield() catch unreachable); | |
| 1169 | self.loop.yield(); | |
| 1177 | 1170 | // we don't care if it fails, we're just trying to kick off the future resolution |
| 1178 | _ = (await (async self.zig_compiler.getNativeLibC() catch unreachable)) catch return; | |
| 1171 | _ = (self.zig_compiler.getNativeLibC()) catch return; | |
| 1179 | 1172 | } |
| 1180 | 1173 | |
| 1181 | 1174 | /// General Purpose Allocator. Must free when done. |
| ... | ... | @@ -1191,8 +1184,8 @@ pub const Compilation = struct { |
| 1191 | 1184 | /// If the temporary directory for this compilation has not been created, it creates it. |
| 1192 | 1185 | /// Then it creates a random file name in that dir and returns it. |
| 1193 | 1186 | pub async fn createRandomOutputPath(self: *Compilation, suffix: []const u8) !Buffer { |
| 1194 | const tmp_dir = try await (async self.getTmpDir() catch unreachable); | |
| 1195 | const file_prefix = await (async self.getRandomFileName() catch unreachable); | |
| 1187 | const tmp_dir = try self.getTmpDir(); | |
| 1188 | const file_prefix = self.getRandomFileName(); | |
| 1196 | 1189 | |
| 1197 | 1190 | const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", file_prefix[0..], suffix); |
| 1198 | 1191 | defer self.gpa().free(file_name); |
| ... | ... | @@ -1207,14 +1200,14 @@ pub const Compilation = struct { |
| 1207 | 1200 | /// Then returns it. The directory is unique to this Compilation and cleaned up when |
| 1208 | 1201 | /// the Compilation deinitializes. |
| 1209 | 1202 | async fn getTmpDir(self: *Compilation) ![]const u8 { |
| 1210 | if (await (async self.tmp_dir.start() catch unreachable)) |ptr| return ptr.*; | |
| 1211 | self.tmp_dir.data = await (async self.getTmpDirImpl() catch unreachable); | |
| 1203 | if (self.tmp_dir.start()) |ptr| return ptr.*; | |
| 1204 | self.tmp_dir.data = self.getTmpDirImpl(); | |
| 1212 | 1205 | self.tmp_dir.resolve(); |
| 1213 | 1206 | return self.tmp_dir.data; |
| 1214 | 1207 | } |
| 1215 | 1208 | |
| 1216 | 1209 | async fn getTmpDirImpl(self: *Compilation) ![]u8 { |
| 1217 | const comp_dir_name = await (async self.getRandomFileName() catch unreachable); | |
| 1210 | const comp_dir_name = self.getRandomFileName(); | |
| 1218 | 1211 | const zig_dir_path = try getZigDir(self.gpa()); |
| 1219 | 1212 | defer self.gpa().free(zig_dir_path); |
| 1220 | 1213 | |
| ... | ... | @@ -1233,7 +1226,7 @@ pub const Compilation = struct { |
| 1233 | 1226 | var rand_bytes: [9]u8 = undefined; |
| 1234 | 1227 | |
| 1235 | 1228 | { |
| 1236 | const held = await (async self.zig_compiler.prng.acquire() catch unreachable); | |
| 1229 | const held = self.zig_compiler.prng.acquire(); | |
| 1237 | 1230 | defer held.release(); |
| 1238 | 1231 | |
| 1239 | 1232 | held.value.random.bytes(rand_bytes[0..]); |
| ... | ... | @@ -1256,7 +1249,7 @@ pub const Compilation = struct { |
| 1256 | 1249 | node: *ast.Node, |
| 1257 | 1250 | expected_type: *Type, |
| 1258 | 1251 | ) !*Value { |
| 1259 | const analyzed_code = try await (async comp.genAndAnalyzeCode(tree_scope, scope, node, expected_type) catch unreachable); | |
| 1252 | const analyzed_code = try comp.genAndAnalyzeCode(tree_scope, scope, node, expected_type); | |
| 1260 | 1253 | defer analyzed_code.destroy(comp.gpa()); |
| 1261 | 1254 | |
| 1262 | 1255 | return analyzed_code.getCompTimeResult(comp); |
| ... | ... | @@ -1266,7 +1259,7 @@ pub const Compilation = struct { |
| 1266 | 1259 | const meta_type = &Type.MetaType.get(comp).base; |
| 1267 | 1260 | defer meta_type.base.deref(comp); |
| 1268 | 1261 | |
| 1269 | const result_val = try await (async comp.analyzeConstValue(tree_scope, scope, node, meta_type) catch unreachable); | |
| 1262 | const result_val = try comp.analyzeConstValue(tree_scope, scope, node, meta_type); | |
| 1270 | 1263 | errdefer result_val.base.deref(comp); |
| 1271 | 1264 | |
| 1272 | 1265 | return result_val.cast(Type).?; |
| ... | ... | @@ -1274,9 +1267,9 @@ pub const Compilation = struct { |
| 1274 | 1267 | |
| 1275 | 1268 | /// This declaration has been blessed as going into the final code generation. |
| 1276 | 1269 | pub async fn resolveDecl(comp: *Compilation, decl: *Decl) !void { |
| 1277 | if (await (async decl.resolution.start() catch unreachable)) |ptr| return ptr.*; | |
| 1270 | if (decl.resolution.start()) |ptr| return ptr.*; | |
| 1278 | 1271 | |
| 1279 | decl.resolution.data = try await (async generateDecl(comp, decl) catch unreachable); | |
| 1272 | decl.resolution.data = try generateDecl(comp, decl); | |
| 1280 | 1273 | decl.resolution.resolve(); |
| 1281 | 1274 | return decl.resolution.data; |
| 1282 | 1275 | } |
| ... | ... | @@ -1298,7 +1291,7 @@ async fn generateDecl(comp: *Compilation, decl: *Decl) !void { |
| 1298 | 1291 | Decl.Id.Var => @panic("TODO"), |
| 1299 | 1292 | Decl.Id.Fn => { |
| 1300 | 1293 | const fn_decl = @fieldParentPtr(Decl.Fn, "base", decl); |
| 1301 | return await (async generateDeclFn(comp, fn_decl) catch unreachable); | |
| 1294 | return generateDeclFn(comp, fn_decl); | |
| 1302 | 1295 | }, |
| 1303 | 1296 | Decl.Id.CompTime => @panic("TODO"), |
| 1304 | 1297 | } |
| ... | ... | @@ -1307,12 +1300,12 @@ async fn generateDecl(comp: *Compilation, decl: *Decl) !void { |
| 1307 | 1300 | async fn generateDeclFn(comp: *Compilation, fn_decl: *Decl.Fn) !void { |
| 1308 | 1301 | const tree_scope = fn_decl.base.tree_scope; |
| 1309 | 1302 | |
| 1310 | const body_node = fn_decl.fn_proto.body_node orelse return await (async generateDeclFnProto(comp, fn_decl) catch unreachable); | |
| 1303 | const body_node = fn_decl.fn_proto.body_node orelse return generateDeclFnProto(comp, fn_decl); | |
| 1311 | 1304 | |
| 1312 | 1305 | const fndef_scope = try Scope.FnDef.create(comp, fn_decl.base.parent_scope); |
| 1313 | 1306 | defer fndef_scope.base.deref(comp); |
| 1314 | 1307 | |
| 1315 | const fn_type = try await (async analyzeFnType(comp, tree_scope, fn_decl.base.parent_scope, fn_decl.fn_proto) catch unreachable); | |
| 1308 | const fn_type = try analyzeFnType(comp, tree_scope, fn_decl.base.parent_scope, fn_decl.fn_proto); | |
| 1316 | 1309 | defer fn_type.base.base.deref(comp); |
| 1317 | 1310 | |
| 1318 | 1311 | var symbol_name = try std.Buffer.init(comp.gpa(), fn_decl.base.name); |
| ... | ... | @@ -1356,12 +1349,12 @@ async fn generateDeclFn(comp: *Compilation, fn_decl: *Decl.Fn) !void { |
| 1356 | 1349 | try fn_type.non_key.Normal.variable_list.append(var_scope); |
| 1357 | 1350 | } |
| 1358 | 1351 | |
| 1359 | const analyzed_code = try await (async comp.genAndAnalyzeCode( | |
| 1352 | const analyzed_code = try comp.genAndAnalyzeCode( | |
| 1360 | 1353 | tree_scope, |
| 1361 | 1354 | fn_val.child_scope, |
| 1362 | 1355 | body_node, |
| 1363 | 1356 | fn_type.key.data.Normal.return_type, |
| 1364 | ) catch unreachable); | |
| 1357 | ); | |
| 1365 | 1358 | errdefer analyzed_code.destroy(comp.gpa()); |
| 1366 | 1359 | |
| 1367 | 1360 | assert(fn_val.block_scope != null); |
| ... | ... | @@ -1378,7 +1371,7 @@ async fn addFnToLinkSet(comp: *Compilation, fn_val: *Value.Fn) void { |
| 1378 | 1371 | |
| 1379 | 1372 | fn_val.link_set_node.data = fn_val; |
| 1380 | 1373 | |
| 1381 | const held = await (async comp.fn_link_set.acquire() catch unreachable); | |
| 1374 | const held = comp.fn_link_set.acquire(); | |
| 1382 | 1375 | defer held.release(); |
| 1383 | 1376 | |
| 1384 | 1377 | held.value.append(fn_val.link_set_node); |
| ... | ... | @@ -1398,7 +1391,7 @@ async fn analyzeFnType( |
| 1398 | 1391 | ast.Node.FnProto.ReturnType.Explicit => |n| n, |
| 1399 | 1392 | ast.Node.FnProto.ReturnType.InferErrorSet => |n| n, |
| 1400 | 1393 | }; |
| 1401 | const return_type = try await (async comp.analyzeTypeExpr(tree_scope, scope, return_type_node) catch unreachable); | |
| 1394 | const return_type = try comp.analyzeTypeExpr(tree_scope, scope, return_type_node); | |
| 1402 | 1395 | return_type.base.deref(comp); |
| 1403 | 1396 | |
| 1404 | 1397 | var params = ArrayList(Type.Fn.Param).init(comp.gpa()); |
| ... | ... | @@ -1414,7 +1407,7 @@ async fn analyzeFnType( |
| 1414 | 1407 | var it = fn_proto.params.iterator(0); |
| 1415 | 1408 | while (it.next()) |param_node_ptr| { |
| 1416 | 1409 | const param_node = param_node_ptr.*.cast(ast.Node.ParamDecl).?; |
| 1417 | const param_type = try await (async comp.analyzeTypeExpr(tree_scope, scope, param_node.type_node) catch unreachable); | |
| 1410 | const param_type = try comp.analyzeTypeExpr(tree_scope, scope, param_node.type_node); | |
| 1418 | 1411 | errdefer param_type.base.deref(comp); |
| 1419 | 1412 | try params.append(Type.Fn.Param{ |
| 1420 | 1413 | .typ = param_type, |
| ... | ... | @@ -1443,7 +1436,7 @@ async fn analyzeFnType( |
| 1443 | 1436 | comp.gpa().free(key.data.Normal.params); |
| 1444 | 1437 | }; |
| 1445 | 1438 | |
| 1446 | const fn_type = try await (async Type.Fn.get(comp, key) catch unreachable); | |
| 1439 | const fn_type = try Type.Fn.get(comp, key); | |
| 1447 | 1440 | key_consumed = true; |
| 1448 | 1441 | errdefer fn_type.base.base.deref(comp); |
| 1449 | 1442 | |
| ... | ... | @@ -1451,12 +1444,12 @@ async fn analyzeFnType( |
| 1451 | 1444 | } |
| 1452 | 1445 | |
| 1453 | 1446 | async fn generateDeclFnProto(comp: *Compilation, fn_decl: *Decl.Fn) !void { |
| 1454 | const fn_type = try await (async analyzeFnType( | |
| 1447 | const fn_type = try analyzeFnType( | |
| 1455 | 1448 | comp, |
| 1456 | 1449 | fn_decl.base.tree_scope, |
| 1457 | 1450 | fn_decl.base.parent_scope, |
| 1458 | 1451 | fn_decl.fn_proto, |
| 1459 | ) catch unreachable); | |
| 1452 | ); | |
| 1460 | 1453 | defer fn_type.base.base.deref(comp); |
| 1461 | 1454 | |
| 1462 | 1455 | var symbol_name = try std.Buffer.init(comp.gpa(), fn_decl.base.name); |
| ... | ... | @@ -1468,14 +1461,3 @@ async fn generateDeclFnProto(comp: *Compilation, fn_decl: *Decl.Fn) !void { |
| 1468 | 1461 | fn_decl.value = Decl.Fn.Val{ .FnProto = fn_proto_val }; |
| 1469 | 1462 | symbol_name_consumed = true; |
| 1470 | 1463 | } |
| 1471 | ||
| 1472 | // TODO these are hacks which should probably be solved by the language | |
| 1473 | fn getAwaitResult(allocator: *Allocator, handle: var) @typeInfo(@typeOf(handle)).Promise.child.? { | |
| 1474 | var result: ?@typeInfo(@typeOf(handle)).Promise.child.? = null; | |
| 1475 | cancel (async<allocator> getAwaitResultAsync(handle, &result) catch unreachable); | |
| 1476 | return result.?; | |
| 1477 | } | |
| 1478 | ||
| 1479 | async fn getAwaitResultAsync(handle: var, out: *?@typeInfo(@typeOf(handle)).Promise.child.?) void { | |
| 1480 | out.* = await handle; | |
| 1481 | } |
src-self-hosted/ir.zig+41-41| ... | ... | @@ -116,16 +116,16 @@ pub const Inst = struct { |
| 116 | 116 | Id.Return => return @fieldParentPtr(Return, "base", base).analyze(ira), |
| 117 | 117 | Id.Const => return @fieldParentPtr(Const, "base", base).analyze(ira), |
| 118 | 118 | Id.Call => return @fieldParentPtr(Call, "base", base).analyze(ira), |
| 119 | Id.DeclRef => return await (async @fieldParentPtr(DeclRef, "base", base).analyze(ira) catch unreachable), | |
| 120 | Id.Ref => return await (async @fieldParentPtr(Ref, "base", base).analyze(ira) catch unreachable), | |
| 119 | Id.DeclRef => return @fieldParentPtr(DeclRef, "base", base).analyze(ira), | |
| 120 | Id.Ref => return @fieldParentPtr(Ref, "base", base).analyze(ira), | |
| 121 | 121 | Id.DeclVar => return @fieldParentPtr(DeclVar, "base", base).analyze(ira), |
| 122 | 122 | Id.CheckVoidStmt => return @fieldParentPtr(CheckVoidStmt, "base", base).analyze(ira), |
| 123 | 123 | Id.Phi => return @fieldParentPtr(Phi, "base", base).analyze(ira), |
| 124 | 124 | Id.Br => return @fieldParentPtr(Br, "base", base).analyze(ira), |
| 125 | 125 | Id.AddImplicitReturnType => return @fieldParentPtr(AddImplicitReturnType, "base", base).analyze(ira), |
| 126 | Id.PtrType => return await (async @fieldParentPtr(PtrType, "base", base).analyze(ira) catch unreachable), | |
| 127 | Id.VarPtr => return await (async @fieldParentPtr(VarPtr, "base", base).analyze(ira) catch unreachable), | |
| 128 | Id.LoadPtr => return await (async @fieldParentPtr(LoadPtr, "base", base).analyze(ira) catch unreachable), | |
| 126 | Id.PtrType => return @fieldParentPtr(PtrType, "base", base).analyze(ira), | |
| 127 | Id.VarPtr => return @fieldParentPtr(VarPtr, "base", base).analyze(ira), | |
| 128 | Id.LoadPtr => return @fieldParentPtr(LoadPtr, "base", base).analyze(ira), | |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
| ... | ... | @@ -441,13 +441,13 @@ pub const Inst = struct { |
| 441 | 441 | .volatility = self.params.volatility, |
| 442 | 442 | }); |
| 443 | 443 | const elem_type = target.getKnownType(); |
| 444 | const ptr_type = try await (async Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{ | |
| 444 | const ptr_type = try Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{ | |
| 445 | 445 | .child_type = elem_type, |
| 446 | 446 | .mut = self.params.mut, |
| 447 | 447 | .vol = self.params.volatility, |
| 448 | 448 | .size = Type.Pointer.Size.One, |
| 449 | 449 | .alignment = Type.Pointer.Align.Abi, |
| 450 | }) catch unreachable); | |
| 450 | }); | |
| 451 | 451 | // TODO: potentially set the hint that this is a stack pointer. But it might not be - this |
| 452 | 452 | // could be a ref of a global, for example |
| 453 | 453 | new_inst.val = IrVal{ .KnownType = &ptr_type.base }; |
| ... | ... | @@ -474,7 +474,7 @@ pub const Inst = struct { |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | pub async fn analyze(self: *const DeclRef, ira: *Analyze) !*Inst { |
| 477 | (await (async ira.irb.comp.resolveDecl(self.params.decl) catch unreachable)) catch |err| switch (err) { | |
| 477 | (ira.irb.comp.resolveDecl(self.params.decl)) catch |err| switch (err) { | |
| 478 | 478 | error.OutOfMemory => return error.OutOfMemory, |
| 479 | 479 | else => return error.SemanticAnalysisFailed, |
| 480 | 480 | }; |
| ... | ... | @@ -527,13 +527,13 @@ pub const Inst = struct { |
| 527 | 527 | self.base.span, |
| 528 | 528 | Inst.VarPtr.Params{ .var_scope = self.params.var_scope }, |
| 529 | 529 | ); |
| 530 | const ptr_type = try await (async Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{ | |
| 530 | const ptr_type = try Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{ | |
| 531 | 531 | .child_type = param.typ, |
| 532 | 532 | .mut = Type.Pointer.Mut.Const, |
| 533 | 533 | .vol = Type.Pointer.Vol.Non, |
| 534 | 534 | .size = Type.Pointer.Size.One, |
| 535 | 535 | .alignment = Type.Pointer.Align.Abi, |
| 536 | }) catch unreachable); | |
| 536 | }); | |
| 537 | 537 | new_inst.val = IrVal{ .KnownType = &ptr_type.base }; |
| 538 | 538 | return new_inst; |
| 539 | 539 | }, |
| ... | ... | @@ -661,13 +661,13 @@ pub const Inst = struct { |
| 661 | 661 | } else blk: { |
| 662 | 662 | break :blk Type.Pointer.Align{ .Abi = {} }; |
| 663 | 663 | }; |
| 664 | const ptr_type = try await (async Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{ | |
| 664 | const ptr_type = try Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{ | |
| 665 | 665 | .child_type = child_type, |
| 666 | 666 | .mut = self.params.mut, |
| 667 | 667 | .vol = self.params.vol, |
| 668 | 668 | .size = self.params.size, |
| 669 | 669 | .alignment = alignment, |
| 670 | }) catch unreachable); | |
| 670 | }); | |
| 671 | 671 | ptr_type.base.base.deref(ira.irb.comp); |
| 672 | 672 | |
| 673 | 673 | return ira.irb.buildConstValue(self.base.scope, self.base.span, &ptr_type.base.base); |
| ... | ... | @@ -1101,7 +1101,7 @@ pub const Builder = struct { |
| 1101 | 1101 | ast.Node.PrefixOp.Op.NegationWrap => return error.Unimplemented, |
| 1102 | 1102 | ast.Node.PrefixOp.Op.Resume => return error.Unimplemented, |
| 1103 | 1103 | ast.Node.PrefixOp.Op.PtrType => |ptr_info| { |
| 1104 | const inst = try await (async irb.genPtrType(prefix_op, ptr_info, scope) catch unreachable); | |
| 1104 | const inst = try irb.genPtrType(prefix_op, ptr_info, scope); | |
| 1105 | 1105 | return irb.lvalWrap(scope, inst, lval); |
| 1106 | 1106 | }, |
| 1107 | 1107 | ast.Node.PrefixOp.Op.SliceType => |ptr_info| return error.Unimplemented, |
| ... | ... | @@ -1112,7 +1112,7 @@ pub const Builder = struct { |
| 1112 | 1112 | const suffix_op = @fieldParentPtr(ast.Node.SuffixOp, "base", node); |
| 1113 | 1113 | switch (suffix_op.op) { |
| 1114 | 1114 | @TagType(ast.Node.SuffixOp.Op).Call => |*call| { |
| 1115 | const inst = try await (async irb.genCall(suffix_op, call, scope) catch unreachable); | |
| 1115 | const inst = try irb.genCall(suffix_op, call, scope); | |
| 1116 | 1116 | return irb.lvalWrap(scope, inst, lval); |
| 1117 | 1117 | }, |
| 1118 | 1118 | @TagType(ast.Node.SuffixOp.Op).ArrayAccess => |n| return error.Unimplemented, |
| ... | ... | @@ -1129,7 +1129,7 @@ pub const Builder = struct { |
| 1129 | 1129 | ast.Node.Id.If => return error.Unimplemented, |
| 1130 | 1130 | ast.Node.Id.ControlFlowExpression => { |
| 1131 | 1131 | const control_flow_expr = @fieldParentPtr(ast.Node.ControlFlowExpression, "base", node); |
| 1132 | return await (async irb.genControlFlowExpr(control_flow_expr, scope, lval) catch unreachable); | |
| 1132 | return irb.genControlFlowExpr(control_flow_expr, scope, lval); | |
| 1133 | 1133 | }, |
| 1134 | 1134 | ast.Node.Id.Suspend => return error.Unimplemented, |
| 1135 | 1135 | ast.Node.Id.VarType => return error.Unimplemented, |
| ... | ... | @@ -1143,7 +1143,7 @@ pub const Builder = struct { |
| 1143 | 1143 | ast.Node.Id.FloatLiteral => return error.Unimplemented, |
| 1144 | 1144 | ast.Node.Id.StringLiteral => { |
| 1145 | 1145 | const str_lit = @fieldParentPtr(ast.Node.StringLiteral, "base", node); |
| 1146 | const inst = try await (async irb.genStrLit(str_lit, scope) catch unreachable); | |
| 1146 | const inst = try irb.genStrLit(str_lit, scope); | |
| 1147 | 1147 | return irb.lvalWrap(scope, inst, lval); |
| 1148 | 1148 | }, |
| 1149 | 1149 | ast.Node.Id.MultilineStringLiteral => return error.Unimplemented, |
| ... | ... | @@ -1154,11 +1154,11 @@ pub const Builder = struct { |
| 1154 | 1154 | ast.Node.Id.Unreachable => return error.Unimplemented, |
| 1155 | 1155 | ast.Node.Id.Identifier => { |
| 1156 | 1156 | const identifier = @fieldParentPtr(ast.Node.Identifier, "base", node); |
| 1157 | return await (async irb.genIdentifier(identifier, scope, lval) catch unreachable); | |
| 1157 | return irb.genIdentifier(identifier, scope, lval); | |
| 1158 | 1158 | }, |
| 1159 | 1159 | ast.Node.Id.GroupedExpression => { |
| 1160 | 1160 | const grouped_expr = @fieldParentPtr(ast.Node.GroupedExpression, "base", node); |
| 1161 | return await (async irb.genNode(grouped_expr.expr, scope, lval) catch unreachable); | |
| 1161 | return irb.genNode(grouped_expr.expr, scope, lval); | |
| 1162 | 1162 | }, |
| 1163 | 1163 | ast.Node.Id.BuiltinCall => return error.Unimplemented, |
| 1164 | 1164 | ast.Node.Id.ErrorSetDecl => return error.Unimplemented, |
| ... | ... | @@ -1167,7 +1167,7 @@ pub const Builder = struct { |
| 1167 | 1167 | ast.Node.Id.Comptime => return error.Unimplemented, |
| 1168 | 1168 | ast.Node.Id.Block => { |
| 1169 | 1169 | const block = @fieldParentPtr(ast.Node.Block, "base", node); |
| 1170 | const inst = try await (async irb.genBlock(block, scope) catch unreachable); | |
| 1170 | const inst = try irb.genBlock(block, scope); | |
| 1171 | 1171 | return irb.lvalWrap(scope, inst, lval); |
| 1172 | 1172 | }, |
| 1173 | 1173 | ast.Node.Id.DocComment => return error.Unimplemented, |
| ... | ... | @@ -1188,13 +1188,13 @@ pub const Builder = struct { |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | async fn genCall(irb: *Builder, suffix_op: *ast.Node.SuffixOp, call: *ast.Node.SuffixOp.Op.Call, scope: *Scope) !*Inst { |
| 1191 | const fn_ref = try await (async irb.genNode(suffix_op.lhs, scope, LVal.None) catch unreachable); | |
| 1191 | const fn_ref = try irb.genNode(suffix_op.lhs, scope, LVal.None); | |
| 1192 | 1192 | |
| 1193 | 1193 | const args = try irb.arena().alloc(*Inst, call.params.len); |
| 1194 | 1194 | var it = call.params.iterator(0); |
| 1195 | 1195 | var i: usize = 0; |
| 1196 | 1196 | while (it.next()) |arg_node_ptr| : (i += 1) { |
| 1197 | args[i] = try await (async irb.genNode(arg_node_ptr.*, scope, LVal.None) catch unreachable); | |
| 1197 | args[i] = try irb.genNode(arg_node_ptr.*, scope, LVal.None); | |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | //bool is_async = node->data.fn_call_expr.is_async; |
| ... | ... | @@ -1239,7 +1239,7 @@ pub const Builder = struct { |
| 1239 | 1239 | //} else { |
| 1240 | 1240 | // align_value = nullptr; |
| 1241 | 1241 | //} |
| 1242 | const child_type = try await (async irb.genNode(prefix_op.rhs, scope, LVal.None) catch unreachable); | |
| 1242 | const child_type = try irb.genNode(prefix_op.rhs, scope, LVal.None); | |
| 1243 | 1243 | |
| 1244 | 1244 | //uint32_t bit_offset_start = 0; |
| 1245 | 1245 | //if (node->data.pointer_type.bit_offset_start != nullptr) { |
| ... | ... | @@ -1366,23 +1366,23 @@ pub const Builder = struct { |
| 1366 | 1366 | buf[buf.len - 1] = 0; |
| 1367 | 1367 | |
| 1368 | 1368 | // next make an array value |
| 1369 | const array_val = try await (async Value.Array.createOwnedBuffer(irb.comp, buf) catch unreachable); | |
| 1369 | const array_val = try Value.Array.createOwnedBuffer(irb.comp, buf); | |
| 1370 | 1370 | buf_cleaned = true; |
| 1371 | 1371 | defer array_val.base.deref(irb.comp); |
| 1372 | 1372 | |
| 1373 | 1373 | // then make a pointer value pointing at the first element |
| 1374 | const ptr_val = try await (async Value.Ptr.createArrayElemPtr( | |
| 1374 | const ptr_val = try Value.Ptr.createArrayElemPtr( | |
| 1375 | 1375 | irb.comp, |
| 1376 | 1376 | array_val, |
| 1377 | 1377 | Type.Pointer.Mut.Const, |
| 1378 | 1378 | Type.Pointer.Size.Many, |
| 1379 | 1379 | 0, |
| 1380 | ) catch unreachable); | |
| 1380 | ); | |
| 1381 | 1381 | defer ptr_val.base.deref(irb.comp); |
| 1382 | 1382 | |
| 1383 | 1383 | return irb.buildConstValue(scope, src_span, &ptr_val.base); |
| 1384 | 1384 | } else { |
| 1385 | const array_val = try await (async Value.Array.createOwnedBuffer(irb.comp, buf) catch unreachable); | |
| 1385 | const array_val = try Value.Array.createOwnedBuffer(irb.comp, buf); | |
| 1386 | 1386 | buf_cleaned = true; |
| 1387 | 1387 | defer array_val.base.deref(irb.comp); |
| 1388 | 1388 | |
| ... | ... | @@ -1438,7 +1438,7 @@ pub const Builder = struct { |
| 1438 | 1438 | child_scope = &defer_child_scope.base; |
| 1439 | 1439 | continue; |
| 1440 | 1440 | } |
| 1441 | const statement_value = try await (async irb.genNode(statement_node, child_scope, LVal.None) catch unreachable); | |
| 1441 | const statement_value = try irb.genNode(statement_node, child_scope, LVal.None); | |
| 1442 | 1442 | |
| 1443 | 1443 | is_continuation_unreachable = statement_value.isNoReturn(); |
| 1444 | 1444 | if (is_continuation_unreachable) { |
| ... | ... | @@ -1481,7 +1481,7 @@ pub const Builder = struct { |
| 1481 | 1481 | try block_scope.incoming_values.append( |
| 1482 | 1482 | try irb.buildConstVoid(parent_scope, Span.token(block.rbrace), true), |
| 1483 | 1483 | ); |
| 1484 | _ = try await (async irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit) catch unreachable); | |
| 1484 | _ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit); | |
| 1485 | 1485 | |
| 1486 | 1486 | _ = try irb.buildGen(Inst.Br, parent_scope, Span.token(block.rbrace), Inst.Br.Params{ |
| 1487 | 1487 | .dest_block = block_scope.end_block, |
| ... | ... | @@ -1496,7 +1496,7 @@ pub const Builder = struct { |
| 1496 | 1496 | }); |
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | _ = try await (async irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit) catch unreachable); | |
| 1499 | _ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit); | |
| 1500 | 1500 | return irb.buildConstVoid(child_scope, Span.token(block.rbrace), true); |
| 1501 | 1501 | } |
| 1502 | 1502 | |
| ... | ... | @@ -1534,7 +1534,7 @@ pub const Builder = struct { |
| 1534 | 1534 | |
| 1535 | 1535 | const outer_scope = irb.begin_scope.?; |
| 1536 | 1536 | const return_value = if (control_flow_expr.rhs) |rhs| blk: { |
| 1537 | break :blk try await (async irb.genNode(rhs, scope, LVal.None) catch unreachable); | |
| 1537 | break :blk try irb.genNode(rhs, scope, LVal.None); | |
| 1538 | 1538 | } else blk: { |
| 1539 | 1539 | break :blk try irb.buildConstVoid(scope, src_span, true); |
| 1540 | 1540 | }; |
| ... | ... | @@ -1545,7 +1545,7 @@ pub const Builder = struct { |
| 1545 | 1545 | const err_block = try irb.createBasicBlock(scope, c"ErrRetErr"); |
| 1546 | 1546 | const ok_block = try irb.createBasicBlock(scope, c"ErrRetOk"); |
| 1547 | 1547 | if (!have_err_defers) { |
| 1548 | _ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit) catch unreachable); | |
| 1548 | _ = try irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit); | |
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | 1551 | const is_err = try irb.build( |
| ... | ... | @@ -1568,7 +1568,7 @@ pub const Builder = struct { |
| 1568 | 1568 | |
| 1569 | 1569 | try irb.setCursorAtEndAndAppendBlock(err_block); |
| 1570 | 1570 | if (have_err_defers) { |
| 1571 | _ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ErrorExit) catch unreachable); | |
| 1571 | _ = try irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ErrorExit); | |
| 1572 | 1572 | } |
| 1573 | 1573 | if (irb.comp.have_err_ret_tracing and !irb.isCompTime(scope)) { |
| 1574 | 1574 | _ = try irb.build(Inst.SaveErrRetAddr, scope, src_span, Inst.SaveErrRetAddr.Params{}); |
| ... | ... | @@ -1580,7 +1580,7 @@ pub const Builder = struct { |
| 1580 | 1580 | |
| 1581 | 1581 | try irb.setCursorAtEndAndAppendBlock(ok_block); |
| 1582 | 1582 | if (have_err_defers) { |
| 1583 | _ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit) catch unreachable); | |
| 1583 | _ = try irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit); | |
| 1584 | 1584 | } |
| 1585 | 1585 | _ = try irb.build(Inst.Br, scope, src_span, Inst.Br.Params{ |
| 1586 | 1586 | .dest_block = ret_stmt_block, |
| ... | ... | @@ -1590,7 +1590,7 @@ pub const Builder = struct { |
| 1590 | 1590 | try irb.setCursorAtEndAndAppendBlock(ret_stmt_block); |
| 1591 | 1591 | return irb.genAsyncReturn(scope, src_span, return_value, false); |
| 1592 | 1592 | } else { |
| 1593 | _ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit) catch unreachable); | |
| 1593 | _ = try irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit); | |
| 1594 | 1594 | return irb.genAsyncReturn(scope, src_span, return_value, false); |
| 1595 | 1595 | } |
| 1596 | 1596 | }, |
| ... | ... | @@ -1610,7 +1610,7 @@ pub const Builder = struct { |
| 1610 | 1610 | // return &const_instruction->base; |
| 1611 | 1611 | //} |
| 1612 | 1612 | |
| 1613 | if (await (async irb.comp.getPrimitiveType(name) catch unreachable)) |result| { | |
| 1613 | if (irb.comp.getPrimitiveType(name)) |result| { | |
| 1614 | 1614 | if (result) |primitive_type| { |
| 1615 | 1615 | defer primitive_type.base.deref(irb.comp); |
| 1616 | 1616 | switch (lval) { |
| ... | ... | @@ -1628,7 +1628,7 @@ pub const Builder = struct { |
| 1628 | 1628 | error.OutOfMemory => return error.OutOfMemory, |
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | switch (await (async irb.findIdent(scope, name) catch unreachable)) { | |
| 1631 | switch (irb.findIdent(scope, name)) { | |
| 1632 | 1632 | Ident.Decl => |decl| { |
| 1633 | 1633 | return irb.build(Inst.DeclRef, scope, src_span, Inst.DeclRef.Params{ |
| 1634 | 1634 | .decl = decl, |
| ... | ... | @@ -1713,11 +1713,11 @@ pub const Builder = struct { |
| 1713 | 1713 | }; |
| 1714 | 1714 | if (generate) { |
| 1715 | 1715 | const defer_expr_scope = defer_scope.defer_expr_scope; |
| 1716 | const instruction = try await (async irb.genNode( | |
| 1716 | const instruction = try irb.genNode( | |
| 1717 | 1717 | defer_expr_scope.expr_node, |
| 1718 | 1718 | &defer_expr_scope.base, |
| 1719 | 1719 | LVal.None, |
| 1720 | ) catch unreachable); | |
| 1720 | ); | |
| 1721 | 1721 | if (instruction.isNoReturn()) { |
| 1722 | 1722 | is_noreturn = true; |
| 1723 | 1723 | } else { |
| ... | ... | @@ -1918,7 +1918,7 @@ pub const Builder = struct { |
| 1918 | 1918 | Scope.Id.Root => return Ident.NotFound, |
| 1919 | 1919 | Scope.Id.Decls => { |
| 1920 | 1920 | const decls = @fieldParentPtr(Scope.Decls, "base", s); |
| 1921 | const locked_table = await (async decls.table.acquireRead() catch unreachable); | |
| 1921 | const locked_table = decls.table.acquireRead(); | |
| 1922 | 1922 | defer locked_table.release(); |
| 1923 | 1923 | if (locked_table.value.get(name)) |entry| { |
| 1924 | 1924 | return Ident{ .Decl = entry.value }; |
| ... | ... | @@ -2534,7 +2534,7 @@ pub async fn gen( |
| 2534 | 2534 | entry_block.ref(&irb); // Entry block gets a reference because we enter it to begin. |
| 2535 | 2535 | try irb.setCursorAtEndAndAppendBlock(entry_block); |
| 2536 | 2536 | |
| 2537 | const result = try await (async irb.genNode(body_node, scope, LVal.None) catch unreachable); | |
| 2537 | const result = try irb.genNode(body_node, scope, LVal.None); | |
| 2538 | 2538 | if (!result.isNoReturn()) { |
| 2539 | 2539 | // no need for save_err_ret_addr because this cannot return error |
| 2540 | 2540 | _ = try irb.genAsyncReturn(scope, Span.token(body_node.lastToken()), result, true); |
| ... | ... | @@ -2564,7 +2564,7 @@ pub async fn analyze(comp: *Compilation, old_code: *Code, expected_type: ?*Type) |
| 2564 | 2564 | continue; |
| 2565 | 2565 | } |
| 2566 | 2566 | |
| 2567 | const return_inst = try await (async old_instruction.analyze(&ira) catch unreachable); | |
| 2567 | const return_inst = try old_instruction.analyze(&ira); | |
| 2568 | 2568 | assert(return_inst.val != IrVal.Unknown); // at least the type should be known at this point |
| 2569 | 2569 | return_inst.linkToParent(old_instruction); |
| 2570 | 2570 | // Note: if we ever modify the above to handle error.CompileError by continuing analysis, |
src-self-hosted/libc_installation.zig+6-6| ... | ... | @@ -178,7 +178,7 @@ pub const LibCInstallation = struct { |
| 178 | 178 | }, |
| 179 | 179 | else => @compileError("unimplemented: find libc for this OS"), |
| 180 | 180 | } |
| 181 | return await (async group.wait() catch unreachable); | |
| 181 | return group.wait(); | |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | async fn findNativeIncludeDirLinux(self: *LibCInstallation, loop: *event.Loop) !void { |
| ... | ... | @@ -301,11 +301,11 @@ pub const LibCInstallation = struct { |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | async fn findNativeLibDirLinux(self: *LibCInstallation, loop: *event.Loop) FindError!void { |
| 304 | self.lib_dir = try await (async ccPrintFileName(loop, "crt1.o", true) catch unreachable); | |
| 304 | self.lib_dir = try ccPrintFileName(loop, "crt1.o", true); | |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | async fn findNativeStaticLibDir(self: *LibCInstallation, loop: *event.Loop) FindError!void { |
| 308 | self.static_lib_dir = try await (async ccPrintFileName(loop, "crtbegin.o", true) catch unreachable); | |
| 308 | self.static_lib_dir = try ccPrintFileName(loop, "crtbegin.o", true); | |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | async fn findNativeDynamicLinker(self: *LibCInstallation, loop: *event.Loop) FindError!void { |
| ... | ... | @@ -324,7 +324,7 @@ pub const LibCInstallation = struct { |
| 324 | 324 | for (dyn_tests) |*dyn_test| { |
| 325 | 325 | try group.call(testNativeDynamicLinker, self, loop, dyn_test); |
| 326 | 326 | } |
| 327 | try await (async group.wait() catch unreachable); | |
| 327 | try group.wait(); | |
| 328 | 328 | for (dyn_tests) |*dyn_test| { |
| 329 | 329 | if (dyn_test.result) |result| { |
| 330 | 330 | self.dynamic_linker_path = result; |
| ... | ... | @@ -339,7 +339,7 @@ pub const LibCInstallation = struct { |
| 339 | 339 | }; |
| 340 | 340 | |
| 341 | 341 | async fn testNativeDynamicLinker(self: *LibCInstallation, loop: *event.Loop, dyn_test: *DynTest) FindError!void { |
| 342 | if (await (async ccPrintFileName(loop, dyn_test.name, false) catch unreachable)) |result| { | |
| 342 | if (ccPrintFileName(loop, dyn_test.name, false)) |result| { | |
| 343 | 343 | dyn_test.result = result; |
| 344 | 344 | return; |
| 345 | 345 | } else |err| switch (err) { |
| ... | ... | @@ -398,7 +398,7 @@ async fn ccPrintFileName(loop: *event.Loop, o_file: []const u8, want_dirname: bo |
| 398 | 398 | const argv = [_][]const u8{ cc_exe, arg1 }; |
| 399 | 399 | |
| 400 | 400 | // TODO This simulates evented I/O for the child process exec |
| 401 | await (async loop.yield() catch unreachable); | |
| 401 | loop.yield(); | |
| 402 | 402 | const errorable_result = std.ChildProcess.exec(loop.allocator, argv, null, null, 1024 * 1024); |
| 403 | 403 | const exec_result = if (std.debug.runtime_safety) blk: { |
| 404 | 404 | break :blk errorable_result catch unreachable; |
src-self-hosted/link.zig+2-2| ... | ... | @@ -61,7 +61,7 @@ pub async fn link(comp: *Compilation) !void { |
| 61 | 61 | ctx.libc = ctx.comp.override_libc orelse blk: { |
| 62 | 62 | switch (comp.target) { |
| 63 | 63 | Target.Native => { |
| 64 | break :blk (await (async comp.zig_compiler.getNativeLibC() catch unreachable)) catch return error.LibCRequiredButNotProvidedOrFound; | |
| 64 | break :blk comp.zig_compiler.getNativeLibC() catch return error.LibCRequiredButNotProvidedOrFound; | |
| 65 | 65 | }, |
| 66 | 66 | else => return error.LibCRequiredButNotProvidedOrFound, |
| 67 | 67 | } |
| ... | ... | @@ -83,7 +83,7 @@ pub async fn link(comp: *Compilation) !void { |
| 83 | 83 | |
| 84 | 84 | { |
| 85 | 85 | // LLD is not thread-safe, so we grab a global lock. |
| 86 | const held = await (async comp.zig_compiler.lld_lock.acquire() catch unreachable); | |
| 86 | const held = comp.zig_compiler.lld_lock.acquire(); | |
| 87 | 87 | defer held.release(); |
| 88 | 88 | |
| 89 | 89 | // Not evented I/O. LLD does its own multithreading internally. |
src-self-hosted/main.zig+12-28| ... | ... | @@ -466,7 +466,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co |
| 466 | 466 | comp.link_objects = link_objects; |
| 467 | 467 | |
| 468 | 468 | comp.start(); |
| 469 | // TODO const process_build_events_handle = try async<loop.allocator> processBuildEvents(comp, color); | |
| 469 | const frame = try async processBuildEvents(comp, color); | |
| 470 | 470 | loop.run(); |
| 471 | 471 | } |
| 472 | 472 | |
| ... | ... | @@ -474,7 +474,7 @@ async fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void { |
| 474 | 474 | var count: usize = 0; |
| 475 | 475 | while (true) { |
| 476 | 476 | // TODO directly awaiting async should guarantee memory allocation elision |
| 477 | const build_event = await (async comp.events.get() catch unreachable); | |
| 477 | const build_event = comp.events.get(); | |
| 478 | 478 | count += 1; |
| 479 | 479 | |
| 480 | 480 | switch (build_event) { |
| ... | ... | @@ -577,13 +577,13 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void { |
| 577 | 577 | var zig_compiler = try ZigCompiler.init(&loop); |
| 578 | 578 | defer zig_compiler.deinit(); |
| 579 | 579 | |
| 580 | // TODO const handle = try async<loop.allocator> findLibCAsync(&zig_compiler); | |
| 580 | const frame = async findLibCAsync(&zig_compiler); | |
| 581 | 581 | |
| 582 | 582 | loop.run(); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | async fn findLibCAsync(zig_compiler: *ZigCompiler) void { |
| 586 | const libc = (await (async zig_compiler.getNativeLibC() catch unreachable)) catch |err| { | |
| 586 | const libc = zig_compiler.getNativeLibC() catch |err| { | |
| 587 | 587 | stderr.print("unable to find libc: {}\n", @errorName(err)) catch process.exit(1); |
| 588 | 588 | process.exit(1); |
| 589 | 589 | }; |
| ... | ... | @@ -660,24 +660,11 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { |
| 660 | 660 | try loop.initMultiThreaded(allocator); |
| 661 | 661 | defer loop.deinit(); |
| 662 | 662 | |
| 663 | var result: FmtError!void = undefined; | |
| 664 | // TODO const main_handle = try async<allocator> asyncFmtMainChecked( | |
| 665 | // TODO &result, | |
| 666 | // TODO &loop, | |
| 667 | // TODO &flags, | |
| 668 | // TODO color, | |
| 669 | // TODO ); | |
| 670 | loop.run(); | |
| 671 | return result; | |
| 672 | } | |
| 673 | ||
| 674 | async fn asyncFmtMainChecked( | |
| 675 | result: *(FmtError!void), | |
| 676 | loop: *event.Loop, | |
| 677 | flags: *const Args, | |
| 678 | color: errmsg.Color, | |
| 679 | ) void { | |
| 680 | result.* = await (async asyncFmtMain(loop, flags, color) catch unreachable); | |
| 663 | return asyncFmtMain( | |
| 664 | &flags, | |
| 665 | color, | |
| 666 | ); | |
| 667 | // loop.run(); | |
| 681 | 668 | } |
| 682 | 669 | |
| 683 | 670 | const FmtError = error{ |
| ... | ... | @@ -707,9 +694,6 @@ async fn asyncFmtMain( |
| 707 | 694 | flags: *const Args, |
| 708 | 695 | color: errmsg.Color, |
| 709 | 696 | ) FmtError!void { |
| 710 | suspend { | |
| 711 | resume @handle(); | |
| 712 | } | |
| 713 | 697 | var fmt = Fmt{ |
| 714 | 698 | .seen = event.Locked(Fmt.SeenMap).init(loop, Fmt.SeenMap.init(loop.allocator)), |
| 715 | 699 | .any_error = false, |
| ... | ... | @@ -723,7 +707,7 @@ async fn asyncFmtMain( |
| 723 | 707 | for (flags.positionals.toSliceConst()) |file_path| { |
| 724 | 708 | try group.call(fmtPath, &fmt, file_path, check_mode); |
| 725 | 709 | } |
| 726 | try await (async group.wait() catch unreachable); | |
| 710 | try group.wait(); | |
| 727 | 711 | if (fmt.any_error) { |
| 728 | 712 | process.exit(1); |
| 729 | 713 | } |
| ... | ... | @@ -734,7 +718,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 734 | 718 | defer fmt.loop.allocator.free(file_path); |
| 735 | 719 | |
| 736 | 720 | { |
| 737 | const held = await (async fmt.seen.acquire() catch unreachable); | |
| 721 | const held = fmt.seen.acquire(); | |
| 738 | 722 | defer held.release(); |
| 739 | 723 | |
| 740 | 724 | if (try held.value.put(file_path, {})) |_| return; |
| ... | ... | @@ -757,7 +741,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 757 | 741 | try group.call(fmtPath, fmt, full_path, check_mode); |
| 758 | 742 | } |
| 759 | 743 | } |
| 760 | return await (async group.wait() catch unreachable); | |
| 744 | return group.wait(); | |
| 761 | 745 | }, |
| 762 | 746 | else => { |
| 763 | 747 | // TODO lock stderr printing |
src-self-hosted/test.zig+4-4| ... | ... | @@ -68,13 +68,13 @@ pub const TestContext = struct { |
| 68 | 68 | |
| 69 | 69 | fn run(self: *TestContext) !void { |
| 70 | 70 | const handle = try self.loop.call(waitForGroup, self); |
| 71 | defer cancel handle; | |
| 71 | defer await handle; | |
| 72 | 72 | self.loop.run(); |
| 73 | 73 | return self.any_err; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | async fn waitForGroup(self: *TestContext) void { |
| 77 | self.any_err = await (async self.group.wait() catch unreachable); | |
| 77 | self.any_err = self.group.wait(); | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | fn testCompileError( |
| ... | ... | @@ -158,7 +158,7 @@ pub const TestContext = struct { |
| 158 | 158 | const exe_file_2 = try std.mem.dupe(allocator, u8, exe_file); |
| 159 | 159 | |
| 160 | 160 | defer comp.destroy(); |
| 161 | const build_event = await (async comp.events.get() catch unreachable); | |
| 161 | const build_event = comp.events.get(); | |
| 162 | 162 | |
| 163 | 163 | switch (build_event) { |
| 164 | 164 | Compilation.Event.Ok => { |
| ... | ... | @@ -200,7 +200,7 @@ pub const TestContext = struct { |
| 200 | 200 | text: []const u8, |
| 201 | 201 | ) !void { |
| 202 | 202 | defer comp.destroy(); |
| 203 | const build_event = await (async comp.events.get() catch unreachable); | |
| 203 | const build_event = comp.events.get(); | |
| 204 | 204 | |
| 205 | 205 | switch (build_event) { |
| 206 | 206 | Compilation.Event.Ok => { |
src-self-hosted/type.zig+18-25| ... | ... | @@ -181,7 +181,7 @@ pub const Type = struct { |
| 181 | 181 | /// If you happen to have an llvm context handy, use getAbiAlignmentInContext instead. |
| 182 | 182 | /// Otherwise, this one will grab one from the pool and then release it. |
| 183 | 183 | pub async fn getAbiAlignment(base: *Type, comp: *Compilation) !u32 { |
| 184 | if (await (async base.abi_alignment.start() catch unreachable)) |ptr| return ptr.*; | |
| 184 | if (base.abi_alignment.start()) |ptr| return ptr.*; | |
| 185 | 185 | |
| 186 | 186 | { |
| 187 | 187 | const held = try comp.zig_compiler.getAnyLlvmContext(); |
| ... | ... | @@ -189,7 +189,7 @@ pub const Type = struct { |
| 189 | 189 | |
| 190 | 190 | const llvm_context = held.node.data; |
| 191 | 191 | |
| 192 | base.abi_alignment.data = await (async base.resolveAbiAlignment(comp, llvm_context) catch unreachable); | |
| 192 | base.abi_alignment.data = base.resolveAbiAlignment(comp, llvm_context); | |
| 193 | 193 | } |
| 194 | 194 | base.abi_alignment.resolve(); |
| 195 | 195 | return base.abi_alignment.data; |
| ... | ... | @@ -197,9 +197,9 @@ pub const Type = struct { |
| 197 | 197 | |
| 198 | 198 | /// If you have an llvm conext handy, you can use it here. |
| 199 | 199 | pub async fn getAbiAlignmentInContext(base: *Type, comp: *Compilation, llvm_context: *llvm.Context) !u32 { |
| 200 | if (await (async base.abi_alignment.start() catch unreachable)) |ptr| return ptr.*; | |
| 200 | if (base.abi_alignment.start()) |ptr| return ptr.*; | |
| 201 | 201 | |
| 202 | base.abi_alignment.data = await (async base.resolveAbiAlignment(comp, llvm_context) catch unreachable); | |
| 202 | base.abi_alignment.data = base.resolveAbiAlignment(comp, llvm_context); | |
| 203 | 203 | base.abi_alignment.resolve(); |
| 204 | 204 | return base.abi_alignment.data; |
| 205 | 205 | } |
| ... | ... | @@ -401,7 +401,7 @@ pub const Type = struct { |
| 401 | 401 | /// takes ownership of key.Normal.params on success |
| 402 | 402 | pub async fn get(comp: *Compilation, key: Key) !*Fn { |
| 403 | 403 | { |
| 404 | const held = await (async comp.fn_type_table.acquire() catch unreachable); | |
| 404 | const held = comp.fn_type_table.acquire(); | |
| 405 | 405 | defer held.release(); |
| 406 | 406 | |
| 407 | 407 | if (held.value.get(&key)) |entry| { |
| ... | ... | @@ -430,15 +430,8 @@ pub const Type = struct { |
| 430 | 430 | switch (key.data) { |
| 431 | 431 | Kind.Generic => |generic| { |
| 432 | 432 | self.non_key = NonKey{ .Generic = {} }; |
| 433 | switch (generic.cc) { | |
| 434 | CallingConvention.Async => |async_allocator_type| { | |
| 435 | try name_stream.print("async<{}> ", async_allocator_type.name); | |
| 436 | }, | |
| 437 | else => { | |
| 438 | const cc_str = ccFnTypeStr(generic.cc); | |
| 439 | try name_stream.write(cc_str); | |
| 440 | }, | |
| 441 | } | |
| 433 | const cc_str = ccFnTypeStr(generic.cc); | |
| 434 | try name_stream.write(cc_str); | |
| 442 | 435 | try name_stream.write("fn("); |
| 443 | 436 | var param_i: usize = 0; |
| 444 | 437 | while (param_i < generic.param_count) : (param_i += 1) { |
| ... | ... | @@ -477,7 +470,7 @@ pub const Type = struct { |
| 477 | 470 | self.base.init(comp, Id.Fn, name_buf.toOwnedSlice()); |
| 478 | 471 | |
| 479 | 472 | { |
| 480 | const held = await (async comp.fn_type_table.acquire() catch unreachable); | |
| 473 | const held = comp.fn_type_table.acquire(); | |
| 481 | 474 | defer held.release(); |
| 482 | 475 | |
| 483 | 476 | _ = try held.value.put(&self.key, self); |
| ... | ... | @@ -606,7 +599,7 @@ pub const Type = struct { |
| 606 | 599 | |
| 607 | 600 | pub async fn get(comp: *Compilation, key: Key) !*Int { |
| 608 | 601 | { |
| 609 | const held = await (async comp.int_type_table.acquire() catch unreachable); | |
| 602 | const held = comp.int_type_table.acquire(); | |
| 610 | 603 | defer held.release(); |
| 611 | 604 | |
| 612 | 605 | if (held.value.get(&key)) |entry| { |
| ... | ... | @@ -630,7 +623,7 @@ pub const Type = struct { |
| 630 | 623 | self.base.init(comp, Id.Int, name); |
| 631 | 624 | |
| 632 | 625 | { |
| 633 | const held = await (async comp.int_type_table.acquire() catch unreachable); | |
| 626 | const held = comp.int_type_table.acquire(); | |
| 634 | 627 | defer held.release(); |
| 635 | 628 | |
| 636 | 629 | _ = try held.value.put(&self.key, self); |
| ... | ... | @@ -648,7 +641,7 @@ pub const Type = struct { |
| 648 | 641 | |
| 649 | 642 | pub async fn gcDestroy(self: *Int, comp: *Compilation) void { |
| 650 | 643 | { |
| 651 | const held = await (async comp.int_type_table.acquire() catch unreachable); | |
| 644 | const held = comp.int_type_table.acquire(); | |
| 652 | 645 | defer held.release(); |
| 653 | 646 | |
| 654 | 647 | _ = held.value.remove(&self.key).?; |
| ... | ... | @@ -742,7 +735,7 @@ pub const Type = struct { |
| 742 | 735 | |
| 743 | 736 | pub async fn gcDestroy(self: *Pointer, comp: *Compilation) void { |
| 744 | 737 | { |
| 745 | const held = await (async comp.ptr_type_table.acquire() catch unreachable); | |
| 738 | const held = comp.ptr_type_table.acquire(); | |
| 746 | 739 | defer held.release(); |
| 747 | 740 | |
| 748 | 741 | _ = held.value.remove(&self.key).?; |
| ... | ... | @@ -753,7 +746,7 @@ pub const Type = struct { |
| 753 | 746 | |
| 754 | 747 | pub async fn getAlignAsInt(self: *Pointer, comp: *Compilation) u32 { |
| 755 | 748 | switch (self.key.alignment) { |
| 756 | Align.Abi => return await (async self.key.child_type.getAbiAlignment(comp) catch unreachable), | |
| 749 | Align.Abi => return self.key.child_type.getAbiAlignment(comp), | |
| 757 | 750 | Align.Override => |alignment| return alignment, |
| 758 | 751 | } |
| 759 | 752 | } |
| ... | ... | @@ -766,14 +759,14 @@ pub const Type = struct { |
| 766 | 759 | switch (key.alignment) { |
| 767 | 760 | Align.Abi => {}, |
| 768 | 761 | Align.Override => |alignment| { |
| 769 | const abi_align = try await (async key.child_type.getAbiAlignment(comp) catch unreachable); | |
| 762 | const abi_align = try key.child_type.getAbiAlignment(comp); | |
| 770 | 763 | if (abi_align == alignment) { |
| 771 | 764 | normal_key.alignment = Align.Abi; |
| 772 | 765 | } |
| 773 | 766 | }, |
| 774 | 767 | } |
| 775 | 768 | { |
| 776 | const held = await (async comp.ptr_type_table.acquire() catch unreachable); | |
| 769 | const held = comp.ptr_type_table.acquire(); | |
| 777 | 770 | defer held.release(); |
| 778 | 771 | |
| 779 | 772 | if (held.value.get(&normal_key)) |entry| { |
| ... | ... | @@ -828,7 +821,7 @@ pub const Type = struct { |
| 828 | 821 | self.base.init(comp, Id.Pointer, name); |
| 829 | 822 | |
| 830 | 823 | { |
| 831 | const held = await (async comp.ptr_type_table.acquire() catch unreachable); | |
| 824 | const held = comp.ptr_type_table.acquire(); | |
| 832 | 825 | defer held.release(); |
| 833 | 826 | |
| 834 | 827 | _ = try held.value.put(&self.key, self); |
| ... | ... | @@ -873,7 +866,7 @@ pub const Type = struct { |
| 873 | 866 | errdefer key.elem_type.base.deref(comp); |
| 874 | 867 | |
| 875 | 868 | { |
| 876 | const held = await (async comp.array_type_table.acquire() catch unreachable); | |
| 869 | const held = comp.array_type_table.acquire(); | |
| 877 | 870 | defer held.release(); |
| 878 | 871 | |
| 879 | 872 | if (held.value.get(&key)) |entry| { |
| ... | ... | @@ -896,7 +889,7 @@ pub const Type = struct { |
| 896 | 889 | self.base.init(comp, Id.Array, name); |
| 897 | 890 | |
| 898 | 891 | { |
| 899 | const held = await (async comp.array_type_table.acquire() catch unreachable); | |
| 892 | const held = comp.array_type_table.acquire(); | |
| 900 | 893 | defer held.release(); |
| 901 | 894 | |
| 902 | 895 | _ = try held.value.put(&self.key, self); |
src-self-hosted/value.zig+4-4| ... | ... | @@ -346,13 +346,13 @@ pub const Value = struct { |
| 346 | 346 | errdefer array_val.base.deref(comp); |
| 347 | 347 | |
| 348 | 348 | const elem_type = array_val.base.typ.cast(Type.Array).?.key.elem_type; |
| 349 | const ptr_type = try await (async Type.Pointer.get(comp, Type.Pointer.Key{ | |
| 349 | const ptr_type = try Type.Pointer.get(comp, Type.Pointer.Key{ | |
| 350 | 350 | .child_type = elem_type, |
| 351 | 351 | .mut = mut, |
| 352 | 352 | .vol = Type.Pointer.Vol.Non, |
| 353 | 353 | .size = size, |
| 354 | 354 | .alignment = Type.Pointer.Align.Abi, |
| 355 | }) catch unreachable); | |
| 355 | }); | |
| 356 | 356 | var ptr_type_consumed = false; |
| 357 | 357 | errdefer if (!ptr_type_consumed) ptr_type.base.base.deref(comp); |
| 358 | 358 | |
| ... | ... | @@ -428,10 +428,10 @@ pub const Value = struct { |
| 428 | 428 | const u8_type = Type.Int.get_u8(comp); |
| 429 | 429 | defer u8_type.base.base.deref(comp); |
| 430 | 430 | |
| 431 | const array_type = try await (async Type.Array.get(comp, Type.Array.Key{ | |
| 431 | const array_type = try Type.Array.get(comp, Type.Array.Key{ | |
| 432 | 432 | .elem_type = &u8_type.base, |
| 433 | 433 | .len = buffer.len, |
| 434 | }) catch unreachable); | |
| 434 | }); | |
| 435 | 435 | errdefer array_type.base.base.deref(comp); |
| 436 | 436 | |
| 437 | 437 | const self = try comp.gpa().create(Value.Array); |