pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:2595:   #define get_string_data(STR,LEN, data) do { \    if((LEN) == -1) \    { \    INT32 what, e; \    INT64 num; \    ptrdiff_t sz; \    DECODE("get_string_data"); \    what &= TAG_MASK; \    if(what<0 || what>2) \    decode_error (data, NULL, "Illegal size shift %d.\n", what); \ +  EDB(1, { \ +  DECODE_WERR(".string %ld<<%d", num, what); \ +  }); \    sz = (ptrdiff_t) num << what; \    if (sz < 0) \    decode_error (data, NULL, "Illegal negative size %td.\n", sz); \    if (sz > data->len - data->ptr) \    decode_error (data, NULL, "Too large size %td (max is %td).\n", \    sz, data->len - data->ptr); \    STR=begin_wide_shared_string(num, what); \    memcpy(STR->str, data->data + data->ptr, sz); \    EDB(6, debug_dump_mem(data->ptr, data->data + data->ptr, sz)); \ -  +  EDB(1, { \ +  DECODE_FLUSH(); \ +  }); \    data->ptr += sz; \    BITFLIP(STR); \    STR=end_shared_string(STR); \    }else{ \    ptrdiff_t sz = (LEN); \    if (sz < 0) \    decode_error (data, NULL, "Illegal negative size %td.\n", sz); \    if (sz > data->len - data->ptr) \    decode_error (data, NULL, "Too large size %td (max is %td).\n", \    sz, data->len - data->ptr); \ -  +  EDB(1, { \ +  DECODE_WERR(".string %ld", sz); \ +  }); \    STR=make_shared_binary_string((char *)(data->data + data->ptr), sz); \    EDB(6, debug_dump_mem(data->ptr, data->data + data->ptr, sz)); \    data->ptr += sz; \    } \ -  +  EDB(1, { \ +  DECODE_FLUSH(); \ +  }); \   }while(0)      #define decode_number(X,data) do { \    INT32 what, e; \    INT64 num; \    DECODE("decode_number"); \    X=(what & TAG_MASK) | ((UINT64)num<<4); \    EDB(5, fprintf(stderr, "%*s ==>%ld\n", \    data->depth, "", (long) X)); \    }while(0) \
pike.git/src/encode.c:3063:    delayed_enc_val = NULL;    break;    }       check_stack(1);       switch(what & TAG_MASK)    {    case TAG_INT:    push_int(num); +  +  EDB(1, { +  DECODE_WERR(".integer %ld", num); +  });    break;       case TAG_STRING:    {    struct pike_string *str;    get_string_data(str, num, data);    push_string(str);    break;    }   
pike.git/src/encode.c:3093:       DECODE("float");       EDB(2,fprintf(stderr, "Exponent: %ld\n", num));       if(!res)    {    switch(num)    {    case Pike_FP_SNAN: /* Signal Not A Number */ +  push_float((FLOAT_TYPE)MAKE_NAN()); +  EDB(1, { +  DECODE_WERR(".float snan"); +  }); +  break; +     case Pike_FP_QNAN: /* Quiet Not A Number */    push_float((FLOAT_TYPE)MAKE_NAN()); -  +  EDB(1, { +  DECODE_WERR(".float qnan"); +  });    break;       case Pike_FP_NINF: /* Negative infinity */    push_float(-(FLOAT_TYPE)MAKE_INF()); -  +  EDB(1, { +  DECODE_WERR(".float -inf"); +  });    break;       case Pike_FP_PINF: /* Positive infinity */    push_float((FLOAT_TYPE)MAKE_INF()); -  +  EDB(1, { +  DECODE_WERR(".float inf"); +  });    break;       case Pike_FP_NZERO: /* Negative Zero */    push_float(-0.0); /* Does this do what we want? */ -  +  EDB(1, { +  DECODE_WERR(".float -0.0"); +  });    break;       default:    push_float((FLOAT_TYPE)ldexp(res, num)); -  +  EDB(1, { +  DECODE_WERR(".float %d", num); +  });    break;    }    break;    }       push_float((FLOAT_TYPE)ldexp(res, num)); -  +  EDB(1, { +  DECODE_WERR(".float %ld, %d", res, num); +  });    break;    }       case TAG_TYPE:    {    struct pike_type *t;    -  +  EDB(1, { +  DECODE_WERR(".entry type, %ld", num); +  }); +     decode_type(t, data);    push_type_value(t);       entry_id = data->counter;    data->counter.u.integer++;    }    break;       case TAG_ARRAY:    {
pike.git/src/encode.c:3146:    if(num < 0)    decode_error(data, NULL,    "Failed to decode array (array size is negative).\n");       /* Heruetical */    if(num > data->len - data->ptr)    decode_error(data, NULL, "Failed to decode array (not enough data).\n");       EDB(2,fprintf(stderr, "%*sDecoding array of size %ld to <%ld>\n",    data->depth, "", num, entry_id.u.integer)); +  EDB(1, { +  DECODE_WERR(".entry array, %ld", num); +  });       SETUP_DECODE_MEMOBJ(T_ARRAY, array, a, allocate_array(num),    free_svalues(ITEM(a), a->size, a->type_field));       types = 0;    for(e=0;e<num;e++)    {    decode_value2(data);    stack_pop_to_no_free (ITEM(a) + e);    types |= 1 << TYPEOF(ITEM(a)[e]);
pike.git/src/encode.c:3177:    "(mapping size is negative).\n");       /* Heuristical */    if(num > data->len - data->ptr)    decode_error(data, NULL, "Failed to decode mapping "    "(not enough data).\n");       EDB(2,fprintf(stderr, "%*sDecoding mapping of size %ld to <%ld>\n",    data->depth, "", num, entry_id.u.integer));    +  EDB(1, { +  DECODE_WERR(".entry mapping, %ld", num); +  }); +     SETUP_DECODE_MEMOBJ(T_MAPPING, mapping, m, allocate_mapping(num), ; );       for(e=0;e<num;e++)    {    decode_value2(data);    decode_value2(data);    mapping_insert(m, Pike_sp-2, Pike_sp-1);    pop_n_elems(2);    }    ref_push_mapping(m);
pike.git/src/encode.c:3208:       /* Heruetical */    if(num > data->len - data->ptr)    decode_error(data, NULL, "Failed to decode multiset "    "(not enough data).\n");       /* NOTE: This code knows stuff about the implementation of multisets...*/       EDB(2,fprintf(stderr, "%*sDecoding multiset of size %ld to <%ld>\n",    data->depth, "", num, entry_id.u.integer)); +  EDB(1, { +  DECODE_WERR(".entry multiset, %ld", num); +  });    SETUP_DECODE_MEMOBJ (T_MULTISET, multiset, m,    allocate_multiset (0, 0, NULL), ;);    /* FIXME: This array could be avoided by building the multiset directly. */    a = low_allocate_array (num, 0);       types = 0;    for(e=0;e<num;e++)    {    decode_value2(data);    stack_pop_to_no_free (ITEM(a) + e);
pike.git/src/encode.c:3235:    merge_multisets (m, l, PIKE_MERGE_DESTR_A | PIKE_ARRAY_OP_ADD);    free_multiset (l);    }    ref_push_multiset(m);    goto decode_done;    }       case TAG_OBJECT:    {    int subtype = 0; +  EDB(1, { +  if (!num) { +  DECODE_WERR(".entry object"); +  } else if (num == 2) { +  DECODE_WERR(".bignum"); +  } else { +  DECODE_WERR(".entry object, %ld", num); +  } +  });    if (num == 4) {    decode_number(subtype, data);    }    decode_value2(data);       switch(num)    {    case 0:    apply(decoder_codec (data),"objectof", 1);    break;
pike.git/src/encode.c:3390:    } else if (TYPEOF(Pike_sp[-1]) != PIKE_T_INT) {    decode_error(data, NULL, "Failed to decode bignum. Got: %O\n",    Pike_sp - 1);    }    }       break;    }       case TAG_FUNCTION: +  EDB(1, { +  if (num) { +  DECODE_WERR(".entry function, %ld", num); +  } else { +  DECODE_WERR(".entry function"); +  } +  }); +     decode_value2(data);    stack_dup(); /* For diagnostic purposes... */       switch(num)    {    case 0:    apply(decoder_codec (data),"functionof", 1);    break;       case 1: {
pike.git/src/encode.c:3470:    case TAG_PROGRAM:    EDB(3,    fprintf(stderr, "%*s TAG_PROGRAM(%ld)\n",    data->depth, "", num));    switch(num)    {    case 0:    {    struct program *p;    +  EDB(1, { +  DECODE_WERR(".entry program"); +  }); +     decode_value2(data);    apply(decoder_codec (data),"programof", 1);       p = program_from_svalue(Pike_sp-1);       if (!p) {    if(data->pickyness)    decode_error(data, NULL, "Failed to decode program. Got: %O\n",    Pike_sp - 1);    pop_stack();
pike.git/src/encode.c:3503:    push_program(p);    break;    }       case 1: /* Old-style encoding. */    {    decode_error(data, NULL, "Failed to decode program. Old-style program encoding is not supported, anymore.\n");    }       case 2: +  EDB(1, { +  DECODE_WERR(".entry program, 2"); +  }); +     decode_value2(data);    decode_value2(data);    if(TYPEOF(Pike_sp[-2]) == T_INT)    {    pop_stack();    }else{    f_arrow(2);    }    if(TYPEOF(Pike_sp[-1]) != T_PROGRAM && data->pickyness)    decode_error(data, NULL, "Failed to decode program. Got: %O\n",    Pike_sp - 1);    break;       case 3: -  +  EDB(1, { +  DECODE_WERR(".entry program, 3"); +  }); +     decode_value2(data);    if ((TYPEOF(Pike_sp[-1]) == T_INT) &&    (Pike_sp[-1].u.integer < PROG_DYNAMIC_ID_START) &&    (Pike_sp[-1].u.integer > 0)) {    struct program *p = id_to_program(Pike_sp[-1].u.integer);    if (!p) {    decode_error(data, NULL, "Failed to get program from ID %O.\n",    Pike_sp - 1);    }    pop_stack();    ref_push_program(p);    } else {    decode_error(data, NULL, "Failed to decode program by ID. "    "Expected integer, got: %O\n", Pike_sp - 1);    }    break;       case 5: { /* Forward reference for new-style encoding. */    struct program *p = low_allocate_program(); -  +  EDB(1, { +  DECODE_WERR(".entry program, 5"); +  });       push_program (p);    EDB(2,    fprintf (stderr, "%*sInited an embryo for a delay encoded program "    "to <%ld>: ",    data->depth, "", entry_id.u.integer);    print_svalue (stderr, Pike_sp - 1);    fputc ('\n', stderr););       data->delay_counter++;
pike.git/src/encode.c:3572:    struct pike_string *save_current_file;    struct object *placeholder = NULL;    INT_TYPE 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 +  EDB(1, { +  DECODE_WERR(".entry program, 4"); +  });       /* Decode byte-order. */    decode_number(byteorder, data);       EDB(4,    fprintf(stderr, "%*sbyte order:%d\n",    data->depth, "", byteorder));       if ((byteorder != PIKE_BYTEORDER)   #if (PIKE_BYTEORDER == 1234)