pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:18:   #include "pike_error.h"   #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"    - RCSID("$Id: encode.c,v 1.105 2001/07/03 04:30:06 hubbe Exp $"); + RCSID("$Id: encode.c,v 1.106 2001/07/03 08:04:59 hubbe Exp $");      /* #define ENCODE_DEBUG */      #ifdef ENCODE_DEBUG   #define EDB(X) X   #else   #define EDB(X)   #endif      /* The sp macro conflicts with Solaris 2.5.1's <sys/conf.h>. */
pike.git/src/encode.c:741:    case T_FUNCTION:    if (data->canonic)    Pike_error("Canonical encoding of functions not supported.\n");    check_stack(1);    push_svalue(val);    apply(data->codec,"nameof", 1);    if(Pike_sp[-1].type == T_INT && Pike_sp[-1].subtype==NUMBER_UNDEFINED)    {    if(val->subtype != FUNCTION_BUILTIN)    { +  if(find_shared_string_identifier(ID_FROM_INT(val->u.object->prog, val->subtype)->name, +  val->u.object->prog)==val->subtype) +  {    /* We have to remove ourself from the cache for now */    struct svalue tmp=data->counter;    tmp.u.integer--;    map_delete(data->encoded, val);       code_entry(type_to_tag(val->type), 1, data);    push_svalue(val);    Pike_sp[-1].type=T_OBJECT;    encode_value2(Pike_sp-1, data);    ref_push_string(ID_FROM_INT(val->u.object->prog, val->subtype)->name);    encode_value2(Pike_sp-1, data);    pop_n_elems(3);       /* Put value back in cache */    mapping_insert(data->encoded, val, &tmp);    return;    } -  +  }    Pike_error("Failed to encode function.\n");    }       code_entry(type_to_tag(val->type), 0,data);    encode_value2(Pike_sp-1, data);    pop_stack();    break;          case T_PROGRAM:
pike.git/src/encode.c:856:    code_number(p->identifier_index[d],data);       for(d=0;d<p->num_variable_index;d++)    code_number(p->variable_index[d],data);       for(d=0;d<p->num_identifier_references;d++)    {    code_number(p->identifier_references[d].inherit_offset,data);    code_number(p->identifier_references[d].identifier_offset,data);    code_number(p->identifier_references[d].id_flags,data); +  EDB(fprintf(stderr,"IDREF%x > %d: { %d, %d, %d }\n", +  p->id,d, +  p->identifier_references[d].inherit_offset, +  p->identifier_references[d].identifier_offset, +  p->identifier_references[d].id_flags);)    }       for(d=0;d<p->num_strings;d++) adddata(p->strings[d]);       for(d=0;d<p->num_inherits;d++)    {    code_number(p->inherits[d].inherit_level,data);    code_number(p->inherits[d].identifier_level,data);    code_number(p->inherits[d].parent_offset,data);    code_number(p->inherits[d].parent_identifier,data);    code_number(p->inherits[d].storage_offset,data);       if(p->inherits[d].parent)    {    ref_push_object(p->inherits[d].parent);    Pike_sp[-1].subtype=p->inherits[d].parent_identifier;    Pike_sp[-1].type=T_FUNCTION; -  +  EDB(fprintf(stderr,"INHERIT%x coded as func { %p, %d }\n", +  p->id, p->inherits[d].parent, p->inherits[d].parent_identifier);)    }else if(p->inherits[d].prog){    ref_push_program(p->inherits[d].prog);    }else{    push_int(0);    }    encode_value2(Pike_sp-1,data);    pop_stack();       adddata3(p->inherits[d].name); -  +  +  EDB(fprintf(stderr,"INHERIT%x > %d: %d id=%d\n", +  p->id,d, +  p->inherits[d].prog->num_identifiers, +  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);    code_number(p->identifiers[d].func.offset,data);
pike.git/src/encode.c:1891:    for(d=0;d<p->num_identifier_references;d++)    {    decode_number(p->identifier_references[d].inherit_offset,data);    if(p->identifier_references[d].inherit_offset > p->num_inherits)    {    p->identifier_references[d].inherit_offset=0;    Pike_error("Malformed program in decode.\n");    }    decode_number(p->identifier_references[d].identifier_offset,data);    decode_number(p->identifier_references[d].id_flags,data); +  +  EDB(fprintf(stderr,"IDREF%x < %d: { %d, %d, %d }\n", +  p->id,d, +  p->identifier_references[d].inherit_offset, +  p->identifier_references[d].identifier_offset, +  p->identifier_references[d].id_flags); )    }       debug_malloc_touch(p);    for(d=0;d<p->num_strings;d++)    getdata(p->strings[d]);       debug_malloc_touch(p);    debug_malloc_touch(dat);       data->pickyness++;
pike.git/src/encode.c:1931:    Pike_error("Program decode failed!\n");    p->refs--;    }       switch(Pike_sp[-1].type)    {    case T_FUNCTION:    if(Pike_sp[-1].subtype == FUNCTION_BUILTIN)    Pike_error("Failed to decode parent.\n");    +  EDB( fprintf(stderr,"INHERIT%x = func { %x, %d} \n",p->id,Pike_sp[-1].u.object, Pike_sp[-1].subtype); ) +     p->inherits[d].parent_identifier=Pike_sp[-1].subtype;    p->inherits[d].prog=program_from_svalue(Pike_sp-1);    if(!p->inherits[d].prog)    Pike_error("Failed to decode parent.\n");    add_ref(p->inherits[d].prog);    p->inherits[d].parent=Pike_sp[-1].u.object;    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);    break;       case T_PROGRAM: -  +  EDB( fprintf(stderr,"INHERIT%x = prog\n",p->id); )    p->inherits[d].prog=Pike_sp[-1].u.program;    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);    break;    default:    Pike_error("Failed to decode inheritance.\n");    }       getdata3(p->inherits[d].name); -  +  +  EDB( fprintf(stderr,"INHERIT%x < %d: %d id=%d\n", +  p->id,d, +  p->inherits[d].prog->num_identifiers, +  p->inherits[d].prog->id); )    }       debug_malloc_touch(dat);          SET_ONERROR(err1, restore_type_stack, Pike_compiler->type_stackp);    SET_ONERROR(err2, restore_type_mark, Pike_compiler->pike_type_mark_stackp);       debug_malloc_touch(p);    for(d=0;d<p->num_identifiers;d++)