Commit 05fe8569 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Merge oper and ref_count fields into one oper_and_refcount field. Define

2006-01-23  Morten Welinder  <terra@gnome.org>

	* src/expr-impl.h (GnmExpr): Merge oper and ref_count fields into
	one oper_and_refcount field.  Define accessors GNM_EXPR_GET_OPER
	and GNM_EXPR_GET_REFCOUNT.  All users changed.
parent f2479c16
2006-01-23 Morten Welinder <terra@gnome.org>
* src/expr-impl.h (GnmExpr): Merge oper and ref_count fields into
one oper_and_refcount field. Define accessors GNM_EXPR_GET_OPER
and GNM_EXPR_GET_REFCOUNT. All users changed.
2006-01-22 Jody Goldberg <jody@gnome.org>
* src/expr-impl.h : arrays can not be larger than 2^32 even on 64 bit
......
......@@ -50,6 +50,7 @@ Morten:
* Fix MID for out-of-bounds values.
* Fix constructed-range parsing for OO.
* Improve .desktop file. [#328015]
* Make expressions use less memory.
Jon Kre:
* Hand clipboard off to clipboard manager when exiting.
......
2006-01-23 Morten Welinder <terra@gnome.org>
* src/expr-impl.h (GnmExpr): Merge oper and ref_count fields into
one oper_and_refcount field. Define accessors GNM_EXPR_GET_OPER
and GNM_EXPR_GET_REFCOUNT. All users changed.
2006-01-22 Jody Goldberg <jody@gnome.org>
* src/expr-impl.h : arrays can not be larger than 2^32 even on 64 bit
......
......@@ -2975,7 +2975,7 @@ excel_write_FORMULA (ExcelWriteState *ewb, ExcelWriteSheet *esheet, GnmCell cons
ms_biff_put_commit (ewb->bp);
if (expr->any.oper == GNM_EXPR_OP_ARRAY_CORNER) {
if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_ARRAY_CORNER) {
GnmCellPos c_in, r_in;
if (gnm_expr_is_data_table (expr->array_corner.expr, &c_in, &r_in)) {
guint16 flags = 0;
......
......@@ -640,10 +640,10 @@ make_function (GnmExprList **stack, int fn_idx, int numargs, Workbook *wb)
char const *f_name = NULL;
if (tmp != NULL) {
if (tmp->any.oper == GNM_EXPR_OP_CONSTANT &&
if (GNM_EXPR_GET_OPER (tmp) == GNM_EXPR_OP_CONSTANT &&
tmp->constant.value->type == VALUE_STRING)
f_name = tmp->constant.value->v_str.val->str;
else if (tmp->any.oper == GNM_EXPR_OP_NAME)
else if (GNM_EXPR_GET_OPER (tmp) == GNM_EXPR_OP_NAME)
f_name = tmp->name.name->name->str;
}
......@@ -985,7 +985,7 @@ excel_parse_formula (MSContainer const *container,
/* not exactly legal, but should be reasonable
* XL has union operator we have sets.
*/
if (l->any.oper != GNM_EXPR_OP_SET) {
if (GNM_EXPR_GET_OPER (l) != GNM_EXPR_OP_SET) {
GnmExprList *args = gnm_expr_list_prepend (NULL, r);
args = gnm_expr_list_prepend (args, l);
parse_list_push (&stack, gnm_expr_new_set (args));
......
......@@ -84,7 +84,7 @@ excel_write_prep_sheet (ExcelWriteState *ewb, Sheet const *sheet)
void
excel_write_prep_expr (ExcelWriteState *ewb, GnmExpr const *expr)
{
switch (expr->any.oper) {
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_RANGE_CTOR:
case GNM_EXPR_OP_INTERSECT:
......@@ -675,7 +675,7 @@ write_node (PolishData *pd, GnmExpr const *expr, int paren_level,
g_return_if_fail (pd);
g_return_if_fail (expr);
switch ((op = expr->any.oper)) {
switch ((op = GNM_EXPR_GET_OPER (expr))) {
case GNM_EXPR_OP_ANY_BINARY :
if (target_type != XL_ARRAY)
target_type = XL_VAL;
......@@ -844,10 +844,10 @@ write_node (PolishData *pd, GnmExpr const *expr, int paren_level,
default : {
gchar *err = g_strdup_printf ("Unknown Operator %d",
expr->any.oper);
GNM_EXPR_GET_OPER (expr));
write_string (pd, err);
g_free (err);
g_warning ("Unhandled expr type %d", expr->any.oper);
g_warning ("Unhandled expr type %d", GNM_EXPR_GET_OPER (expr));
break;
}
}
......
......@@ -1724,7 +1724,7 @@ gnumeric_isref (FunctionEvalInfo *ei, GnmExprList const *expr_node_list)
if (!t)
return NULL;
return value_new_bool (t->any.oper == GNM_EXPR_OP_CELLREF);
return value_new_bool (GNM_EXPR_GET_OPER (t) == GNM_EXPR_OP_CELLREF);
}
/***************************************************************************/
......
......@@ -452,8 +452,8 @@ gnumeric_areas (FunctionEvalInfo *ei, GnmExprList const *l)
return value_new_error_VALUE (ei->pos);
expr = l->data;
restart :
switch (expr->any.oper) {
restart:
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_CONSTANT:
if (expr->constant.value->type == VALUE_ERROR)
return value_dup (expr->constant.value);
......@@ -899,7 +899,7 @@ gnumeric_index (FunctionEvalInfo *ei, GnmExprList const *l)
value_release (v);
}
if (source->any.oper == GNM_EXPR_OP_SET) {
if (GNM_EXPR_GET_OPER (source) == GNM_EXPR_OP_SET) {
source = gnm_expr_list_nth (source->set.set, elem[2]);
if (elem[2] < 0 || source == NULL)
return value_new_error_REF (ei->pos);
......
......@@ -5470,7 +5470,7 @@ function_marshal_arg (FunctionEvalInfo *ei,
*type_mismatch = NULL;
if (t->any.oper == GNM_EXPR_OP_CELLREF)
if (GNM_EXPR_GET_OPER (t) == GNM_EXPR_OP_CELLREF)
v = value_new_cellrange (&t->cellref.ref, &t->cellref.ref,
ei->pos->eval.col,
ei->pos->eval.row);
......
......@@ -284,7 +284,7 @@ lotus_negate (const GnmExpr *e)
{
const GnmExpr *res;
if (e->any.oper == GNM_EXPR_OP_UNARY_NEG) {
if (GNM_EXPR_GET_OPER (e) == GNM_EXPR_OP_UNARY_NEG) {
res = e->unary.value;
gnm_expr_ref (res);
gnm_expr_unref (e);
......
......@@ -1240,7 +1240,7 @@ oo_named_expr (GsfXMLIn *xin, xmlChar const **attrs)
&perr);
g_free (tmp);
if (expr == NULL || expr->any.oper != GNM_EXPR_OP_CELLREF) {
if (expr == NULL || GNM_EXPR_GET_OPER (expr) != GNM_EXPR_OP_CELLREF) {
oo_warning (xin, _("Unable to parse position for expression '%s' @ '%s' because '%s'"),
name, base_str, perr.err->message);
parse_error_free (&perr);
......
......@@ -102,7 +102,7 @@ do_af_suggest (GnmExpr const *expr, const GnmEvalPos *epos, GOFormat **explicit)
}
#endif
switch (expr->any.oper) {
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_EQUAL:
case GNM_EXPR_OP_GT:
case GNM_EXPR_OP_LT:
......
......@@ -526,7 +526,7 @@ cell_array_bound (GnmCell const *cell, GnmRange *res)
g_return_val_if_fail (res != NULL, FALSE);
expr = cell->base.expression;
if (expr->any.oper == GNM_EXPR_OP_ARRAY_ELEM) {
if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_ARRAY_ELEM) {
cell = sheet_cell_get (cell->base.sheet,
cell->pos.col - expr->array_elem.x,
cell->pos.row - expr->array_elem.y);
......@@ -537,7 +537,7 @@ cell_array_bound (GnmCell const *cell, GnmRange *res)
expr = cell->base.expression;
}
if (expr->any.oper != GNM_EXPR_OP_ARRAY_CORNER)
if (GNM_EXPR_GET_OPER (expr) != GNM_EXPR_OP_ARRAY_CORNER)
return FALSE;
range_init (res, cell->pos.col, cell->pos.row,
......@@ -550,7 +550,7 @@ GnmExprArrayCorner const *
cell_is_array_corner (GnmCell const *cell)
{
if (cell != NULL && cell_has_expr (cell) &&
cell->base.expression->any.oper == GNM_EXPR_OP_ARRAY_CORNER)
GNM_EXPR_GET_OPER (cell->base.expression) == GNM_EXPR_OP_ARRAY_CORNER)
return &cell->base.expression->array_corner;
return NULL;
}
......@@ -565,7 +565,7 @@ gboolean
cell_is_array (GnmCell const *cell)
{
if (cell != NULL && cell_has_expr (cell))
switch (cell->base.expression->any.oper) {
switch (GNM_EXPR_GET_OPER (cell->base.expression)) {
case GNM_EXPR_OP_ARRAY_CORNER :
case GNM_EXPR_OP_ARRAY_ELEM :
return TRUE;
......@@ -585,7 +585,7 @@ gboolean
cell_is_nonsingleton_array (GnmCell const *cell)
{
if (cell != NULL && cell_has_expr (cell))
switch (cell->base.expression->any.oper) {
switch (GNM_EXPR_GET_OPER (cell->base.expression)) {
case GNM_EXPR_OP_ARRAY_CORNER : {
GnmExprArrayCorner const *corner = &cell->base.expression->array_corner;
return corner->cols > 1 || corner->rows > 1;
......
......@@ -126,11 +126,10 @@ paste_cell_with_operation (Sheet *dst_sheet,
} else {
GnmEvalPos pos;
GnmExpr expr, arg_a, arg_b;
arg_a.constant.oper = GNM_EXPR_OP_CONSTANT;
arg_a.constant.value = dst->value;
arg_b.constant.oper = GNM_EXPR_OP_CONSTANT;
arg_b.constant.value = src->val;
expr.binary.oper = op;
gnm_expr_constant_init (&arg_a.constant, dst->value);
gnm_expr_constant_init (&arg_b.constant, src->val);
GNM_EXPR_SET_OPER_REF1 (&expr, op);
expr.binary.value_a = &arg_a;
expr.binary.value_b = &arg_b;
......
......@@ -716,7 +716,7 @@ link_expr_dep (GnmEvalPos *ep, GnmExpr const *tree)
{
g_return_val_if_fail (tree != NULL, DEPENDENT_NO_FLAG);
switch (tree->any.oper) {
switch (GNM_EXPR_GET_OPER (tree)) {
case GNM_EXPR_OP_ANY_BINARY:
return link_expr_dep (ep, tree->binary.value_a) |
link_expr_dep (ep, tree->binary.value_b);
......@@ -807,7 +807,7 @@ link_expr_dep (GnmEvalPos *ep, GnmExpr const *tree)
static void
unlink_expr_dep (GnmDependent *dep, GnmExpr const *tree)
{
switch (tree->any.oper) {
switch (GNM_EXPR_GET_OPER (tree)) {
case GNM_EXPR_OP_ANY_BINARY:
unlink_expr_dep (dep, tree->binary.value_a);
unlink_expr_dep (dep, tree->binary.value_b);
......
......@@ -458,7 +458,7 @@ dialog_formula_guru_load_expr (GtkTreePath const *parent_path, gint child_num,
gtk_tree_path_append_index (path, child_num);
}
switch (expr->any.oper) {
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_FUNCALL:
dialog_formula_guru_load_fd (path, expr->func.func, state);
for (args = expr->func.arg_list, i = 0; args; args = args->next, i++)
......
......@@ -5,79 +5,61 @@
#include "numbers.h"
#include "parse-util.h"
struct _GnmExprConstant {
GnmExprOp oper;
int ref_count;
struct _GnmExprConstant {
guint32 oper_and_refcount;
GnmValue const *value;
};
struct _GnmExprFunction {
GnmExprOp oper;
int ref_count;
GnmFunc *func;
guint32 oper_and_refcount;
GnmFunc *func;
GnmExprList *arg_list;
};
struct _GnmExprUnary {
GnmExprOp oper;
int ref_count;
guint32 oper_and_refcount;
GnmExpr const *value;
};
struct _GnmExprBinary {
GnmExprOp oper;
int ref_count;
guint32 oper_and_refcount;
GnmExpr const *value_a;
GnmExpr const *value_b;
};
/* We could break this out into multiple types to be more space efficient */
struct _GnmExprName {
GnmExprOp oper;
int ref_count;
Sheet *optional_scope;
Workbook *optional_wb_scope;
guint32 oper_and_refcount;
Sheet *optional_scope;
Workbook *optional_wb_scope;
GnmNamedExpr *name;
};
struct _GnmExprCellRef {
GnmExprOp oper;
int ref_count;
guint32 oper_and_refcount;
GnmCellRef ref;
};
struct _GnmExprArrayCorner {
GnmExprOp oper;
int ref_count;
guint32 cols, rows;
guint32 oper_and_refcount;
guint32 cols, rows;
GnmValue *value; /* Last array result */
GnmExpr const *expr; /* Real Expression */
};
struct _GnmExprArrayElem {
GnmExprOp oper;
int ref_count;
guint32 x, y;
guint32 oper_and_refcount;
guint32 x, y;
};
struct _GnmExprSet {
GnmExprOp oper;
int ref_count;
guint32 oper_and_refcount;
GnmExprList *set;
};
union _GnmExpr {
struct {
GnmExprOp oper;
int ref_count;
} any;
guint32 oper_and_refcount;
GnmExprConstant constant;
GnmExprFunction func;
GnmExprUnary unary;
......@@ -89,11 +71,14 @@ union _GnmExpr {
GnmExprSet set;
};
#define gnm_expr_constant_init(expr, val) \
do { \
(expr)->ref_count = 1; \
(expr)->oper = GNM_EXPR_OP_CONSTANT; \
(expr)->value = val; \
#define GNM_EXPR_GET_REFCOUNT(e) ((e)->oper_and_refcount & ((1 << 27) - 1))
#define GNM_EXPR_GET_OPER(e) ((GnmExprOp)((e)->oper_and_refcount >> 27))
#define GNM_EXPR_SET_OPER_REF1(e,o) ((e)->oper_and_refcount = (((o) << 27) | 1))
#define gnm_expr_constant_init(expr, val) \
do { \
GNM_EXPR_SET_OPER_REF1(expr, GNM_EXPR_OP_CONSTANT); \
(expr)->value = val; \
} while (0)
#endif /* GNUMERIC_EXPR_IMPL_H */
......@@ -341,7 +341,7 @@ expr_name_check_for_loop (char const *name, GnmExpr const *expr)
{
g_return_val_if_fail (expr != NULL, TRUE);
switch (expr->any.oper) {
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_RANGE_CTOR:
case GNM_EXPR_OP_INTERSECT:
case GNM_EXPR_OP_ANY_BINARY:
......
......@@ -103,7 +103,7 @@ gnm_expr_new_constant (GnmValue *v)
static guint
gnm_expr_function_hash (GnmExprFunction const *expr)
{
guint h = expr->oper;
guint h = GNM_EXPR_GET_OPER (expr);
GnmExprList *l;
for (l = expr->arg_list; l; l = l->next)
h = (h * 3) ^ (GPOINTER_TO_INT (l->data));
......@@ -126,8 +126,7 @@ gnm_expr_new_funcall (GnmFunc *func, GnmExprList *arg_list)
if (!ans)
return NULL;
ans->ref_count = 1;
ans->oper = GNM_EXPR_OP_FUNCALL;
GNM_EXPR_SET_OPER_REF1 (ans, GNM_EXPR_OP_FUNCALL);
gnm_func_ref (func);
ans->func = func;
ans->arg_list = arg_list;
......@@ -142,13 +141,14 @@ static guint
gnm_expr_unary_hash (GnmExprUnary const *expr)
{
return (GPOINTER_TO_INT (expr->value) * 7) ^
(guint)(expr->oper);
(guint)GNM_EXPR_GET_OPER (expr);
}
static gboolean
gnm_expr_unary_eq (GnmExprUnary const *a,
GnmExprUnary const *b)
{
return a->oper == b->oper && a->value == b->value;
return GNM_EXPR_GET_OPER (a) == GNM_EXPR_GET_OPER (b) &&
a->value == b->value;
}
#endif
......@@ -161,8 +161,7 @@ gnm_expr_new_unary (GnmExprOp op, GnmExpr const *e)
if (!ans)
return NULL;
ans->ref_count = 1;
ans->oper = op;
GNM_EXPR_SET_OPER_REF1 (ans, op);
ans->value = e;
return (GnmExpr *)ans;
......@@ -176,7 +175,7 @@ gnm_expr_binary_hash (GnmExprBinary const *expr)
{
return (GPOINTER_TO_INT (expr->value_a) * 7) ^
(GPOINTER_TO_INT (expr->value_b) * 3) ^
(guint)(expr->oper);
(guint)(GNM_EXPR_GET_OPER (expr));
}
#endif
......@@ -189,8 +188,7 @@ gnm_expr_new_binary (GnmExpr const *l, GnmExprOp op, GnmExpr const *r)
if (!ans)
return NULL;
ans->ref_count = 1;
ans->oper = op;
GNM_EXPR_SET_OPER_REF1 (ans, op);
ans->value_a = l;
ans->value_b = r;
......@@ -217,8 +215,7 @@ gnm_expr_new_name (GnmNamedExpr *name,
if (!ans)
return NULL;
ans->ref_count = 1;
ans->oper = GNM_EXPR_OP_NAME;
GNM_EXPR_SET_OPER_REF1 (ans, GNM_EXPR_OP_NAME);
ans->name = name;
expr_name_ref (name);
......@@ -246,8 +243,7 @@ gnm_expr_new_cellref (GnmCellRef const *cr)
if (!ans)
return NULL;
ans->ref_count = 1;
ans->oper = GNM_EXPR_OP_CELLREF;
GNM_EXPR_SET_OPER_REF1 (ans, GNM_EXPR_OP_CELLREF);
ans->ref = *cr;
return (GnmExpr *)ans;
......@@ -279,8 +275,7 @@ gnm_expr_new_array_corner(int cols, int rows, GnmExpr const *expr)
if (ans == NULL)
return NULL;
ans->ref_count = 1;
ans->oper = GNM_EXPR_OP_ARRAY_CORNER;
GNM_EXPR_SET_OPER_REF1 (ans, GNM_EXPR_OP_ARRAY_CORNER);
ans->rows = rows;
ans->cols = cols;
ans->value = NULL;
......@@ -297,8 +292,7 @@ gnm_expr_new_array_elem (int x, int y)
if (ans == NULL)
return NULL;
ans->ref_count = 1;
ans->oper = GNM_EXPR_OP_ARRAY_ELEM;
GNM_EXPR_SET_OPER_REF1 (ans, GNM_EXPR_OP_ARRAY_ELEM);
ans->x = x;
ans->y = y;
return (GnmExpr *)ans;
......@@ -310,7 +304,7 @@ gnm_expr_new_array_elem (int x, int y)
static guint
gnm_expr_set_hash (GnmExprSet const *expr)
{
guint h = expr->oper;
guint h = GNM_EXPR_GET_OPER (expr);
GnmExprList *l;
for (l = expr->set; l; l = l->next)
h = (h * 3) ^ (GPOINTER_TO_INT (l->data));
......@@ -327,8 +321,7 @@ gnm_expr_new_set (GnmExprList *set)
if (!ans)
return NULL;
ans->ref_count = 1;
ans->oper = GNM_EXPR_OP_SET;
GNM_EXPR_SET_OPER_REF1 (ans, GNM_EXPR_OP_SET);
ans->set = set;
return (GnmExpr *)ans;
......@@ -344,18 +337,22 @@ void
gnm_expr_ref (GnmExpr const *expr)
{
g_return_if_fail (expr != NULL);
g_return_if_fail (expr->any.ref_count > 0);
g_return_if_fail (GNM_EXPR_GET_REFCOUNT (expr) > 0);
((GnmExpr *)expr)->any.ref_count++;
/* We're screwed if the refcount overflows. */
((GnmExpr *)expr)->oper_and_refcount++;
}
static void
do_gnm_expr_unref (GnmExpr const *expr)
{
if (--((GnmExpr *)expr)->any.ref_count > 0)
/* We're screwed if the refcount underflows. */
((GnmExpr *)expr)->oper_and_refcount--;
if (GNM_EXPR_GET_REFCOUNT (expr) > 0)
return;
switch (expr->any.oper) {
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_RANGE_CTOR:
case GNM_EXPR_OP_INTERSECT:
case GNM_EXPR_OP_ANY_BINARY:
......@@ -416,12 +413,12 @@ void
gnm_expr_unref (GnmExpr const *expr)
{
g_return_if_fail (expr != NULL);
g_return_if_fail (expr->any.ref_count > 0);
g_return_if_fail (GNM_EXPR_GET_REFCOUNT (expr) > 0);
if (expr->any.ref_count == 1)
if (GNM_EXPR_GET_REFCOUNT (expr) == 1)
do_gnm_expr_unref (expr);
else
((GnmExpr *)expr)->any.ref_count--;
((GnmExpr *)expr)->oper_and_refcount--;
}
/**
......@@ -433,7 +430,7 @@ gnm_expr_is_shared (GnmExpr const *expr)
{
g_return_val_if_fail (expr != NULL, FALSE);
return (expr->any.ref_count > 1);
return (GNM_EXPR_GET_REFCOUNT (expr) > 1);
}
/**
......@@ -451,10 +448,10 @@ gnm_expr_equal (GnmExpr const *a, GnmExpr const *b)
g_return_val_if_fail (a != NULL, FALSE);
g_return_val_if_fail (b != NULL, FALSE);
if (a->any.oper != b->any.oper)
if (GNM_EXPR_GET_OPER (a) != GNM_EXPR_GET_OPER (b))
return FALSE;
switch (a->any.oper) {
switch (GNM_EXPR_GET_OPER (a)) {
case GNM_EXPR_OP_RANGE_CTOR:
case GNM_EXPR_OP_INTERSECT:
case GNM_EXPR_OP_ANY_BINARY:
......@@ -511,7 +508,7 @@ array_elem_get_corner (GnmExprArrayElem const *elem,
g_return_val_if_fail (corner != NULL, NULL);
g_return_val_if_fail (cell_has_expr (corner), NULL);
g_return_val_if_fail (corner->base.expression != (void *)0xdeadbeef, NULL);
g_return_val_if_fail (corner->base.expression->any.oper == GNM_EXPR_OP_ARRAY_CORNER, NULL);
g_return_val_if_fail (GNM_EXPR_GET_OPER (corner->base.expression) == GNM_EXPR_OP_ARRAY_CORNER, NULL);
return corner;
}
......@@ -520,7 +517,7 @@ static gboolean
gnm_expr_extract_ref (GnmRangeRef *res, GnmExpr const *expr,
GnmEvalPos const *pos, GnmExprEvalFlags flags)
{
switch (expr->any.oper) {
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_FUNCALL : {
gboolean failed = TRUE;
GnmValue *v;
......@@ -660,7 +657,7 @@ bin_arith (GnmExpr const *expr, GnmEvalPos const *ep,
/* FIXME: we could use simple (cheap) heuristics to
catch most cases where overflow will not happen. */
switch (expr->any.oper){
switch (GNM_EXPR_GET_OPER (expr)){
case GNM_EXPR_OP_ADD:
dres = (gnm_float)ia + (gnm_float)ib;
break;
......@@ -700,7 +697,7 @@ bin_arith (GnmExpr const *expr, GnmEvalPos const *ep,
gnm_float const va = value_get_as_float (a);
gnm_float const vb = value_get_as_float (b);
switch (expr->any.oper){
switch (GNM_EXPR_GET_OPER (expr)){
case GNM_EXPR_OP_ADD:
return value_new_float (va + vb);
......@@ -774,7 +771,7 @@ cb_bin_cmp (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
return value_dup (a);
if (b != NULL && b->type == VALUE_ERROR)
return value_dup (b);
return bin_cmp (expr->any.oper, value_compare (a, b, FALSE), ep);
return bin_cmp (GNM_EXPR_GET_OPER (expr), value_compare (a, b, FALSE), ep);
}
static GnmValue *
......@@ -1024,7 +1021,7 @@ gnm_expr_range_op (GnmExpr const *expr, GnmEvalPos const *ep,
gnm_rangeref_normalize (&a_ref, ep, &a_start, &a_end, &a_range);
gnm_rangeref_normalize (&b_ref, ep, &b_start, &b_end, &b_range);
if (expr->any.oper != GNM_EXPR_OP_INTERSECT)
if (GNM_EXPR_GET_OPER (expr) != GNM_EXPR_OP_INTERSECT)
res_range = range_union (&a_range, &b_range);
else if (!range_intersection (&res_range, &a_range, &b_range))
return value_new_error_NULL (ep);
......@@ -1058,7 +1055,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
g_return_val_if_fail (expr != NULL, handle_empty (NULL, flags));
g_return_val_if_fail (pos != NULL, handle_empty (NULL, flags));
switch (expr->any.oper){
switch (GNM_EXPR_GET_OPER (expr)){
case GNM_EXPR_OP_EQUAL:
case GNM_EXPR_OP_NOT_EQUAL:
case GNM_EXPR_OP_GT:
......@@ -1091,7 +1088,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
(gpointer) expr);
}
res = bin_cmp (expr->any.oper, value_compare (a, b, FALSE), pos);
res = bin_cmp (GNM_EXPR_GET_OPER (expr), value_compare (a, b, FALSE), pos);
if (a != NULL)
value_release (a);
if (b != NULL)
......@@ -1187,7 +1184,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
a = gnm_expr_eval (expr->unary.value, pos, flags);
if (a->type == VALUE_ERROR)
return a;
if (expr->any.oper == GNM_EXPR_OP_UNARY_PLUS)
if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_UNARY_PLUS)
return a;
/* 2) #!VALUE error if A is not a number */
......@@ -1204,7 +1201,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
value_area_get_width (a, pos),
value_area_get_height (a, pos));
value_area_foreach (a, pos, CELL_ITER_ALL,
(ValueAreaFunc) ((expr->any.oper == GNM_EXPR_OP_UNARY_NEG)
(ValueAreaFunc) ((GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_UNARY_NEG)
? cb_iter_unary_neg : cb_iter_percentage),
res);
value_release (a);
......@@ -1212,7 +1209,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
}
if (!VALUE_IS_NUMBER (a))
res = value_new_error_VALUE (pos);
else if (expr->any.oper == GNM_EXPR_OP_UNARY_NEG)
else if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_UNARY_NEG)
res = negate_value (a);
else {
res = value_new_float (value_get_as_float (a) / 100);
......@@ -1442,7 +1439,7 @@ do_expr_as_string (GString *target, GnmExpr const *expr, GnmParsePos const *pp,
{ ":", 9, 1, 0, 0 }, /* Range Ctor */
{ " ", 8, 1, 0, 0 } /* Intersection */
};
int const op = expr->any.oper;
GnmExprOp const op = GNM_EXPR_GET_OPER (expr);
switch (op) {
case GNM_EXPR_OP_RANGE_CTOR:
......@@ -1828,7 +1825,7 @@ gnm_expr_rewrite (GnmExpr const *expr, GnmExprRewriteInfo const *rwinfo)
{
g_return_val_if_fail (expr != NULL, NULL);
switch (expr->any.oper) {
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_RANGE_CTOR:
case GNM_EXPR_OP_INTERSECT:
case GNM_EXPR_OP_ANY_BINARY: {
......@@ -1843,14 +1840,14 @@ gnm_expr_rewrite (GnmExpr const *expr, GnmExprRewriteInfo const *rwinfo)
else if (b == NULL)
gnm_expr_ref ((b = expr->binary.value_b));
return gnm_expr_new_binary (a, expr->any.oper, b);
return gnm_expr_new_binary (a, GNM_EXPR_GET_OPER (expr), b);
}
case GNM_EXPR_OP_ANY_UNARY: {
GnmExpr const *a = gnm_expr_rewrite (expr->unary.value, rwinfo);
if (a == NULL)
return NULL;
return gnm_expr_new_unary (expr->any.oper, a);
return gnm_expr_new_unary (GNM_EXPR_GET_OPER (expr), a);
}
case GNM_EXPR_OP_FUNCALL: {
......@@ -2051,7 +2048,7 @@ GnmFunc *
gnm_expr_get_func_def (GnmExpr const *expr)
{
g_return_val_if_fail (expr != NULL, NULL);