Branch: Tag:

2008-01-26

2008-01-26 22:34:27 by Martin Stjernholm <mast@lysator.liu.se>

Eradicated all instances of setting type to T_INT without also setting the
subtype in an svalue. From now on one should either set the subtype or use
the new svalue type PIKE_T_FREE (see svalue.h).

Rev: src/OCPikeInterpreter.m:1.3
Rev: src/apply_low.h:1.32
Rev: src/array.c:1.198
Rev: src/array.h:1.71
Rev: src/bignum.c:1.42
Rev: src/builtin.cmod:1.193
Rev: src/builtin_functions.c:1.650
Rev: src/configure.in:1.1038
Rev: src/cpp.c:1.164
Rev: src/encode.c:1.250
Rev: src/error.c:1.151
Rev: src/interpret.c:1.385
Rev: src/interpret_functions.h:1.197
Rev: src/iterators.cmod:1.64
Rev: src/las.c:1.403
Rev: src/main.c:1.228
Rev: src/mapping.c:1.195
Rev: src/module.c:1.47
Rev: src/modules/Gmp/mpz_glue.c:1.170
Rev: src/modules/HTTPLoop/accept_and_parse.c:1.39
Rev: src/modules/HTTPLoop/requestobject.c:1.31
Rev: src/modules/Image/colortable.c:1.130
Rev: src/modules/Java/jvm.c:1.84
Rev: src/modules/Parser/html.c:1.178
Rev: src/modules/Parser/xml.cmod:1.97
Rev: src/modules/Postgres/postgres.c:1.55
Rev: src/modules/_math/math.c:1.87
Rev: src/modules/files/sendfile.c:1.78
Rev: src/modules/spider/spider.c:1.134
Rev: src/multiset.c:1.106
Rev: src/object.c:1.281
Rev: src/operators.c:1.226
Rev: src/pike_error.h:1.42
Rev: src/post_modules/Shuffler/Shuffler.cmod:1.45
Rev: src/post_modules/_ADT/circular_list.cmod:1.18
Rev: src/post_modules/_ADT/sequence.cmod:1.19
Rev: src/program.c:1.642
Rev: src/signal_handler.c:1.331
Rev: src/sscanf.c:1.170
Rev: src/svalue.c:1.234
Rev: src/svalue.h:1.149

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: builtin_functions.c,v 1.649 2008/01/23 19:52:49 grubba Exp $ + || $Id: builtin_functions.c,v 1.650 2008/01/26 22:34:17 mast Exp $   */      #include "global.h"
3942:    struct svalue *save_sp = Pike_sp;    JMP_BUF tmp;    if (SETJMP(tmp)) { -  struct svalue thrown = throw_value; +  struct svalue thrown;    struct pike_string *s; -  throw_value.type = T_INT; +  move_svalue (&thrown, &throw_value); +  mark_free_svalue (&throw_value);    pop_n_elems(Pike_sp - save_sp);    yywarning("Optimizer failure in replace().");    s = format_exception_for_error_msg (&thrown);
6082:    }    else    { -  pval->u.array=resize_array(pval->u.array,pval->u.array->size+1); -  pval->u.array->item[pval->u.array->size-1].type=T_INT; -  pval->u.array->item[pval->u.array->size-1].subtype=NUMBER_NUMBER; -  pval->u.array->item[pval->u.array->size-1].u.integer=i; +  struct array *a = pval->u.array= +  resize_array(pval->u.array,pval->u.array->size+1); +  struct svalue *s = ITEM(a) + pval->u.array->size-1; +  s->type=T_INT; +  s->subtype=NUMBER_NUMBER; +  s->u.integer=i;    }    }   
7533:   /*! @module Array    */    + #ifdef HAVE_UNION_INIT + static const struct svalue one = {PIKE_T_INT, NUMBER_NUMBER, {1}}; + #endif +    /*! @decl array uniq(array a)    *!    *! Remove elements that are duplicates.
7552:   {    struct array *a, *b;    struct mapping *m; + #ifndef HAVE_UNION_INIT    struct svalue one; -  + #endif    int i, j=0,size=0;       get_all_args("uniq", args, "%a", &a);    push_mapping(m = allocate_mapping(a->size));    push_array(b = allocate_array(a->size));    -  + #ifndef HAVE_UNION_INIT    one.type = T_INT; -  +  one.subtype = NUMBER_NUMBER;    one.u.integer = 1; -  + #endif    for(i =0; i< a->size; i++)    {    mapping_insert(m, ITEM(a)+i, &one);
7982:    push_svalue(mysp-3); /* arr */    f_values(1);    push_svalue(mysp-2); /* fun */ -  *Pike_sp=mysp[-1]; /* extra */ -  mysp[-1].type=T_INT; +  move_svalue (Pike_sp, mysp-1); /* extra */ +  mark_free_svalue (mysp-1);    dmalloc_touch_svalue(Pike_sp);    push_array_items(Pike_sp->u.array);    f_map(splice+2); /* ... arr fun extra -> ... retval */
7999:    (multiset)(map(indices(arr),fun,@extra)); */    push_svalue(Pike_sp-args); /* take indices from arr */    free_svalue(Pike_sp-args-1); /* move it to top of stack */ -  Pike_sp[-args-1].type=T_INT; +  mark_free_svalue (Pike_sp-args-1);    f_indices(1); /* call f_indices */    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);
8019:    (string)(map((array)arr,fun,@extra)); */    push_svalue(Pike_sp-args); /* take indices from arr */    free_svalue(Pike_sp-args-1); /* move it to top of stack */ -  Pike_sp[-args-1].type=T_INT; +  mark_free_svalue (Pike_sp-args-1);    o_cast(NULL,T_ARRAY); /* cast the string to an array */    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);
8139:    if (UNSAFE_IS_ZERO (Pike_sp-args+1)) {    free_svalue (Pike_sp-args+1);    move_svalue (Pike_sp-args+1, Pike_sp-args); -  Pike_sp[-args].type = T_INT; +  mark_free_svalue (Pike_sp-args);    mega_apply (APPLY_STACK, args-1, 0, 0);    stack_pop_keep_top();    return;
8400:    map(values(arr),fun,@extra)); */    MEMMOVE(Pike_sp-args+2,Pike_sp-args,args*sizeof(*Pike_sp));    Pike_sp+=2; -  Pike_sp[-args-2].type=T_INT; -  Pike_sp[-args-1].type=T_INT; +  mark_free_svalue (Pike_sp-args-2); +  mark_free_svalue (Pike_sp-args-1);       push_svalue(Pike_sp-args);    f_indices(1);
8438:    case T_MULTISET:    push_svalue(Pike_sp-args); /* take indices from arr */    free_svalue(Pike_sp-args-1); /* move it to top of stack */ -  Pike_sp[-args-1].type=T_INT; +  mark_free_svalue (Pike_sp-args-1);    f_indices(1); /* call f_indices */    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);
8456:    case T_STRING:    push_svalue(Pike_sp-args); /* take indices from arr */    free_svalue(Pike_sp-args-1); /* move it to top of stack */ -  Pike_sp[-args-1].type=T_INT; +  mark_free_svalue (Pike_sp-args-1);    o_cast(NULL,T_ARRAY); /* cast the string to an array */    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);