mirror of
https://github.com/janet-lang/janet
synced 2024-12-27 17:00:27 +00:00
Allow 1 argument call of debug/stacktrace
Since fibers now track the last value signaled.
This commit is contained in:
parent
96262e7d87
commit
bd2e335063
@ -299,9 +299,11 @@ static Janet cfun_debug_stack(int32_t argc, Janet *argv) {
|
||||
}
|
||||
|
||||
static Janet cfun_debug_stacktrace(int32_t argc, Janet *argv) {
|
||||
janet_fixarity(argc, 2);
|
||||
janet_arity(argc, 1, 2);
|
||||
JanetFiber *fiber = janet_getfiber(argv, 0);
|
||||
janet_stacktrace(fiber, argv[1]);
|
||||
Janet x = argc == 1 ? janet_wrap_nil() : argv[1];
|
||||
x = janet_checktype(x, JANET_NIL) ? fiber->last_value : x;
|
||||
janet_stacktrace(fiber, x);
|
||||
return argv[0];
|
||||
}
|
||||
|
||||
@ -377,10 +379,10 @@ static const JanetReg debug_cfuns[] = {
|
||||
},
|
||||
{
|
||||
"debug/stacktrace", cfun_debug_stacktrace,
|
||||
JDOC("(debug/stacktrace fiber err)\n\n"
|
||||
"Prints a nice looking stacktrace for a fiber. The error message "
|
||||
"err must be passed to the function as fiber's do not keep track of "
|
||||
"the last error they have thrown. Returns the fiber.")
|
||||
JDOC("(debug/stacktrace fiber &opt err)\n\n"
|
||||
"Prints a nice looking stacktrace for a fiber. Can optionally provide "
|
||||
"an error value to print the stack trace with. If `err` is nil or not "
|
||||
"provided, will default to `(fiber/last-value fiber)`. Returns the fiber.")
|
||||
},
|
||||
{
|
||||
"debug/lineage", cfun_debug_lineage,
|
||||
|
@ -1065,7 +1065,11 @@ static JanetSignal run_vm(JanetFiber *fiber, Janet in) {
|
||||
janet_status_names[sub_status]);
|
||||
}
|
||||
fiber->child = f;
|
||||
vm_return((int) sub_status, stack[B]);
|
||||
if (janet_checktype(stack[B], JANET_NIL)) {
|
||||
vm_return((int) sub_status, f->last_value);
|
||||
} else {
|
||||
vm_return((int) sub_status, stack[B]);
|
||||
}
|
||||
}
|
||||
|
||||
VM_OP(JOP_CANCEL) {
|
||||
|
Loading…
Reference in New Issue
Block a user