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.122 2001/08/10 21:43:22 mast Exp $"); + RCSID("$Id: encode.c,v 1.123 2001/08/10 22:06:14 grubba Exp $");      /* #define ENCODE_DEBUG */      #ifdef ENCODE_DEBUG   /* Pass a nonzero integer as the third arg to encode_value,    * encode_value_canonic and decode_value to activate this debug. */   #define EDB(N,X) do if (data->debug>=N) {X;} while (0)   #else   #define EDB(N,X) do {} while (0)   #endif
pike.git/src/encode.c:44:   #endif /* sp */      #ifdef _AIX   #include <net/nh.h>   #endif      #ifdef HAVE_NETINET_IN_H   #include <netinet/in.h>   #endif    + #ifdef HAVE_IEEFP_H + #include <ieeefp.h> + #endif /* HAVE_IEEEFP_H */ +    #include <math.h>      /* Restore the sp macro */   #ifdef STACKPOINTER_WAS_DEFINED   #define sp Pike_sp   #undef STACK_POINTER_WAS_DEFINED   #endif /* STACKPOINTER_WAS_DEFINED */      #ifdef HAVE_FREXP   #define FREXP frexp
pike.git/src/encode.c:597:    EDB(2,fprintf(stderr, "%*sEncoded type to <%d>: ",    data->depth, "", data->counter.u.integer);    print_svalue(stderr, val);    fputc('\n', stderr););    mapping_insert(data->encoded, val, &data->counter);    data->counter.u.integer++;    break;       case T_FLOAT:    { +  double d = val->u.float_number;      #define Pike_FP_SNAN -4 /* Signal Not A Number */   #define Pike_FP_QNAN -3 /* Quiet Not A Number */   #define Pike_FP_NINF -2 /* Negative infinity */   #define Pike_FP_PINF -1 /* Positive infinity */   #define Pike_FP_ZERO 0 /* Backwards compatible zero */   #define Pike_FP_NZERO 1 /* Negative Zero */   #define Pike_FP_PZERO 0 /* Positive zero */   #define Pike_FP_UNKNOWN -4711 /* Positive zero */   
pike.git/src/encode.c:651: Inside #if defined(HAVE_FPCLASS)
   default:    goto encode_normal_float;    }    break;    encode_normal_float:      #else    {    int pike_ftype=Pike_FP_UNKNOWN;   #ifdef HAVE_ISINF -  if(isinf(val->u.float_number)) +  if(isinf(d))    pike_ftype=Pike_FP_PINF;    else   #endif   #ifdef HAVE_ISNAN -  if(isnan(val->u.float_number)) { +  if(isnan(d)) {    pike_ftype=Pike_FP_SNAN;    } else   #endif   #ifdef HAVE_ISZERO -  if(iszero(val->u.float_number)) +  if(iszero(d))    pike_ftype=Pike_FP_PZERO;    else   #endif   #ifdef HAVE_FINITE -  if(!finite(val->u.float_number)) +  if(!finite(d))    pike_ftype=Pike_FP_PINF;   #endif    ; /* Terminate any remaining else */       if(   #ifdef HAVE_SIGNBIT -  signbit(val->u.float_number) +  signbit(d)   #else -  val->u.float_number<0.0 +  d<0.0   #endif    ) {    switch(pike_ftype)    {    case Pike_FP_PINF:    pike_ftype=Pike_FP_NINF;    break;       case Pike_FP_PZERO:    pike_ftype=Pike_FP_NZERO;
pike.git/src/encode.c:699:       if(pike_ftype != Pike_FP_UNKNOWN)    {    code_entry(TAG_FLOAT,0,data);    code_entry(TAG_FLOAT,pike_ftype,data);    break;    }    }   #endif    -  if(val->u.float_number==0.0) +  if(d == 0.0)    {    code_entry(TAG_FLOAT,0,data);    code_entry(TAG_FLOAT,0,data);    }else{    INT64 x;    int y;    double tmp;    -  tmp = FREXP((double)val->u.float_number, &y); +  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 */
pike.git/src/encode.c:907:    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); +  code_entry(TAG_FUNCTION, 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);   #ifdef ENCODE_DEBUG    data->depth -= 2;   #endif    return;    }    }    Pike_error("Encoding of efuns is not supported yet.\n");    }    -  code_entry(type_to_tag(val->type), 0,data); +  code_entry(TAG_FUNCTION, 0, data);    encode_value2(Pike_sp-1, data);    pop_stack();    break;          case T_PROGRAM:    {    int d;    if (val->u.program->id < PROG_DYNAMIC_ID_START) { -  code_entry(type_to_tag(val->type), 3, data); +  code_entry(TAG_PROGRAM, 3, data);    push_int(val->u.program->id);    encode_value2(Pike_sp-1, data);    pop_stack();    break;    }    if (data->canonic)    Pike_error("Canonical encoding of programs not supported.\n");    check_stack(1);    push_svalue(val);    apply(data->codec,"nameof", 1);
pike.git/src/encode.c:962:    struct program *p=val->u.program;    if( (p->flags & PROGRAM_HAS_C_METHODS) || p->event_handler )    {    if(p->parent)    {    /* 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), 2,data); +  code_entry(TAG_PROGRAM, 2, data);    ref_push_program(p->parent);    encode_value2(Pike_sp-1,data);       ref_push_program(p);    f_function_name(1);    if(Pike_sp[-1].type == PIKE_T_INT)    Pike_error("Cannot encode C programs.\n");    encode_value2(Pike_sp-1, data);       pop_n_elems(3);
pike.git/src/encode.c:986: Inside #if defined(ENCODE_DEBUG)
  #ifdef ENCODE_DEBUG    data->depth -= 2;   #endif    return;    }    if( p->event_handler )    Pike_error("Cannot encode programs with event handlers.\n");    Pike_error("Cannot encode C programs.\n");    }    /*FIXME: save p->parent!! */ -  code_entry(type_to_tag(val->type), 1,data); +  code_entry(TAG_PROGRAM, 1, data);    f_version(0);    encode_value2(Pike_sp-1,data);    pop_stack();    code_number(p->flags,data);    code_number(p->storage_needed,data);    code_number(p->xstorage,data);    code_number(p->parent_info_storage,data);       code_number(p->alignment_needed,data);    code_number(p->timestamp.tv_sec,data);
pike.git/src/encode.c:1115:       for(d=0;d<NUM_LFUNS;d++)    code_number(p->lfuns[d], data);       for(d=0;d<p->num_constants;d++)    {    encode_value2(& p->constants[d].sval, data);    adddata3(p->constants[d].name);    }    }else{ -  code_entry(type_to_tag(val->type), 0,data); +  code_entry(TAG_PROGRAM, 0, data);    encode_value2(Pike_sp-1, data);    }    pop_stack();    break;    }    }      #ifdef ENCODE_DEBUG    data->depth -= 2;   #endif