Skip to content

Commit

Permalink
Merge pull request #32 from fastly/sv/add-cdata-codegen-with-eager-ou…
Browse files Browse the repository at this point in the history
…tputs-part-2

cdata codegen with eager outputs, part 2
  • Loading branch information
silentbicycle authored Oct 14, 2024
2 parents 7cb37be + 03033cc commit adf2f2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/libfsm/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ fsm_exec(const struct fsm *fsm,

/* TODO: pass struct of callbacks to call during each event; transitions etc */

#if EXPENSIVE_CHECKS
if (!fsm_all(fsm, fsm_isdfa)) {
errno = EINVAL;
return -1;
}
#endif

if (!fsm_getstart(fsm, &state)) {
errno = EINVAL;
Expand Down
11 changes: 7 additions & 4 deletions src/libfsm/print/cdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,21 +604,21 @@ generate_interpreter(FILE *f, const struct cdata_config *config, const struct fs

switch (opt->ambig) {
case AMBIG_NONE:
fprintf(f,
"\t\t(void)endid_base;\n");
break;

case AMBIG_ERROR:
case AMBIG_EARLIEST:
fprintf(f,
"\t\t*id = *endid_base;\n"
"\t\t(void)endid_count;\n"
"\t}\n");
"\t\t(void)endid_count;\n");
break;

case AMBIG_MULTIPLE:
fprintf(f,
"\t\t*%s = endid_base;\n"
"\t\t*%s = endid_count;\n"
"\t}\n",
"\t\t*%s = endid_count;\n",
/* TODO: rename these to endid_ids and endid_count?
* That will be an interface change. */
"ids", "count");
Expand All @@ -628,6 +628,9 @@ generate_interpreter(FILE *f, const struct cdata_config *config, const struct fs
assert(!"unreached");
abort();
}

fprintf(f,
"\t}\n");
}

/* If the end state has eager_outputs, set their flags. */
Expand Down

0 comments on commit adf2f2c

Please sign in to comment.