refactor: renaming clocking flags and fix some comments to be more readable

This commit is contained in:
Glen Whitney 2023-04-30 08:57:20 -04:00
parent da48b4c4f8
commit cffd105e19
3 changed files with 23 additions and 20 deletions

View File

@ -33,9 +33,9 @@ void initcellcontents(Cell *fresh)
fresh->updated = false;
fresh->locked = false;
fresh->ignored = false;
fresh->clock_t0 = false;
fresh->clock_t1 = false;
fresh->clock_t2 = false;
fresh->use_iter_cont = false;
fresh->clock_resolving = false;
fresh->clock_requested = false;
}
/* getcont -- get contents */
@ -45,7 +45,7 @@ Token gettok(const Cell *cell, TokVariety v)
emp.type = EMPTY;
if (cell == NULLCELL) return emp;
if (v == CONTINGENT)
v = (cell->clock_t0 && cell->tok[ITER_CONT].type != EMPTY)
v = (cell->use_iter_cont && cell->tok[ITER_CONT].type != EMPTY)
? ITER_CONT : BASE_CONT;
return cell->tok[v];
}

View File

@ -22,9 +22,9 @@ typedef struct
unsigned int updated:1;
unsigned int locked:1;
unsigned int ignored:1;
unsigned int clock_t0:1;
unsigned int clock_t1:1;
unsigned int clock_t2:1;
unsigned int use_iter_cont:1;
unsigned int clock_resolving:1;
unsigned int clock_requested:1;
} Cell;
#define NULLCELL ((Cell*)0)

View File

@ -104,9 +104,9 @@ static void dump_cell(Sheet *sheet, int x, int y, int z)
if (c->updated) printf(" updated ");
if (c->locked) printf(" locked ");
if (c->ignored) printf(" ignored ");
if (c->clock_t0) printf(" clock_t0 ");
if (c->clock_t1) printf(" clock_t1 ");
if (c->clock_t2) printf(" clock_t2 ");
if (c->use_iter_cont) printf(" use_iter_cont ");
if (c->clock_resolving) printf(" clock_resolving ");
if (c->clock_requested) printf(" clock_requested ");
printf("\n\n");
}
/*}}}*/
@ -448,7 +448,7 @@ void forceupdate(Sheet *sheet)
size_t i; Cell *cell;
for (ALL_CELLS_IN_SHEET(sheet,i,cell))
if (cell != NULLCELL) {
cell->updated = cell->clock_t0 = cell->clock_t1 = cell->clock_t2 = false;
cell->updated = cell->use_iter_cont = cell->clock_resolving = cell->clock_requested = false;
tfree(&(cell->tok[STYLE_VAL]));
}
update(sheet);
@ -613,7 +613,7 @@ Token recompvalue(Sheet *sheet, const Location at)
upd_sheet = sheet;
LOCATION_GETS(upd_l, at);
max_eval = MAX_EVALNEST;
if (!(cell->clock_t1))
if (!(cell->clock_resolving))
{
cell->updated = true;
oldvalue = gettok(cell, CURR_VAL);
@ -633,6 +633,9 @@ Token recompvalue(Sheet *sheet, const Location at)
LOCATION_GETS(upd_l, old_l);
max_eval = old_max_eval;
}
/* When upd_clock was true on entry, the result is going to be thrown
away in any case, so don't bother doing the copy.
*/
if (!orig_upd_clock) result = tcopy(cell->tok[CURR_VAL]);
/*}}}*/
return result;
@ -666,7 +669,7 @@ void update(Sheet *sheet)
sheet->clk = 0;
if (iterating == 1)
{
line_msg(NULL, _("Realculation running, press Escape to abort it"));
line_msg(NULL, _("Recalculation running, press Escape to abort it"));
++iterating;
}
else if (iterating == 0) ++iterating;
@ -674,12 +677,12 @@ void update(Sheet *sheet)
size_t i;
for (ALL_CELLS_IN_SHEET(sheet,i,cell))
{
if (cell && cell->clock_t2)
if (cell && cell->clock_requested)
{
cell->updated = false;
cell->clock_t0 = true;
cell->clock_t1 = true;
cell->clock_t2 = false;
cell->use_iter_cont = true;
cell->clock_resolving = true;
cell->clock_requested = false;
tfree(&(cell->tok[STYLE_VAL]));
}
}
@ -691,12 +694,12 @@ void update(Sheet *sheet)
}
for (ALL_CELLS_IN_SHEET(sheet,i,cell))
{
if (cell && cell->clock_t1)
if (cell && cell->clock_resolving)
{
tfree(&(cell->tok[CURR_VAL]));
cell->tok[CURR_VAL] = cell->tok[RES_VAL];;
cell->tok[RES_VAL].type = EMPTY;
cell->clock_t1 = false;
cell->clock_resolving = false;
}
}
upd_clock = false;
@ -905,7 +908,7 @@ void clk(Sheet *sheet, const Location at)
assert(LOC_WITHIN(sheet,at));
if (CELL_AT(sheet,at))
{
CELL_AT(sheet,at)->clock_t2 = true;
CELL_AT(sheet,at)->clock_requested = true;
sheet->clk = true;
}
}