Removed log from the standard library

This commit is contained in:
2025-02-22 18:02:50 +01:00
parent df782ae1cb
commit 467fbd9725
11 changed files with 38 additions and 41 deletions

25
lib/io/fmt.q Normal file
View File

@ -0,0 +1,25 @@
import mem
import sys
number(x int) {
buffer := mem.alloc(20)
address, count := itoa(x, buffer)
sys.write(1, address, count)
mem.free(buffer)
}
itoa(x int, buffer []byte) -> (*byte, int) {
end := buffer + len(buffer)
tmp := end
digit := 0
loop {
x, digit = x / 10
tmp -= 1
tmp[0] = '0' + digit
if x == 0 {
return tmp, end - tmp
}
}
}