- /* change context */
- answer = 0;
- storage = (programs + n)->storage;
- storage_size = (programs + n)->storage_size;
- argument = NULL;
- argument_size = 0;
- stack = (programs + n)->stack;
- if (nbargs > 0) {
- argument = (double *) callocordie (nbargs, sizeof (double));
- for (i = 0, l = 0; i < nbargs; l++) {
- if (args[l]) {
- argument[i++] = evaluate_element (args[l], 0);
- }
- }
- argument_size = nbargs;
+ /* backup context */
+ workspace_t *tmp = backup_ws (alloc_ws ());
+ restore_ws (programs[n]);
+
+ /* set arguments */
+ VERBOSE (DEBUG, fprintf (stdout, "argument before evaluation (%d)\n", size_tab (argument)));
+ for (i = 0; i < size_tab (argument); i++) {
+ VERBOSE (DEBUG, fprintf (stdout, "arg %d value: %g\n", i + 1, get_tab (argument, i + 1)));
+ }
+ VERBOSE (DEBUG, fprintf (stdout, "evaluate %d args\n", nbargs));
+ tab_t *new_argument = def (nbargs, args);
+ tab_t *old_argument = argument;
+ argument = new_argument;
+ VERBOSE (DEBUG, fprintf (stdout, "argument after evaluation (%d)\n", size_tab (argument)));
+ for (i = 0; i < size_tab (argument); i++) {
+ VERBOSE (DEBUG, fprintf (stdout, "arg %d value: %g\n", i + 1, get_tab (argument, i + 1)));