More debug features, update README, new makefile

This commit is contained in:
2025-12-08 15:06:29 +11:00
parent bd1a47d118
commit 2ca3789024
8 changed files with 354 additions and 21 deletions

View File

@@ -190,6 +190,10 @@ GroundDebugInstruction parseDebugInstruction(char* in) {
gdi.type = CONTINUE;
} else if (strcmp(instruction, "exit") == 0) {
gdi.type = EXIT;
} else if (strcmp(instruction, "step") == 0) {
gdi.type = STEP;
} else if (strcmp(instruction, "view") == 0) {
gdi.type = VIEW;
} else if (strcmp(instruction, "help") == 0) {
gdi.type = HELP;
} else {
@@ -209,6 +213,7 @@ GroundDebugInstruction parseDebugInstruction(char* in) {
GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
GroundLabel* labels = NULL;
GroundVariable* variables = NULL;
int instructionsToPause = -1;
GroundScope scope;
if (inScope != NULL) {
@@ -277,7 +282,7 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
}
}
}
if (in->instructions[i].type == PAUSE) {
if (in->instructions[i].type == PAUSE || instructionsToPause == 0) {
printf("Paused execution\n");
printf("Previous instruction: ");
if (i > 0) {
@@ -341,6 +346,19 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
freeGroundProgram(&program);
break;
}
case STEP: {
if (gdi.arg != NULL && strlen(gdi.arg) > 0) {
instructionsToPause = atoi(gdi.arg);
} else {
instructionsToPause = 1;
}
instructionsToPause++;
shouldBreak = true;
break;
}
case VIEW: {
break;
}
case HELP: {
printf("Ground Debugger Help\n");
printf("Didn't mean to end up here? Type \"continue\" to escape this prompt.\n");
@@ -351,6 +369,7 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
printf(" inspect (variable): Shows the contents of a variable\n");
printf(" eval (code): Runs Ground code in the current scope\n");
printf(" help: Shows this help message");
break;
}
case UNKNOWN: {
printf("Unknown instruction (type \"help\" for help)");
@@ -361,8 +380,11 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
break;
}
}
continue;
if (in->instructions[i].type == PAUSE) {
continue;
}
}
instructionsToPause --;
int ci = currentInstruction;
GroundValue gv = interpretGroundInstruction(in->instructions[i], &scope);
if (gv.type != NONE) {