# 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: string) -> 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 = n + 1 } return n }