+#include <stdio.h>
+
#include "parser.h"
#include "tabular.h"
double def (int nbops, element_t **ops)
{
int i;
- argument = resize_tab (argument, nbops);
+ tab_t *new = alloc_tab (nbops);
for (i = 0; i < nbops; i++) {
- set_tab (argument, i + 1, evaluate_element (ops[i], 0));
+ double val = evaluate_element (ops[i], 0);
+ VERBOSE (DEBUG, fprintf (stdout, "arg[%d] = %g\n", i + i, val));
+ set_tab (new, i + 1, val);
}
+ free_tab (argument);
+ argument = new;
return size_tab (argument);
}
VERBOSE (WARNING, fprintf (stdout, "error unknown program (%d)\n", id));
return 0;
}
+ VERBOSE (DEBUG, fprintf (stdout, "id -> n; %d -> %d\n", id, n));
- /* backup context */
- workspace_t *tmp = backup_ws (alloc_ws ());
- restore_ws (programs[n]);
-
/* set arguments */
free_tab (argument);
argument = NULL;
+ VERBOSE (DEBUG, fprintf (stdout, "nbargs; %d\n", nbargs));
if (nbargs > 0) {
def (nbargs, args);
}
+ /* backup context */
+ workspace_t *tmp = backup_ws (alloc_ws ());
+ restore_ws (programs[n]);
+
/* evaluate program */
answer = 0;
element_t *elements = dupelement (programs[n]->root);
ret = evaluate_element (elements, 0);
+ VERBOSE (DEBUG, fprintf (stdout, "ret; %g\n", ret));
delelement (elements);
/* clean arguments */