Merge commit '37338cb' into lang/foundations (itoa of INT_MIN: a 2^31 hex literal in 32-bit arithmetic kept its value); reseeded, bootstrap-cfree fixpoint holds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 22:09:09 +03:00
commit 847048825a
5 changed files with 5548 additions and 5515 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -20,12 +20,19 @@ function str_starts(s: pointer, prefix: pointer) -> bool {
# integer -> fresh decimal string
function itoa(v: int) -> pointer {
if v == 0 { let z = bytes(2); z[0] = '0'; z[1] = 0; return z }
var neg = false
# digits are taken off v as it is, never off -v: the most negative int has no positive twin, and
# -v overflowed back to itself, so a 0x80000000 in an i32 was emitted as a bare "-"
let neg = v < 0
var x = v
if x < 0 { neg = true; x = -x }
let tmp = bytes(16)
let tmp = bytes(24)
var n = 0
while x > 0 { tmp[n] = 48 + x % 10; x /= 10; n += 1 }
while x != 0 {
var d = x % 10
if d < 0 { d = -d }
tmp[n] = 48 + d
x /= 10
n += 1
}
var total = n
if neg { total += 1 }
let out = bytes(total + 1)