reg_alloc4
auto reg_alloc4 =
q{--- reg_alloc4
void setRangeu8(u8* slice, u64 from, u64 to, u8 value) {}
void formatInt(i64 i, u8[21]* output, u32 minSize, u8[]* result)
{
u32 numDigits = 0;
if (i == 0)
{
if (minSize == 0)
minSize = 1;
setRangeu8((*output).ptr, 21 - minSize, 21, '0');
(*output)[20] = '0';
numDigits = minSize;
}
else
{
bool neg = i < 0;
if (neg) {
i = -i;
}
bool overflow = i < 0;
if (overflow)
i = i64.max;
while (i)
{
u8 c = cast(u8)('0' + i % 10);
(*output)[21 - ++numDigits] = c;
i /= 10;
}
while (numDigits < minSize) {
(*output)[21 - ++numDigits] = '0';
}
if (neg) {
(*output)[21 - ++numDigits] = '-';
}
if (overflow) {
++(*output)[20];
}
}
(*result).ptr = (*output).ptr + (21 - numDigits);
(*result).length = numDigits;
}
};
tests reg_alloc
functionsvariables