pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:236:       /* Optimization */    if(data->refs == 1 && destructive)    {    /* An array with one ref cannot possibly be cyclic */    struct svalue sval;    data->type_field = BIT_MIXED | BIT_UNFINISHED;    for(e=0;e<data->size;e++)    {    index_no_free(&sval, ITEM(data)+e, index); -  types |= 1 << sval.type; +  types |= 1 << TYPEOF(sval);    free_svalue(ITEM(data)+e);    move_svalue (ITEM(data) + e, &sval);    }    data->type_field = types;    add_ref (data);    return data;    }       if((a=(struct array *)BEGIN_CYCLIC(data,0)))    {    add_ref(a);    }else{    push_array(a=allocate_array(data->size));    SET_CYCLIC_RET(a);       for(e=0;e<a->size;e++) {    index_no_free(ITEM(a)+e, ITEM(data)+e, index); -  types |= 1 << ITEM(a)[e].type; +  types |= 1 << TYPEOF(ITEM(a)[e]);    }    a->type_field = types;       dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--;    }    END_CYCLIC();       return a;   }      PMOD_EXPORT void simple_array_index_no_free(struct svalue *s,    struct array *a,struct svalue *ind)   { -  switch(ind->type) +  switch(TYPEOF(*ind))    {    case T_INT: {    INT_TYPE p = ind->u.integer;    INT_TYPE i = p < 0 ? p + a->size : p;    if(i<0 || i>=a->size) {    struct svalue tmp; -  tmp.type=T_ARRAY; -  tmp.u.array=a; +  SET_SVAL(tmp, T_ARRAY, 0, array, a);    if (a->size) {    index_error(0,0,0,&tmp,ind,    "Index %"PRINTPIKEINT"d is out of array range "    "%d..%d.\n", p, -a->size, a->size-1);    } else {    index_error(0,0,0,&tmp,ind,    "Attempt to index the empty array with %"PRINTPIKEINT"d.\n", p);    }    }    array_index_no_free(s,a,i);    break;    }       case T_STRING:    { -  /* Set the type afterwards to avoid a clobbered svalue in case -  * array_column throws. */ -  s->u.array = array_column (a, ind, 0); -  s->type = T_ARRAY; +  SET_SVAL(*s, T_ARRAY, 0, array, array_column(a, ind, 0));    break;    }       default:    {    struct svalue tmp; -  tmp.type=T_ARRAY; -  tmp.u.array=a; +  SET_SVAL(tmp, T_ARRAY, 0, array, a);    index_error(0,0,0,&tmp,ind,"Array index is neither int nor string.\n");    }    }   }      /**    * Extract an svalue from an array.    */   PMOD_EXPORT void array_free_index(struct array *v,INT32 index)   {
pike.git/src/array.c:331:   }      /** set an element in an array to a value.    *    * @param a the array whose element is to be set    * @param ind an int or string containing the index to set    * @param s the value to set    */   PMOD_EXPORT void simple_set_index(struct array *a,struct svalue *ind,struct svalue *s)   { -  switch (ind->type) { +  switch (TYPEOF(*ind)) {    case T_INT: {    INT_TYPE p = ind->u.integer;    INT_TYPE i = p < 0 ? p + a->size : p;    if(i<0 || i>=a->size) {    if (a->size) {    Pike_error("Index %"PRINTPIKEINT"d is out of array range "    "%d..%d.\n", p, -a->size, a->size-1);    } else {    Pike_error("Attempt to index the empty array with %"PRINTPIKEINT"d.\n", p);    }
pike.git/src/array.c:364:    assign_svalue(Pike_sp-2, &a->item[i]);    assign_lvalue(Pike_sp-2, s);    }    pop_n_elems(2);    break;    }       default:    {    struct svalue tmp; -  tmp.type=T_ARRAY; -  tmp.u.array=a; +  SET_SVAL(tmp, T_ARRAY, 0, array, a);    index_error(0,0,0,&tmp,ind,"Array index is neither int nor string.\n");    }    }   }      /**    * Insert an svalue into an array and grow the array if necessary.    */   PMOD_EXPORT struct array *array_insert(struct array *v,struct svalue *s,INT32 index)   {
pike.git/src/array.c:417:    sizeof(struct svalue) * (v->size-index));    assert_free_svalue (ITEM(ret) + index);    if (v->refs == 1) {    /* Optimization: Steal the references. */    v->size = 0;    } else if (v->type_field & BIT_REF_TYPES) {    /* Adjust the references. */    int e = v->size;    struct svalue *s = ITEM(ret);    while (e--) { -  if (s->type <= MAX_REF_TYPE) add_ref(s->u.dummy); +  if (TYPEOF(*s) <= MAX_REF_TYPE) add_ref(s->u.dummy);    s++;    }    }    free_array(v);    v=ret;    }       array_set_index_no_free (v,index,s);       return v;
pike.git/src/array.c:448: Inside #if defined(PIKE_DEBUG)
   struct svalue *val = lval + 2;   #ifdef PIKE_DEBUG    if (args < 3) {    Pike_fatal("Too few arguments to o_append_array(): %d\n", args);    }   #endif    args -= 3;    /* Note: val should always be a zero here! */    lvalue_to_svalue_no_free(val, lval);    -  if (val->type == T_ARRAY) { +  if (TYPEOF(*val) == T_ARRAY) {    struct svalue tmp;    struct array *v = val->u.array;    /* This is so that we can minimize the number of references    * to the array, and be able to use destructive operations.    * It's done by freeing the old reference to foo after it has been    * pushed on the stack. That way foo can have only 1 reference if we    * are lucky, and then the low array manipulation routines can    * be destructive if they like.    */ -  tmp.type=PIKE_T_INT; -  tmp.subtype=NUMBER_NUMBER; -  tmp.u.integer=0; +  SET_SVAL(tmp, PIKE_T_INT, NUMBER_NUMBER, integer, 0);    assign_lvalue(lval, &tmp);       if (args == 1) {    val->u.array = array_insert(v, Pike_sp - 1, v->size);    pop_stack();    } else if (!args) {    /* FIXME: Weak? */    if ((v->refs > 1) && (v->size)) {    val->u.array = copy_array(v);    free_array(v);
pike.git/src/array.c:487:    val->u.array = v;    pop_n_elems(args);    }    assign_lvalue(lval, val);    } else {    int i;    struct object *o;    struct program *p;    /* Fall back to aggregate(). */    f_aggregate(args); -  if ((val->type == T_OBJECT) && +  if ((TYPEOF(*val) == T_OBJECT) &&    /* One ref in the lvalue, and one on the stack. */    ((o = val->u.object)->refs <= 2) &&    (p = o->prog) && -  (i = FIND_LFUN(p->inherits[Pike_sp[-2].subtype].prog, +  (i = FIND_LFUN(p->inherits[SUBTYPEOF(Pike_sp[-2])].prog,    LFUN_ADD_EQ)) != -1) { -  apply_low(o, i + p->inherits[Pike_sp[-2].subtype].identifier_level, 1); +  apply_low(o, i + p->inherits[SUBTYPEOF(Pike_sp[-2])].identifier_level, 1);    /* NB: The lvalue already contains the object, so    * no need to reassign it.    */    pop_stack();    } else {    f_add(2);    assign_lvalue(lval, val);    }    }    stack_pop_2_elems_keep_top();
pike.git/src/array.c:578:    if(a->size == size) return a;    if(size > a->size)    {    /* We should grow the array */       if((a->malloced_size >= size) &&    ((a->item + size) <= (a->real_item + a->malloced_size)))    {    for(;a->size < size; a->size++)    { -  ITEM(a)[a->size].type=T_INT; -  ITEM(a)[a->size].subtype=NUMBER_NUMBER; -  ITEM(a)[a->size].u.integer=0; +  SET_SVAL(ITEM(a)[a->size], T_INT, NUMBER_NUMBER, integer, 0);    }    a->type_field |= BIT_INT;    return a;    } else {    struct array *ret;    ret = array_set_flags(low_allocate_array(size, size + 1), a->flags);    MEMCPY(ITEM(ret), ITEM(a), sizeof(struct svalue)*a->size);    ret->type_field = DO_NOT_WARN((TYPE_FIELD)(a->type_field | BIT_INT));    a->size=0;    free_array(a);
pike.git/src/array.c:676:       check_destructed(s);      #ifdef PIKE_DEBUG    if(d_flag > 1) array_check_type_field(v);   #endif    /* Why search for something that is not there?    * however, we must explicitly check for searches    * for destructed objects/functions    */ -  if((v->type_field & (1 << s->type)) || +  if((v->type_field & (1 << TYPEOF(*s))) ||    (UNSAFE_IS_ZERO(s) && (v->type_field & (BIT_FUNCTION|BIT_OBJECT))) || -  ( (v->type_field | (1<<s->type)) & BIT_OBJECT )) /* for overloading */ +  ( (v->type_field | (1<<TYPEOF(*s))) & BIT_OBJECT )) /* for overloading */    {    if(start)    {    for(e=start;e<v->size;e++)    if(is_eq(ITEM(v)+e,s)) return e;    }else{    TYPE_FIELD t=0;    for(e=0;e<v->size;e++)    {    if(is_eq(ITEM(v)+e,s)) return e; -  t |= 1<<ITEM(v)[e].type; +  t |= 1<<TYPEOF(ITEM(v)[e]);    }    v->type_field=t;    }    }    return -1;   }      /**    * Slice a piece of an array (conditionally destructively)    * @param v the array to slice
pike.git/src/array.c:807:    INT16 types;       types = 0;   #ifdef PIKE_DEBUG    if(d_flag > 1) array_check_type_field(v);   #endif    if(v->type_field & (BIT_OBJECT | BIT_FUNCTION))    {    for(e=0; e<v->size; e++)    { -  if((ITEM(v)[e].type == T_OBJECT || -  (ITEM(v)[e].type == T_FUNCTION && -  ITEM(v)[e].subtype!=FUNCTION_BUILTIN)) && +  if((TYPEOF(ITEM(v)[e]) == T_OBJECT || +  (TYPEOF(ITEM(v)[e]) == T_FUNCTION && +  SUBTYPEOF(ITEM(v)[e]) != FUNCTION_BUILTIN)) &&    (!ITEM(v)[e].u.object->prog))    {    free_svalue(ITEM(v)+e); -  ITEM(v)[e].type=T_INT; -  ITEM(v)[e].subtype=NUMBER_DESTRUCTED; -  ITEM(v)[e].u.integer=0; +  SET_SVAL(ITEM(v)[e], T_INT, NUMBER_DESTRUCTED, integer, 0);       types |= BIT_INT;    }else{ -  types |= 1<<ITEM(v)[e].type; +  types |= 1<<TYPEOF(ITEM(v)[e]);    }    }    v->type_field = types;    }   }      /**    * This function finds the index of any destructed object in a set.    * It could be optimized to search out the object part with a binary    * search lookup if the array is mixed.
pike.git/src/array.c:843:    INT32 e;    TYPE_FIELD types;   #ifdef PIKE_DEBUG    if(d_flag > 1) array_check_type_field(v);   #endif    if(v->type_field & (BIT_OBJECT | BIT_FUNCTION))    {    types=0;    for(e=0; e<v->size; e++)    { -  if((ITEM(v)[e].type == T_OBJECT || -  (ITEM(v)[e].type == T_FUNCTION && -  ITEM(v)[e].subtype!=FUNCTION_BUILTIN)) && +  if((TYPEOF(ITEM(v)[e]) == T_OBJECT || +  (TYPEOF(ITEM(v)[e]) == T_FUNCTION && +  SUBTYPEOF(ITEM(v)[e]) != FUNCTION_BUILTIN)) &&    (!ITEM(v)[e].u.object->prog))    return e; -  types |= 1<<ITEM(v)[e].type; +  types |= 1<<TYPEOF(ITEM(v)[e]);    }    v->type_field = types;    }   #ifdef PIKE_DEBUG    if(d_flag > 1) array_check_type_field(v);   #endif    return -1;   }      static int internal_cmpfun(INT32 *a,
pike.git/src/array.c:911:   }      /* Returns CMPFUN_UNORDERED if no relation is established through lfun    * calls, or -CMPFUN_UNORDERED if no order defining lfuns (i.e. `< or    * `>) were found. */   static int lfun_cmp (const struct svalue *a, const struct svalue *b)   {    struct program *p;    int default_res = -CMPFUN_UNORDERED, fun;    -  if (a->type == T_OBJECT && (p = a->u.object->prog)) { -  if ((fun = FIND_LFUN(p->inherits[a->subtype].prog, LFUN_LT)) != -1) { +  if (TYPEOF(*a) == T_OBJECT && (p = a->u.object->prog)) { +  if ((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*a)].prog, LFUN_LT)) != -1) {    push_svalue(b);    apply_low(a->u.object, -  fun + p->inherits[a->subtype].identifier_level, 1); +  fun + p->inherits[SUBTYPEOF(*a)].identifier_level, 1);    if(!UNSAFE_IS_ZERO(Pike_sp-1))    {    pop_stack();    return -1;    }    pop_stack();    default_res = CMPFUN_UNORDERED;    }    -  if ((fun = FIND_LFUN(p->inherits[a->subtype].prog, LFUN_GT)) != -1) { +  if ((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*a)].prog, LFUN_GT)) != -1) {    push_svalue(b);    apply_low(a->u.object, -  fun + p->inherits[a->subtype].identifier_level, 1); +  fun + p->inherits[SUBTYPEOF(*a)].identifier_level, 1);    if(!UNSAFE_IS_ZERO(Pike_sp-1))    {    pop_stack();    return 1;    }    pop_stack();    default_res = CMPFUN_UNORDERED;    }    -  if ((fun = FIND_LFUN(p->inherits[a->subtype].prog, LFUN_EQ)) != -1) { +  if ((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*a)].prog, LFUN_EQ)) != -1) {    push_svalue(b);    apply_low(a->u.object, -  fun + p->inherits[a->subtype].identifier_level, 1); +  fun + p->inherits[SUBTYPEOF(*a)].identifier_level, 1);    if (!UNSAFE_IS_ZERO(Pike_sp-1)) {    pop_stack();    return 0;    }    pop_stack();    }    }    -  if(b->type == T_OBJECT && (p = b->u.object->prog)) { -  if ((fun = FIND_LFUN(p->inherits[b->subtype].prog, LFUN_LT)) != -1) { +  if(TYPEOF(*b) == T_OBJECT && (p = b->u.object->prog)) { +  if ((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*b)].prog, LFUN_LT)) != -1) {    push_svalue(a);    apply_low(b->u.object, -  fun + p->inherits[b->subtype].identifier_level, 1); +  fun + p->inherits[SUBTYPEOF(*b)].identifier_level, 1);    if(!UNSAFE_IS_ZERO(Pike_sp-1))    {    pop_stack();    return 1;    }    pop_stack();    default_res = CMPFUN_UNORDERED;    }    -  if ((fun = FIND_LFUN(p->inherits[b->subtype].prog, LFUN_GT)) != -1) { +  if ((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*b)].prog, LFUN_GT)) != -1) {    push_svalue(a);    apply_low(b->u.object, -  fun + p->inherits[b->subtype].identifier_level, 1); +  fun + p->inherits[SUBTYPEOF(*b)].identifier_level, 1);    if(!UNSAFE_IS_ZERO(Pike_sp-1))    {    pop_stack();    return -1;    }    pop_stack();    default_res = CMPFUN_UNORDERED;    }    -  if ((fun = FIND_LFUN(p->inherits[b->subtype].prog, LFUN_EQ)) != -1) { +  if ((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*b)].prog, LFUN_EQ)) != -1) {    push_svalue(a);    apply_low(b->u.object, -  fun + p->inherits[b->subtype].identifier_level, 1); +  fun + p->inherits[SUBTYPEOF(*b)].identifier_level, 1);    if (!UNSAFE_IS_ZERO(Pike_sp-1)) {    pop_stack();    return 0;    }    pop_stack();    }    }       return default_res;   }      static int obj_or_func_cmp (const struct svalue *a, const struct svalue *b)   /* Call with either two T_OBJECT or two T_FUNCTION. */   {    int a_subtype, b_subtype, res;    struct svalue tmp_a, tmp_b;    -  assert ((a->type == T_OBJECT && b->type == T_OBJECT) || -  (a->type == T_FUNCTION && b->type == T_FUNCTION)); +  assert ((TYPEOF(*a) == T_OBJECT && TYPEOF(*b) == T_OBJECT) || +  (TYPEOF(*a) == T_FUNCTION && TYPEOF(*b) == T_FUNCTION));       if (a->u.object == b->u.object) -  return a->subtype - b->subtype; +  return SUBTYPEOF(*a) - SUBTYPEOF(*b);       /* Destructed objects are considered equal to each other, and    * greater than others. That makes them sort close to real zeroes,    * which are sorted after objects without compare functions. */    if (!a->u.object->prog)    return !b->u.object->prog ? 0 : 1;    else if (!b->u.object->prog)    return -1;    -  if (a->type == T_FUNCTION) { +  if (TYPEOF(*a) == T_FUNCTION) {    /* Sort pike functions before builtins. */ -  if (a->subtype == FUNCTION_BUILTIN) { -  if (b->subtype == FUNCTION_BUILTIN) +  if (SUBTYPEOF(*a) == FUNCTION_BUILTIN) { +  if (SUBTYPEOF(*b) == FUNCTION_BUILTIN)    return a->u.efun < b->u.efun ? -1 : (a->u.efun == b->u.efun ? 0 : 1);    else    return 1;    }    else -  if (b->subtype == FUNCTION_BUILTIN) +  if (SUBTYPEOF(*b) == FUNCTION_BUILTIN)    return -1;       if (a->u.object->prog != b->u.object->prog)    return a->u.object->prog < b->u.object->prog ? -1 : 1; -  if (a->subtype != b->subtype) -  return a->subtype - b->subtype; +  if (SUBTYPEOF(*a) != SUBTYPEOF(*b)) +  return SUBTYPEOF(*a) - SUBTYPEOF(*b);       /* We have the same function but in different objects. Compare the    * objects themselves. */    /* FIXME: Should we try to convert the subtypes to the ones for    * the closest inherits? That'd make some sense if the functions    * are private, but otherwise it's doubtful. */ -  a_subtype = b_subtype = a->subtype; -  tmp_a = *a; -  tmp_a.type = T_OBJECT; -  tmp_a.subtype = 0; +  a_subtype = b_subtype = SUBTYPEOF(*a); +  SET_SVAL(tmp_a, T_OBJECT, 0, object, a->u.object);    a = &tmp_a; -  tmp_b = *b; -  tmp_b.type = T_OBJECT; -  tmp_b.subtype = 0; +  SET_SVAL(tmp_b, T_OBJECT, 0, object, b->u.object);    b = &tmp_b;    }       else { -  a_subtype = a->subtype; -  b_subtype = b->subtype; +  a_subtype = SUBTYPEOF(*a); +  b_subtype = SUBTYPEOF(*b);    }       res = lfun_cmp (a, b);       if (res == -CMPFUN_UNORDERED) {    /* If the objects had no inequality comparison lfuns to call, use    * their pointers to get a well defined internal sort order. Let's    * also group objects cloned from the same program. */    if (a->u.object->prog == b->u.object->prog)    return a->u.object < b->u.object ? -1 : 1;
pike.git/src/array.c:1069:    return a->u.object->prog < b->u.object->prog ? -1 : 1;    }    else if (!res)    return a_subtype - b_subtype;       return res;   }      int set_svalue_cmpfun(const struct svalue *a, const struct svalue *b)   { -  int typediff = a->type - b->type; +  int typediff = TYPEOF(*a) - TYPEOF(*b);    if (typediff) { -  if (a->type == T_OBJECT || b->type == T_OBJECT) { +  if (TYPEOF(*a) == T_OBJECT || TYPEOF(*b) == T_OBJECT) {    int res = lfun_cmp (a, b);    if (res != -CMPFUN_UNORDERED) return res;    }    return typediff;    }    -  switch(a->type) +  switch(TYPEOF(*a))    {    case T_FLOAT:    if(a->u.float_number < b->u.float_number) return -1;    if(a->u.float_number > b->u.float_number) return 1;    return 0;       case T_INT:    if(a->u.integer < b->u.integer) return -1;    if(a->u.integer > b->u.integer) return 1;    return 0;
pike.git/src/array.c:1104:    default:    if(a->u.refs < b->u.refs) return -1;    if(a->u.refs > b->u.refs) return 1;    return 0;    }    /* NOT REACHED */   }      static int switch_svalue_cmpfun(const struct svalue *a, const struct svalue *b)   { -  int typediff = a->type - b->type; +  int typediff = TYPEOF(*a) - TYPEOF(*b);    if (typediff)    return typediff;    -  switch(a->type) +  switch(TYPEOF(*a))    {    case T_INT:    if(a->u.integer < b->u.integer) return -1;    if(a->u.integer > b->u.integer) return 1;    return 0;       case T_FLOAT:    if(a->u.float_number < b->u.float_number) return -1;    if(a->u.float_number > b->u.float_number) return 1;    return 0;
pike.git/src/array.c:1137:    default:    if(a->u.refs < b->u.refs) return -1;    if(a->u.refs > b->u.refs) return 1;    return 0;    }    /* NOT REACHED */   }      int alpha_svalue_cmpfun(const struct svalue *a, const struct svalue *b)   { -  int typediff = a->type - b->type; +  int typediff = TYPEOF(*a) - TYPEOF(*b);    if (typediff) { -  if (a->type == T_OBJECT || b->type == T_OBJECT) { +  if (TYPEOF(*a) == T_OBJECT || TYPEOF(*b) == T_OBJECT) {    int res = lfun_cmp (a, b);    if (res != -CMPFUN_UNORDERED) return res;    }    return typediff;    }    -  switch(a->type) +  switch(TYPEOF(*a))    {    case T_INT:    if(a->u.integer < b->u.integer) return -1;    if(a->u.integer > b->u.integer) return 1;    return 0;       case T_FLOAT:    if(a->u.float_number < b->u.float_number) return -1;    if(a->u.float_number > b->u.float_number) return 1;    return 0;
pike.git/src/array.c:1220:   #define ID low_sort_svalues   #include "fsort_template.h"   #undef CMP   #undef TYPE   #undef ID      /* Same, but only integers. */   static int alpha_int_svalue_cmpfun(const struct svalue *a, const struct svalue *b)   {   #ifdef PIKE_DEBUG -  if ((a->type != T_INT) || (b->type != T_INT)) { +  if ((TYPEOF(*a) != T_INT) || (TYPEOF(*b) != T_INT)) {    Pike_fatal("Invalid elements in supposedly integer array.\n");    }   #endif /* PIKE_DEBUG */    if(a->u.integer < b->u.integer) return -1;    if(a->u.integer > b->u.integer) return 1;    return 0;   }      #define CMP(X,Y) alpha_int_svalue_cmpfun(X,Y)   #define TYPE struct svalue
pike.git/src/array.c:1356:    return ~a;   }      INT32 set_lookup(struct array *a, struct svalue *s)   {   #ifdef PIKE_DEBUG    if(d_flag > 1) array_check_type_field(a);   #endif       /* objects may have `< `> operators, evil stuff! */ -  if(s->type != T_OBJECT && !(a->type_field & BIT_OBJECT)) +  if(TYPEOF(*s) != T_OBJECT && !(a->type_field & BIT_OBJECT))    {    /* face it, it's not there */ -  if( (((2 << s->type) -1) & a->type_field) == 0) +  if( (((2 << TYPEOF(*s)) -1) & a->type_field) == 0)    return -1;       /* face it, it's not there */ -  if( ((BIT_MIXED << s->type) & BIT_MIXED & a->type_field) == 0) +  if( ((BIT_MIXED << TYPEOF(*s)) & BIT_MIXED & a->type_field) == 0)    return ~a->size;    }       return low_lookup(a,s,set_svalue_cmpfun);   }      INT32 switch_lookup(struct array *a, struct svalue *s)   {    /* face it, it's not there */   #ifdef PIKE_DEBUG    if(d_flag > 1) array_check_type_field(a);   #endif    /* objects may have `< `> operators, evil stuff! */ -  if(s->type != T_OBJECT && !(a->type_field & BIT_OBJECT)) +  if(TYPEOF(*s) != T_OBJECT && !(a->type_field & BIT_OBJECT))    { -  if( (((2 << s->type) -1) & a->type_field) == 0) +  if( (((2 << TYPEOF(*s)) -1) & a->type_field) == 0)    return -1;       /* face it, it's not there */ -  if( ((BIT_MIXED << s->type) & BIT_MIXED & a->type_field) == 0) +  if( ((BIT_MIXED << TYPEOF(*s)) & BIT_MIXED & a->type_field) == 0)    return ~a->size;    }       return low_lookup(a,s,switch_svalue_cmpfun);   }         /**    * Reorganize an array in the order specified by 'order'.    */
pike.git/src/array.c:1433:    if(v->flags & ARRAY_LVALUE)    {    v->type_field=BIT_MIXED|BIT_UNFINISHED;    return BIT_MIXED|BIT_UNFINISHED;    }       t=0;       for(e=0; e<v->size; e++) {    check_svalue (ITEM(v) + e); -  t |= 1 << ITEM(v)[e].type; +  t |= 1 << TYPEOF(ITEM(v)[e]);    }      #ifdef PIKE_DEBUG    if(t & ~(v->type_field))    {    describe(v);    Pike_fatal("Type field out of order (old:0x%04x new:0x%04x)!\n",    v->type_field, t);    }   #endif
pike.git/src/array.c:1469: Inside #if defined(PIKE_DEBUG) and #if defined(TRACE_UNFINISHED_TYPE_FIELDS)
     #ifdef TRACE_UNFINISHED_TYPE_FIELDS    if (v->type_field & BIT_UNFINISHED && !accept_unfinished_type_fields) {    fputs ("Array got an unfinished type field.\n", stderr);    describe_something (v, T_ARRAY, 2, 2, 0, NULL);    }   #endif       for(e=0; e<v->size; e++)    { -  if(ITEM(v)[e].type > MAX_TYPE) +  if(TYPEOF(ITEM(v)[e]) > MAX_TYPE)    Pike_fatal("Type is out of range.\n");    -  t |= 1 << ITEM(v)[e].type; +  t |= 1 << TYPEOF(ITEM(v)[e]);    }       if(t & ~(v->type_field))    {    describe(v);    Pike_fatal("Type field out of order!\n");    }   }   #endif /* PIKE_DEBUG */      /**    * Get a pointer to the 'union anything' specified if it is of the specified    * type. The 'union anything' may be changed, but not the type.    */   PMOD_EXPORT union anything *low_array_get_item_ptr(struct array *a,    INT32 ind,    TYPE_T t)   { -  if(ITEM(a)[ind].type == t) return & (ITEM(a)[ind].u); +  if(TYPEOF(ITEM(a)[ind]) == t) return & (ITEM(a)[ind].u);    return 0;   }      /**    * Get a pointer to the 'union anything' specified if it is of the specified    * type. The 'union anything' may be changed, but not the type.    * The differance between this routine and the one above is that this takes    * the index as an svalue.    */   PMOD_EXPORT union anything *array_get_item_ptr(struct array *a,    struct svalue *ind,    TYPE_T t)   {    INT_TYPE i, p; -  if(ind->type != T_INT) +  if(TYPEOF(*ind) != T_INT)    Pike_error("Expected integer as array index, got %s.\n", -  get_name_of_type (ind->type)); +  get_name_of_type (TYPEOF(*ind)));    p = ind->u.integer;    i = p < 0 ? p + a->size : p;    if(i<0 || i>=a->size) {    if (a->size) {    Pike_error("Index %"PRINTPIKEINT"d is out of array range "    "%d..%d.\n", p, -a->size, a->size-1);    } else {    Pike_error("Attempt to index the empty array with %"PRINTPIKEINT"d.\n", p);    }    }
pike.git/src/array.c:2144:    case BIT_PROGRAM:    for(e=1; e<a->size; e++)    if(ITEM(a)[e].u.refs != ITEM(a)[0].u.refs)    break;    break;       case BIT_OBJECT:    case BIT_FUNCTION:    for(e=1; e<a->size; e++)    if(ITEM(a)[e].u.object != ITEM(a)[0].u.object || -  ITEM(a)[e].subtype != ITEM(a)[0].subtype) +  SUBTYPEOF(ITEM(a)[e]) != SUBTYPEOF(ITEM(a)[0]))    break;    break;    }    debug_malloc_touch(a);    if(e == a->size)    return mkefuncallnode("allocate",mknode(F_ARG_LIST,    mkintnode(a->size),    mksvaluenode(ITEM(a))));    }       if(array_is_constant(a,0))    {    debug_malloc_touch(a); -  s.type=T_ARRAY; -  s.subtype=0; -  s.u.array=a; +  SET_SVAL(s, T_ARRAY, 0, array, a);    return mkconstantsvaluenode(&s);    }else{    node *ret=0;    debug_malloc_touch(a);    for(e = a->size; e--;) {    if (ret) {    ret = mknode(F_ARG_LIST, mksvaluenode(ITEM(a)+e), ret);    } else {    ret = mksvaluenode(ITEM(a)+e);    }
pike.git/src/array.c:2327: Inside #if 0
   if(!str->len)    {    return allocate_array_no_init(0,0);    }   #endif    if(!del->len)    {    ret=allocate_array_no_init(str->len,0);    for(e=0;e<str->len;e++)    { -  ITEM(ret)[e].type=T_STRING; -  ITEM(ret)[e].u.string=string_slice(str,e,1); +  SET_SVAL(ITEM(ret)[e], T_STRING, 0, string, string_slice(str,e,1));    }    }else{    SearchMojt mojt;    ONERROR uwp;    explode_searchfunc f = (explode_searchfunc)0;       s=str->str;    end=s+(str->len << str->size_shift);       ret=allocate_array(10);
pike.git/src/array.c:2368:    {    if(ret->size == ret->malloced_size)    {    e=ret->size;    ACCEPT_UNFINISHED_TYPE_FIELDS {    ret=resize_array(ret, e * 2);    } END_ACCEPT_UNFINISHED_TYPE_FIELDS;    ret->size=e;    }    -  ITEM(ret)[ret->size].u.string=string_slice(str, +  SET_SVAL(ITEM(ret)[ret->size], T_STRING, 0, string, +  string_slice(str,    (s-str->str)>>str->size_shift, -  (tmp-s)>>str->size_shift); -  ITEM(ret)[ret->size].type=T_STRING; +  (tmp-s)>>str->size_shift));    ret->size++;       s=tmp+(del->len << str->size_shift);    }       if(ret->size == ret->malloced_size)    {    e=ret->size;    ACCEPT_UNFINISHED_TYPE_FIELDS {    ret=resize_array(ret, e * 2);    } END_ACCEPT_UNFINISHED_TYPE_FIELDS;    ret->size=e;    }    -  ITEM(ret)[ret->size].u.string=string_slice(str, +  SET_SVAL(ITEM(ret)[ret->size], T_STRING, 0, string, +  string_slice(str,    (s-str->str)>>str->size_shift, -  (end-s)>>str->size_shift); -  -  ITEM(ret)[ret->size].type=T_STRING; +  (end-s)>>str->size_shift));    ret->size++;       CALL_AND_UNSET_ONERROR (uwp);    }    ret->type_field=BIT_STRING;    return ret;   }      /** Implode an array by creating a string with all of the array's    * elements separated by a delimiter.
pike.git/src/array.c:2419:   {    INT32 len, e;    PCHARP r;    struct pike_string *ret;    struct svalue *ae;    int max_shift = del->size_shift;       len=0;       for(e=a->size, ae=a->item; e--; ae++) -  switch(ae->type) +  switch(TYPEOF(*ae))    {    case T_INT:    if(!ae->u.integer)    continue; /* skip zero (strings) */    /* FALLTHROUGH */    default:    Pike_error("Array element %d is not a string\n", ae-a->item);    case T_STRING:    len+=ae->u.string->len + del->len;    if(ae->u.string->size_shift > max_shift)
pike.git/src/array.c:2441:    break;    }    if(len) len-=del->len;       ret=begin_wide_shared_string(len,max_shift);    r=MKPCHARP_STR(ret);    len = del->len;    if((e = a->size))    for(ae=a->item;;ae++)    { -  switch(ae->type) +  switch(TYPEOF(*ae))    {    case T_STRING:    {    struct pike_string *tmp = ae->u.string;    pike_string_cpy(r,tmp);    INC_PCHARP(r,tmp->len);    break;    }    default:    case T_INT:
pike.git/src/array.c:2489:       if (!a->size) {    ret = (a->flags & ARRAY_WEAK_FLAG) ? &weak_empty_array : &empty_array;    add_ref(ret);    return ret;    }       ret=allocate_array_no_init(a->size,0);       if (m) { -  aa.type = T_ARRAY; -  aa.subtype = 0; -  aa.u.array = a; -  bb.type = T_ARRAY; -  bb.subtype = 0; -  bb.u.array = ret; +  SET_SVAL(aa, T_ARRAY, 0, array, a); +  SET_SVAL(bb, T_ARRAY, 0, array, ret);    low_mapping_insert(m, &aa, &bb, 1);    }       ret->flags = a->flags & ~ARRAY_LVALUE;       copy_svalues_recursively_no_free(ITEM(ret),ITEM(a),a->size,m);       ret->type_field=a->type_field;    return ret;   }
pike.git/src/array.c:2537:    if ((flags & 1) && (a->refs == 1)) {    /* Destructive operation possible. */    ref_push_array(a);    a->type_field |= BIT_UNFINISHED;    for (e=0; e < a->size; e++)    {    assign_svalues_no_free(Pike_sp, argp, args, BIT_MIXED);    Pike_sp+=args;    /* FIXME: Don't throw apply errors from apply_svalue here. */    apply_svalue(ITEM(a)+e,args); -  new_types |= 1 << Pike_sp[-1].type; +  new_types |= 1 << TYPEOF(Pike_sp[-1]);    assign_svalue(ITEM(a)+e, &Pike_sp[-1]);    pop_stack();    }    a->type_field = new_types;   #ifdef PIKE_DEBUG    array_check_type_field(a);   #endif    } else {    struct array *aa;    push_array(aa = allocate_array_no_init(0, a->size));    for (e=0; (e<a->size) && (e < aa->malloced_size); e++)    {    assign_svalues_no_free(Pike_sp, argp, args, BIT_MIXED);    Pike_sp+=args;    /* FIXME: Don't throw apply errors from apply_svalue here. */    apply_svalue(ITEM(a)+e,args); -  new_types |= 1 << Pike_sp[-1].type; +  new_types |= 1 << TYPEOF(Pike_sp[-1]);    assign_svalue_no_free(ITEM(aa)+e, &Pike_sp[-1]);    aa->size = e+1;    pop_stack();    }    aa->type_field = new_types;   #ifdef PIKE_DEBUG    array_check_type_field(aa);   #endif    }    stack_pop_n_elems_keep_top(args);
pike.git/src/array.c:2681: Inside #if defined(PIKE_DEBUG)
  #endif    Pike_fatal("Array item pointer is too small!\n");    }       if(a->refs <=0 )    Pike_fatal("Array has zero refs.\n");          for(e=0;e<a->size;e++)    { -  if(! ( (1 << ITEM(a)[e].type) & (a->type_field) ) && ITEM(a)[e].type<16) +  if(! ( (1 << TYPEOF(ITEM(a)[e])) & (a->type_field) ) && +  TYPEOF(ITEM(a)[e])<16)    Pike_fatal("Type field lies.\n");       check_svalue(ITEM(a)+e);    }   }      void check_all_arrays(void)   {    struct array *a;    for (a = first_array; a; a = a->next)
pike.git/src/array.c:3030:    struct array *ret;       if (!a->size) {    add_ref(a);    return a;    }       size=0;    for(e=0;e<a->size;e++)    { -  if(ITEM(a)[e].type!=T_ARRAY) +  if(TYPEOF(ITEM(a)[e]) != T_ARRAY)    Pike_error("Implode array contains non-arrays.\n");    size+=ITEM(a)[e].u.array->size;    }       ret=allocate_array((a->size -1) * b->size + size);    size=0;    ret->type_field=0;    for(e=0;e<a->size;e++)    {    if(e)