Self-hosted compiler (selfhost/*.ludic), runtime, examples, editor tooling, and docs. Phase 1 of the syntax-redesign cohesion pass has landed: edge-system fix, signature-query, when-alias, and the documentation truth-pass. Suite green (14/14), C-free bootstrap fixpoint holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
22 lines
561 B
Text
22 lines
561 B
Text
# io.ludic — reading the input file and writing the output, plus tiny stdio.
|
|
# The compiler reads one .ludic file whole and emits LLVM IR text to stdout.
|
|
|
|
fn read_file(path: str) -> ptr {
|
|
let f = file_open(path, "rb")
|
|
if ptr_is_null(f) { return ptr_null() }
|
|
file_seek(f, 0, 2)
|
|
let n = file_tell(f)
|
|
file_seek(f, 0, 0)
|
|
let buf = mem_alloc(n + 1)
|
|
file_read(f, buf, n)
|
|
poke8(buf, n, 0)
|
|
file_close(f)
|
|
return buf
|
|
}
|
|
|
|
# length of a NUL-terminated buffer
|
|
fn cstr_len(s: ptr) -> int {
|
|
let n = 0
|
|
while peek8(s, n) != 0 { n = n + 1 }
|
|
return n
|
|
}
|