std/text/boxing
std/boxing — i32 / i64 radix conversions, plus the Float / Char
conversion facades.i32 and i64 decimal parsing, decimal rendering, and IEEE
classification all resolve through the primitive method surface
(s.toI32(), v.toString(), …) or the std/numeric/math bounds
(math::i32Min(), …) — nothing here duplicates them. What's left is
the radix (binary / hex / octal) surface, which has no primitive-method
table row of its own for the parse-with-explicit-base form, plus f32
and char: neither is admitted by the primitive-receiver gate
(hir_builder::…::calls::method), so their conversions stay
static-utility facades (Float, Char) rather than methods.
Pure Axle end to end — no native shim. The IEEE parser / formatter forf64 are the runtime-backed primitives of std/text (parseF64 /f64ToString), reached here by cross-module use (Float round-trips
through them). The radix formatters, radix parser, and the Float
special constants (materialised from their exact IEEE bit patterns via__f32FromBits) are computed in Axle.
Free functions
| Type | Method and description |
|---|---|
| __formatBinary(value : i64, width : i32) : string Binary text (no leading zeros, no 0b) of the low width bits ofvalue. The caller masks value to the unsigned interpretation itwants; bit i is read as (value >> i) & 1, which is correct fori < width regardless of the shift's sign behaviour. |
| __formatHex(value : i64, nibbles : i32) : string Lowercase hex text (no leading zeros) of the low nibbles * 4 bitsof value. |
| __formatOctal(value : i64, groups : i32) : string Octal text (no leading zeros) of the low groups * 3 bits ofvalue. |
| __i32ToHex(v : i32) : string v.toHex() — lowercase hex text of v's unsigned 32-bit interpretation. |
| __i32ToBin(v : i32) : string v.toBin() — binary text of v's unsigned 32-bit interpretation(no 0b). |
| __i32ToOct(v : i32) : string v.toOct() — octal text of v's unsigned 32-bit interpretation. |
| __i64ToHex(v : i64) : string v.toHex() — lowercase hex text of v's unsigned 64-bit interpretation. |
| __i64ToBin(v : i64) : string v.toBin() — binary text of v's unsigned 64-bit interpretation(no 0b). |
| __parseRadix(s : string, base : i32) : i64 Parse s as a signed integer in base (2..=36), accepting anoptional leading + / -. Digits are 0..9 then a..z(case-insensitive) for values 10..35. Accumulates in i64 so[ parseI32Base] can range-check the wide result before narrowing.Text too long for an i64 throws rather than wrapping. Axle's + and* wrap, so an unguarded acc * base + d turns "99999999999999999999"into an arbitrary in-range number — and parseI32Base's own range checkthen approves it, because by the time it looks the value is already inside the range. A parse that cannot represent its input must say so. |
| parseI32Base(s : string, base : i32) : i32 Parse s in an arbitrary base (2..=36) as an i32; narrows after arange check. Free function, not a method: the base is a second meaningful argument, not incidental context, so parseI32Base(s, base)reads at least as clearly as a method would and needs no primitive- method table row. |
| parseI64Base(s : string, base : i32) : i64 Parse s in an arbitrary base (2..=36) as an i64. |
| __charToI32(c : char) : i32 The i32 codepoint of c — a char and an i32 are both 4-bytestack slots, so reading c's address back as ptr<i32> recoversthe exact codepoint with no lossy round trip (unlike the IEEE bit tricks above, this reinterpret IS the value: a char's storagerepresentation is its Unicode scalar value). |
| __i32ToCharUnchecked(cp : i32) : char The char whose codepoint is cp, with no scalar-valuevalidation — private helper for call sites that already proved cp is a valid Unicode scalar value (e.g. read back from a realstring's charAt). [Char::fromI32] is the validating publicentry point. |
| __isValidScalarValue(cp : i32) : bool true when cp is a valid Unicode scalar value: in range[0, 0x10FFFF] and not a surrogate ([0xD800, 0xDFFF] is reservedfor UTF-16 encoding and never a scalar value on its own). Mirrors the range check StringBuilder::appendChar uses to fall back toU+FFFD. |
Method detail
#__formatBinary
Binary text (no leading zeros, no 0b) of the low width bits ofvalue. The caller masks value to the unsigned interpretation it
wants; bit i is read as (value >> i) & 1, which is correct fori < width regardless of the shift's sign behaviour.
value bit pattern to render, low width bits significantwidth number of low bits to render#__formatHex
Lowercase hex text (no leading zeros) of the low nibbles * 4 bits
of value.
value bit pattern to render, low nibbles * 4 bits significantnibbles number of 4-bit hex digits to render#__formatOctal
Octal text (no leading zeros) of the low groups * 3 bits ofvalue.
value bit pattern to render, low groups * 3 bits significantgroups number of 3-bit octal digits to render#__i32ToHex
v.toHex() — lowercase hex text of v's unsigned 32-bit interpretation.
v i32 to render, read as unsigned 32-bit#__i32ToBin
v.toBin() — binary text of v's unsigned 32-bit interpretation
(no 0b).
v i32 to render, read as unsigned 32-bit#__i32ToOct
v.toOct() — octal text of v's unsigned 32-bit interpretation.
v i32 to render, read as unsigned 32-bit#__i64ToHex
v.toHex() — lowercase hex text of v's unsigned 64-bit interpretation.
v i64 to render, read as unsigned 64-bit#__i64ToBin
v.toBin() — binary text of v's unsigned 64-bit interpretation
(no 0b).
v i64 to render, read as unsigned 64-bit#__parseRadix
Parse s as a signed integer in base (2..=36), accepting an
optional leading + / -. Digits are 0..9 then a..z
(case-insensitive) for values 10..35. Accumulates in i64 so
[parseI32Base] can range-check the wide result before narrowing.
Text too long for an i64 throws rather than wrapping. Axle's + and* wrap, so an unguarded acc * base + d turns "99999999999999999999"
into an arbitrary in-range number — and parseI32Base's own range check
then approves it, because by the time it looks the value is already
inside the range. A parse that cannot represent its input must say so.
s text to parse, optional leading + / - then digitsbase radix, 2..=36#parseI32Base
Parse s in an arbitrary base (2..=36) as an i32; narrows after a
range check. Free function, not a method: the base is a second
meaningful argument, not incidental context, so parseI32Base(s, base)
reads at least as clearly as a method would and needs no primitive-
method table row.
s text to parse in the given radixbase radix, 2..=36#parseI64Base
Parse s in an arbitrary base (2..=36) as an i64.
s text to parse in the given radixbase radix, 2..=36#__charToI32
The i32 codepoint of c — a char and an i32 are both 4-byte
stack slots, so reading c's address back as ptr<i32> recovers
the exact codepoint with no lossy round trip (unlike the IEEE bit
tricks above, this reinterpret IS the value: a char's storage
representation is its Unicode scalar value).
c char whose codepoint is read out#__i32ToCharUnchecked
The char whose codepoint is cp, with no scalar-value
validation — private helper for call sites that already provedcp is a valid Unicode scalar value (e.g. read back from a realstring's charAt). [Char::fromI32] is the validating public
entry point.
cp codepoint to reinterpret as a char#__isValidScalarValue
true when cp is a valid Unicode scalar value: in range[0, 0x10FFFF] and not a surrogate ([0xD800, 0xDFFF] is reserved
for UTF-16 encoding and never a scalar value on its own). Mirrors
the range check StringBuilder::appendChar uses to fall back to
U+FFFD.
cp candidate codepointC class Float
Static-utility facade for f32. f32 is not part of the primitive-
receiver gate (hir_builder::…::calls::method) that admitsi32 / i64 / f64 / bool, so unlike those types' conversions —
all removed from this file in favour of s.toI32() / v.toString() /
the bounds in std::numeric::math — f32's parse / format /
classify / bounds surface has no method or free-function form to
collapse into, and stays a class. Parsing and formatting round-trip
through the f64 primitives (there is no dedicated single-precision
parser / formatter, and narrowing / widening between f32 and f64
is a lossless-both-ways-representable as cast already supported by
every numeric target); the classification predicates are pure IEEE
comparisons and the special constants are materialised from their
exact 32-bit patterns.
Methods
| Type | Method and description |
|---|---|
| parse(s : string) : f32 |
| toString(v : f32) : string |
| isNaN(v : f32) : bool |
| isInfinite(v : f32) : bool |
| isFinite(v : f32) : bool |
| min() : f32 |
| max() : f32 |
| positiveInfinity() : f32 |
| negativeInfinity() : f32 |
| notANumber() : f32 |
Method detail
#parse
#toString
#isNaN
#isInfinite
#isFinite
#min
#max
#positiveInfinity
#negativeInfinity
#notANumber
C class Char
Static-utility facade for char — a char is a 32-bit Unicode
scalar value, distinct from the plain i32 codepoints string's
per-character surface (charAt / appendChar) uses. Char is the
bridge between the two: toI32 /fromI32 convert to/from that codepoint form, and
every other method composes on top of the existing Unicode-awarestring primitives (case fold, blank test) rather than
re-implementing Unicode classification.
Methods
| Type | Method and description |
|---|---|
| toI32(c : char) : i32 |
| fromI32(cp : i32) : char |
| parse(s : string) : char |
| toString(c : char) : string |
| min() : char |
| max() : char |
| isDigit(c : char) : bool |
| isWhitespace(c : char) : bool |
| toUpperCase(c : char) : char |
| toLowerCase(c : char) : char |