| author | |
| committer | |
| log | fe4963412f939d4f72eb5f0153a253116206749b |
| tree | 1ff6242dfa3dccb082e825466202d5289f31f172 |
| parent | 8b2622cdd58cec697d9d1f8f49717b6ce7ee3e2e |
| signature | Commit is signed but in an unrecognized format. |
11 files changed, 133 insertions(+), 142 deletions(-)
src-self-hosted/codegen.zig+6-8| ... | ... | @@ -45,13 +45,11 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code) |
| 45 | 45 | |
| 46 | 46 | // Don't use ZIG_VERSION_STRING here. LLVM misparses it when it includes |
| 47 | 47 | // the git revision. |
| 48 | const producer = try std.Buffer.allocPrint( | |
| 49 | &code.arena.allocator, | |
| 50 | "zig {}.{}.{}", | |
| 48 | const producer = try std.Buffer.allocPrint(&code.arena.allocator, "zig {}.{}.{}", .{ | |
| 51 | 49 | @as(u32, c.ZIG_VERSION_MAJOR), |
| 52 | 50 | @as(u32, c.ZIG_VERSION_MINOR), |
| 53 | 51 | @as(u32, c.ZIG_VERSION_PATCH), |
| 54 | ); | |
| 52 | }); | |
| 55 | 53 | const flags = ""; |
| 56 | 54 | const runtime_version = 0; |
| 57 | 55 | const compile_unit_file = llvm.CreateFile( |
| ... | ... | @@ -93,7 +91,7 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code) |
| 93 | 91 | llvm.DIBuilderFinalize(dibuilder); |
| 94 | 92 | |
| 95 | 93 | if (comp.verbose_llvm_ir) { |
| 96 | std.debug.warn("raw module:\n"); | |
| 94 | std.debug.warn("raw module:\n", .{}); | |
| 97 | 95 | llvm.DumpModule(ofile.module); |
| 98 | 96 | } |
| 99 | 97 | |
| ... | ... | @@ -120,18 +118,18 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code) |
| 120 | 118 | is_small, |
| 121 | 119 | )) { |
| 122 | 120 | if (std.debug.runtime_safety) { |
| 123 | std.debug.panic("unable to write object file {}: {s}\n", output_path.toSliceConst(), err_msg); | |
| 121 | std.debug.panic("unable to write object file {}: {s}\n", .{ output_path.toSliceConst(), err_msg }); | |
| 124 | 122 | } |
| 125 | 123 | return error.WritingObjectFileFailed; |
| 126 | 124 | } |
| 127 | 125 | //validate_inline_fns(g); TODO |
| 128 | 126 | fn_val.containing_object = output_path; |
| 129 | 127 | if (comp.verbose_llvm_ir) { |
| 130 | std.debug.warn("optimized module:\n"); | |
| 128 | std.debug.warn("optimized module:\n", .{}); | |
| 131 | 129 | llvm.DumpModule(ofile.module); |
| 132 | 130 | } |
| 133 | 131 | if (comp.verbose_link) { |
| 134 | std.debug.warn("created {}\n", output_path.toSliceConst()); | |
| 132 | std.debug.warn("created {}\n", .{output_path.toSliceConst()}); | |
| 135 | 133 | } |
| 136 | 134 | } |
| 137 | 135 |
src-self-hosted/compilation.zig+12-15| ... | ... | @@ -807,7 +807,7 @@ pub const Compilation = struct { |
| 807 | 807 | root_scope.realpath, |
| 808 | 808 | max_src_size, |
| 809 | 809 | ) catch |err| { |
| 810 | try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", @errorName(err)); | |
| 810 | try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", .{@errorName(err)}); | |
| 811 | 811 | return; |
| 812 | 812 | }; |
| 813 | 813 | errdefer self.gpa().free(source_code); |
| ... | ... | @@ -878,7 +878,7 @@ pub const Compilation = struct { |
| 878 | 878 | try self.addCompileError(tree_scope, Span{ |
| 879 | 879 | .first = fn_proto.fn_token, |
| 880 | 880 | .last = fn_proto.fn_token + 1, |
| 881 | }, "missing function name"); | |
| 881 | }, "missing function name", .{}); | |
| 882 | 882 | continue; |
| 883 | 883 | }; |
| 884 | 884 | |
| ... | ... | @@ -942,7 +942,7 @@ pub const Compilation = struct { |
| 942 | 942 | const root_scope = blk: { |
| 943 | 943 | // TODO async/await std.fs.realpath |
| 944 | 944 | const root_src_real_path = std.fs.realpathAlloc(self.gpa(), root_src_path) catch |err| { |
| 945 | try self.addCompileErrorCli(root_src_path, "unable to open: {}", @errorName(err)); | |
| 945 | try self.addCompileErrorCli(root_src_path, "unable to open: {}", .{@errorName(err)}); | |
| 946 | 946 | return; |
| 947 | 947 | }; |
| 948 | 948 | errdefer self.gpa().free(root_src_real_path); |
| ... | ... | @@ -991,7 +991,7 @@ pub const Compilation = struct { |
| 991 | 991 | defer unanalyzed_code.destroy(comp.gpa()); |
| 992 | 992 | |
| 993 | 993 | if (comp.verbose_ir) { |
| 994 | std.debug.warn("unanalyzed:\n"); | |
| 994 | std.debug.warn("unanalyzed:\n", .{}); | |
| 995 | 995 | unanalyzed_code.dump(); |
| 996 | 996 | } |
| 997 | 997 | |
| ... | ... | @@ -1003,7 +1003,7 @@ pub const Compilation = struct { |
| 1003 | 1003 | errdefer analyzed_code.destroy(comp.gpa()); |
| 1004 | 1004 | |
| 1005 | 1005 | if (comp.verbose_ir) { |
| 1006 | std.debug.warn("analyzed:\n"); | |
| 1006 | std.debug.warn("analyzed:\n", .{}); | |
| 1007 | 1007 | analyzed_code.dump(); |
| 1008 | 1008 | } |
| 1009 | 1009 | |
| ... | ... | @@ -1048,14 +1048,14 @@ pub const Compilation = struct { |
| 1048 | 1048 | |
| 1049 | 1049 | const gop = try locked_table.getOrPut(decl.name); |
| 1050 | 1050 | if (gop.found_existing) { |
| 1051 | try self.addCompileError(decl.tree_scope, decl.getSpan(), "redefinition of '{}'", decl.name); | |
| 1051 | try self.addCompileError(decl.tree_scope, decl.getSpan(), "redefinition of '{}'", .{decl.name}); | |
| 1052 | 1052 | // TODO note: other definition here |
| 1053 | 1053 | } else { |
| 1054 | 1054 | gop.kv.value = decl; |
| 1055 | 1055 | } |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | fn addCompileError(self: *Compilation, tree_scope: *Scope.AstTree, span: Span, comptime fmt: []const u8, args: ...) !void { | |
| 1058 | fn addCompileError(self: *Compilation, tree_scope: *Scope.AstTree, span: Span, comptime fmt: []const u8, args: var) !void { | |
| 1059 | 1059 | const text = try std.fmt.allocPrint(self.gpa(), fmt, args); |
| 1060 | 1060 | errdefer self.gpa().free(text); |
| 1061 | 1061 | |
| ... | ... | @@ -1065,7 +1065,7 @@ pub const Compilation = struct { |
| 1065 | 1065 | try self.prelink_group.call(addCompileErrorAsync, self, msg); |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | fn addCompileErrorCli(self: *Compilation, realpath: []const u8, comptime fmt: []const u8, args: ...) !void { | |
| 1068 | fn addCompileErrorCli(self: *Compilation, realpath: []const u8, comptime fmt: []const u8, args: var) !void { | |
| 1069 | 1069 | const text = try std.fmt.allocPrint(self.gpa(), fmt, args); |
| 1070 | 1070 | errdefer self.gpa().free(text); |
| 1071 | 1071 | |
| ... | ... | @@ -1092,12 +1092,9 @@ pub const Compilation = struct { |
| 1092 | 1092 | defer exported_symbol_names.release(); |
| 1093 | 1093 | |
| 1094 | 1094 | if (try exported_symbol_names.value.put(decl.name, decl)) |other_decl| { |
| 1095 | try self.addCompileError( | |
| 1096 | decl.tree_scope, | |
| 1097 | decl.getSpan(), | |
| 1098 | "exported symbol collision: '{}'", | |
| 1095 | try self.addCompileError(decl.tree_scope, decl.getSpan(), "exported symbol collision: '{}'", .{ | |
| 1099 | 1096 | decl.name, |
| 1100 | ); | |
| 1097 | }); | |
| 1101 | 1098 | // TODO add error note showing location of other symbol |
| 1102 | 1099 | } |
| 1103 | 1100 | } |
| ... | ... | @@ -1162,7 +1159,7 @@ pub const Compilation = struct { |
| 1162 | 1159 | const tmp_dir = try self.getTmpDir(); |
| 1163 | 1160 | const file_prefix = self.getRandomFileName(); |
| 1164 | 1161 | |
| 1165 | const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", file_prefix[0..], suffix); | |
| 1162 | const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", .{ file_prefix[0..], suffix }); | |
| 1166 | 1163 | defer self.gpa().free(file_name); |
| 1167 | 1164 | |
| 1168 | 1165 | const full_path = try std.fs.path.join(self.gpa(), &[_][]const u8{ tmp_dir, file_name[0..] }); |
| ... | ... | @@ -1303,7 +1300,7 @@ fn generateDeclFn(comp: *Compilation, fn_decl: *Decl.Fn) !void { |
| 1303 | 1300 | try comp.addCompileError(tree_scope, Span{ |
| 1304 | 1301 | .first = param_decl.firstToken(), |
| 1305 | 1302 | .last = param_decl.type_node.firstToken(), |
| 1306 | }, "missing parameter name"); | |
| 1303 | }, "missing parameter name", .{}); | |
| 1307 | 1304 | return error.SemanticAnalysisFailed; |
| 1308 | 1305 | }; |
| 1309 | 1306 | const param_name = tree_scope.tree.tokenSlice(name_token); |
src-self-hosted/errmsg.zig+5-7| ... | ... | @@ -231,7 +231,7 @@ pub const Msg = struct { |
| 231 | 231 | pub fn printToStream(msg: *const Msg, stream: var, color_on: bool) !void { |
| 232 | 232 | switch (msg.data) { |
| 233 | 233 | .Cli => { |
| 234 | try stream.print("{}:-:-: error: {}\n", msg.realpath, msg.text); | |
| 234 | try stream.print("{}:-:-: error: {}\n", .{ msg.realpath, msg.text }); | |
| 235 | 235 | return; |
| 236 | 236 | }, |
| 237 | 237 | else => {}, |
| ... | ... | @@ -254,24 +254,22 @@ pub const Msg = struct { |
| 254 | 254 | const start_loc = tree.tokenLocationPtr(0, first_token); |
| 255 | 255 | const end_loc = tree.tokenLocationPtr(first_token.end, last_token); |
| 256 | 256 | if (!color_on) { |
| 257 | try stream.print( | |
| 258 | "{}:{}:{}: error: {}\n", | |
| 257 | try stream.print("{}:{}:{}: error: {}\n", .{ | |
| 259 | 258 | path, |
| 260 | 259 | start_loc.line + 1, |
| 261 | 260 | start_loc.column + 1, |
| 262 | 261 | msg.text, |
| 263 | ); | |
| 262 | }); | |
| 264 | 263 | return; |
| 265 | 264 | } |
| 266 | 265 | |
| 267 | try stream.print( | |
| 268 | "{}:{}:{}: error: {}\n{}\n", | |
| 266 | try stream.print("{}:{}:{}: error: {}\n{}\n", .{ | |
| 269 | 267 | path, |
| 270 | 268 | start_loc.line + 1, |
| 271 | 269 | start_loc.column + 1, |
| 272 | 270 | msg.text, |
| 273 | 271 | tree.source[start_loc.line_start..start_loc.line_end], |
| 274 | ); | |
| 272 | }); | |
| 275 | 273 | try stream.writeByteNTimes(' ', start_loc.column); |
| 276 | 274 | try stream.writeByteNTimes('~', last_token.end - first_token.start); |
| 277 | 275 | try stream.write("\n"); |
src-self-hosted/introspect.zig+1-1| ... | ... | @@ -48,7 +48,7 @@ pub fn resolveZigLibDir(allocator: *mem.Allocator) ![]u8 { |
| 48 | 48 | \\Unable to find zig lib directory: {}. |
| 49 | 49 | \\Reinstall Zig or use --zig-install-prefix. |
| 50 | 50 | \\ |
| 51 | , @errorName(err)); | |
| 51 | , .{@errorName(err)}); | |
| 52 | 52 | |
| 53 | 53 | return error.ZigLibDirNotFound; |
| 54 | 54 | }; |
src-self-hosted/ir.zig+38-40| ... | ... | @@ -32,16 +32,16 @@ pub const IrVal = union(enum) { |
| 32 | 32 | |
| 33 | 33 | pub fn dump(self: IrVal) void { |
| 34 | 34 | switch (self) { |
| 35 | .Unknown => std.debug.warn("Unknown"), | |
| 35 | .Unknown => std.debug.warn("Unknown", .{}), | |
| 36 | 36 | .KnownType => |typ| { |
| 37 | std.debug.warn("KnownType("); | |
| 37 | std.debug.warn("KnownType(", .{}); | |
| 38 | 38 | typ.dump(); |
| 39 | std.debug.warn(")"); | |
| 39 | std.debug.warn(")", .{}); | |
| 40 | 40 | }, |
| 41 | 41 | .KnownValue => |value| { |
| 42 | std.debug.warn("KnownValue("); | |
| 42 | std.debug.warn("KnownValue(", .{}); | |
| 43 | 43 | value.dump(); |
| 44 | std.debug.warn(")"); | |
| 44 | std.debug.warn(")", .{}); | |
| 45 | 45 | }, |
| 46 | 46 | } |
| 47 | 47 | } |
| ... | ... | @@ -90,9 +90,9 @@ pub const Inst = struct { |
| 90 | 90 | inline while (i < @memberCount(Id)) : (i += 1) { |
| 91 | 91 | if (base.id == @field(Id, @memberName(Id, i))) { |
| 92 | 92 | const T = @field(Inst, @memberName(Id, i)); |
| 93 | std.debug.warn("#{} = {}(", base.debug_id, @tagName(base.id)); | |
| 93 | std.debug.warn("#{} = {}(", .{ base.debug_id, @tagName(base.id) }); | |
| 94 | 94 | @fieldParentPtr(T, "base", base).dump(); |
| 95 | std.debug.warn(")"); | |
| 95 | std.debug.warn(")", .{}); | |
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | } |
| ... | ... | @@ -173,7 +173,7 @@ pub const Inst = struct { |
| 173 | 173 | if (self.isCompTime()) { |
| 174 | 174 | return self.val.KnownValue; |
| 175 | 175 | } else { |
| 176 | try ira.addCompileError(self.span, "unable to evaluate constant expression"); | |
| 176 | try ira.addCompileError(self.span, "unable to evaluate constant expression", .{}); | |
| 177 | 177 | return error.SemanticAnalysisFailed; |
| 178 | 178 | } |
| 179 | 179 | } |
| ... | ... | @@ -269,11 +269,11 @@ pub const Inst = struct { |
| 269 | 269 | const ir_val_init = IrVal.Init.Unknown; |
| 270 | 270 | |
| 271 | 271 | pub fn dump(self: *const Call) void { |
| 272 | std.debug.warn("#{}(", self.params.fn_ref.debug_id); | |
| 272 | std.debug.warn("#{}(", .{self.params.fn_ref.debug_id}); | |
| 273 | 273 | for (self.params.args) |arg| { |
| 274 | std.debug.warn("#{},", arg.debug_id); | |
| 274 | std.debug.warn("#{},", .{arg.debug_id}); | |
| 275 | 275 | } |
| 276 | std.debug.warn(")"); | |
| 276 | std.debug.warn(")", .{}); | |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | pub fn hasSideEffects(self: *const Call) bool { |
| ... | ... | @@ -284,19 +284,17 @@ pub const Inst = struct { |
| 284 | 284 | const fn_ref = try self.params.fn_ref.getAsParam(); |
| 285 | 285 | const fn_ref_type = fn_ref.getKnownType(); |
| 286 | 286 | const fn_type = fn_ref_type.cast(Type.Fn) orelse { |
| 287 | try ira.addCompileError(fn_ref.span, "type '{}' not a function", fn_ref_type.name); | |
| 287 | try ira.addCompileError(fn_ref.span, "type '{}' not a function", .{fn_ref_type.name}); | |
| 288 | 288 | return error.SemanticAnalysisFailed; |
| 289 | 289 | }; |
| 290 | 290 | |
| 291 | 291 | const fn_type_param_count = fn_type.paramCount(); |
| 292 | 292 | |
| 293 | 293 | if (fn_type_param_count != self.params.args.len) { |
| 294 | try ira.addCompileError( | |
| 295 | self.base.span, | |
| 296 | "expected {} arguments, found {}", | |
| 294 | try ira.addCompileError(self.base.span, "expected {} arguments, found {}", .{ | |
| 297 | 295 | fn_type_param_count, |
| 298 | 296 | self.params.args.len, |
| 299 | ); | |
| 297 | }); | |
| 300 | 298 | return error.SemanticAnalysisFailed; |
| 301 | 299 | } |
| 302 | 300 | |
| ... | ... | @@ -375,7 +373,7 @@ pub const Inst = struct { |
| 375 | 373 | const ir_val_init = IrVal.Init.NoReturn; |
| 376 | 374 | |
| 377 | 375 | pub fn dump(self: *const Return) void { |
| 378 | std.debug.warn("#{}", self.params.return_value.debug_id); | |
| 376 | std.debug.warn("#{}", .{self.params.return_value.debug_id}); | |
| 379 | 377 | } |
| 380 | 378 | |
| 381 | 379 | pub fn hasSideEffects(self: *const Return) bool { |
| ... | ... | @@ -509,7 +507,7 @@ pub const Inst = struct { |
| 509 | 507 | const ir_val_init = IrVal.Init.Unknown; |
| 510 | 508 | |
| 511 | 509 | pub fn dump(inst: *const VarPtr) void { |
| 512 | std.debug.warn("{}", inst.params.var_scope.name); | |
| 510 | std.debug.warn("{}", .{inst.params.var_scope.name}); | |
| 513 | 511 | } |
| 514 | 512 | |
| 515 | 513 | pub fn hasSideEffects(inst: *const VarPtr) bool { |
| ... | ... | @@ -567,7 +565,7 @@ pub const Inst = struct { |
| 567 | 565 | const target = try self.params.target.getAsParam(); |
| 568 | 566 | const target_type = target.getKnownType(); |
| 569 | 567 | if (target_type.id != .Pointer) { |
| 570 | try ira.addCompileError(self.base.span, "dereference of non pointer type '{}'", target_type.name); | |
| 568 | try ira.addCompileError(self.base.span, "dereference of non pointer type '{}'", .{target_type.name}); | |
| 571 | 569 | return error.SemanticAnalysisFailed; |
| 572 | 570 | } |
| 573 | 571 | const ptr_type = @fieldParentPtr(Type.Pointer, "base", target_type); |
| ... | ... | @@ -705,7 +703,7 @@ pub const Inst = struct { |
| 705 | 703 | const ir_val_init = IrVal.Init.Unknown; |
| 706 | 704 | |
| 707 | 705 | pub fn dump(self: *const CheckVoidStmt) void { |
| 708 | std.debug.warn("#{}", self.params.target.debug_id); | |
| 706 | std.debug.warn("#{}", .{self.params.target.debug_id}); | |
| 709 | 707 | } |
| 710 | 708 | |
| 711 | 709 | pub fn hasSideEffects(inst: *const CheckVoidStmt) bool { |
| ... | ... | @@ -715,7 +713,7 @@ pub const Inst = struct { |
| 715 | 713 | pub fn analyze(self: *const CheckVoidStmt, ira: *Analyze) !*Inst { |
| 716 | 714 | const target = try self.params.target.getAsParam(); |
| 717 | 715 | if (target.getKnownType().id != .Void) { |
| 718 | try ira.addCompileError(self.base.span, "expression value is ignored"); | |
| 716 | try ira.addCompileError(self.base.span, "expression value is ignored", .{}); | |
| 719 | 717 | return error.SemanticAnalysisFailed; |
| 720 | 718 | } |
| 721 | 719 | return ira.irb.buildConstVoid(self.base.scope, self.base.span, true); |
| ... | ... | @@ -801,7 +799,7 @@ pub const Inst = struct { |
| 801 | 799 | const ir_val_init = IrVal.Init.Unknown; |
| 802 | 800 | |
| 803 | 801 | pub fn dump(inst: *const AddImplicitReturnType) void { |
| 804 | std.debug.warn("#{}", inst.params.target.debug_id); | |
| 802 | std.debug.warn("#{}", .{inst.params.target.debug_id}); | |
| 805 | 803 | } |
| 806 | 804 | |
| 807 | 805 | pub fn hasSideEffects(inst: *const AddImplicitReturnType) bool { |
| ... | ... | @@ -826,7 +824,7 @@ pub const Inst = struct { |
| 826 | 824 | const ir_val_init = IrVal.Init.Unknown; |
| 827 | 825 | |
| 828 | 826 | pub fn dump(inst: *const TestErr) void { |
| 829 | std.debug.warn("#{}", inst.params.target.debug_id); | |
| 827 | std.debug.warn("#{}", .{inst.params.target.debug_id}); | |
| 830 | 828 | } |
| 831 | 829 | |
| 832 | 830 | pub fn hasSideEffects(inst: *const TestErr) bool { |
| ... | ... | @@ -888,7 +886,7 @@ pub const Inst = struct { |
| 888 | 886 | const ir_val_init = IrVal.Init.Unknown; |
| 889 | 887 | |
| 890 | 888 | pub fn dump(inst: *const TestCompTime) void { |
| 891 | std.debug.warn("#{}", inst.params.target.debug_id); | |
| 889 | std.debug.warn("#{}", .{inst.params.target.debug_id}); | |
| 892 | 890 | } |
| 893 | 891 | |
| 894 | 892 | pub fn hasSideEffects(inst: *const TestCompTime) bool { |
| ... | ... | @@ -971,11 +969,11 @@ pub const Code = struct { |
| 971 | 969 | pub fn dump(self: *Code) void { |
| 972 | 970 | var bb_i: usize = 0; |
| 973 | 971 | for (self.basic_block_list.toSliceConst()) |bb| { |
| 974 | std.debug.warn("{s}_{}:\n", bb.name_hint, bb.debug_id); | |
| 972 | std.debug.warn("{s}_{}:\n", .{ bb.name_hint, bb.debug_id }); | |
| 975 | 973 | for (bb.instruction_list.toSliceConst()) |instr| { |
| 976 | std.debug.warn(" "); | |
| 974 | std.debug.warn(" ", .{}); | |
| 977 | 975 | instr.dump(); |
| 978 | std.debug.warn("\n"); | |
| 976 | std.debug.warn("\n", .{}); | |
| 979 | 977 | } |
| 980 | 978 | } |
| 981 | 979 | } |
| ... | ... | @@ -993,6 +991,7 @@ pub const Code = struct { |
| 993 | 991 | self.tree_scope, |
| 994 | 992 | ret_value.span, |
| 995 | 993 | "unable to evaluate constant expression", |
| 994 | .{}, | |
| 996 | 995 | ); |
| 997 | 996 | return error.SemanticAnalysisFailed; |
| 998 | 997 | } else if (inst.hasSideEffects()) { |
| ... | ... | @@ -1000,6 +999,7 @@ pub const Code = struct { |
| 1000 | 999 | self.tree_scope, |
| 1001 | 1000 | inst.span, |
| 1002 | 1001 | "unable to evaluate constant expression", |
| 1002 | .{}, | |
| 1003 | 1003 | ); |
| 1004 | 1004 | return error.SemanticAnalysisFailed; |
| 1005 | 1005 | } |
| ... | ... | @@ -1359,7 +1359,7 @@ pub const Builder = struct { |
| 1359 | 1359 | irb.code.tree_scope, |
| 1360 | 1360 | src_span, |
| 1361 | 1361 | "invalid character in string literal: '{c}'", |
| 1362 | str_token[bad_index], | |
| 1362 | .{str_token[bad_index]}, | |
| 1363 | 1363 | ); |
| 1364 | 1364 | return error.SemanticAnalysisFailed; |
| 1365 | 1365 | }, |
| ... | ... | @@ -1523,6 +1523,7 @@ pub const Builder = struct { |
| 1523 | 1523 | irb.code.tree_scope, |
| 1524 | 1524 | src_span, |
| 1525 | 1525 | "return expression outside function definition", |
| 1526 | .{}, | |
| 1526 | 1527 | ); |
| 1527 | 1528 | return error.SemanticAnalysisFailed; |
| 1528 | 1529 | } |
| ... | ... | @@ -1533,6 +1534,7 @@ pub const Builder = struct { |
| 1533 | 1534 | irb.code.tree_scope, |
| 1534 | 1535 | src_span, |
| 1535 | 1536 | "cannot return from defer expression", |
| 1537 | .{}, | |
| 1536 | 1538 | ); |
| 1537 | 1539 | scope_defer_expr.reported_err = true; |
| 1538 | 1540 | } |
| ... | ... | @@ -1629,7 +1631,7 @@ pub const Builder = struct { |
| 1629 | 1631 | } |
| 1630 | 1632 | } else |err| switch (err) { |
| 1631 | 1633 | error.Overflow => { |
| 1632 | try irb.comp.addCompileError(irb.code.tree_scope, src_span, "integer too large"); | |
| 1634 | try irb.comp.addCompileError(irb.code.tree_scope, src_span, "integer too large", .{}); | |
| 1633 | 1635 | return error.SemanticAnalysisFailed; |
| 1634 | 1636 | }, |
| 1635 | 1637 | error.OutOfMemory => return error.OutOfMemory, |
| ... | ... | @@ -1663,7 +1665,7 @@ pub const Builder = struct { |
| 1663 | 1665 | // TODO put a variable of same name with invalid type in global scope |
| 1664 | 1666 | // so that future references to this same name will find a variable with an invalid type |
| 1665 | 1667 | |
| 1666 | try irb.comp.addCompileError(irb.code.tree_scope, src_span, "unknown identifier '{}'", name); | |
| 1668 | try irb.comp.addCompileError(irb.code.tree_scope, src_span, "unknown identifier '{}'", .{name}); | |
| 1667 | 1669 | return error.SemanticAnalysisFailed; |
| 1668 | 1670 | } |
| 1669 | 1671 | |
| ... | ... | @@ -2008,7 +2010,7 @@ const Analyze = struct { |
| 2008 | 2010 | const next_instruction = ira.parent_basic_block.instruction_list.at(ira.instruction_index); |
| 2009 | 2011 | |
| 2010 | 2012 | if (!next_instruction.is_generated) { |
| 2011 | try ira.addCompileError(next_instruction.span, "unreachable code"); | |
| 2013 | try ira.addCompileError(next_instruction.span, "unreachable code", .{}); | |
| 2012 | 2014 | break; |
| 2013 | 2015 | } |
| 2014 | 2016 | ira.instruction_index += 1; |
| ... | ... | @@ -2041,7 +2043,7 @@ const Analyze = struct { |
| 2041 | 2043 | } |
| 2042 | 2044 | } |
| 2043 | 2045 | |
| 2044 | fn addCompileError(self: *Analyze, span: Span, comptime fmt: []const u8, args: ...) !void { | |
| 2046 | fn addCompileError(self: *Analyze, span: Span, comptime fmt: []const u8, args: var) !void { | |
| 2045 | 2047 | return self.irb.comp.addCompileError(self.irb.code.tree_scope, span, fmt, args); |
| 2046 | 2048 | } |
| 2047 | 2049 | |
| ... | ... | @@ -2330,12 +2332,10 @@ const Analyze = struct { |
| 2330 | 2332 | break :cast; |
| 2331 | 2333 | }; |
| 2332 | 2334 | if (!fits) { |
| 2333 | try ira.addCompileError( | |
| 2334 | source_instr.span, | |
| 2335 | "integer value '{}' cannot be stored in type '{}'", | |
| 2335 | try ira.addCompileError(source_instr.span, "integer value '{}' cannot be stored in type '{}'", .{ | |
| 2336 | 2336 | from_int, |
| 2337 | 2337 | dest_type.name, |
| 2338 | ); | |
| 2338 | }); | |
| 2339 | 2339 | return error.SemanticAnalysisFailed; |
| 2340 | 2340 | } |
| 2341 | 2341 | |
| ... | ... | @@ -2498,12 +2498,10 @@ const Analyze = struct { |
| 2498 | 2498 | // } |
| 2499 | 2499 | //} |
| 2500 | 2500 | |
| 2501 | try ira.addCompileError( | |
| 2502 | source_instr.span, | |
| 2503 | "expected type '{}', found '{}'", | |
| 2501 | try ira.addCompileError(source_instr.span, "expected type '{}', found '{}'", .{ | |
| 2504 | 2502 | dest_type.name, |
| 2505 | 2503 | from_type.name, |
| 2506 | ); | |
| 2504 | }); | |
| 2507 | 2505 | //ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node, |
| 2508 | 2506 | // buf_sprintf("expected type '%s', found '%s'", |
| 2509 | 2507 | // buf_ptr(&wanted_type->name), |
src-self-hosted/libc_installation.zig+13-15| ... | ... | @@ -65,7 +65,7 @@ pub const LibCInstallation = struct { |
| 65 | 65 | if (line.len == 0 or line[0] == '#') continue; |
| 66 | 66 | var line_it = std.mem.separate(line, "="); |
| 67 | 67 | const name = line_it.next() orelse { |
| 68 | try stderr.print("missing equal sign after field name\n"); | |
| 68 | try stderr.print("missing equal sign after field name\n", .{}); | |
| 69 | 69 | return error.ParseError; |
| 70 | 70 | }; |
| 71 | 71 | const value = line_it.rest(); |
| ... | ... | @@ -83,7 +83,7 @@ pub const LibCInstallation = struct { |
| 83 | 83 | }, |
| 84 | 84 | else => { |
| 85 | 85 | if (value.len == 0) { |
| 86 | try stderr.print("field cannot be empty: {}\n", key); | |
| 86 | try stderr.print("field cannot be empty: {}\n", .{key}); | |
| 87 | 87 | return error.ParseError; |
| 88 | 88 | } |
| 89 | 89 | const dupe = try std.mem.dupe(allocator, u8, value); |
| ... | ... | @@ -97,7 +97,7 @@ pub const LibCInstallation = struct { |
| 97 | 97 | } |
| 98 | 98 | for (found_keys) |found_key, i| { |
| 99 | 99 | if (!found_key.found) { |
| 100 | try stderr.print("missing field: {}\n", keys[i]); | |
| 100 | try stderr.print("missing field: {}\n", .{keys[i]}); | |
| 101 | 101 | return error.ParseError; |
| 102 | 102 | } |
| 103 | 103 | } |
| ... | ... | @@ -105,6 +105,11 @@ pub const LibCInstallation = struct { |
| 105 | 105 | |
| 106 | 106 | pub fn render(self: *const LibCInstallation, out: *std.io.OutStream(fs.File.WriteError)) !void { |
| 107 | 107 | @setEvalBranchQuota(4000); |
| 108 | const lib_dir = self.lib_dir orelse ""; | |
| 109 | const static_lib_dir = self.static_lib_dir orelse ""; | |
| 110 | const msvc_lib_dir = self.msvc_lib_dir orelse ""; | |
| 111 | const kernel32_lib_dir = self.kernel32_lib_dir orelse ""; | |
| 112 | const dynamic_linker_path = self.dynamic_linker_path orelse util.getDynamicLinkerPath(Target{ .Native = {} }); | |
| 108 | 113 | try out.print( |
| 109 | 114 | \\# The directory that contains `stdlib.h`. |
| 110 | 115 | \\# On Linux, can be found with: `cc -E -Wp,-v -xc /dev/null` |
| ... | ... | @@ -132,14 +137,7 @@ pub const LibCInstallation = struct { |
| 132 | 137 | \\# Only needed when targeting Linux. |
| 133 | 138 | \\dynamic_linker_path={} |
| 134 | 139 | \\ |
| 135 | , | |
| 136 | self.include_dir, | |
| 137 | self.lib_dir orelse "", | |
| 138 | self.static_lib_dir orelse "", | |
| 139 | self.msvc_lib_dir orelse "", | |
| 140 | self.kernel32_lib_dir orelse "", | |
| 141 | self.dynamic_linker_path orelse util.getDynamicLinkerPath(Target{ .Native = {} }), | |
| 142 | ); | |
| 140 | , .{ self.include_dir, lib_dir, static_lib_dir, msvc_lib_dir, kernel32_lib_dir, dynamic_linker_path }); | |
| 143 | 141 | } |
| 144 | 142 | |
| 145 | 143 | /// Finds the default, native libc. |
| ... | ... | @@ -255,7 +253,7 @@ pub const LibCInstallation = struct { |
| 255 | 253 | for (searches) |search| { |
| 256 | 254 | result_buf.shrink(0); |
| 257 | 255 | const stream = &std.io.BufferOutStream.init(&result_buf).stream; |
| 258 | try stream.print("{}\\Include\\{}\\ucrt", search.path, search.version); | |
| 256 | try stream.print("{}\\Include\\{}\\ucrt", .{ search.path, search.version }); | |
| 259 | 257 | |
| 260 | 258 | const stdlib_path = try fs.path.join( |
| 261 | 259 | allocator, |
| ... | ... | @@ -282,7 +280,7 @@ pub const LibCInstallation = struct { |
| 282 | 280 | for (searches) |search| { |
| 283 | 281 | result_buf.shrink(0); |
| 284 | 282 | const stream = &std.io.BufferOutStream.init(&result_buf).stream; |
| 285 | try stream.print("{}\\Lib\\{}\\ucrt\\", search.path, search.version); | |
| 283 | try stream.print("{}\\Lib\\{}\\ucrt\\", .{ search.path, search.version }); | |
| 286 | 284 | switch (builtin.arch) { |
| 287 | 285 | .i386 => try stream.write("x86"), |
| 288 | 286 | .x86_64 => try stream.write("x64"), |
| ... | ... | @@ -360,7 +358,7 @@ pub const LibCInstallation = struct { |
| 360 | 358 | for (searches) |search| { |
| 361 | 359 | result_buf.shrink(0); |
| 362 | 360 | const stream = &std.io.BufferOutStream.init(&result_buf).stream; |
| 363 | try stream.print("{}\\Lib\\{}\\um\\", search.path, search.version); | |
| 361 | try stream.print("{}\\Lib\\{}\\um\\", .{ search.path, search.version }); | |
| 364 | 362 | switch (builtin.arch) { |
| 365 | 363 | .i386 => try stream.write("x86\\"), |
| 366 | 364 | .x86_64 => try stream.write("x64\\"), |
| ... | ... | @@ -395,7 +393,7 @@ pub const LibCInstallation = struct { |
| 395 | 393 | /// caller owns returned memory |
| 396 | 394 | fn ccPrintFileName(allocator: *Allocator, o_file: []const u8, want_dirname: bool) ![]u8 { |
| 397 | 395 | const cc_exe = std.os.getenv("CC") orelse "cc"; |
| 398 | const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={}", o_file); | |
| 396 | const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={}", .{o_file}); | |
| 399 | 397 | defer allocator.free(arg1); |
| 400 | 398 | const argv = [_][]const u8{ cc_exe, arg1 }; |
| 401 | 399 |
src-self-hosted/link.zig+20-13| ... | ... | @@ -75,9 +75,9 @@ pub fn link(comp: *Compilation) !void { |
| 75 | 75 | if (comp.verbose_link) { |
| 76 | 76 | for (ctx.args.toSliceConst()) |arg, i| { |
| 77 | 77 | const space = if (i == 0) "" else " "; |
| 78 | std.debug.warn("{}{s}", space, arg); | |
| 78 | std.debug.warn("{}{s}", .{ space, arg }); | |
| 79 | 79 | } |
| 80 | std.debug.warn("\n"); | |
| 80 | std.debug.warn("\n", .{}); | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | const extern_ofmt = toExternObjectFormatType(util.getObjectFormat(comp.target)); |
| ... | ... | @@ -94,7 +94,7 @@ pub fn link(comp: *Compilation) !void { |
| 94 | 94 | // TODO capture these messages and pass them through the system, reporting them through the |
| 95 | 95 | // event system instead of printing them directly here. |
| 96 | 96 | // perhaps try to parse and understand them. |
| 97 | std.debug.warn("{}\n", ctx.link_msg.toSliceConst()); | |
| 97 | std.debug.warn("{}\n", .{ctx.link_msg.toSliceConst()}); | |
| 98 | 98 | } |
| 99 | 99 | return error.LinkFailed; |
| 100 | 100 | } |
| ... | ... | @@ -334,13 +334,13 @@ fn constructLinkerArgsCoff(ctx: *Context) !void { |
| 334 | 334 | |
| 335 | 335 | const is_library = ctx.comp.kind == .Lib; |
| 336 | 336 | |
| 337 | const out_arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", ctx.out_file_path.toSliceConst()); | |
| 337 | const out_arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.toSliceConst()}); | |
| 338 | 338 | try ctx.args.append(@ptrCast([*:0]const u8, out_arg.ptr)); |
| 339 | 339 | |
| 340 | 340 | if (ctx.comp.haveLibC()) { |
| 341 | try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", ctx.libc.msvc_lib_dir.?)).ptr)); | |
| 342 | try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", ctx.libc.kernel32_lib_dir.?)).ptr)); | |
| 343 | try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", ctx.libc.lib_dir.?)).ptr)); | |
| 341 | try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.msvc_lib_dir.?})).ptr)); | |
| 342 | try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.kernel32_lib_dir.?})).ptr)); | |
| 343 | try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.lib_dir.?})).ptr)); | |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | if (ctx.link_in_crt) { |
| ... | ... | @@ -348,17 +348,20 @@ fn constructLinkerArgsCoff(ctx: *Context) !void { |
| 348 | 348 | const d_str = if (ctx.comp.build_mode == .Debug) "d" else ""; |
| 349 | 349 | |
| 350 | 350 | if (ctx.comp.is_static) { |
| 351 | const cmt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", d_str); | |
| 351 | const cmt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", .{d_str}); | |
| 352 | 352 | try ctx.args.append(@ptrCast([*:0]const u8, cmt_lib_name.ptr)); |
| 353 | 353 | } else { |
| 354 | const msvcrt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", d_str); | |
| 354 | const msvcrt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", .{d_str}); | |
| 355 | 355 | try ctx.args.append(@ptrCast([*:0]const u8, msvcrt_lib_name.ptr)); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | const vcruntime_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", lib_str, d_str); | |
| 358 | const vcruntime_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", .{ | |
| 359 | lib_str, | |
| 360 | d_str, | |
| 361 | }); | |
| 359 | 362 | try ctx.args.append(@ptrCast([*:0]const u8, vcruntime_lib_name.ptr)); |
| 360 | 363 | |
| 361 | const crt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", lib_str, d_str); | |
| 364 | const crt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", .{ lib_str, d_str }); | |
| 362 | 365 | try ctx.args.append(@ptrCast([*:0]const u8, crt_lib_name.ptr)); |
| 363 | 366 | |
| 364 | 367 | // Visual C++ 2015 Conformance Changes |
| ... | ... | @@ -508,7 +511,11 @@ fn constructLinkerArgsMachO(ctx: *Context) !void { |
| 508 | 511 | .IPhoneOS => try ctx.args.append("-iphoneos_version_min"), |
| 509 | 512 | .IPhoneOSSimulator => try ctx.args.append("-ios_simulator_version_min"), |
| 510 | 513 | } |
| 511 | const ver_str = try std.fmt.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", platform.major, platform.minor, platform.micro); | |
| 514 | const ver_str = try std.fmt.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", .{ | |
| 515 | platform.major, | |
| 516 | platform.minor, | |
| 517 | platform.micro, | |
| 518 | }); | |
| 512 | 519 | try ctx.args.append(@ptrCast([*:0]const u8, ver_str.ptr)); |
| 513 | 520 | |
| 514 | 521 | if (ctx.comp.kind == .Exe) { |
| ... | ... | @@ -584,7 +591,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void { |
| 584 | 591 | try ctx.args.append("-lSystem"); |
| 585 | 592 | } else { |
| 586 | 593 | if (mem.indexOfScalar(u8, lib.name, '/') == null) { |
| 587 | const arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-l{}\x00", lib.name); | |
| 594 | const arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-l{}\x00", .{lib.name}); | |
| 588 | 595 | try ctx.args.append(@ptrCast([*:0]const u8, arg.ptr)); |
| 589 | 596 | } else { |
| 590 | 597 | const arg = try std.cstr.addNullByte(&ctx.arena.allocator, lib.name); |
src-self-hosted/main.zig+24-25| ... | ... | @@ -128,7 +128,7 @@ pub fn main() !void { |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | try stderr.print("unknown command: {}\n\n", args[1]); | |
| 131 | try stderr.print("unknown command: {}\n\n", .{args[1]}); | |
| 132 | 132 | try stderr.write(usage); |
| 133 | 133 | process.argsFree(allocator, args); |
| 134 | 134 | process.exit(1); |
| ... | ... | @@ -329,14 +329,14 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co |
| 329 | 329 | if (cur_pkg.parent) |parent| { |
| 330 | 330 | cur_pkg = parent; |
| 331 | 331 | } else { |
| 332 | try stderr.print("encountered --pkg-end with no matching --pkg-begin\n"); | |
| 332 | try stderr.print("encountered --pkg-end with no matching --pkg-begin\n", .{}); | |
| 333 | 333 | process.exit(1); |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | if (cur_pkg.parent != null) { |
| 339 | try stderr.print("unmatched --pkg-begin\n"); | |
| 339 | try stderr.print("unmatched --pkg-begin\n", .{}); | |
| 340 | 340 | process.exit(1); |
| 341 | 341 | } |
| 342 | 342 | |
| ... | ... | @@ -345,7 +345,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co |
| 345 | 345 | 0 => null, |
| 346 | 346 | 1 => flags.positionals.at(0), |
| 347 | 347 | else => { |
| 348 | try stderr.print("unexpected extra parameter: {}\n", flags.positionals.at(1)); | |
| 348 | try stderr.print("unexpected extra parameter: {}\n", .{flags.positionals.at(1)}); | |
| 349 | 349 | process.exit(1); |
| 350 | 350 | }, |
| 351 | 351 | }; |
| ... | ... | @@ -477,13 +477,13 @@ fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void { |
| 477 | 477 | |
| 478 | 478 | switch (build_event) { |
| 479 | 479 | .Ok => { |
| 480 | stderr.print("Build {} succeeded\n", count) catch process.exit(1); | |
| 480 | stderr.print("Build {} succeeded\n", .{count}) catch process.exit(1); | |
| 481 | 481 | }, |
| 482 | 482 | .Error => |err| { |
| 483 | stderr.print("Build {} failed: {}\n", count, @errorName(err)) catch process.exit(1); | |
| 483 | stderr.print("Build {} failed: {}\n", .{ count, @errorName(err) }) catch process.exit(1); | |
| 484 | 484 | }, |
| 485 | 485 | .Fail => |msgs| { |
| 486 | stderr.print("Build {} compile errors:\n", count) catch process.exit(1); | |
| 486 | stderr.print("Build {} compile errors:\n", .{count}) catch process.exit(1); | |
| 487 | 487 | for (msgs) |msg| { |
| 488 | 488 | defer msg.destroy(); |
| 489 | 489 | msg.printToFile(stderr_file, color) catch process.exit(1); |
| ... | ... | @@ -544,12 +544,11 @@ const Fmt = struct { |
| 544 | 544 | |
| 545 | 545 | fn parseLibcPaths(allocator: *Allocator, libc: *LibCInstallation, libc_paths_file: []const u8) void { |
| 546 | 546 | libc.parse(allocator, libc_paths_file, stderr) catch |err| { |
| 547 | stderr.print( | |
| 548 | "Unable to parse libc path file '{}': {}.\n" ++ | |
| 549 | "Try running `zig libc` to see an example for the native target.\n", | |
| 547 | stderr.print("Unable to parse libc path file '{}': {}.\n" ++ | |
| 548 | "Try running `zig libc` to see an example for the native target.\n", .{ | |
| 550 | 549 | libc_paths_file, |
| 551 | 550 | @errorName(err), |
| 552 | ) catch {}; | |
| 551 | }) catch {}; | |
| 553 | 552 | process.exit(1); |
| 554 | 553 | }; |
| 555 | 554 | } |
| ... | ... | @@ -563,7 +562,7 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void { |
| 563 | 562 | return; |
| 564 | 563 | }, |
| 565 | 564 | else => { |
| 566 | try stderr.print("unexpected extra parameter: {}\n", args[1]); | |
| 565 | try stderr.print("unexpected extra parameter: {}\n", .{args[1]}); | |
| 567 | 566 | process.exit(1); |
| 568 | 567 | }, |
| 569 | 568 | } |
| ... | ... | @@ -572,7 +571,7 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void { |
| 572 | 571 | defer zig_compiler.deinit(); |
| 573 | 572 | |
| 574 | 573 | const libc = zig_compiler.getNativeLibC() catch |err| { |
| 575 | stderr.print("unable to find libc: {}\n", @errorName(err)) catch {}; | |
| 574 | stderr.print("unable to find libc: {}\n", .{@errorName(err)}) catch {}; | |
| 576 | 575 | process.exit(1); |
| 577 | 576 | }; |
| 578 | 577 | libc.render(stdout) catch process.exit(1); |
| ... | ... | @@ -614,7 +613,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { |
| 614 | 613 | defer allocator.free(source_code); |
| 615 | 614 | |
| 616 | 615 | const tree = std.zig.parse(allocator, source_code) catch |err| { |
| 617 | try stderr.print("error parsing stdin: {}\n", err); | |
| 616 | try stderr.print("error parsing stdin: {}\n", .{err}); | |
| 618 | 617 | process.exit(1); |
| 619 | 618 | }; |
| 620 | 619 | defer tree.deinit(); |
| ... | ... | @@ -718,7 +717,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 718 | 717 | }, |
| 719 | 718 | else => { |
| 720 | 719 | // TODO lock stderr printing |
| 721 | try stderr.print("unable to open '{}': {}\n", file_path, err); | |
| 720 | try stderr.print("unable to open '{}': {}\n", .{ file_path, err }); | |
| 722 | 721 | fmt.any_error = true; |
| 723 | 722 | return; |
| 724 | 723 | }, |
| ... | ... | @@ -726,7 +725,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 726 | 725 | defer fmt.allocator.free(source_code); |
| 727 | 726 | |
| 728 | 727 | const tree = std.zig.parse(fmt.allocator, source_code) catch |err| { |
| 729 | try stderr.print("error parsing file '{}': {}\n", file_path, err); | |
| 728 | try stderr.print("error parsing file '{}': {}\n", .{ file_path, err }); | |
| 730 | 729 | fmt.any_error = true; |
| 731 | 730 | return; |
| 732 | 731 | }; |
| ... | ... | @@ -747,7 +746,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 747 | 746 | if (check_mode) { |
| 748 | 747 | const anything_changed = try std.zig.render(fmt.allocator, io.null_out_stream, tree); |
| 749 | 748 | if (anything_changed) { |
| 750 | try stderr.print("{}\n", file_path); | |
| 749 | try stderr.print("{}\n", .{file_path}); | |
| 751 | 750 | fmt.any_error = true; |
| 752 | 751 | } |
| 753 | 752 | } else { |
| ... | ... | @@ -757,7 +756,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 757 | 756 | |
| 758 | 757 | const anything_changed = try std.zig.render(fmt.allocator, baf.stream(), tree); |
| 759 | 758 | if (anything_changed) { |
| 760 | try stderr.print("{}\n", file_path); | |
| 759 | try stderr.print("{}\n", .{file_path}); | |
| 761 | 760 | try baf.finish(); |
| 762 | 761 | } |
| 763 | 762 | } |
| ... | ... | @@ -774,7 +773,7 @@ fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void { |
| 774 | 773 | // NOTE: Cannot use empty string, see #918. |
| 775 | 774 | comptime const native_str = if (comptime mem.eql(u8, arch_tag, @tagName(builtin.arch))) " (native)\n" else "\n"; |
| 776 | 775 | |
| 777 | try stdout.print(" {}{}", arch_tag, native_str); | |
| 776 | try stdout.print(" {}{}", .{ arch_tag, native_str }); | |
| 778 | 777 | } |
| 779 | 778 | } |
| 780 | 779 | try stdout.write("\n"); |
| ... | ... | @@ -787,7 +786,7 @@ fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void { |
| 787 | 786 | // NOTE: Cannot use empty string, see #918. |
| 788 | 787 | comptime const native_str = if (comptime mem.eql(u8, os_tag, @tagName(builtin.os))) " (native)\n" else "\n"; |
| 789 | 788 | |
| 790 | try stdout.print(" {}{}", os_tag, native_str); | |
| 789 | try stdout.print(" {}{}", .{ os_tag, native_str }); | |
| 791 | 790 | } |
| 792 | 791 | } |
| 793 | 792 | try stdout.write("\n"); |
| ... | ... | @@ -800,13 +799,13 @@ fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void { |
| 800 | 799 | // NOTE: Cannot use empty string, see #918. |
| 801 | 800 | comptime const native_str = if (comptime mem.eql(u8, abi_tag, @tagName(builtin.abi))) " (native)\n" else "\n"; |
| 802 | 801 | |
| 803 | try stdout.print(" {}{}", abi_tag, native_str); | |
| 802 | try stdout.print(" {}{}", .{ abi_tag, native_str }); | |
| 804 | 803 | } |
| 805 | 804 | } |
| 806 | 805 | } |
| 807 | 806 | |
| 808 | 807 | fn cmdVersion(allocator: *Allocator, args: []const []const u8) !void { |
| 809 | try stdout.print("{}\n", std.mem.toSliceConst(u8, c.ZIG_VERSION_STRING)); | |
| 808 | try stdout.print("{}\n", .{std.mem.toSliceConst(u8, c.ZIG_VERSION_STRING)}); | |
| 810 | 809 | } |
| 811 | 810 | |
| 812 | 811 | const args_test_spec = [_]Flag{Flag.Bool("--help")}; |
| ... | ... | @@ -865,7 +864,7 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void { |
| 865 | 864 | } |
| 866 | 865 | } |
| 867 | 866 | |
| 868 | try stderr.print("unknown sub command: {}\n\n", args[0]); | |
| 867 | try stderr.print("unknown sub command: {}\n\n", .{args[0]}); | |
| 869 | 868 | try stderr.write(usage_internal); |
| 870 | 869 | } |
| 871 | 870 | |
| ... | ... | @@ -878,14 +877,14 @@ fn cmdInternalBuildInfo(allocator: *Allocator, args: []const []const u8) !void { |
| 878 | 877 | \\ZIG_LLVM_CONFIG_EXE {} |
| 879 | 878 | \\ZIG_DIA_GUIDS_LIB {} |
| 880 | 879 | \\ |
| 881 | , | |
| 880 | , .{ | |
| 882 | 881 | std.mem.toSliceConst(u8, c.ZIG_CMAKE_BINARY_DIR), |
| 883 | 882 | std.mem.toSliceConst(u8, c.ZIG_CXX_COMPILER), |
| 884 | 883 | std.mem.toSliceConst(u8, c.ZIG_LLD_INCLUDE_PATH), |
| 885 | 884 | std.mem.toSliceConst(u8, c.ZIG_LLD_LIBRARIES), |
| 886 | 885 | std.mem.toSliceConst(u8, c.ZIG_LLVM_CONFIG_EXE), |
| 887 | 886 | std.mem.toSliceConst(u8, c.ZIG_DIA_GUIDS_LIB), |
| 888 | ); | |
| 887 | }); | |
| 889 | 888 | } |
| 890 | 889 | |
| 891 | 890 | const CliPkg = struct { |
src-self-hosted/type.zig+11-15| ... | ... | @@ -399,7 +399,7 @@ pub const Type = struct { |
| 399 | 399 | .Generic => |generic| { |
| 400 | 400 | self.non_key = NonKey{ .Generic = {} }; |
| 401 | 401 | const cc_str = ccFnTypeStr(generic.cc); |
| 402 | try name_stream.print("{}fn(", cc_str); | |
| 402 | try name_stream.print("{}fn(", .{cc_str}); | |
| 403 | 403 | var param_i: usize = 0; |
| 404 | 404 | while (param_i < generic.param_count) : (param_i += 1) { |
| 405 | 405 | const arg = if (param_i == 0) "var" else ", var"; |
| ... | ... | @@ -407,7 +407,7 @@ pub const Type = struct { |
| 407 | 407 | } |
| 408 | 408 | try name_stream.write(")"); |
| 409 | 409 | if (key.alignment) |alignment| { |
| 410 | try name_stream.print(" align({})", alignment); | |
| 410 | try name_stream.print(" align({})", .{alignment}); | |
| 411 | 411 | } |
| 412 | 412 | try name_stream.write(" var"); |
| 413 | 413 | }, |
| ... | ... | @@ -416,7 +416,7 @@ pub const Type = struct { |
| 416 | 416 | .Normal = NonKey.Normal{ .variable_list = std.ArrayList(*Scope.Var).init(comp.gpa()) }, |
| 417 | 417 | }; |
| 418 | 418 | const cc_str = ccFnTypeStr(normal.cc); |
| 419 | try name_stream.print("{}fn(", cc_str); | |
| 419 | try name_stream.print("{}fn(", .{cc_str}); | |
| 420 | 420 | for (normal.params) |param, i| { |
| 421 | 421 | if (i != 0) try name_stream.write(", "); |
| 422 | 422 | if (param.is_noalias) try name_stream.write("noalias "); |
| ... | ... | @@ -428,9 +428,9 @@ pub const Type = struct { |
| 428 | 428 | } |
| 429 | 429 | try name_stream.write(")"); |
| 430 | 430 | if (key.alignment) |alignment| { |
| 431 | try name_stream.print(" align({})", alignment); | |
| 431 | try name_stream.print(" align({})", .{alignment}); | |
| 432 | 432 | } |
| 433 | try name_stream.print(" {}", normal.return_type.name); | |
| 433 | try name_stream.print(" {}", .{normal.return_type.name}); | |
| 434 | 434 | }, |
| 435 | 435 | } |
| 436 | 436 | |
| ... | ... | @@ -584,7 +584,7 @@ pub const Type = struct { |
| 584 | 584 | errdefer comp.gpa().destroy(self); |
| 585 | 585 | |
| 586 | 586 | const u_or_i = "ui"[@boolToInt(key.is_signed)]; |
| 587 | const name = try std.fmt.allocPrint(comp.gpa(), "{c}{}", u_or_i, key.bit_count); | |
| 587 | const name = try std.fmt.allocPrint(comp.gpa(), "{c}{}", .{ u_or_i, key.bit_count }); | |
| 588 | 588 | errdefer comp.gpa().free(name); |
| 589 | 589 | |
| 590 | 590 | self.base.init(comp, .Int, name); |
| ... | ... | @@ -767,23 +767,19 @@ pub const Type = struct { |
| 767 | 767 | .Non => "", |
| 768 | 768 | }; |
| 769 | 769 | const name = switch (self.key.alignment) { |
| 770 | .Abi => try std.fmt.allocPrint( | |
| 771 | comp.gpa(), | |
| 772 | "{}{}{}{}", | |
| 770 | .Abi => try std.fmt.allocPrint(comp.gpa(), "{}{}{}{}", .{ | |
| 773 | 771 | size_str, |
| 774 | 772 | mut_str, |
| 775 | 773 | vol_str, |
| 776 | 774 | self.key.child_type.name, |
| 777 | ), | |
| 778 | .Override => |alignment| try std.fmt.allocPrint( | |
| 779 | comp.gpa(), | |
| 780 | "{}align<{}> {}{}{}", | |
| 775 | }), | |
| 776 | .Override => |alignment| try std.fmt.allocPrint(comp.gpa(), "{}align<{}> {}{}{}", .{ | |
| 781 | 777 | size_str, |
| 782 | 778 | alignment, |
| 783 | 779 | mut_str, |
| 784 | 780 | vol_str, |
| 785 | 781 | self.key.child_type.name, |
| 786 | ), | |
| 782 | }), | |
| 787 | 783 | }; |
| 788 | 784 | errdefer comp.gpa().free(name); |
| 789 | 785 | |
| ... | ... | @@ -852,7 +848,7 @@ pub const Type = struct { |
| 852 | 848 | }; |
| 853 | 849 | errdefer comp.gpa().destroy(self); |
| 854 | 850 | |
| 855 | const name = try std.fmt.allocPrint(comp.gpa(), "[{}]{}", key.len, key.elem_type.name); | |
| 851 | const name = try std.fmt.allocPrint(comp.gpa(), "[{}]{}", .{ key.len, key.elem_type.name }); | |
| 856 | 852 | errdefer comp.gpa().free(name); |
| 857 | 853 | |
| 858 | 854 | self.base.init(comp, .Array, name); |
src-self-hosted/util.zig+2-2| ... | ... | @@ -175,7 +175,7 @@ pub fn llvmTargetFromTriple(triple: std.Buffer) !*llvm.Target { |
| 175 | 175 | var result: *llvm.Target = undefined; |
| 176 | 176 | var err_msg: [*:0]u8 = undefined; |
| 177 | 177 | if (llvm.GetTargetFromTriple(triple.toSlice(), &result, &err_msg) != 0) { |
| 178 | std.debug.warn("triple: {s} error: {s}\n", triple.toSlice(), err_msg); | |
| 178 | std.debug.warn("triple: {s} error: {s}\n", .{ triple.toSlice(), err_msg }); | |
| 179 | 179 | return error.UnsupportedTarget; |
| 180 | 180 | } |
| 181 | 181 | return result; |
| ... | ... | @@ -206,7 +206,7 @@ pub fn getTriple(allocator: *std.mem.Allocator, self: std.Target) !std.Buffer { |
| 206 | 206 | const env_name = if (self.isWasm()) "wasm" else @tagName(self.getAbi()); |
| 207 | 207 | |
| 208 | 208 | var out = &std.io.BufferOutStream.init(&result).stream; |
| 209 | try out.print("{}-unknown-{}-{}", @tagName(self.getArch()), @tagName(self.getOs()), env_name); | |
| 209 | try out.print("{}-unknown-{}-{}", .{ @tagName(self.getArch()), @tagName(self.getOs()), env_name }); | |
| 210 | 210 | |
| 211 | 211 | return result; |
| 212 | 212 | } |
src-self-hosted/value.zig+1-1| ... | ... | @@ -53,7 +53,7 @@ pub const Value = struct { |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | pub fn dump(base: *const Value) void { |
| 56 | std.debug.warn("{}", @tagName(base.id)); | |
| 56 | std.debug.warn("{}", .{@tagName(base.id)}); | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | pub fn getLlvmConst(base: *Value, ofile: *ObjectFile) (error{OutOfMemory}!?*llvm.Value) { |