ERR/E3.0 (slice 3b): comptime trace resolution

#run failures now print the same `func at file:line:col` trace as
runtime, resolved in-process via the interpreter's IR/source tables.

- Read-side context-split op `.trace_resolve` (mirror of .trace_frame),
  lowered from a name-recognized `__trace_resolve_frame(u64) -> Frame`.
- emit_llvm: inttoptr the operand to *Frame + load (the value
  .trace_frame stamped in).
- interp: unpack (func_id << 32 | span.start); resolve func/file from
  module.functions and line/col via SourceLoc.compute over a new
  source_map (setSourceMap wired at every production interp site).
- trace.sx: frame_at -> u64; to_string routes each frame through
  __trace_resolve_frame, so one source works in both machines.

Compiled path behavior unchanged (243/244/247 identical; it now loads
via the op). New examples/253-comptime-trace.sx exercises the comptime
path. Gates: zig build, zig build test, run_examples.sh -> 291 passed.
This commit is contained in:
agra
2026-06-01 15:33:50 +03:00
parent 11f6377d9c
commit b5241243e6
11 changed files with 120 additions and 5 deletions

View File

@@ -104,6 +104,13 @@ pub const Op = union(enum) {
/// `(func_id << 32 | span.start)` for the comptime resolver (slice 3b). The
/// result feeds the existing `sx_trace_push(u64)` call.
trace_frame,
/// ERR E3.0 slice 3b — the read-side resolver: a raw trace-buffer `u64` →
/// a `Frame` value. The mirror of `trace_frame`'s context split.
/// `emit_llvm` reinterprets the operand as `*Frame` and loads it (the value
/// `trace_frame` stamped in). `interp` unpacks `(func_id, span.start)` and
/// resolves it via the module's functions + the source map into a `Frame`
/// aggregate. Result type is the `Frame` `TypeId`.
trace_resolve: UnaryOp,
/// Comptime-only Type value. Carried as a `Value.type_tag(TypeId)`
/// in the interpreter. NEVER emitted to LLVM — types are erased
/// after lowering. `emit_llvm` bails loudly if it sees one,