ERR/E4.1: trace.print_interpreter_frames() — Phase E4 complete
The last E4 item: a comptime call-frame dump. - New nullary `interp_print_frames` IR op (inst/print). The interpreter maintains a `call_chain` side-stack (push/pop a FuncId around each sx-bodied `call`, freed in deinit) and `printInterpFrames` appends the chain to its output — most-recent-last, with the dump frame itself skipped. emit_llvm makes the op a no-op: compiled code has no interpreter stack, and the only caller is `process.exit`'s dead `is_comptime()` branch. - Lowered from a name-recognized `__interp_print_frames()` builtin (tryLowerReflectionCall + inferExprType → void). - `trace.print_interpreter_frames()` wraps the builtin; wired into `process.exit`'s comptime branch (process.sx now imports trace.sx). - Frame source locations await IR-offset resolution (the comptime analog of DWARF), so only function names print today. examples/252-interp-frames.sx (top-level `#run` drives the dump; exit 0). Phase E4 (entry-point + stdlib error story) is now 100% complete.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#import "std.sx";
|
||||
trace :: #import "trace.sx";
|
||||
|
||||
// =====================================================================
|
||||
// process.sx — subprocess + environment stdlib (POSIX backend).
|
||||
@@ -136,6 +137,7 @@ clib_exit :: (code: s32) -> noreturn #foreign libc "_exit";
|
||||
exit :: (code: u8, loc: Source_Location = #caller_location) -> noreturn {
|
||||
if is_comptime() {
|
||||
print("\nprocess.exit({}) called from {} at {}:{}\n", code, loc.func, loc.file, loc.line);
|
||||
trace.print_interpreter_frames();
|
||||
}
|
||||
clib_exit(xx code);
|
||||
}
|
||||
|
||||
@@ -60,3 +60,12 @@ print_current :: () {
|
||||
write(2, s.ptr, xx s.len);
|
||||
}
|
||||
}
|
||||
|
||||
// Dump the comptime (`#run`) interpreter call-frame chain (ERR E4.1). At
|
||||
// comptime the interpreter walks its active sx frames and appends them to the
|
||||
// build output; in compiled code this folds to nothing (there is no
|
||||
// interpreter stack — the only caller is a dead `is_comptime()` branch).
|
||||
// Frame source locations await IR-offset resolution, so only names print today.
|
||||
print_interpreter_frames :: () {
|
||||
__interp_print_frames();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user