Encapsulated the static data of procedure.[ch] into a single object, to be
[pspp-builds.git] / src / language / xforms / compute.c
index 0a399285604e7da5fc967d77fd767d205d9cbaa4..c4ea4c5a4db266958b2f20bfb78a1049f6c0f26a 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <data/case.h>
 #include <data/dictionary.h>
-#include <procedure.h>
+#include <data/procedure.h>
 #include <data/transformations.h>
 #include <data/variable.h>
 #include <language/command.h>
@@ -94,7 +94,8 @@ cmd_compute (void)
   if (compute->rvalue == NULL)
     goto fail;
 
-  add_transformation (get_proc_func (lvalue), compute_trns_free, compute);
+  add_transformation (current_dataset, 
+                     get_proc_func (lvalue), compute_trns_free, compute);
 
   lvalue_finalize (lvalue, compute);
 
@@ -110,7 +111,7 @@ cmd_compute (void)
 
 /* Handle COMPUTE or IF with numeric target variable. */
 static int
-compute_num (void *compute_, struct ccase *c, int case_num)
+compute_num (void *compute_, struct ccase *c, casenum_t case_num)
 {
   struct compute_trns *compute = compute_;
 
@@ -125,7 +126,7 @@ compute_num (void *compute_, struct ccase *c, int case_num)
 /* Handle COMPUTE or IF with numeric vector element target
    variable. */
 static int
-compute_num_vec (void *compute_, struct ccase *c, int case_num)
+compute_num_vec (void *compute_, struct ccase *c, casenum_t case_num)
 {
   struct compute_trns *compute = compute_;
 
@@ -157,7 +158,7 @@ compute_num_vec (void *compute_, struct ccase *c, int case_num)
 
 /* Handle COMPUTE or IF with string target variable. */
 static int
-compute_str (void *compute_, struct ccase *c, int case_num)
+compute_str (void *compute_, struct ccase *c, casenum_t case_num)
 {
   struct compute_trns *compute = compute_;
 
@@ -172,7 +173,7 @@ compute_str (void *compute_, struct ccase *c, int case_num)
 /* Handle COMPUTE or IF with string vector element target
    variable. */
 static int
-compute_str_vec (void *compute_, struct ccase *c, int case_num)
+compute_str_vec (void *compute_, struct ccase *c, casenum_t case_num)
 {
   struct compute_trns *compute = compute_;
 
@@ -219,7 +220,7 @@ cmd_if (void)
   compute = compute_trns_create ();
 
   /* Test expression. */
-  compute->test = expr_parse (default_dict, EXPR_BOOLEAN);
+  compute->test = expr_parse (dataset_dict (current_dataset), EXPR_BOOLEAN);
   if (compute->test == NULL)
     goto fail;
 
@@ -235,7 +236,8 @@ cmd_if (void)
   if (compute->rvalue == NULL)
     goto fail;
 
-  add_transformation (get_proc_func (lvalue), compute_trns_free, compute);
+  add_transformation (current_dataset, 
+                     get_proc_func (lvalue), compute_trns_free, compute);
 
   lvalue_finalize (lvalue, compute);
 
@@ -267,7 +269,7 @@ parse_rvalue (const struct lvalue *lvalue)
 {
   bool is_numeric = lvalue_get_type (lvalue) == NUMERIC;
 
-  return expr_parse (default_dict, is_numeric ? EXPR_NUMBER : EXPR_STRING);
+  return expr_parse (dataset_dict (current_dataset), is_numeric ? EXPR_NUMBER : EXPR_STRING);
 }
 
 /* Returns a new struct compute_trns after initializing its fields. */
@@ -325,7 +327,7 @@ lvalue_parse (void)
   if (lex_look_ahead () == '(')
     {
       /* Vector. */
-      lvalue->vector = dict_lookup_vector (default_dict, tokid);
+      lvalue->vector = dict_lookup_vector (dataset_dict (current_dataset), tokid);
       if (lvalue->vector == NULL)
        {
          msg (SE, _("There is no vector named %s."), tokid);
@@ -336,7 +338,7 @@ lvalue_parse (void)
       lex_get ();
       if (!lex_force_match ('('))
        goto lossage;
-      lvalue->element = expr_parse (default_dict, EXPR_NUMBER);
+      lvalue->element = expr_parse (dataset_dict (current_dataset), EXPR_NUMBER);
       if (lvalue->element == NULL)
         goto lossage;
       if (!lex_force_match (')'))
@@ -362,7 +364,7 @@ lvalue_get_type (const struct lvalue *lvalue)
 {
   if (lvalue->vector == NULL) 
     {
-      struct variable *var = dict_lookup_var (default_dict, lvalue->var_name);
+      struct variable *var = dict_lookup_var (dataset_dict (current_dataset), lvalue->var_name);
       if (var == NULL)
         return NUMERIC;
       else
@@ -372,7 +374,7 @@ lvalue_get_type (const struct lvalue *lvalue)
     return lvalue->vector->var[0]->type;
 }
 
-/* Returns nonzero if LVALUE has a vector as its target. */
+/* Returns true if LVALUE has a vector as its target. */
 static bool
 lvalue_is_vector (const struct lvalue *lvalue) 
 {
@@ -386,9 +388,9 @@ lvalue_finalize (struct lvalue *lvalue, struct compute_trns *compute)
 {
   if (lvalue->vector == NULL)
     {
-      compute->variable = dict_lookup_var (default_dict, lvalue->var_name);
+      compute->variable = dict_lookup_var (dataset_dict (current_dataset), lvalue->var_name);
       if (compute->variable == NULL)
-         compute->variable = dict_create_var_assert (default_dict,
+         compute->variable = dict_create_var_assert (dataset_dict (current_dataset),
                                                      lvalue->var_name, 0);
 
       compute->fv = compute->variable->fv;