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.177 2003/06/04 13:03:11 nilsson Exp $ + || $Id: encode.c,v 1.178 2003/06/05 12:34:43 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: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.177 2003/06/04 13:03:11 nilsson Exp $"); + RCSID("$Id: encode.c,v 1.178 2003/06/05 12:34:43 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:441:    *    * force_dump == 1: Dump the thing now.    *    * force_dump == 2: A forward reference has been encoded to this    * thing. Now it's time to dump it. */      static void encode_value2(struct svalue *val, struct encode_data *data, int force_dump)      #ifdef PIKE_DEBUG   #undef encode_value2 - #define encode_value2(X,Y,Z) do { \ -  struct svalue *_=Pike_sp; \ -  encode_value2_(X,Y,Z); \ -  if(Pike_sp!=_) Pike_fatal("encode_value2 failed!\n"); \ + #define encode_value2(X,Y,Z) do { \ +  struct svalue *_=Pike_sp; \ +  struct svalue *X_ = (X); \ +  encode_value2_(X_,Y,Z); \ +  if(Pike_sp != _) { \ +  fprintf(stderr, "Stack error when encoding:\n"); \ +  print_svalue(stderr, X_); \ +  fprintf(stderr, "\n"); \ +  if (X_->type == T_PROGRAM) { \ +  dump_program_tables(X_->u.program, 2); \ +  } \ +  Pike_fatal("encode_value2() failed %p != %p!\n", \ +  Pike_sp, _); \ +  } \    } while(0)   #endif      {    static struct svalue dested = {    T_INT, NUMBER_DESTRUCTED,   #ifdef HAVE_UNION_INIT    {0}, /* Only to avoid warnings. */   #endif    };
pike.git/src/encode.c:507:   #endif    if (val->type != T_TYPE) {    entry_id = data->counter; /* It's always a small integer. */    EDB(1,fprintf(stderr, "%*sEncoding to <%d>: ",    data->depth, "", entry_id.u.integer);    if(data->debug == 1)    {    fprintf(stderr,"TAG%d",val->type);    }else{    print_svalue(stderr, val); -  +     }    fputc('\n', stderr););    mapping_insert(data->encoded, val, &entry_id);    data->counter.u.integer++;    }    }       switch(val->type)    {    case T_INT:
pike.git/src/encode.c:962:    if(Pike_sp[-1].type == val->type)    Pike_error("Error in master()->nameof(), same type returned.\n");    if(Pike_sp[-1].type == T_INT && Pike_sp[-1].subtype == NUMBER_UNDEFINED)    {    struct program *p=val->u.program;    pop_stack();    if( (p->flags & PROGRAM_HAS_C_METHODS) || p->event_handler )    {    if(p->parent)    { -  /* We have to remove ourself from the cache for now */ +  /* We have to remove ourselves from the cache for now */    struct svalue tmp = entry_id;    map_delete(data->encoded, val);       code_entry(TAG_PROGRAM, 2, data);    ref_push_program(p->parent); -  encode_value2(Pike_sp-1,data, 0); +  encode_value2(Pike_sp-1, data, 0);       ref_push_program(p);    f_function_name(1);    if(Pike_sp[-1].type == PIKE_T_INT)    Pike_error("Cannot encode C programs.\n");    encode_value2(Pike_sp-1, data, 0);    -  pop_n_elems(3); +  pop_n_elems(2);       /* Put value back in cache */    mapping_insert(data->encoded, val, &tmp);    goto encode_done;    }    if( p->event_handler )    Pike_error("Cannot encode programs with event handlers.\n");    Pike_error("Cannot encode C programs.\n");    }