Skip to content

Commit

Permalink
Pass through retlist for print_ir() output too.
Browse files Browse the repository at this point in the history
  • Loading branch information
katef committed Aug 30, 2024
1 parent 8f9ea4d commit d60c6b2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/libfsm/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,6 @@ fsm_print(FILE *f, const struct fsm *fsm,
}
}

if (print_ir != NULL) {
r = print_ir(f, opt, hooks, ir);
goto done;
}

/*
* We're building the retlist here based on the ir.
* I think we could build the retlist earlier instead,
Expand All @@ -377,6 +372,12 @@ fsm_print(FILE *f, const struct fsm *fsm,
goto error;
}

if (print_ir != NULL) {
r = print_ir(f, opt, hooks, &retlist, ir);
free_retlist(&retlist);
goto done;
}

a = zero;

/* TODO: non-const a */
Expand Down
1 change: 1 addition & 0 deletions src/libfsm/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ typedef int fsm_print_f(FILE *f,
typedef int ir_print_f(FILE *f,
const struct fsm_options *opt,
const struct fsm_hooks *hooks,
const struct ret_list *retlist,
const struct ir *ir);

typedef int vm_print_f(FILE *f,
Expand Down
5 changes: 5 additions & 0 deletions src/libfsm/print/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ int
fsm_print_c(FILE *f,
const struct fsm_options *opt,
const struct fsm_hooks *hooks,
const struct ret_list *retlist,
const struct ir *ir)
{
const char *prefix;
Expand All @@ -523,6 +524,10 @@ fsm_print_c(FILE *f,
assert(hooks != NULL);
assert(ir != NULL);

/* XXX: it would actually make sense to use the retlist here,
* but my plan is to remove the ir-based C codegen anyway */
(void) retlist;

if (opt->prefix != NULL) {
prefix = opt->prefix;
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/libfsm/print/irdot.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ int
fsm_print_ir(FILE *f,
const struct fsm_options *opt,
const struct fsm_hooks *hooks,
const struct ret_list *retlist,
const struct ir *ir)
{
size_t i;
Expand All @@ -338,6 +339,8 @@ fsm_print_ir(FILE *f,
assert(hooks != NULL);
assert(ir != NULL);

(void) retlist;

fprintf(f, "# generated\n");
fprintf(f, "digraph G {\n");

Expand Down
3 changes: 3 additions & 0 deletions src/libfsm/print/irjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ int
fsm_print_irjson(FILE *f,
const struct fsm_options *opt,
const struct fsm_hooks *hooks,
const struct ret_list *retlist,
const struct ir *ir)
{
size_t i;
Expand All @@ -228,6 +229,8 @@ fsm_print_irjson(FILE *f,
assert(hooks != NULL);
assert(ir != NULL);

(void) retlist;

fprintf(f, "{\n");

fprintf(f, "\t\"start\": %u,\n", ir->start);
Expand Down

0 comments on commit d60c6b2

Please sign in to comment.