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.269 2008/05/21 20:07:41 grubba Exp $ + || $Id: encode.c,v 1.270 2008/05/26 09:26:57 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: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);    -  debug_malloc_touch(p); +  /* FIXME: Ought to accept codecs without __register_new_program(). */    -  +  ref_push_program(p); +  apply(data->codec, "__register_new_program", 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;    EDB(2,fprintf(stderr, "%*sDecoding a program to <%d>: ",
pike.git/src/encode.c:4505:    *    * 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"); +  } +  debug_malloc_touch(c->placeholder); +  free_program(c->placeholder->prog); +  add_ref(c->placeholder->prog = p); +  c->placeholder->storage=c->p->storage_needed ? +  (char *)xalloc(c->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. */    local_num_program = p->num_program;