pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:25:   #include "version.h"   #include "bignum.h"   #include "pikecode.h"   #include "pike_types.h"   #include "opcodes.h"   #include "peep.h"   #include "pike_compiler.h"   #include "bitvector.h"   #include "pike_float.h"   #include "sprintf.h" + #include "modules/Gmp/my_gmp.h"      /* #define ENCODE_DEBUG */      /* Use the old encoding method for programs. */   /* #define OLD_PIKE_ENCODE_PROGRAM */      #ifdef ENCODE_DEBUG   /* Pass a nonzero integer as the third arg to encode_value,    * encode_value_canonic and decode_value to activate this debug. It    * both enables debug messages and also lessens the pickyness to
pike.git/src/encode.c:690:    switch(TYPEOF(*val))    {    case T_INT:    /* NOTE: Doesn't encode NUMBER_UNDEFINED et al. */    {    INT_TYPE i=val->u.integer;   #if SIZEOF_INT_TYPE > 4    if (i != (INT32)i)    {    MP_INT tmp; -  /* Note: Assumes sizeof_int_type is a multiple of 8. */ - #if (SIZEOF_INT_TYPE > SIZEOF_LONG) || (SIZEOF_INT_TYPE&7) - # error Assumption about size of int type not true. - #endif -  char buffer[16*(SIZEOF_INT_TYPE/8)]; -  size_t l; +  +  code_entry(TAG_OBJECT, 2, data); +  EDB(1, { +  ENCODE_WERR(".bignum %*s# %ld", 20, "", i); +  }); +     /* Note: conversion to base 36 could be done directly here -  using / and % instead. Doing it like this is actually -  only slightly slower, however, and saves on code size. +  * using / and % instead. Doing it like this is actually +  * only slightly slower, however, and saves on code size. +  * +  * Note that we also must adjust the data->encoded mapping, +  * to not confuse the decoder. This is easiest to do by +  * performing a recursive call, which means that we need +  * a proper pike_string anyway.    */    mpz_init_set_si( &tmp, i ); -  mpz_get_str( buffer, 36, &tmp ); +  push_string(low_get_mpz_digits(&tmp, 36));    mpz_clear( &tmp ); -  l = strlen(buffer); -  code_entry(TAG_OBJECT, 2, data); -  code_entry(TAG_STRING, l, data); -  addstr(buffer,l); -  -  EDB(1, { -  ENCODE_WERR(".bignum %ld", i); -  }); +  encode_value2(Pike_sp-1, data, force_encode); +  pop_stack();    }    else   #endif    {    code_entry(TAG_INT, i, data);       EDB(1, {    ENCODE_WERR(".integer %ld", i);    });    }