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.214 2004/05/12 14:58:29 grubba Exp $ + || $Id: encode.c,v 1.215 2004/05/19 09:19:13 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.214 2004/05/12 14:58:29 grubba Exp $"); + RCSID("$Id: encode.c,v 1.215 2004/05/19 09:19:13 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:104:   #define TAG_DELAYED 14 /* Note: Coincides with T_ZERO. */   #define TAG_AGAIN 15   #define TAG_MASK 15   #define TAG_NEG 16   #define TAG_SMALL 32   #define SIZE_SHIFT 6   #define MAX_SMALL (1<<(8-SIZE_SHIFT))   #define COUNTER_START (-MAX_SMALL)      /* Entries used to encode the identifier_references table. */ + #define ID_ENTRY_TYPE_CONSTANT -4   #define ID_ENTRY_EFUN_CONSTANT -3   #define ID_ENTRY_RAW -2   #define ID_ENTRY_EOT -1   #define ID_ENTRY_VARIABLE 0   #define ID_ENTRY_FUNCTION 1   #define ID_ENTRY_CONSTANT 2   #define ID_ENTRY_INHERIT 3      struct encode_data   {
pike.git/src/encode.c:1241: Inside #if defined(PIKE_PORTABLE_BYTECODE)
  #ifdef PIKE_PORTABLE_BYTECODE    /* Encode the efun constants since they are needed by the optimizer. */    {    struct svalue str_sval;    str_sval.type = T_STRING;    str_sval.subtype = 0;       /* constants */    for(d=0;d<p->num_constants;d++)    { -  if ((p->constants[d].sval.type != T_FUNCTION) || -  (p->constants[d].sval.subtype != FUNCTION_BUILTIN)) { +  if ((p->constants[d].sval.type == T_FUNCTION) && +  (p->constants[d].sval.subtype == FUNCTION_BUILTIN)) { +  code_number(ID_ENTRY_EFUN_CONSTANT, data); +  } else if (p->constants[d].sval.type == T_TYPE) { +  code_number(ID_ENTRY_TYPE_CONSTANT, data); +  } else {    continue;    } -  code_number(ID_ENTRY_EFUN_CONSTANT, data); +     code_number(d, data);    /* value */    encode_value2(&p->constants[d].sval, data, 0);       /* name */    if (p->constants[d].name) {    str_sval.u.string = p->constants[d].name;    encode_value2(&str_sval, data, 0);    } else {    push_int(0);
pike.git/src/encode.c:1556:    /* Encode the constant values table. */    {    struct svalue str_sval;    str_sval.type = T_STRING;    str_sval.subtype = 0;       /* constants */    for(d=0;d<p->num_constants;d++)    {   #ifdef PIKE_PORTABLE_BYTECODE -  if ((p->constants[d].sval.type == T_FUNCTION) && -  (p->constants[d].sval.subtype == FUNCTION_BUILTIN)) { +  if (((p->constants[d].sval.type == T_FUNCTION) && +  (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 (p->constants[d].name) {    str_sval.u.string = p->constants[d].name;
pike.git/src/encode.c:3567:    }       /* Decode identifier_references, inherits and identifiers. */    decode_number(entry_type, data);    EDB(4,    fprintf(stderr, "%*sDecoding identifier references.\n",    data->depth, ""));   #ifdef ENCODE_DEBUG    data->depth+=2;   #endif -  while (entry_type == ID_ENTRY_EFUN_CONSTANT) { +  while ((entry_type == ID_ENTRY_EFUN_CONSTANT) || +  (entry_type == ID_ENTRY_TYPE_CONSTANT)) {    INT32 efun_no;    struct program_constant *constant;    decode_number(efun_no, data);    EDB(2, -  fprintf(stderr, "%*sDecoding efun constant #%d.\n", +  fprintf(stderr, "%*sDecoding efun/type constant #%d.\n",    data->depth, "", efun_no));    if ((efun_no < 0) || (efun_no >= local_num_constants)) {    ref_push_program (p);    decode_error(Pike_sp - 1, NULL, -  "Bad efun number: %d (expected 0 - %d).\n", +  "Bad efun/type number: %d (expected 0 - %d).\n",    efun_no, local_num_constants-1);    }    constant = p->constants+efun_no;    /* value */    decode_value2(data); -  +  switch(entry_type) { +  case ID_ENTRY_EFUN_CONSTANT:    if ((Pike_sp[-1].type != T_FUNCTION) ||    (Pike_sp[-1].subtype != FUNCTION_BUILTIN)) {    ref_push_program (p);    decode_error(Pike_sp - 1, Pike_sp - 2,    "Expected efun constant: ");    } -  +  break; +  case ID_ENTRY_TYPE_CONSTANT: +  if (Pike_sp[-1].type != T_TYPE) { +  ref_push_program (p); +  decode_error(Pike_sp - 1, Pike_sp - 2, +  "Expected type constant: "); +  } +  break; +  default: +  Pike_error("Internal error: Unsupported early constant (%d)\n", +  entry_type); +  break; +  }    /* name */    decode_value2(data);    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,