| 1 | const __provide__ = :| print-stack my-proc |
|
| 2 |
|
| 3 | proc 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 |
|
| 14 | proc my-proc {
|
| 15 | print-stack
|
| 16 | }
|
| 17 |
|
| 18 | func myfunc2(a, b) {
|
| 19 | return (a + b)
|
| 20 | }
|
| 21 |
|
| 22 | func identity(x) {
|
| 23 | print-stack
|
| 24 | return (x)
|
| 25 | }
|
| 26 |
|
| 27 | func myfunc(x) {
|
| 28 | return (identity(myfunc2(42, x+1)))
|
| 29 | }
|
| 30 |
|
| 31 | proc call-func {
|
| 32 | var x = myfunc(99)
|
| 33 | echo $x
|
| 34 | }
|
| 35 |
|