rt.l0
Module: sys.rt
Source: compiler/shared/l0/stdlib/sys/rt.l0 Language: Dea/L0
Symbols
- rt_string_get
- rt_string_bytes_ptr
- rt_strlen
- rt_string_equals
- rt_string_compare
- rt_string_concat
- rt_string_slice
- rt_string_from_byte_array
- rt_string_from_byte
- rt_string_retain
- rt_string_release
- rt_read_file_all
- rt_write_file_all
- rt_flush_stdout
- rt_flush_stderr
- rt_print
- rt_print_stderr
- rt_println
- rt_println_stderr
- rt_print_int
- rt_print_int_stderr
- rt_print_bool
- rt_print_bool_stderr
- rt_read_line
- rt_read_char
- rt_abort
- rt_exit
- rt_srand
- rt_rand
- rt_errno
- rt_get_env_var
- rt_get_argc
- rt_get_pid
- rt_get_argv
- rt_time_unix
- rt_time_monotonic
- rt_time_monotonic_supported
- rt_time_local_offset_sec
- rt_time_local_is_dst
- rt_system
- rt_file_info
- rt_delete_file
- RtTimeParts
- RtFileInfo
Function rt_string_get
1
extern func rt_string_get(s: string, index: int) -> byte
Return the character at the given index in the string as a byte (0-255).
Parameters:
s: The string.index: The index.
Returns: The character byte.
Function rt_string_bytes_ptr
1
extern func rt_string_bytes_ptr(s: string) -> byte*
Return a pointer to the raw byte data of a string.
Parameters:
s: The string.
Returns: Pointer to the first byte.
Function rt_strlen
1
extern func rt_strlen(str: string) -> int
Return the length of the string.
Parameters:
str: The string.
Returns: The length.
Function rt_string_equals
1
extern func rt_string_equals(a: string, b: string) -> bool
Return whether two strings are equal.
Parameters:
a: The first string.b: The second string.
Returns: True if equal, false otherwise.
Function rt_string_compare
1
extern func rt_string_compare(a: string, b: string) -> int
Compare two strings lexicographically.
Parameters:
a: The first string.b: The second string.
Returns: A negative value if a < b, zero if a == b, positive if a > b.
Function rt_string_concat
1
extern func rt_string_concat(a: string, b: string) -> string
Concatenate two strings and return the result.
Parameters:
a: The first string.b: The second string.
Returns: The combined string.
Function rt_string_slice
1
extern func rt_string_slice(s: string, start: int, end: int) -> string
Return a slice of the string from start to end (exclusive).
Parameters:
s: The string.start: The starting index.end: The ending index.
Returns: The string slice.
Function rt_string_from_byte_array
1
extern func rt_string_from_byte_array(bytes: byte*, len: int) -> string
Create a string from a byte array of given length.
Parameters:
bytes: The pointer to the byte array.len: The length of the array.
Returns: New string containing the provided bytes.
Function rt_string_from_byte
1
extern func rt_string_from_byte(b: byte) -> string
Create a string from a single byte value.
Parameters:
b: The byte value.
Returns: A string containing the byte.
Function rt_string_retain
1
extern func rt_string_retain(s: string) -> void
Increment reference count for heap strings.
No-op for static or non-reference-counted strings.
Parameters:
s: The string to retain.
Function rt_string_release
1
extern func rt_string_release(s: string) -> void
Decrement reference count for heap strings and free if count reaches zero.
No-op for static or non-reference-counted strings.
Parameters:
s: The string to release.
Function rt_read_file_all
1
extern func rt_read_file_all(path: string) -> string?
Read a file’s entire contents into a string.
Parameters:
path: The path to the file.
Returns: The file content, or null on error.
Function rt_write_file_all
1
extern func rt_write_file_all(path: string, data: string) -> bool
Write a string completely to a file.
Parameters:
path: The path to the file.data: The string content.
Returns: True on success, false otherwise.
Function rt_flush_stdout
1
extern func rt_flush_stdout() -> void
Flush the standard output buffer.
Function rt_flush_stderr
1
extern func rt_flush_stderr() -> void
Flush the standard error buffer.
Function rt_print
1
extern func rt_print(s: string) -> void
Print a string to standard output without newline.
Parameters:
s: The string to print.
Function rt_print_stderr
1
extern func rt_print_stderr(s: string) -> void
Print a string to standard error without newline.
Parameters:
s: The string to print.
Function rt_println
1
extern func rt_println() -> void
Print a newline to standard output.
Function rt_println_stderr
1
extern func rt_println_stderr() -> void
Print a newline to standard error.
Function rt_print_int
1
extern func rt_print_int(x: int) -> void
Print an integer to standard output.
Parameters:
x: The integer to print.
Function rt_print_int_stderr
1
extern func rt_print_int_stderr(x: int) -> void
Print an integer to standard error.
Parameters:
x: The integer to print.
Function rt_print_bool
1
extern func rt_print_bool(x: bool) -> void
Print a boolean to standard output.
Parameters:
x: The boolean to print.
Function rt_print_bool_stderr
1
extern func rt_print_bool_stderr(x: bool) -> void
Print a boolean to standard error.
Parameters:
x: The boolean to print.
Function rt_read_line
1
extern func rt_read_line() -> string?
Read a line from standard input, returning null if EOF.
Returns: The line read, or null.
Function rt_read_char
1
extern func rt_read_char() -> int
Read a single character from standard input.
Returns: The character read as an integer, or -1 on EOF.
Function rt_abort
1
extern func rt_abort(message: string) -> void
Abort program execution with a message.
Parameters:
message: The abort message.
Function rt_exit
1
extern func rt_exit(code: int) -> void
Exit the program with the provided code.
Parameters:
code: The exit code.
Function rt_srand
1
extern func rt_srand(seed: int) -> void
Seed the runtime random number generator.
Parameters:
seed: The integer seed.
Function rt_rand
1
extern func rt_rand(max: int) -> int
Generate a random integer less than the given maximum.
Parameters:
max: The upper bound (exclusive).
Returns: A random integer.
Function rt_errno
1
extern func rt_errno() -> int
Get the last runtime error number.
Returns: The errno value.
Function rt_get_env_var
1
extern func rt_get_env_var(name: string) -> string?
Get the value of an environment variable, or null if not set.
Parameters:
name: The name of the environment variable.
Returns: The value of the variable, or null.
Function rt_get_argc
1
extern func rt_get_argc() -> int
Get the number of command-line arguments.
Returns: The argc value.
Function rt_get_pid
1
extern func rt_get_pid() -> int
Get the current process identifier.
Returns: The process identifier.
Function rt_get_argv
1
extern func rt_get_argv(i: int) -> string
Get the command-line argument at the given index.
Parameters:
i: The index.
Returns: The argument string.
Function rt_time_unix
1
extern func rt_time_unix(out: RtTimeParts*) -> bool
Capture current unix wall time into out .
Parameters:
out: Pointer to the RtTimeParts to fill.
Returns: True on success, false otherwise.
Function rt_time_monotonic
1
extern func rt_time_monotonic(out: RtTimeParts*) -> bool
Capture monotonic time into out .
Parameters:
out: Pointer to the RtTimeParts to fill.
Returns: True on success, false otherwise.
Function rt_time_monotonic_supported
1
extern func rt_time_monotonic_supported() -> bool
Returns true if monotonic clock is supported by the runtime.
Returns: True if supported.
Function rt_time_local_offset_sec
1
extern func rt_time_local_offset_sec(unix_sec: int) -> int?
Returns local UTC offset in seconds for the given unix second, or null on error.
Parameters:
unix_sec: The Unix timestamp in seconds.
Returns: The offset in seconds, or null.
Function rt_time_local_is_dst
1
extern func rt_time_local_is_dst(unix_sec: int) -> bool?
Returns whether local time is in DST for the given unix second, or null on error.
Parameters:
unix_sec: The Unix timestamp in seconds.
Returns: True if DST, false if not, or null.
Function rt_system
1
extern func rt_system(cmd: string) -> int
Execute a system command and return its normalized status code.
Parameters:
cmd: The command string to execute.
Returns: The command exit code, or a normalized signal-style status.
Function rt_file_info
1
extern func rt_file_info(path: string) -> RtFileInfo
Return basic metadata for a path.
Parameters:
path: The file-system path.
Returns: File metadata with nullable size and timestamp fields.
Function rt_delete_file
1
extern func rt_delete_file(path: string) -> bool
Delete the file at the given path, returning true on success.
Parameters:
path: The file path.
Returns: True if deleted, false otherwise.
Struct RtTimeParts
Represents components of wall or monotonic time.
RtTimeParts Field sec
1
sec: int
RtTimeParts Field nsec
1
nsec: int
Struct RtFileInfo
Represents basic file metadata used by bootstrap tooling.
RtFileInfo Field exists
1
exists: bool
RtFileInfo Field is_file
1
is_file: bool
RtFileInfo Field is_dir
1
is_dir: bool
RtFileInfo Field size
1
size: int?
RtFileInfo Field mtime_sec
1
mtime_sec: int?
RtFileInfo Field mtime_nsec
1
mtime_nsec: int?