pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:271:    num -= (((INT64)256) << (t<<3));    else    break;    }       tag |= t << SIZE_SHIFT;    addchar((char)tag);       switch(t)    { - #if 0 -  case 7: addchar(DO_NOT_WARN((char)((num >> 56)&0xff))); -  case 6: addchar(DO_NOT_WARN((char)((num >> 48)&0xff))); -  case 5: addchar(DO_NOT_WARN((char)((num >> 40)&0xff))); -  case 4: addchar(DO_NOT_WARN((char)((num >> 32)&0xff))); - #endif /* 0 */ +     case 3: addchar(DO_NOT_WARN((char)((num >> 24)&0xff)));    case 2: addchar(DO_NOT_WARN((char)((num >> 16)&0xff)));    case 1: addchar(DO_NOT_WARN((char)((num >> 8)&0xff)));    case 0: addchar(DO_NOT_WARN((char)(num&0xff)));    }   }      static void code_number(ptrdiff_t num, struct encode_data *data)   {    EDB(5, fprintf(stderr, "%*scode_number(%d)\n",
pike.git/src/encode.c:721:    double tmp;       tmp = frexp(d, &y);    x = DO_NOT_WARN((INT64)((((INT64)1)<<(sizeof(INT64)*8 - 2))*tmp));    y -= sizeof(INT64)*8 - 2;       EDB(2,fprintf(stderr,    "Encoding float... tmp: %10g, x: 0x%016llx, y: %d\n",    tmp, x, y));    - #if 0 -  if (x && !(x & 0xffffffffUL)) { - #endif /* 0 */ +     x >>= 32;    y += 32;       EDB(2,fprintf(stderr,    "Reducing float... x: 0x%08llx, y: %d\n",    x, y)); - #if 0 -  } - #endif /* 0 */ - #if 0 -  while(x && y && !(x&1)) -  { -  x>>=1; -  y++; -  } - #endif +     code_entry(TAG_FLOAT,x,data);    code_entry(TAG_FLOAT,y,data);    }    break;    }       case T_ARRAY:    code_entry(TAG_ARRAY, val->u.array->size, data);    for(i=0; i<val->u.array->size; i++)    encode_value2(ITEM(val->u.array)+i, data, 0);
pike.git/src/encode.c:1028:    "%*sencode: encoding C program via parent.\n",    data->depth, ""));    map_delete(data->encoded, val);       code_entry(TAG_PROGRAM, 2, data);    ref_push_program(p->parent);    encode_value2(Pike_sp-1, data, 0);       ref_push_program(p);    f_function_name(1); - #if 0 -  if(TYPEOF(Pike_sp[-1]) == PIKE_T_INT) -  Pike_error("Cannot encode C programs.\n"); - #endif +     encode_value2(Pike_sp-1, data, 0);       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"); - #if 0 -  Pike_error("Cannot encode C programs.\n"); - #endif +     } else {    EDB(1, fprintf(stderr,    "%*sencode: encoding program overloading a C program.\n",    data->depth, ""));    }    }       /* Portable encoding (4 and 5). */       if (!force_encode) {
pike.git/src/encode.c:1683:    (SUBTYPEOF(p->constants[d].sval) == FUNCTION_BUILTIN)) ||    (TYPEOF(p->constants[d].sval) == T_TYPE)) {    /* Already encoded above. */    continue;    }       /* value */    encode_value2(&p->constants[d].sval, data, 0);       /* name */ - #if 0 -  if (p->constants[d].name) { -  str_sval.u.string = p->constants[d].name; -  encode_value2(&str_sval, data, 0); -  } else { - #endif /* 0 */ +     push_int(0);    encode_value2(Pike_sp-1, data, 0);    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--; - #if 0 +     } - #endif /* 0 */ +     } -  } +     }else{    code_entry(TAG_PROGRAM, 0, data);    encode_value2(Pike_sp-1, data, 0);    pop_stack();    }    break;    }    }      encode_done:;
pike.git/src/encode.c:1934:    int delay_counter;    struct pike_string *raw;    struct decode_data *next;   #ifdef PIKE_THREADS    struct thread_state *thread_state;    struct object *thread_obj;   #endif   #ifdef ENCODE_DEBUG    int debug, depth;   #endif - #if TWO_PASS_DECODE_WORKS -  /* The delay stuff can trig a second pass through the decoder, -  * but it doesn't seem to really handle that. /mast */ -  struct Supporter supporter; - #endif +    };      static struct object *decoder_codec (struct decode_data *data)   {    struct pike_string *decoder_str;    if (data->codec) return data->codec;    MAKE_CONST_STRING (decoder_str, "Decoder");    return data->codec = lookup_codec (decoder_str);   }   
pike.git/src/encode.c:2092:    INT64 num; \    DECODE("decode_number"); \    X=(what & TAG_MASK) | ((unsigned INT64)num<<4); \    EDB(5, fprintf(stderr, "%*s ==>%ld\n", \    data->depth, "", (long) X)); \    }while(0) \         static void restore_type_stack(struct pike_type **old_stackp)   { - #if 0 -  fprintf(stderr, "Restoring type-stack: %p => %p\n", -  Pike_compiler->type_stackp, old_stackp); - #endif /* 0 */ +    #ifdef PIKE_DEBUG    if (old_stackp > Pike_compiler->type_stackp) {    Pike_fatal("type stack out of sync!\n");    }   #endif /* PIKE_DEBUG */    while(Pike_compiler->type_stackp > old_stackp) {    free_type(*(Pike_compiler->type_stackp--));    }   }      static void restore_type_mark(struct pike_type ***old_type_mark_stackp)   { - #if 0 -  fprintf(stderr, "Restoring type-mark: %p => %p\n", -  Pike_compiler->pike_type_mark_stackp, old_type_mark_stackp); - #endif /* 0 */ +    #ifdef PIKE_DEBUG    if (old_type_mark_stackp > Pike_compiler->pike_type_mark_stackp) {    Pike_fatal("type Pike_interpreter.mark_stack out of sync!\n");    }   #endif /* PIKE_DEBUG */    Pike_compiler->pike_type_mark_stackp = old_type_mark_stackp;   }      static void low_decode_type(struct decode_data *data)   {
pike.git/src/encode.c:3014:    push_program (p);    EDB(2,    fprintf (stderr, "%*sInited an embryo for a delay encoded program "    "to <%d>: ",    data->depth, "", entry_id.u.integer);    print_svalue (stderr, Pike_sp - 1);    fputc ('\n', stderr););       data->delay_counter++;    - #if 0 -  /* Is this necessary? In that case, how do we pass an -  * adequate context to __register_new_program so that it -  * knows which program is being decoded? */ -  ref_push_program (p); -  apply (decoder_codec (data), "__register_new_program", 1); -  -  /* Returns a placeholder. */ -  if (TYPEOF(Pike_sp[-1]) == T_OBJECT) { -  if (Pike_sp[-1].u.object->prog != null_program) -  decode_error (data, NULL, "Placeholder object is not " -  "a null_program clone.\n"); -  } -  else if (TYPEOF(Pike_sp[-1]) != T_INT || -  Pike_sp[-1].u.integer) -  decode_error (data, NULL, "Expected placeholder object or zero " -  "from __register_new_program.\n"); -  pop_stack(); - #endif -  +     break;    }       case 4: /* New-style encoding. */    {    struct program *p;    ONERROR err;    ONERROR err2;    int byteorder;    int bytecode_method;
pike.git/src/encode.c:3119:       /* We don't want to be affected by #pragma save_parent or    * __pragma_save_parent__.    */    old_pragmas = c->lex.pragmas;    c->lex.pragmas = (old_pragmas & ~ID_SAVE_PARENT)|ID_DONT_SAVE_PARENT;       /* Start the new program. */    low_start_new_program(p, 1, NULL, 0, NULL);    p = Pike_compiler->new_program; - #if TWO_PASS_DECODE_WORKS -  if(! data->supporter.prog) -  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);       {    int fun = find_identifier("__register_new_program",    decoder_codec (data)->prog);
pike.git/src/encode.c:3300:    break;    default:    if (data->pickyness)    decode_error(data, NULL, "Internal error: "    "Unsupported early constant (%d).\n",    entry_type);    break;    }    /* name */    decode_value2(data); - #if 0 -  if (TYPEOF(Pike_sp[-1]) == T_STRING) { -  constant->name = Pike_sp[-1].u.string; -  } else if ((TYPEOF(Pike_sp[-1]) == T_INT) && -  !Pike_sp[-1].u.integer) { -  constant->name = NULL; -  } else { -  ref_push_program (p); -  decode_error(data, Pike_sp - 1, -  "Name of constant is not a string: %O\n", -  Pike_sp - 2); -  } -  constant->sval = Pike_sp[-2]; -  dmalloc_touch_svalue(Pike_sp-1); -  dmalloc_touch_svalue(Pike_sp-2); -  Pike_sp -= 2; - #else /* !0 */ +     constant->offset = -1;    pop_stack();    constant->sval = Pike_sp[-1];    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp -= 1; - #endif /* 0 */ +     decode_number(entry_type, data);    }       while (entry_type != ID_ENTRY_EOT) {    decode_number(id_flags, data);    if ((entry_type != ID_ENTRY_RAW) &&    (entry_type != ID_ENTRY_INHERIT)) {    /* Common identifier fields. */       unsigned INT32 filename_strno;
pike.git/src/encode.c:3836:    /* Already initialized. */    EDB(5,    fprintf(stderr, "%*sskipping constant %d\n",    data->depth, "", e));    continue;    }    /* value */    decode_value2(data);    /* name */    decode_value2(data); - #if 0 -  if (TYPEOF(Pike_sp[-1]) == T_STRING) { -  constant->name = Pike_sp[-1].u.string; -  } else if ((TYPEOF(Pike_sp[-1]) == T_INT) && -  !Pike_sp[-1].u.integer) { -  constant->name = NULL; -  } else { -  ref_push_program (p); -  decode_error(data, Pike_sp - 1, -  "Name of constant is not a string: %O\n", -  Pike_sp - 2); -  } -  constant->sval = Pike_sp[-2]; -  dmalloc_touch_svalue(Pike_sp-1); -  dmalloc_touch_svalue(Pike_sp-2); -  Pike_sp -= 2; - #else /* !0 */ +     constant->offset = -1;    pop_stack();    constant->sval = Pike_sp[-1];    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp -= 1; - #endif /* 0 */ +     EDB(5,    fprintf(stderr, "%*sDecoded constant %d to a %s\n",    data->depth, "",    e, get_name_of_type(TYPEOF(constant->sval))));    }      #ifdef ENCODE_DEBUG    if (!data->debug)   #endif    data->pickyness--;
pike.git/src/encode.c:4043:    current_decode = data;       decode_value2(data);       while (data->ptr < data->len) {    decode_value2 (data);    pop_stack();    }   }    - #if TWO_PASS_DECODE_WORKS - /* Run pass2 */ - int re_decode(struct decode_data *data, int ignored) - { -  JMP_BUF recovery; -  struct svalue orig_thrown; -  move_svalue (&orig_thrown, &throw_value); -  mark_free_svalue (&throw_value); -  -  if (SETJMP (recovery)) { -  UNSETJMP (recovery); -  call_handle_error(); -  move_svalue (&throw_value, &orig_thrown); -  free_decode_data (data, 0, 1); -  return 0; -  } -  -  else { -  data->next = current_decode; -  low_do_decode (data); -  UNSETJMP (recovery); -  move_svalue (&throw_value, &orig_thrown); -  free_decode_data (data, 0, 0); -  return 1; -  } - } - #endif -  +    static void error_free_decode_data (struct decode_data *data)   {    int delay;    debug_malloc_touch (data); - #if TWO_PASS_DECODE_WORKS -  delay=unlink_current_supporter(&data->supporter); -  call_dependants(& data->supporter, 1); - #else +     delay = 0; - #endif +     free_decode_data (data, delay, 1);   }      static INT32 my_decode(struct pike_string *tmp,    struct object *codec   #ifdef ENCODE_DEBUG    , int debug   #endif    )   {
pike.git/src/encode.c:4161:       data->decoded=allocate_mapping(128);       add_ref (data->data_str);    if (data->codec) add_ref (data->codec);   #ifdef PIKE_THREADS    add_ref (data->thread_obj);   #endif    SET_ONERROR(err, error_free_decode_data, data);    - #if TWO_PASS_DECODE_WORKS -  init_supporter(& data->supporter, -  (supporter_callback *) re_decode, -  (void *)data); - #endif -  +     low_do_decode (data);       {    int delay; - #if TWO_PASS_DECODE_WORKS -  delay=unlink_current_supporter(&data->supporter); -  call_dependants(& data->supporter, 1); - #else +     delay = 0; - #endif +     free_decode_data (data, delay, 0);    }       UNSET_ONERROR(err);       return 1;   }      /*! @class MasterObject    */