selfhost/check/ walks every function, the entry, tests, globals' initializers and @On listeners with real scopes, and refuses mixed number kinds, text and numbers, two record types, mismatched slices and fn types, wrong argument counts, wrong returns and wrong push elements - every mix-up at once, each at its line. LUDIC_CHECK_REPORT=1 lists them by category. pointer stays untyped (L7's). What it found is fixed: render3d's HDR scan calling the float-bits extern f_lt with floats; ludic.shooter's right-stick aim overflowing past half a push; prof.ludic storing longs in []int; extern arguments now coerced to their parameters. Text-returning runtime functions say string; Assets.ready says bool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
556 B
Text
22 lines
556 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.
|
|
|
|
function read_file(path: pointer) -> pointer {
|
|
let f = file_open(path, "rb")
|
|
if (f == null) { return null }
|
|
file_seek(f, 0, 2)
|
|
let n = file_tell(f)
|
|
file_seek(f, 0, 0)
|
|
let buf = bytes(n + 1)
|
|
file_read(f, buf, n)
|
|
buf[n] = 0
|
|
file_close(f)
|
|
return buf
|
|
}
|
|
|
|
# length of a NUL-terminated buffer
|
|
function cstr_len(s: pointer) -> int {
|
|
var n = 0
|
|
while s[n] != 0 { n += 1 }
|
|
return n
|
|
}
|