- verifier.zig: staged pipeline per spec 07 §8.6, deterministic order - budget.zig: fixed limits from spec 08 §7 (E5101) - cfg.zig: terminators, branch arity, switch/enum.switch shape (E5002) - ssa.zig: Cooper-Harvey-Kennedy dominators, use dominance (E5001) - types.zig: operand/result types, casts, calls, returns, recursive aggregates (E1001, E1002, E1003) - check.zig runs parse -> verify; seed conformance tests get module headers; tests for unimplemented phases report PENDING
36 lines
1.3 KiB
Zig
36 lines
1.3 KiB
Zig
//! Front door used by the CLI, the conformance runner and (later) `ajid`:
|
|
//! parse → verify, collecting diagnostics (spec 07 §8.6).
|
|
|
|
const std = @import("std");
|
|
const air = @import("air.zig");
|
|
const diag = @import("diag.zig");
|
|
const verifier = @import("verifier.zig");
|
|
|
|
pub const Status = enum {
|
|
/// Module verified; no error diagnostics.
|
|
accepted,
|
|
/// At least one error diagnostic.
|
|
rejected,
|
|
/// The pipeline cannot yet decide this input.
|
|
unimplemented,
|
|
};
|
|
|
|
pub const Report = struct {
|
|
status: Status,
|
|
diagnostics: []const diag.Diagnostic,
|
|
/// Present when `status == .accepted`.
|
|
module: ?air.Module = null,
|
|
/// Pipeline stage that is missing when `status == .unimplemented`.
|
|
missing_stage: []const u8 = "",
|
|
};
|
|
|
|
/// Checks a text AIR module. All allocations go into `arena`.
|
|
pub fn checkAir(arena: std.mem.Allocator, file_name: []const u8, source: []const u8) !Report {
|
|
const parsed = try air.parse.parse(arena, file_name, source);
|
|
if (parsed.diagnostics.len != 0) return .{ .status = .rejected, .diagnostics = parsed.diagnostics };
|
|
const module = parsed.module.?;
|
|
const ds = try verifier.verify(arena, file_name, module);
|
|
if (ds.len != 0) return .{ .status = .rejected, .diagnostics = ds };
|
|
return .{ .status = .accepted, .diagnostics = &.{}, .module = module };
|
|
}
|