Branch: Tag:

2003-04-28

2003-04-28 00:32:44 by Martin Stjernholm <mast@lysator.liu.se>

Improved type fields for arrays.

Rev: src/array.c:1.143
Rev: src/backend.cmod:1.42
Rev: src/builtin.cmod:1.134
Rev: src/builtin_functions.c:1.490
Rev: src/encode.c:1.172
Rev: src/interpret.c:1.304
Rev: src/iterators.cmod:1.41
Rev: src/main.c:1.175
Rev: src/mapping.c:1.166
Rev: src/modules/files/efuns.c:1.127
Rev: src/modules/system/memory.c:1.24
Rev: src/object.c:1.236
Rev: src/opcodes.c:1.145
Rev: src/operators.c:1.177
Rev: src/post_modules/Unicode/unicode_module.cmod:1.7
Rev: src/post_modules/_ADT/circular_list.cmod:1.8
Rev: src/post_modules/_ADT/sequence.cmod:1.8

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: encode.c,v 1.171 2003/04/02 19:22:43 mast Exp $ + || $Id: encode.c,v 1.172 2003/04/28 00:32:43 mast Exp $   */      #include "global.h"
27:   #include "bignum.h"   #include "pikecode.h"    - RCSID("$Id: encode.c,v 1.171 2003/04/02 19:22:43 mast Exp $"); + RCSID("$Id: encode.c,v 1.172 2003/04/28 00:32:43 mast Exp $");      /* #define ENCODE_DEBUG */   
2161:    case TAG_ARRAY:    {    struct array *a; +  TYPE_FIELD types;    if(num < 0)    Pike_error("Failed to decode array. (array size is negative)\n");   
2174:    SETUP_DECODE_MEMOBJ(T_ARRAY, array, a, allocate_array(num),    free_svalues(ITEM(a), a->size, a->type_field));    +  types = 0;    for(e=0;e<num;e++)    {    decode_value2(data); -  ITEM(a)[e]=Pike_sp[-1]; -  Pike_sp--; -  dmalloc_touch_svalue(Pike_sp); +  stack_pop_to_no_free (ITEM(a) + e); +  types |= 1 << ITEM(a)[e].type;    } -  +  a->type_field = types;    ref_push_array(a);   #ifdef ENCODE_DEBUG    data->depth -= 2;
2221:    {    struct multiset *m;    struct array *a; +  TYPE_FIELD types;    if(num<0)    Pike_error("Failed to decode multiset. (multiset size is negative)\n");   
2243:    a=m->ind;   #endif    +  types = 0;    for(e=0;e<num;e++)    {    decode_value2(data); -  assign_svalue(a->item+e , Pike_sp-1); -  pop_stack(); -  dmalloc_touch_svalue(Pike_sp); +  stack_pop_to_no_free (ITEM(a) + e); +  types |= 1 << ITEM(a)[e].type;    } -  array_fix_type_field(a); +  a->type_field = types;   #ifdef PIKE_NEW_MULTISETS    {    struct multiset *l = mkmultiset (a);
2469:    }    /* Remove the extra entry from the stack. */    ref_push_program(p); -  stack_pop_n_elems_keep_top(2); +  stack_pop_2_elems_keep_top();    break;    }