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.250 2008/01/26 22:34:19 mast Exp $ + || $Id: encode.c,v 1.251 2008/02/02 21:39:44 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:110:      /* 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 + #define ID_ENTRY_ALIAS 4      struct encode_data   {    int canonic;    struct object *codec;    struct svalue counter;    struct mapping *encoded;    /* The encoded mapping maps encoded things to their entry IDs. A    * value less than COUNTER_START means that it's a forward reference    * to a thing not yet encoded. */
pike.git/src/encode.c:1434:    SEE_STATIC|SEE_PRIVATE);    if (i >= 0) {    /* Found the symbol. */    gs_flags = PTR_FROM_INT(p, i)->id_flags;    }    free_string(symbol);    }    }       if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) { -  Pike_error("Encoding of aliases not supported yet.\n"); +  code_number(ID_ENTRY_ALIAS, data); +  +  /* flags */ +  code_number(ref->id_flags, data); +  +  /* name */ +  str_sval.u.string = id->name; +  encode_value2(&str_sval, data, 0); +  +  /* depth */ +  code_number(id->func.ext_ref.depth, data); +  +  /* refno */ +  code_number(id->func.ext_ref.id, data); +  +  /* type */ +  ref_push_type_value(id->type); +  encode_value2(Pike_sp-1, data, 0); +  pop_stack(); +  break; +     } else switch (id->identifier_flags & IDENTIFIER_TYPE_MASK) {    case IDENTIFIER_CONSTANT:    EDB(3,    fprintf(stderr, "%*sencode: encoding constant\n",    data->depth, ""));       code_number(ID_ENTRY_CONSTANT, data);    if (gs_flags >= 0) {    code_number(gs_flags, data);    } else {
pike.git/src/encode.c:4107:    decode_error(Pike_sp - 2, Pike_sp - 1,    "Bad function identifier offset "    "(expected %d, got %d) for ", no, n);    }       dmalloc_touch_svalue(Pike_sp-1);    dmalloc_touch_svalue(Pike_sp-2);    Pike_sp -= 2;    }    break; +  case ID_ENTRY_ALIAS: +  { +  int depth; +  int refno; +  int no; +  int n; +  +  /* name */ +  decode_value2(data); +  if (Pike_sp[-1].type != T_STRING) { +  ref_push_program (p); +  decode_error(Pike_sp - 1, Pike_sp - 2, +  "Bad alias name (not a string): "); +  } +  +  /* depth */ +  decode_number(depth, data); +  +  /* refno */ +  decode_number(refno, data); +  +  /* FIXME: +  * Verify validity of depth and refno. +  */ +  +  /* type */ +  decode_value2(data); +  if (Pike_sp[-1].type != T_TYPE) { +  ref_push_program (p); +  decode_error(Pike_sp - 1, Pike_sp - 2, +  "Bad constant type (not a type): "); +  } +  +  /* Expected identifier number. */ +  decode_number(no, data); +  +  EDB(5, +  fprintf(stderr, +  "%*slow_define_alias(\"%s\", X, 0x%04x)\n", +  data->depth, "", +  Pike_sp[-2].u.string->str, id_flags)); +  +  /* Alters +  * +  * variable_index, identifiers and +  * identifier_references +  */ +  n = low_define_alias(Pike_sp[-2].u.string, +  Pike_sp[-1].u.type, id_flags, +  depth, refno); +  +  if (no != n) { +  ref_push_program (p); +  decode_error(Pike_sp - 1, Pike_sp - 3, +  "Bad alias identifier offset " +  "(expected %d, got %d) for ", no, n); +  } +  +  pop_n_elems(2); +  } +  break;    case ID_ENTRY_INHERIT:    {    struct program *prog;    struct object *parent = NULL;    int parent_identifier;    int parent_offset;    struct pike_string *name = NULL;    int no;       decode_number(no, data);