2022-01-29 00:53:57 +08:00
|
|
|
#include "PikaVM.h"
|
|
|
|
#include "dataStrs.h"
|
2022-01-28 00:43:09 +08:00
|
|
|
|
2022-01-28 12:07:48 +08:00
|
|
|
extern PikaObj* __pikaMain;
|
2022-05-27 09:56:41 +08:00
|
|
|
static enum shell_state __obj_shellLineHandler_debug(PikaObj* self,
|
2022-01-28 12:07:48 +08:00
|
|
|
char* input_line) {
|
|
|
|
/* continue */
|
|
|
|
if (strEqu("c", input_line)) {
|
2022-01-30 19:59:29 +08:00
|
|
|
return SHELL_STATE_EXIT;
|
|
|
|
}
|
|
|
|
/* next */
|
|
|
|
if (strEqu("n", input_line)) {
|
2022-01-28 00:43:09 +08:00
|
|
|
return SHELL_STATE_EXIT;
|
|
|
|
}
|
2022-01-29 00:53:57 +08:00
|
|
|
/* launch shell */
|
2022-01-28 12:07:48 +08:00
|
|
|
if (strEqu("sh", input_line)) {
|
|
|
|
/* exit pika shell */
|
|
|
|
pikaScriptShell(__pikaMain);
|
|
|
|
return SHELL_STATE_CONTINUE;
|
|
|
|
}
|
2022-01-30 19:59:29 +08:00
|
|
|
/* quit */
|
|
|
|
if (strEqu("q", input_line)) {
|
|
|
|
obj_setInt(self, "enable", 0);
|
|
|
|
return SHELL_STATE_EXIT;
|
|
|
|
}
|
2022-01-29 00:53:57 +08:00
|
|
|
/* print */
|
|
|
|
if (strIsStartWith(input_line, "p ")) {
|
|
|
|
char* path = input_line + 2;
|
2022-07-20 10:32:01 +08:00
|
|
|
Arg* asm_buff = arg_newStr("B0\n1 REF ");
|
2022-01-29 00:53:57 +08:00
|
|
|
asm_buff = arg_strAppend(asm_buff, path);
|
|
|
|
asm_buff = arg_strAppend(asm_buff, "\n0 RUN print\n");
|
|
|
|
pikaVM_runAsm(__pikaMain, arg_getStr(asm_buff));
|
|
|
|
arg_deinit(asm_buff);
|
2022-01-30 00:34:14 +08:00
|
|
|
return SHELL_STATE_CONTINUE;
|
2022-01-29 00:53:57 +08:00
|
|
|
}
|
2022-01-30 19:59:29 +08:00
|
|
|
obj_run(__pikaMain, input_line);
|
2022-01-29 00:53:57 +08:00
|
|
|
return SHELL_STATE_CONTINUE;
|
2022-01-28 00:43:09 +08:00
|
|
|
}
|
|
|
|
|
2022-01-30 19:59:29 +08:00
|
|
|
void PikaDebug_Debuger___init__(PikaObj* self) {
|
|
|
|
/* global enable contral */
|
|
|
|
obj_setInt(self, "enable", 1);
|
|
|
|
}
|
|
|
|
|
2022-01-28 00:43:09 +08:00
|
|
|
void PikaDebug_Debuger_set_trace(PikaObj* self) {
|
2022-01-30 19:59:29 +08:00
|
|
|
if (!obj_getInt(self, "enable")) {
|
|
|
|
return;
|
|
|
|
}
|
2022-01-28 12:07:48 +08:00
|
|
|
struct shell_config cfg = {
|
|
|
|
.prefix = "(pika-debug) ",
|
|
|
|
};
|
2022-05-27 09:56:41 +08:00
|
|
|
obj_shellLineProcess(self, __obj_shellLineHandler_debug, &cfg);
|
2022-01-28 00:43:09 +08:00
|
|
|
}
|