pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:1:   /*   || 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.215 2004/05/19 09:19:13 grubba Exp $ + || $Id: encode.c,v 1.216 2004/05/29 18:13:41 grubba Exp $   */      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "mapping.h"
pike.git/src/encode.c:24:   #include "fsort.h"   #include "threads.h"   #include "stuff.h"   #include "version.h"   #include "bignum.h"   #include "pikecode.h"   #include "pike_types.h"   #include "opcodes.h"   #include "peep.h"    - RCSID("$Id: encode.c,v 1.215 2004/05/19 09:19:13 grubba Exp $"); + RCSID("$Id: encode.c,v 1.216 2004/05/29 18:13:41 grubba Exp $");      /* #define ENCODE_DEBUG */      /* Use the old encoding method for programs. */   /* #define OLD_PIKE_ENCODE_PROGRAM */      #ifdef ENCODE_DEBUG   /* Pass a nonzero integer as the third arg to encode_value,    * encode_value_canonic and decode_value to activate this debug. */   #define EDB(N,X) do { debug_malloc_touch(data); if (data->debug>=N) {X;} } while (0)
pike.git/src/encode.c:1129:    p->identifiers[d].name->str);    }    }       for(d=0;d<NUM_LFUNS;d++)    code_number(p->lfuns[d], data);       for(d=0;d<p->num_constants;d++)    {    encode_value2(& p->constants[d].sval, data, 0); -  adddata3(p->constants[d].name); +  adddata3(NULL /* p->constants[d].name */);    }      #else /* !OLD_PIKE_ENCODE_PROGRAM */       /* Portable encoding (4 and 5). */       if (!force_encode) {    /* Encode later (5). */    EDB(1, fprintf(stderr, "%*sencode: delayed encoding of program\n",    data->depth, ""));
pike.git/src/encode.c:1255: Inside #if defined(PIKE_PORTABLE_BYTECODE)
   } else if (p->constants[d].sval.type == T_TYPE) {    code_number(ID_ENTRY_TYPE_CONSTANT, data);    } else {    continue;    }    code_number(d, data);    /* value */    encode_value2(&p->constants[d].sval, data, 0);       /* name */ + #if 0    if (p->constants[d].name) {    str_sval.u.string = p->constants[d].name;    encode_value2(&str_sval, data, 0);    } else { -  + #endif /* 0 */    push_int(0);    encode_value2(Pike_sp-1, data, 0);    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--; -  + #if 0    } -  + #endif /* 0 */    }    }   #endif /* PIKE_PORTABLE_BYTECODE */    /* Dump the identifiers in a portable manner... */    {    int inherit_num = 1;    struct svalue str_sval;    char *id_dumped = (char *) alloca(p->num_identifiers);    MEMSET(id_dumped,0,p->num_identifiers);    str_sval.type = T_STRING;
pike.git/src/encode.c:1571: Inside #if defined(PIKE_PORTABLE_BYTECODE)
   (p->constants[d].sval.subtype == FUNCTION_BUILTIN)) ||    (p->constants[d].sval.type == T_TYPE)) {    /* Already encoded above. */    continue;    }   #endif /* PIKE_PORTABLE_BYTECODE */    /* value */    encode_value2(&p->constants[d].sval, data, 0);       /* name */ + #if 0    if (p->constants[d].name) {    str_sval.u.string = p->constants[d].name;    encode_value2(&str_sval, data, 0);    } else { -  + #endif /* 0 */    push_int(0);    encode_value2(Pike_sp-1, data, 0);    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--; -  + #if 0    } -  + #endif /* 0 */    }    }   #endif /* OLD_PIKE_ENCODE_PROGRAM */    }else{    code_entry(TAG_PROGRAM, 0, data);    encode_value2(Pike_sp-1, data, 0);    pop_stack();    }    break;    }
pike.git/src/encode.c:3124:    decode_value2(data);    if(data->pass > 1)    {    assign_svalue(& p->constants[d].sval , Pike_sp -1 );    pop_stack();    }else{    dmalloc_touch_svalue(Pike_sp-1);    p->constants[d].sval=*--Pike_sp;    }    dmalloc_touch_svalue(Pike_sp); -  getdata3(p->constants[d].name); +  { +  struct pike_string *dummy = NULL; +  getdata3(dummy /*p->constants[d].name*/); +  if (dummy) free_string(dummy);    } -  +  }      #ifdef PIKE_DEBUG    {    int q;    for(q=0;q<p->num_inherits;q++)    if(!p->inherits[q].prog)    Pike_fatal("FOOBAR!@!!!\n");    }   #endif   
pike.git/src/encode.c:3554:    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--;    }       /* First pass constants.    *    * These will be replaced later on.    */    {    struct program_constant constant; -  constant.name = NULL; +     constant.sval.type = T_INT;    constant.sval.subtype = NUMBER_UNDEFINED;    constant.sval.u.integer = 0; -  +  constant.offset = -1;       for(e=0;e<local_num_constants;e++) {    add_to_constants(constant);    }    }       /* Decode identifier_references, inherits and identifiers. */    decode_number(entry_type, data);    EDB(4,    fprintf(stderr, "%*sDecoding identifier references.\n",
pike.git/src/encode.c:3612:    "Expected type constant: ");    }    break;    default:    Pike_error("Internal error: Unsupported early constant (%d)\n",    entry_type);    break;    }    /* name */    decode_value2(data); + #if 0    if (Pike_sp[-1].type == T_STRING) {    constant->name = Pike_sp[-1].u.string;    } else if ((Pike_sp[-1].type == T_INT) &&    !Pike_sp[-1].u.integer) {    constant->name = NULL;    } else {    ref_push_program (p);    decode_error(Pike_sp - 1, Pike_sp - 2,    "Name of constant is not a string: ");    }    constant->sval = Pike_sp[-2];    dmalloc_touch_svalue(Pike_sp-1);    dmalloc_touch_svalue(Pike_sp-2);    Pike_sp -= 2; -  + #else /* !0 */ +  constant->offset = -1; +  pop_stack(); +  constant->sval = Pike_sp[-1]; +  dmalloc_touch_svalue(Pike_sp-1); +  Pike_sp -= 1; + #endif /* 0 */    decode_number(entry_type, data);    }    while (entry_type != ID_ENTRY_EOT) {    decode_number(id_flags, data);    switch(entry_type) {    case ID_ENTRY_RAW:    {    int no;    int ref_no;    struct reference ref;
pike.git/src/encode.c:4063:    /* Already initialized. */    EDB(5,    fprintf(stderr, "%*sskipping constant %d\n",    data->depth, "", e));    continue;    }    /* value */    decode_value2(data);    /* name */    decode_value2(data); + #if 0    if (Pike_sp[-1].type == T_STRING) {    constant->name = Pike_sp[-1].u.string;    } else if ((Pike_sp[-1].type == T_INT) &&    !Pike_sp[-1].u.integer) {    constant->name = NULL;    } else {    ref_push_program (p);    decode_error(Pike_sp - 1, Pike_sp - 2,    "Name of constant is not a string: ");    }    constant->sval = Pike_sp[-2];    dmalloc_touch_svalue(Pike_sp-1);    dmalloc_touch_svalue(Pike_sp-2);    Pike_sp -= 2; -  + #else /* !0 */ +  constant->offset = -1; +  pop_stack(); +  constant->sval = Pike_sp[-1]; +  dmalloc_touch_svalue(Pike_sp-1); +  Pike_sp -= 1; + #endif /* 0 */    EDB(5,    fprintf(stderr, "%*sDecoded constant %d to a %s\n",    data->depth, "",    e, get_name_of_type(constant->sval.type)));    }       data->pickyness--;       /* The program should be consistent now. */    p->flags &= ~PROGRAM_AVOID_CHECK;