fix some rough edges around stack traces

hide irrelevant CallFrames
fix span info for the implicit stack frame
This commit is contained in:
りき萌 2025-06-25 21:10:54 +02:00
parent e49885c83a
commit 7a52dbebd0
4 changed files with 34 additions and 11 deletions

View file

@ -280,7 +280,9 @@ class ErrorException extends HTMLElement {
}
};
for (let i = 0; i < this.result.stackTrace.length; ++i) {
// Iterate in reverse to let uppermost stack frames "win" and overwrite bottommost stack
// frames' colouring.
for (let i = this.result.stackTrace.length - 1; i >= 0; i--) {
let frame = this.result.stackTrace[i];
if (frame.span != null) {
diagnostics.push({

View file

@ -336,6 +336,12 @@ export class Haku {
let count = w2.haku2_vm_stackframe_count(this.#pVm2);
let trace = [];
for (let i = 0; i < count; ++i) {
// Don't collect information about return marker stack frames.
// They don't actually represent function calls, they're only used to signal the .ret
// instruction at which the VM ought to halt.
let isReturnMarker = w2.haku2_vm_stackframe_is_return_marker(this.#pVm2, i) != 0;
if (isReturnMarker) continue;
let isSystem = w2.haku2_vm_stackframe_is_system(this.#pVm2, i) != 0;
let pc = w2.haku2_vm_stackframe_pc(this.#pVm2, i);