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.271 2008/05/26 10:41:23 grubba Exp $ + || $Id: encode.c,v 1.272 2008/05/26 12:15:35 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:3765:    ONERROR err;    ONERROR err2;    int byteorder;    int bytecode_method;    int entry_type;    INT16 id_flags;    INT16 p_flags;    ptrdiff_t old_pragmas;    struct compilation *c;    struct pike_string *save_current_file; +  struct object *placeholder = NULL;    unsigned INT32 save_current_line;   #define FOO(NUMTYPE,Y,ARGTYPE,NAME) \    NUMTYPE PIKE_CONCAT(local_num_, NAME) = 0;   #include "program_areas.h"      #ifdef ENCODE_DEBUG    data->depth += 2;   #endif       /* Decode byte-order. */
pike.git/src/encode.c:3846:    data->supporter.prog = p;   #endif       p->flags = p_flags;       /* Kludge to get end_first_pass() to free the program. */    Pike_compiler->num_parse_error++;       SET_ONERROR(err, cleanup_new_program_decode, NULL);    -  /* FIXME: Ought to accept codecs without __register_new_program(). */ +  { +  int fun = find_identifier("__register_new_program", +  data->codec->prog);    -  +  if (fun >= 0) {    ref_push_program(p); -  apply(data->codec, "__register_new_program", 1); +  apply_low(data->codec, fun, 1);       /* Returned a placeholder */    if(Pike_sp[-1].type == T_OBJECT)    {    add_ref(c->placeholder=Pike_sp[-1].u.object);    if(c->placeholder->prog != null_program) {    Pike_error("Placeholder object is not "    "a __null_program clone.\n");    }    } else if (Pike_sp[-1].type != T_INT ||    Pike_sp[-1].u.integer) {    Pike_error ("Expected placeholder object or zero "    "from __register_new_program.\n");    }    pop_stack(); -  +  } +  }       copy_shared_string(save_current_file, c->lex.current_file);    save_current_line = c->lex.current_line;       SET_ONERROR(err2, restore_current_file, save_current_file);       if (!delayed_enc_val) {    struct svalue prog;    prog.type=T_PROGRAM;    prog.u.program=p;
pike.git/src/encode.c:4524:    * lfuns and identifier_index    */    ref_push_program (p);    if (!(p = end_first_pass(2))) {    decode_error(Pike_sp - 1, NULL, "Failed to decode program.\n");    }    pop_stack();    push_program(p);       if (c->placeholder) { -  if (c->placeholder->prog != null_program) { -  Pike_error("Placeholder has been zapped during decoding.\n"); +  push_object(placeholder = c->placeholder); +  c->placeholder = NULL;    } -  debug_malloc_touch(c->placeholder); -  free_program(c->placeholder->prog); -  add_ref(c->placeholder->prog = p); -  c->placeholder->storage = p->storage_needed ? -  (char *)xalloc(p->storage_needed) : -  (char *)NULL; -  call_c_initializers(c->placeholder); -  call_pike_initializers(c->placeholder,0); -  } +        exit_compiler();       EDB(5, dump_program_tables(p, data->depth));   #ifdef PIKE_DEBUG    check_program (p);   #endif       if (bytecode_method == PIKE_BYTECODE_PORTABLE) {    /* We've regenerated p->program, so these may be off. */
pike.git/src/encode.c:4619:    }       data->pickyness--;       /* The program should be consistent now. */    p->flags &= ~PROGRAM_AVOID_CHECK;       EDB(5, fprintf(stderr, "%*sProgram flags: 0x%04x\n",    data->depth, "", p->flags));    +  if (placeholder) { +  if (placeholder->prog != null_program) { +  Pike_error("Placeholder has been zapped during decoding.\n"); +  } +  debug_malloc_touch(placeholder); +  free_program(placeholder->prog); +  add_ref(placeholder->prog = p); +  placeholder->storage = p->storage_needed ? +  (char *)xalloc(p->storage_needed) : +  (char *)NULL; +  call_c_initializers(placeholder); +  call_pike_initializers(placeholder, 0); +  pop_stack(); +  } +    #ifdef ENCODE_DEBUG    data->depth -= 2;   #endif    goto decode_done;    }       default:    Pike_error("Cannot decode program encoding type %d\n",num);    }    break;