Skip to content

Commit

Permalink
fixed debugging for CexpCond
Browse files Browse the repository at this point in the history
  • Loading branch information
billhails committed Dec 2, 2023
1 parent 7b4172c commit 0821e61
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// #define TEST_STACK
// #define DEBUG_STACK
// #define DEBUG_STEP
// #define DEBUG_STRESS_GC
#define DEBUG_STRESS_GC
// #define DEBUG_LOG_GC
// #define DEBUG_GC
// #define DEBUG_TPMC_MATCH
Expand Down
23 changes: 23 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,26 @@ void printCexpIf(CexpIf *x) {
fprintf(stderr, ")");
}

void printCexpCond(CexpCond *x) {
fprintf(stderr, "(cond ");
printAexp(x->condition);
fprintf(stderr, " ");
printCexpCondCases(x->cases);
fprintf(stderr, ")");
}

void printCexpCondCases(CexpCondCases *x) {
while (x != NULL) {
fprintf(stderr, "(%d ", x->option);
printExp(x->body);
fprintf(stderr, ")");
if (x->next) {
fprintf(stderr, " ");
}
x = x->next;
}
}

void printCexpLetRec(CexpLetRec *x) {
fprintf(stderr, "(letrec ");
printLetRecBindings(x->bindings);
Expand Down Expand Up @@ -625,6 +645,9 @@ void printCexp(Cexp *x) {
case CEXP_TYPE_IF:
printCexpIf(x->val.iff);
break;
case CEXP_TYPE_COND:
printCexpCond(x->val.cond);
break;
case CEXP_TYPE_CALLCC:
fprintf(stderr, "(call/cc ");
printAexp(x->val.callCC);
Expand Down
2 changes: 2 additions & 0 deletions src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void printCexp(Cexp *x);
void printCexpMatch(CexpMatch *x);
void printMatchList(MatchList *x);
void printCexpIf(CexpIf *x);
void printCexpCond(CexpCond *x);
void printCexpCondCases(CexpCondCases *x);
void printCexpLetRec(CexpLetRec *x);
void printCTEnv(CTEnv *x);
void printExp(Exp *x);
Expand Down

0 comments on commit 0821e61

Please sign in to comment.