Jump into REPL when executing with --repl-on-error and an error occurs, when the REPL is builtin you will have access to the full stack then. (0.25.0)
This commit is contained in:
parent
41fa946f1c
commit
c71857a068
9 changed files with 309 additions and 7 deletions
13
src/fun.c
13
src/fun.c
|
|
@ -24,11 +24,13 @@ static void print_usage(const char *prog) {
|
|||
printf("Fun %s\n", FUN_VERSION);
|
||||
printf("Usage:\n");
|
||||
#ifdef FUN_WITH_REPL
|
||||
printf(" %s [--trace|-t] [script.fun]\n", prog ? prog : "fun");
|
||||
printf(" %s [--trace|-t] [--repl-on-error] [script.fun]\n", prog ? prog : "fun");
|
||||
printf(" %s --help | -h\n", prog ? prog : "fun");
|
||||
printf(" %s --version | -V\n", prog ? prog : "fun");
|
||||
printf("\n");
|
||||
printf("Options:\n --trace, -t Print executed ops and stack tops during run\n\n");
|
||||
printf("Options:\n");
|
||||
printf(" --trace, -t Print executed ops and stack tops during run\n");
|
||||
printf(" --repl-on-error Enter interactive REPL on runtime error with stack preserved\n\n");
|
||||
printf("When no script is provided, a REPL starts. Submit an empty line to execute the buffer.\n");
|
||||
#else
|
||||
printf(" %s [--trace|-t] <script.fun>\n", prog ? prog : "fun");
|
||||
|
|
@ -59,6 +61,13 @@ int main(int argc, char **argv) {
|
|||
vm.trace_enabled = 1;
|
||||
continue;
|
||||
}
|
||||
#ifdef FUN_WITH_REPL
|
||||
if (strcmp(arg, "--repl-on-error") == 0) {
|
||||
vm.repl_on_error = 1;
|
||||
vm.on_error_repl = fun_run_repl; /* provide REPL entry to core VM */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
/* first non-option assumed to be script path */
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue