final class · System
NumberText
final class NumberText
The text a format makes: bytes (ASCII), grown as needed, then one string of exactly them.
- Kind
- final class
- Namespace
- System
- Assembly
- System.Core
- Access
- internal, final
- Source file
Format.ant
Inheritance
- Base classes
-
AnyNumberText
Methods
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
NumberText as Antril, decompiled from its Larva HIR.
// System.NumberText — System.Core (decompiled from Larva HIR)
into namespace System
{
/// The text a format makes: bytes (ASCII), grown as needed, then one string of exactly them.
final class NumberText
{
u8[] bytes;
i32 count;
[NoInline]
Grow()
{
u8[] bigger = new u8[bytes.Length * 2];
loop (i32 i = 0..count)
bigger[i] = bytes[i];
bytes = bigger;
}
public:
Add(u8 unit)
{
if (count == bytes.Length)
Grow();
bytes[count] = unit;
count++;
}
/// A non-negative number's digits.
Number(i32 value)
{
i32 width = 1;
loop (i32 m = value; m >= 10; m = m / 10)
width++;
loop (count + width > bytes.Length)
Grow();
loop (i32 i = width - 1; i >= 0; i--)
{
bytes[count + i] = (u8)(48 + value % 10);
value = value / 10;
}
count += width;
}
Made() : str
{
u8[] exact = new u8[count];
loop (i32 i = 0..count)
exact[i] = bytes[i];
return new str(exact);
}
}
}