Axle v0.14.1
Package

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 for
f64 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

TypeMethod and description
string
__formatBinary(value : i64, width : i32) : string Binary text (no leading zeros, no 0b) of the low width bits of
value. The caller masks value to the unsigned interpretation it
wants; bit i is read as (value >> i) & 1, which is correct for
i < width regardless of the shift's sign behaviour.
string
__formatHex(value : i64, nibbles : i32) : string Lowercase hex text (no leading zeros) of the low nibbles * 4 bits
of value.
string
__formatOctal(value : i64, groups : i32) : string Octal text (no leading zeros) of the low groups * 3 bits of
value.
string
__i32ToHex(v : i32) : string v.toHex() — lowercase hex text of v's unsigned 32-bit interpretation.
string
__i32ToBin(v : i32) : string v.toBin() — binary text of v's unsigned 32-bit interpretation
(no 0b).
string
__i32ToOct(v : i32) : string v.toOct() — octal text of v's unsigned 32-bit interpretation.
string
__i64ToHex(v : i64) : string v.toHex() — lowercase hex text of v's unsigned 64-bit interpretation.
string
__i64ToBin(v : i64) : string v.toBin() — binary text of v's unsigned 64-bit interpretation
(no 0b).
i64
__parseRadix(s : string, base : i32) : i64 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.
i32
parseI32Base(s : string, base : i32) : i32 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.
i64
parseI64Base(s : string, base : i32) : i64 Parse s in an arbitrary base (2..=36) as an i64.
i32
__charToI32(c : char) : i32 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).
char
__i32ToCharUnchecked(cp : i32) : char The char whose codepoint is cp, with no scalar-value
validation — private helper for call sites that already proved
cp is a valid Unicode scalar value (e.g. read back from a real
string's charAt). [Char::fromI32] is the validating public
entry point.
bool
__isValidScalarValue(cp : i32) : bool 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.

Method detail

#__formatBinary

__formatBinary(value : i64, width : i32) : string

Binary text (no leading zeros, no 0b) of the low width bits of
value. The caller masks value to the unsigned interpretation it
wants; bit i is read as (value >> i) & 1, which is correct for
i < width regardless of the shift's sign behaviour.

Parameters
value bit pattern to render, low width bits significant
width number of low bits to render

#__formatHex

__formatHex(value : i64, nibbles : i32) : string

Lowercase hex text (no leading zeros) of the low nibbles * 4 bits
of value.

Parameters
value bit pattern to render, low nibbles * 4 bits significant
nibbles number of 4-bit hex digits to render

#__formatOctal

__formatOctal(value : i64, groups : i32) : string

Octal text (no leading zeros) of the low groups * 3 bits of
value.

Parameters
value bit pattern to render, low groups * 3 bits significant
groups number of 3-bit octal digits to render

#__i32ToHex

__i32ToHex(v : i32) : string

v.toHex() — lowercase hex text of v's unsigned 32-bit interpretation.

Parameters
v i32 to render, read as unsigned 32-bit

#__i32ToBin

__i32ToBin(v : i32) : string

v.toBin() — binary text of v's unsigned 32-bit interpretation
(no 0b).

Parameters
v i32 to render, read as unsigned 32-bit

#__i32ToOct

__i32ToOct(v : i32) : string

v.toOct() — octal text of v's unsigned 32-bit interpretation.

Parameters
v i32 to render, read as unsigned 32-bit

#__i64ToHex

__i64ToHex(v : i64) : string

v.toHex() — lowercase hex text of v's unsigned 64-bit interpretation.

Parameters
v i64 to render, read as unsigned 64-bit

#__i64ToBin

__i64ToBin(v : i64) : string

v.toBin() — binary text of v's unsigned 64-bit interpretation
(no 0b).

Parameters
v i64 to render, read as unsigned 64-bit

#__parseRadix

__parseRadix(s : string, base : i32) : i64 ! ParseException

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.

Parameters
s text to parse, optional leading + / - then digits
base radix, 2..=36

#parseI32Base

parseI32Base(s : string, base : i32) : i32 ! ParseException

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.

Parameters
s text to parse in the given radix
base radix, 2..=36

#parseI64Base

parseI64Base(s : string, base : i32) : i64 ! ParseException

Parse s in an arbitrary base (2..=36) as an i64.

Parameters
s text to parse in the given radix
base radix, 2..=36

#__charToI32

__charToI32(c : char) : i32

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).

Parameters
c char whose codepoint is read out

#__i32ToCharUnchecked

__i32ToCharUnchecked(cp : i32) : char

The char whose codepoint is cp, with no scalar-value
validation — private helper for call sites that already proved
cp is a valid Unicode scalar value (e.g. read back from a real
string's charAt). [Char::fromI32] is the validating public
entry point.

Parameters
cp codepoint to reinterpret as a char

#__isValidScalarValue

__isValidScalarValue(cp : i32) : bool

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.

Parameters
cp candidate codepoint

C class Float

Static-utility facade for f32. f32 is not part of the primitive-
receiver gate (hir_builder::…::calls::method) that admits
i32 / 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

Method detail

#parse

parse(s : string) : f32 ! ParseException

#toString

toString(v : f32) : string

#isNaN

isNaN(v : f32) : bool

#isInfinite

isInfinite(v : f32) : bool

#isFinite

isFinite(v : f32) : bool

#min

min() : f32

#max

max() : f32

#positiveInfinity

positiveInfinity() : f32

#negativeInfinity

negativeInfinity() : f32

#notANumber

notANumber() : f32

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-aware
string primitives (case fold, blank test) rather than
re-implementing Unicode classification.

Methods

Method detail

#toI32

toI32(c : char) : i32

#fromI32

fromI32(cp : i32) : char ! IllegalArgumentException

#parse

parse(s : string) : char ! ParseException

#toString

toString(c : char) : string

#min

min() : char

#max

max() : char

#isDigit

isDigit(c : char) : bool

#isWhitespace

isWhitespace(c : char) : bool

#toUpperCase

toUpperCase(c : char) : char

#toLowerCase

toLowerCase(c : char) : char