\f
/* Transformation functions. */
+/* Handle COMPUTE or IF with numeric target variable. */
static int
-compute_num (struct trns_header *compute_, struct ccase *c)
+compute_num (struct trns_header *compute_, struct ccase *c,
+ int case_num)
{
struct compute_trns *compute = (struct compute_trns *) compute_;
if (compute->test == NULL
- || expr_evaluate (compute->test, c, NULL) == 1.0)
+ || expr_evaluate (compute->test, c, case_num, NULL) == 1.0)
{
- expr_evaluate (compute->rvalue, c, &c->data[compute->fv]);
+ expr_evaluate (compute->rvalue, c, case_num, &c->data[compute->fv]);
}
return -1;
}
+/* Handle COMPUTE or IF with numeric vector element target
+ variable. */
static int
-compute_num_vec (struct trns_header *compute_, struct ccase *c)
+compute_num_vec (struct trns_header *compute_, struct ccase *c,
+ int case_num)
{
struct compute_trns *compute = (struct compute_trns *) compute_;
if (compute->test == NULL
- || expr_evaluate (compute->test, c, NULL) == 1.0)
+ || expr_evaluate (compute->test, c, case_num, NULL) == 1.0)
{
/* Index into the vector. */
union value index;
/* Rounded index value. */
int rindx;
- expr_evaluate (compute->element, c, &index);
+ expr_evaluate (compute->element, c, case_num, &index);
rindx = floor (index.f + EPSILON);
if (index.f == SYSMIS || rindx < 1 || rindx > compute->vector->cnt)
{
index.f, compute->vector->name);
return -1;
}
- expr_evaluate (compute->rvalue, c,
+ expr_evaluate (compute->rvalue, c, case_num,
&c->data[compute->vector->var[rindx - 1]->fv]);
}
return -1;
}
+/* Handle COMPUTE or IF with string target variable. */
static int
-compute_str (struct trns_header *compute_, struct ccase *c)
+compute_str (struct trns_header *compute_, struct ccase *c,
+ int case_num)
{
struct compute_trns *compute = (struct compute_trns *) compute_;
if (compute->test == NULL
- || expr_evaluate (compute->test, c, NULL) == 1.0)
+ || expr_evaluate (compute->test, c, case_num, NULL) == 1.0)
{
/* Temporary storage for string expression return value. */
union value v;
- expr_evaluate (compute->rvalue, c, &v);
+ expr_evaluate (compute->rvalue, c, case_num, &v);
st_bare_pad_len_copy (c->data[compute->fv].s, &v.c[1], compute->width,
v.c[0]);
}
return -1;
}
+/* Handle COMPUTE or IF with string vector element target
+ variable. */
static int
-compute_str_vec (struct trns_header *compute_, struct ccase *c)
+compute_str_vec (struct trns_header *compute_, struct ccase *c,
+ int case_num)
{
struct compute_trns *compute = (struct compute_trns *) compute_;
if (compute->test == NULL
- || expr_evaluate (compute->test, c, NULL) == 1.0)
+ || expr_evaluate (compute->test, c, case_num, NULL) == 1.0)
{
/* Temporary storage for string expression return value. */
union value v;
/* Variable reference by indexed vector. */
struct variable *vr;
- expr_evaluate (compute->element, c, &index);
+ expr_evaluate (compute->element, c, case_num, &index);
rindx = floor (index.f + EPSILON);
if (index.f == SYSMIS || rindx < 1 || rindx > compute->vector->cnt)
{
return -1;
}
- expr_evaluate (compute->rvalue, c, &v);
+ expr_evaluate (compute->rvalue, c, case_num, &v);
vr = compute->vector->var[rindx - 1];
st_bare_pad_len_copy (c->data[vr->fv].s, &v.c[1], vr->width, v.c[0]);
}
expr_free (compute->rvalue);
}
\f
+/* COMPUTE or IF target variable or vector element. */
struct lvalue
{
char var_name[9]; /* Destination variable name, or "". */
struct expression *element; /* Destination vector element, or NULL. */
};
+/* Parses the target variable or vector elector into a new
+ `struct lvalue', which is returned. */
static struct lvalue *
lvalue_parse (void)
{
return NULL;
}
+/* Returns the type (NUMERIC or ALPHA) of the target variable or
+ vector in LVALUE. */
static int
lvalue_get_type (const struct lvalue *lvalue)
{
return lvalue->vector->var[0]->type;
}
+/* Returns nonzero if LVALUE has a vector as its target. */
static int
lvalue_is_vector (const struct lvalue *lvalue)
{
return lvalue->vector != NULL;
}
+/* Finalizes making LVALUE the target of COMPUTE, by creating the
+ target variable if necessary and setting fields in COMPUTE. */
static void
lvalue_finalize (struct lvalue *lvalue,
struct compute_trns *compute)
compute->fv = compute->variable->fv;
compute->width = compute->variable->width;
-
-
/* Goofy behavior, but compatible: Turn off LEAVE. */
if (dict_class_from_id (compute->variable->name) != DC_SCRATCH)
compute->variable->reinit = 1;
lvalue_destroy (lvalue);
}
+/* Destroys LVALUE. */
static void
lvalue_destroy (struct lvalue *lvalue)
{