Commit c6aa08e3 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

Removed parsed node from here too. (eval_range): Removed computation logic

1999-11-03  Miguel de Icaza  <miguel@gnu.org>

	* src/expr.c (eval_range): Removed parsed node from here too.
	(eval_range): Removed computation logic from here.
	(eval_expr_real): ditto.

	* src/func.c (iterate_cellrange_callback): Ditto.

	* src/cell.c (cell_eval, cell_eval_content): Redone the evaluation
	logic to put all the actual details in a single spot.

1999-11-03  Miguel de Icaza  <miguel@gnu.org>

	* src/expr.c (eval_expr_real): Removed cell->parsed_node &&
	(cell->flags & CELL_QUEUED_FOR_RECALC)) from condition.

	* src/func.c (iterate_cellrange_callback): ditto.

1999-11-02  Miguel de Icaza  <miguel@gnu.org>

	* src/workbook.c: change the binding.  Not clear to me yet if we
	need to fix gnome-libs.

1999-11-04  Jody Goldberg <jgoldberg@home.com>
parent 0bf3ac95
No preview for this file type
No preview for this file type
......@@ -13,16 +13,12 @@
#include "ranges.h"
#include "eval.h"
#undef DEBUG_EVALUATION
void
cell_eval (Cell *cell)
static void
cell_eval_content (Cell *cell)
{
Value *v;
FunctionEvalInfo s;
g_return_if_fail (cell != NULL);
#ifdef DEBUG_EVALUATION
{
EvalPosition fp;
......@@ -65,6 +61,33 @@ cell_eval (Cell *cell)
cell->col->pos, cell->row->pos);
}
void
cell_eval (Cell *cell)
{
g_return_if_fail (cell != NULL);
if (cell->generation == cell->sheet->workbook->generation)
return;
cell->generation = cell->sheet->workbook->generation;
if (cell->parsed_node){
GList *deps, *l;
cell_eval_content (cell);
deps = cell_get_dependencies (cell);
for (l = deps; l; l = l->next){
Cell *one_cell;
one_cell = l->data;
if (one_cell->generation != cell->sheet->workbook->generation)
cell_queue_recalc (one_cell);
}
g_list_free (deps);
}
}
/*
* Comparission function for the dependency hash table
*/
......@@ -403,19 +426,35 @@ search_cell_deps (gpointer key, gpointer value, gpointer closure)
Range *range = &(deprange->range);
get_cell_dep_closure_t *c = closure;
GList *l;
int draw;
if (deprange->sheet != c->sheet)
return;
draw = FALSE;
if (c->col == 1 && c->row == 1){
draw = TRUE;
}
/* No intersection is the common case */
if (!range_contains (range, c->col, c->row))
if (!range_contains (range, c->col, c->row)){
return;
}
for (l = deprange->cell_list; l; l = l->next) {
Cell *cell = l->data;
c->list = g_list_prepend (c->list, cell);
}
#ifdef DEBUG_EVALUATION
printf ("Adding list: [\n");
for (l = deprange->cell_list; l; l = l->next) {
Cell *cell = l->data;
printf (" %s(%d), ", cell_name (cell->col->pos, cell->row->pos), cell->generation);
}
printf ("]\n");
#endif
}
GList *
......@@ -463,6 +502,9 @@ cell_queue_recalc (Cell *cell)
if (cell->flags & CELL_QUEUED_FOR_RECALC)
return;
#ifdef DEBUG_EVALUATION
printf ("Queuing: %s\n", cell_name (cell->col->pos, cell->row->pos));
#endif
wb = cell->sheet->workbook;
wb->eval_queue = g_list_prepend (wb->eval_queue, cell);
cell->flags |= CELL_QUEUED_FOR_RECALC;
......@@ -511,6 +553,9 @@ cell_queue_recalc_list (GList *list, gboolean freelist)
if (cell->flags & CELL_QUEUED_FOR_RECALC)
continue;
#ifdef DEBUG_EVALUATION
printf ("Queuing: %s\n", cell_name (cell->col->pos, cell->row->pos));
#endif
wb->eval_queue = g_list_prepend (wb->eval_queue, cell);
cell->flags |= CELL_QUEUED_FOR_RECALC;
......@@ -570,36 +615,10 @@ workbook_recalc (Workbook *wb)
generation = wb->generation;
while ((cell = pick_next_cell_from_queue (wb))){
GList *deps, *l;
if (cell->generation == generation)
continue;
cell->generation = generation;
cell_eval (cell);
deps = cell_get_dependencies (cell);
#ifdef DEBUG_EVALUATION
printf ("\nDepends for %s:%s :\n",
cell->sheet->name,
cell_name (cell->col->pos, cell->row->pos));
#endif
for (l = deps; l; l = l->next){
Cell *one_cell;
one_cell = l->data;
if (one_cell->generation != generation){
cell_queue_recalc (one_cell);
#ifdef DEBUG_EVALUATION
printf ("\t%s:%s,\n",
one_cell->sheet->name,
cell_name(one_cell->col->pos,
one_cell->row->pos));
#endif
}
}
g_list_free (deps);
}
}
......
......@@ -13,16 +13,12 @@
#include "ranges.h"
#include "eval.h"
#undef DEBUG_EVALUATION
void
cell_eval (Cell *cell)
static void
cell_eval_content (Cell *cell)
{
Value *v;
FunctionEvalInfo s;
g_return_if_fail (cell != NULL);
#ifdef DEBUG_EVALUATION
{
EvalPosition fp;
......@@ -65,6 +61,33 @@ cell_eval (Cell *cell)
cell->col->pos, cell->row->pos);
}
void
cell_eval (Cell *cell)
{
g_return_if_fail (cell != NULL);
if (cell->generation == cell->sheet->workbook->generation)
return;
cell->generation = cell->sheet->workbook->generation;
if (cell->parsed_node){
GList *deps, *l;
cell_eval_content (cell);
deps = cell_get_dependencies (cell);
for (l = deps; l; l = l->next){
Cell *one_cell;
one_cell = l->data;
if (one_cell->generation != cell->sheet->workbook->generation)
cell_queue_recalc (one_cell);
}
g_list_free (deps);
}
}
/*
* Comparission function for the dependency hash table
*/
......@@ -403,19 +426,35 @@ search_cell_deps (gpointer key, gpointer value, gpointer closure)
Range *range = &(deprange->range);
get_cell_dep_closure_t *c = closure;
GList *l;
int draw;
if (deprange->sheet != c->sheet)
return;
draw = FALSE;
if (c->col == 1 && c->row == 1){
draw = TRUE;
}
/* No intersection is the common case */
if (!range_contains (range, c->col, c->row))
if (!range_contains (range, c->col, c->row)){
return;
}
for (l = deprange->cell_list; l; l = l->next) {
Cell *cell = l->data;
c->list = g_list_prepend (c->list, cell);
}
#ifdef DEBUG_EVALUATION
printf ("Adding list: [\n");
for (l = deprange->cell_list; l; l = l->next) {
Cell *cell = l->data;
printf (" %s(%d), ", cell_name (cell->col->pos, cell->row->pos), cell->generation);
}
printf ("]\n");
#endif
}
GList *
......@@ -463,6 +502,9 @@ cell_queue_recalc (Cell *cell)
if (cell->flags & CELL_QUEUED_FOR_RECALC)
return;
#ifdef DEBUG_EVALUATION
printf ("Queuing: %s\n", cell_name (cell->col->pos, cell->row->pos));
#endif
wb = cell->sheet->workbook;
wb->eval_queue = g_list_prepend (wb->eval_queue, cell);
cell->flags |= CELL_QUEUED_FOR_RECALC;
......@@ -511,6 +553,9 @@ cell_queue_recalc_list (GList *list, gboolean freelist)
if (cell->flags & CELL_QUEUED_FOR_RECALC)
continue;
#ifdef DEBUG_EVALUATION
printf ("Queuing: %s\n", cell_name (cell->col->pos, cell->row->pos));
#endif
wb->eval_queue = g_list_prepend (wb->eval_queue, cell);
cell->flags |= CELL_QUEUED_FOR_RECALC;
......@@ -570,36 +615,10 @@ workbook_recalc (Workbook *wb)
generation = wb->generation;
while ((cell = pick_next_cell_from_queue (wb))){
GList *deps, *l;
if (cell->generation == generation)
continue;
cell->generation = generation;
cell_eval (cell);
deps = cell_get_dependencies (cell);
#ifdef DEBUG_EVALUATION
printf ("\nDepends for %s:%s :\n",
cell->sheet->name,
cell_name (cell->col->pos, cell->row->pos));
#endif
for (l = deps; l; l = l->next){
Cell *one_cell;
one_cell = l->data;
if (one_cell->generation != generation){
cell_queue_recalc (one_cell);
#ifdef DEBUG_EVALUATION
printf ("\t%s:%s,\n",
one_cell->sheet->name,
cell_name(one_cell->col->pos,
one_cell->row->pos));
#endif
}
}
g_list_free (deps);
}
}
......
......@@ -753,13 +753,8 @@ eval_range (FunctionEvalInfo *s, Value *v)
for (c = start_col; c <= end_col; ++c) {
if ((cell = sheet_cell_get (sheet, c, r)) == NULL)
continue;
if (cell->generation != gen) {
cell->generation = gen;
if (cell->parsed_node &&
(cell->flags & CELL_QUEUED_FOR_RECALC))
cell_eval (cell);
}
if (cell->generation != gen)
cell_eval (cell);
}
}
......@@ -1060,11 +1055,8 @@ eval_expr_real (FunctionEvalInfo *s, ExprTree const *tree)
if (cell == NULL)
return NULL;
if (cell->generation != s->pos.sheet->workbook->generation){
cell->generation = s->pos.sheet->workbook->generation;
if (cell->parsed_node && (cell->flags & CELL_QUEUED_FOR_RECALC))
cell_eval (cell);
}
if (cell->generation != s->pos.sheet->workbook->generation)
cell_eval (cell);
return value_duplicate (cell->value);
}
......
......@@ -39,12 +39,8 @@ iterate_cellrange_callback (Sheet *sheet, int col, int row,
EvalPosition ep;
Value *res;
if (cell->generation != sheet->workbook->generation){
cell->generation = sheet->workbook->generation;
if (cell->parsed_node && (cell->flags & CELL_QUEUED_FOR_RECALC))
cell_eval (cell);
}
if (cell->generation != sheet->workbook->generation)
cell_eval (cell);
/* If we encounter an error for the strict case, short-circuit here. */
if (data->strict && (NULL != (res = cell_is_error(cell))))
......
......@@ -971,7 +971,7 @@ static GnomeUIInfo workbook_menu_insert_special [] = {
{ GNOME_APP_UI_ITEM, N_("Current _time"),
N_("Insert the current time into the selected cell(s)"),
insert_current_time_cmd,
NULL, NULL, 0, 0, ';', GDK_CONTROL_MASK | GDK_SHIFT_MASK },
NULL, NULL, 0, 0, ':', GDK_CONTROL_MASK | GDK_SHIFT_MASK },
GNOMEUIINFO_END
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment