1
from pypy.rpython.lltypesystem.lltype import GcArray, Array, Char, malloc
2
from pypy.rlib.rarithmetic import r_uint
4
CHAR_ARRAY = GcArray(Char)
6
def ll_int_str(repr, i):
10
from pypy.rpython.lltypesystem.rstr import mallocstr
11
temp = malloc(CHAR_ARRAY, 20)
24
temp[len] = chr(i%10+ord('0'))
28
result = mallocstr(len)
36
result.chars[j] = temp[len-j-1]
40
hex_chars = malloc(Array(Char), 16, immortal=True)
45
def ll_int2hex(i, addPrefix):
46
from pypy.rpython.lltypesystem.rstr import mallocstr
47
temp = malloc(CHAR_ARRAY, 20)
60
temp[len] = hex_chars[i & 0xf]
66
result = mallocstr(len)
74
result.chars[j+1] = 'x'
77
result.chars[j] = temp[len-j-1]
81
def ll_int2oct(i, addPrefix):
82
from pypy.rpython.lltypesystem.rstr import mallocstr
88
temp = malloc(CHAR_ARRAY, 25)
97
temp[len] = hex_chars[i & 0x7]
103
result = mallocstr(len)
107
result.chars[0] = '-'
110
result.chars[j] = '0'
113
result.chars[j] = temp[len-j-1]
117
def ll_float_str(repr, f):
118
from pypy.rpython.lltypesystem.module.ll_strtod import Implementation
119
from pypy.rpython.lltypesystem.rstr import percent_f
120
return Implementation.ll_strtod_formatd(percent_f, f)