struct Status [src]
Information about the success or failure of a parse.
Fields
ast: ?Ast = null
zoir: ?Zoir = null
type_check: ?Error.TypeCheckFailure = null
Members
- deinit (Function)
- format (Function)
- iterateErrors (Function)
Source
pub const Status = struct {
ast: ?Ast = null,
zoir: ?Zoir = null,
type_check: ?Error.TypeCheckFailure = null,
fn assertEmpty(self: Status) void {
assert(self.ast == null);
assert(self.zoir == null);
assert(self.type_check == null);
}
pub fn deinit(self: *Status, gpa: Allocator) void {
if (self.ast) |*ast| ast.deinit(gpa);
if (self.zoir) |*zoir| zoir.deinit(gpa);
if (self.type_check) |tc| tc.deinit(gpa);
self.* = undefined;
}
pub fn iterateErrors(self: *const Status) Error.Iterator {
return .{ .status = self };
}
pub fn format(
self: *const @This(),
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = fmt;
_ = options;
var errors = self.iterateErrors();
while (errors.next()) |err| {
const loc = err.getLocation(self);
const msg = err.fmtMessage(self);
try writer.print("{}:{}: error: {}\n", .{ loc.line + 1, loc.column + 1, msg });
var notes = err.iterateNotes(self);
while (notes.next()) |note| {
const note_loc = note.getLocation(self);
const note_msg = note.fmtMessage(self);
try writer.print("{}:{}: note: {s}\n", .{
note_loc.line + 1,
note_loc.column + 1,
note_msg,
});
}
}
}
}