Expose krk_dumpTraceback so, eg., bim can call it at the right time

This commit is contained in:
K. Lange 2021-01-05 23:23:16 +09:00
parent 5b19419045
commit 1d02ed3c7d
2 changed files with 4 additions and 2 deletions

4
vm.c
View File

@ -68,7 +68,7 @@ static void dumpStack(CallFrame * frame) {
* an exception was thrown. If there the exception value
* is not None, it will also be printed using safe methods.
*/
static void dumpTraceback() {
void krk_dumpTraceback() {
fprintf(stderr, "Traceback, most recent first, %d call frame%s:\n", (int)vm.frameCount, vm.frameCount == 1 ? "" : "s");
for (size_t i = 0; i <= vm.frameCount - 1; i++) {
CallFrame * frame = &vm.frames[i];
@ -2733,7 +2733,7 @@ static int handleException() {
* VM stack state. It should still be safe to execute more code after
* this reset, so the repl can throw errors and keep accepting new lines.
*/
dumpTraceback();
krk_dumpTraceback();
krk_resetStack();
vm.frameCount = 0;
}

2
vm.h
View File

@ -135,3 +135,5 @@ extern int krk_callValue(KrkValue callee, int argCount, int extra);
extern KrkValue krk_dict_of(int argc, KrkValue argv[]);
extern KrkValue krk_callSimple(KrkValue value, int argCount, int isMethod);
extern void krk_finalizeClass(KrkClass * _class);
extern void krk_dumpTraceback();