Changeset 32722 in project


Ignore:
Timestamp:
08/21/15 17:52:53 (5 years ago)
Author:
sjamaan
Message:

numbers: Convert number<->string conversion routines to work with argvector CHICKEN

Location:
release/4/numbers/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/numbers/trunk/numbers-c.c

    r32721 r32722  
    19861986
    19871987void C_ccall
    1988 C_digits_to_integer(C_word c, C_word self, C_word k, C_word str,
    1989                     C_word start, C_word end, C_word radix, C_word negp)
    1990 {
     1988CPS_PROC5(C_digits_to_integer, c, self, k, str, start, end, radix, negp)
     1989{
     1990  CPS_BODY5(c, self, k, str, start, end, radix, negp);
    19911991  assert((C_unfix(radix) > 1) && C_fitsinbignumhalfdigitp(C_unfix(radix)));
    19921992 
     
    21232123}
    21242124
    2125 void C_ccall C_basic_number_to_string(C_word c, C_word closure, C_word k, C_word num, ...)
    2126 {
     2125void C_ccall CPS_PROCNPLUS1(C_basic_number_to_string, c, closure, k, num)
     2126{
     2127  CPS_BODYNPLUS1(c, closure, k, num);
    21272128  C_word radix;
    21282129
     
    21302131    radix = C_fix(10);
    21312132  } else if(c == 4) {
     2133#ifdef ARGVECTOR_CHICKEN
     2134    radix = __av[3];
     2135#else
    21322136    va_list v;
    21332137
     
    21352139    radix = va_arg(v, C_word);
    21362140    va_end(v);
     2141#endif
    21372142   
    21382143    if(!(radix & C_FIXNUM_BIT))
     
    21432148
    21442149  if(num & C_FIXNUM_BIT) {
    2145     C_u_fixnum_to_string(4, (C_word)NULL, k, num, radix);
     2150    CPS_CALL(C_u_fixnum_to_string, 4, (C_word)NULL, k, num, radix);
    21462151  } else if (C_immediatep(num)) {
    21472152    barf(C_BAD_ARGUMENT_TYPE_ERROR, "number->string", num);
    21482153  } else if(C_block_header(num) == C_FLONUM_TAG) {
    2149     C_u_flonum_to_string(4, (C_word)NULL, k, num, radix);
     2154    CPS_CALL(C_u_flonum_to_string, 4, (C_word)NULL, k, num, radix);
    21502155  } else if (C_IS_BIGNUM_TYPE(num)) {
    2151     C_u_integer_to_string(4, (C_word)NULL, k, num, radix);
     2156    CPS_CALL(C_u_integer_to_string, 4, (C_word)NULL, k, num, radix);
    21522157  } else {
    21532158    try_extended_number("numbers#@extended-number->string", 3, k, num, radix);
     
    21552160}
    21562161
    2157 void C_ccall
    2158 C_u_fixnum_to_string(C_word c, C_word self, C_word k, C_word num, C_word radix)
    2159 {
     2162void C_ccall CPS_PROC2(C_u_fixnum_to_string, c, self, k, num, radix)
     2163{
     2164  CPS_BODY2(c, self, k, num, radix);
    21602165  C_char *p;
    21612166  C_word *a, neg = num & C_INT_SIGN_BIT ? 1 : 0;
     
    21742179}
    21752180
    2176 void C_ccall
    2177 C_u_flonum_to_string(C_word c, C_word self, C_word k, C_word num, C_word radix)
    2178 {
     2181void C_ccall CPS_PROC2(C_u_flonum_to_string, c, self, k, num, radix)
     2182{
     2183  CPS_BODY2(c, self, k, num, radix);
    21792184  C_word *a;
    21802185  C_char *p;
     
    22302235
    22312236/* Naming is a little inconsistent, but looks saner.  We're not R-O-B-O-T-S! */
    2232 void C_ccall
    2233 C_u_integer_to_string(C_word c, C_word self, C_word k, C_word num, C_word radix)
    2234 {
     2237void C_ccall CPS_PROC2(C_u_integer_to_string, c, self, k, num, radix)
     2238{
     2239  CPS_BODY2(c, self, k, num, radix);
    22352240  if (num & C_FIXNUM_BIT) {
    2236     C_u_fixnum_to_string(4, (C_word)NULL, k, num, radix);
     2241    CPS_CALL(C_u_fixnum_to_string, 4, (C_word)NULL, k, num, radix);
    22372242  } else {
    22382243    int len, radix_shift;
  • release/4/numbers/trunk/numbers-c.h

    r32721 r32722  
    2727# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word *__av)
    2828# define CPS_PROC2(name, c, s, k, a1, a2) name(C_word c, C_word *__av)
     29# define CPS_PROC3(name, c, s, k, a1, a2, a3) name(C_word c, C_word *__av)
     30# define CPS_PROC4(name, c, s, k, a1, a2, a3, a4) name(C_word c, C_word *__av)
     31# define CPS_PROC5(name, c, s, k, a1, a2, a3, a4, a5) name(C_word c, C_word *__av)
     32# define CPS_PROCNPLUS1(name, c, s, k, a1) name(C_word c, C_word *__av)
     33/* Excuse the mess */
    2934# define CPS_BODY1(c, s, k, a1) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0;
    3035# define CPS_BODY2(c, s, k, a1, a2) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0; C_word a2 = c >= 2 ? __av[3] : 0;
     36# define CPS_BODY3(c, s, k, a1, a2, a3) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0; C_word a2 = c >= 2 ? __av[3] : 0; C_word a3 = c >= 3 ? __av[4] : 0;
     37# define CPS_BODY4(c, s, k, a1, a2, a3, a4) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0; C_word a2 = c >= 2 ? __av[3] : 0; C_word a3 = c >= 3 ? __av[4] : 0; C_word a4 = c >= 4 ? __av[5] : 0;
     38# define CPS_BODY5(c, s, k, a1, a2, a3, a4, a5) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0; C_word a2 = c >= 2 ? __av[3] : 0; C_word a3 = c >= 3 ? __av[4] : 0; C_word a4 = c >= 4 ? __av[5] : 0; C_word a5 = c >= 5 ? __av[6] : 0;
     39# define CPS_BODYNPLUS1(c, s, k, a1) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0;
    3140# define CPS_CALL(fn, c, s, k, ...) do { C_word avk[] = {s,k,__VA_ARGS__}; fn(c, avk); } while(0)
     41
    3242#else
     43
    3344# define C_kontinue2(k, r1, r2) C_values(4,C_SCHEME_UNDEFINED,k,r1,r2)
    3445# define CONT_BODY(s, a1) /* Nothing */
     
    3647# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word s, C_word k, C_word a1)
    3748# define CPS_PROC2(name, c, s, k, a1, a2) name(C_word c, C_word s, C_word k, C_word a1, C_word a2)
     49# define CPS_PROC3(name, c, s, k, a1, a2, a3) name(C_word c, C_word s, C_word k, C_word a1, C_word a2, C_word a3)
     50# define CPS_PROC4(name, c, s, k, a1, a2, a3, a4) name(C_word c, C_word s, C_word k, C_word a1, C_word a2, C_word a3, C_word a4, C_word a5)
     51# define CPS_PROC5(name, c, s, k, a1, a2, a3, a4, a5) name(C_word c, C_word s, C_word k, C_word a1, C_word a2, C_word a3, C_word a4, C_word a5)
     52# define CPS_PROCNPLUS1(name, c, s, k, a1) name(C_word c, C_word s, C_word k, C_word a1, ...)
    3853# define CPS_BODY1(c, s, k, a1) /* Nothing */
    3954# define CPS_BODY2(c, s, k, a1, a2) /* Nothing */
     55# define CPS_BODY3(c, s, k, a1, a2, a3) /* Nothing */
     56# define CPS_BODY4(c, s, k, a1, a2, a3, a4) /* Nothing */
     57# define CPS_BODY5(c, s, k, a1, a2, a3, a4, a5) /* Nothing */
     58# define CPS_BODYNPLUS1(c, s, k, a1) /* Nothing */
    4059# define CPS_CALL(fn, c, s, k, ...)  fn(c, s, k, __VA_ARGS__);
    4160#endif
     
    211230void C_ccall CPS_PROC1(C_u_integer_random, c, self, k, max) C_noret;
    212231
    213 void C_ccall C_digits_to_integer(C_word c, C_word self, C_word k, C_word n, C_word start, C_word end, C_word radix, C_word negp) C_noret;
    214 void C_ccall C_basic_number_to_string(C_word c, C_word closure, C_word k, C_word num, ...) C_noret;
    215 void C_ccall C_u_fixnum_to_string(C_word c, C_word self, C_word k, C_word num, C_word radix) C_noret;
    216 void C_ccall C_u_flonum_to_string(C_word c, C_word self, C_word k, C_word num, C_word radix) C_noret;
    217 void C_ccall C_u_integer_to_string(C_word c, C_word self, C_word k, C_word num, C_word radix) C_noret;
    218 void C_ccall C_u_fixnum_to_string(C_word c, C_word self, C_word k, C_word num, C_word radix) C_noret;
     232void C_ccall CPS_PROC5(C_digits_to_integer, c, self, k, n, start, end, radix, negp) C_noret;
     233void C_ccall CPS_PROCNPLUS1(C_basic_number_to_string, c, closure, k, num) C_noret;
     234void C_ccall CPS_PROC2(C_u_fixnum_to_string, c, self, k, num, radix) C_noret;
     235void C_ccall CPS_PROC2(C_u_flonum_to_string, c, self, k, num, radix) C_noret;
     236void C_ccall CPS_PROC2(C_u_integer_to_string, c, self, k, num, radix) C_noret;
    219237void C_ccall CPS_PROC1(C_u_flo_to_int, c, self, k, x) C_noret;
    220238C_word C_ccall C_u_i_integer_bit_setp(C_word n, C_word i);
Note: See TracChangeset for help on using the changeset viewer.