Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions bf_simple2_yk.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ void interp(char *prog, char *prog_end, char *cells, char *cells_end,
char *instr = prog;
char *cell = cells;
while (instr < prog_end) {
YkLocation *loc = NULL;
if (*instr == ']')
loc = &yklocs[instr - prog];
yk_mt_control_point(mt, loc);
yk_mt_control_point(mt, &yklocs[instr - prog]);
switch (*instr) {
case '>': {
if (cell++ == cells_end)
Expand Down Expand Up @@ -124,8 +121,12 @@ int main(int argc, char *argv[]) {
YkLocation *yklocs = calloc(prog_len, sizeof(YkLocation));
if (yklocs == NULL)
err(1, "out of memory");
for (YkLocation *ykloc = yklocs; ykloc < yklocs + prog_len; ykloc++)
*ykloc = yk_location_new();
for (size_t i = 0; i < prog_len; i++) {
if (prog[i] == ']')
yklocs[i] = yk_location_new();
else
yklocs[i] = yk_location_null();
}

interp(prog, prog + prog_len, cells, cells + CELLS_LEN, mt, yklocs);
free(yklocs);
Expand Down
13 changes: 7 additions & 6 deletions bf_simple_yk.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ void interp(char *prog, char *prog_end, char *cells, char *cells_end,
char *instr = prog;
char *cell = cells;
while (instr < prog_end) {
YkLocation *loc = NULL;
if (*instr == ']')
loc = &yklocs[instr - prog];
yk_mt_control_point(mt, loc);
yk_mt_control_point(mt, &yklocs[instr - prog]);
switch (*instr) {
case '>': {
if (cell++ == cells_end)
Expand Down Expand Up @@ -109,8 +106,12 @@ int main(int argc, char *argv[]) {
YkLocation *yklocs = calloc(prog_len, sizeof(YkLocation));
if (yklocs == NULL)
err(1, "out of memory");
for (YkLocation *ykloc = yklocs; ykloc < yklocs + prog_len; ykloc++)
*ykloc = yk_location_new();
for (size_t i = 0; i < prog_len; i++) {
if (prog[i] == ']')
yklocs[i] = yk_location_new();
else
yklocs[i] = yk_location_null();
}

interp(prog, prog + prog_len, cells, cells + CELLS_LEN, mt, yklocs);
free(yklocs);
Expand Down