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: array.c,v 1.142 2003/04/27 17:46:47 mast Exp $ + || $Id: array.c,v 1.143 2003/04/28 00:32:42 mast Exp $   */      #include "global.h"
26:   #include "cyclic.h"   #include "multiset.h"    - RCSID("$Id: array.c,v 1.142 2003/04/27 17:46:47 mast Exp $"); + RCSID("$Id: array.c,v 1.143 2003/04/28 00:32:42 mast Exp $");      PMOD_EXPORT struct array empty_array=   {
64:   struct array *gc_internal_array = &empty_array;   static struct array *gc_mark_array_pos = 0;    + #ifdef TRACE_UNFINISHED_TYPE_FIELDS + PMOD_EXPORT int accept_unfinished_type_fields = 0; + PMOD_EXPORT void dont_accept_unfinished_type_fields (void *orig) + { +  accept_unfinished_type_fields = (int) orig; + } + #endif    -  +    /* Allocate an array, this might be changed in the future to    * allocate linked lists or something    * NOTE: the new array have zero references
89:    GC_ALLOC(v);       +  if (size)    /* for now, we don't know what will go in here */ -  v->type_field=BIT_MIXED | BIT_UNFINISHED; +  v->type_field = BIT_MIXED | BIT_UNFINISHED; +  else +  v->type_field = 0;    v->flags=0;       v->malloced_size = DO_NOT_WARN((INT32)(size + extra_space));
1171:       if(v->flags & ARRAY_LVALUE)    { -  v->type_field=BIT_MIXED; +  v->type_field=BIT_MIXED|BIT_UNFINISHED;    return;    }    -  for(e=0; e<v->size; e++) t |= 1 << ITEM(v)[e].type; +  for(e=0; e<v->size; e++) { +  check_svalue (ITEM(v) + e); +  t |= 1 << ITEM(v)[e].type; +  }      #ifdef PIKE_DEBUG    if(t & ~(v->type_field))
1199: Inside #if defined(PIKE_DEBUG)
   if(v->flags & ARRAY_LVALUE)    return;    + #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)
1973:    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;    }   
1989:    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;    }   
2142:    ret=allocate_array_no_init(a->size,0);    for(e=0;e<a->size;e++)    assign_svalue_no_free(ITEM(ret)+e,ITEM(a)+a->size+~e); +  ret->type_field = a->type_field;    return ret;   }