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.237 2006/02/21 06:31:59 mast Exp $ + || $Id: encode.c,v 1.238 2006/10/27 18:43:15 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:1319:       /* Fix locally defined identifiers. */    for (; d < d_max; d++) {    struct reference *ref = p->identifier_references + d;    struct inherit *inh = INHERIT_FROM_PTR(p, ref);    struct identifier *id = ID_FROM_PTR(p, ref);       /* Skip identifiers that haven't been overloaded. */    if (ref->id_flags & ID_INHERITED) continue;    +  /* Skip getter/setter variables; they get pulled in +  * by their respective functions. +  */ +  if (IDENTIFIER_IS_VARIABLE(id->identifier_flags) && +  (id->run_time_type == PIKE_T_GET_SET)) +  continue; +     EDB(3,    fprintf(stderr,    "%*sencoding identifier ref %d: %4x \"%s\"\n",    data->depth, "", d,    id->identifier_flags,    id->name->str));      #ifdef ENCODE_DEBUG    data->depth += 2;   #endif
pike.git/src/encode.c:1367:    ref_no = i;    break;    }    }    }    if (ref_no == -1) {    Pike_error("Failed to reverse explicit reference\n");    }    code_number(ref_no, data);    } else { +  int gs_flags = -1; +     if (id_dumped[ref->identifier_offset]) {    EDB(3,    fprintf(stderr, "%*sencode: already encoded reference\n",    data->depth, ""));    goto next_identifier_ref;    }    id_dumped[ref->identifier_offset] = 1;    -  +  if (id->name && (id->name->len>3) && +  (index_shared_string(id->name, 0) == '`') && +  (index_shared_string(id->name, 1) == '-') && +  (index_shared_string(id->name, 2) == '>')) { +  struct pike_string *symbol = NULL; +  if (index_shared_string(id->name, id->name->len-1) != '=') { +  /* Getter callback. */ +  symbol = string_slice(id->name, 3, id->name->len - 3); +  } else if (id->name->len > 4) { +  /* Setter callback. */ +  symbol = string_slice(id->name, 3, id->name->len - 4); +  } +  if (symbol) { +  int i = really_low_find_shared_string_identifier(symbol, p, +  SEE_STATIC|SEE_PRIVATE); +  if (i >= 0) { +  /* Found the symbol. */ +  gs_flags = PTR_FROM_INT(p, i)->id_flags; +  } +  free_string(symbol); +  } +  } +     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 {    code_number(ref->id_flags, data); -  +  }       /* name */    str_sval.u.string = id->name;    encode_value2(&str_sval, data, 0);       /* offset */    code_number(id->func.offset, data);       /* type */    ref_push_type_value(id->type);
pike.git/src/encode.c:1406:    /* run-time type */    code_number(id->run_time_type, data);    break;       case IDENTIFIER_PIKE_FUNCTION:    EDB(3,    fprintf(stderr, "%*sencode: encoding function\n",    data->depth, ""));       code_number(ID_ENTRY_FUNCTION, data); +  if (gs_flags >= 0) { +  code_number(gs_flags, data); +  } else {    code_number(ref->id_flags, data); -  +  }       /* name */    str_sval.u.string = id->name;    encode_value2(&str_sval, data, 0);       /* type */    ref_push_type_value(id->type);    encode_value2(Pike_sp-1, data, 0);    pop_stack();   
pike.git/src/encode.c:1453:    "(identifier=\"%S\").\n",    p->identifiers[d].name);    break;       case IDENTIFIER_VARIABLE:    EDB(3,    fprintf(stderr, "%*sencode: encoding variable\n",    data->depth, ""));       code_number(ID_ENTRY_VARIABLE, data); +  if (gs_flags >= 0) { +  code_number(gs_flags, data); +  } else {    code_number(ref->id_flags, data); -  +  }       /* name */    str_sval.u.string = id->name;    encode_value2(&str_sval, data, 0);       /* type */    ref_push_type_value(id->type);    encode_value2(Pike_sp-1, data, 0);    pop_stack();    break;