OILS / spec / testdata / debug-frame-lib.ysh View on Github | oils.pub

30 lines, 24 significant
1const __provide__ = :| print-stack my-proc |
2
3proc print-stack (; ; prefix=true) {
4 for i, frame in (vm.getDebugStack()) {
5 #write --end '' -- $[formatDebugFrame(fr, prefix=" #$[i+1] ")]
6 if (prefix) {
7 write --end '' -- " #$[i+1] $[frame.toString()]"
8 } else {
9 write --end '' -- "$[frame.toString()]"
10 }
11 }
12}
13
14proc my-proc {
15 print-stack
16}
17
18proc call-func {
19 var x = myfunc(99)
20 echo $x
21}
22
23func myfunc2(a, b) {
24 print-stack
25 return (a + b)
26}
27
28func myfunc(x) {
29 return (myfunc2(x+1, 42))
30}