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.192 2003/07/30 18:52:15 mast Exp $ + || $Id: encode.c,v 1.193 2003/08/03 00:53:20 mast 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:20:   #include "operators.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "fsort.h"   #include "threads.h"   #include "stuff.h"   #include "version.h"   #include "bignum.h"   #include "pikecode.h"    - RCSID("$Id: encode.c,v 1.192 2003/07/30 18:52:15 mast Exp $"); + RCSID("$Id: encode.c,v 1.193 2003/08/03 00:53:20 mast 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:1117:    p->inherits[d].prog->id););    }       for(d=0;d<p->num_identifiers;d++)    {    adddata(p->identifiers[d].name);    encode_type(p->identifiers[d].type, data);    code_number(p->identifiers[d].identifier_flags,data);    code_number(p->identifiers[d].run_time_type,data);    code_number(p->identifiers[d].opt_flags,data); -  if (!(p->identifiers[d].identifier_flags & IDENTIFIER_C_FUNCTION)) { +  if (!IDENTIFIER_IS_C_FUNCTION(p->identifiers[d].identifier_flags)) {    code_number(p->identifiers[d].func.offset,data);    } else {    Pike_error("Cannot encode functions implemented in C "    "(identifier='%s').\n",    p->identifiers[d].name->str);    }    }       for(d=0;d<NUM_LFUNS;d++)    code_number(p->lfuns[d], data);
pike.git/src/encode.c:1321:    code_number(ref_no, data);    } else {    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 (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { -  /* Constant */ -  +  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);    code_number(ref->id_flags, data);       /* name */    str_sval.u.string = id->name;    encode_value2(&str_sval, data, 0);
pike.git/src/encode.c:1345:    /* offset */    code_number(id->func.offset, data);       /* type */    ref_push_type_value(id->type);    encode_value2(Pike_sp-1, data, 0);    pop_stack();       /* run-time type */    code_number(id->run_time_type, data); -  } else if (IDENTIFIER_IS_PIKE_FUNCTION(id->identifier_flags)) { -  /* Pike function */ +  break;    -  +  case IDENTIFIER_PIKE_FUNCTION:    EDB(3,    fprintf(stderr, "%*sencode: encoding function\n",    data->depth, ""));       code_number(ID_ENTRY_FUNCTION, data);    code_number(ref->id_flags, data);       /* name */    str_sval.u.string = id->name;    encode_value2(&str_sval, data, 0);
pike.git/src/encode.c:1372:    pop_stack();       /* func_flags (aka identifier_flags) */    code_number(id->identifier_flags, data);       /* func */    code_number(id->func.offset, data);       /* opt_flags */    code_number(id->opt_flags, data); -  } else if (id->identifier_flags & IDENTIFIER_C_FUNCTION) { -  /* C Function */ +  break; +  +  case IDENTIFIER_C_FUNCTION:    /* Not supported. */    Pike_error("Cannot encode functions implemented in C "    "(identifier='%s').\n",    p->identifiers[d].name->str); -  } else { -  /* Variable */ +  break; +  +  case IDENTIFIER_VARIABLE:    EDB(3,    fprintf(stderr, "%*sencode: encoding variable\n",    data->depth, ""));       code_number(ID_ENTRY_VARIABLE, data);    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; +  +  default: + #ifdef PIKE_DEBUG +  Pike_fatal ("Unknown identifier type.\n"); + #endif    }    }       /* Identifier reference number */    code_number(d, data);       next_identifier_ref:    ; /* C requires a statement after lables. */   #ifdef ENCODE_DEBUG    data->depth -= 2;
pike.git/src/encode.c:2947:    SET_ONERROR(err2, restore_type_mark, Pike_compiler->pike_type_mark_stackp);       debug_malloc_touch(p);    for(d=0;d<p->num_identifiers;d++)    {    getdata(p->identifiers[d].name);    decode_type(p->identifiers[d].type,data);    decode_number(p->identifiers[d].identifier_flags,data);    decode_number(p->identifiers[d].run_time_type,data);    decode_number(p->identifiers[d].opt_flags,data); -  if (!(p->identifiers[d].identifier_flags & IDENTIFIER_C_FUNCTION)) +  if (!IDENTIFIER_IS_C_FUNCTION(p->identifiers[d].identifier_flags))    {    decode_number(p->identifiers[d].func.offset,data);    } else {    ref_push_program (p);    ref_push_string (p->identifiers[d].name);    decode_error(Pike_sp - 1, Pike_sp - 2,    "Cannot decode function implemented in C: ");    }    }