compiler/shared/l0/stdlib/sys/rt.l0

Module sys.rt

Overview Symbols grouped by source file: compiler/shared/l0/stdlib/sys/rt.l0

Module: sys.rt

Source: compiler/shared/l0/stdlib/sys/rt.l0 Language: Dea/L0

Symbols

Function rt_string_get

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

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

extern func rt_strlen(str: string) -> int

Return the length of the string.

Parameters:

  • str: The string.

Returns: The length.

Function rt_string_equals

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

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

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

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

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

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

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

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

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

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

extern func rt_flush_stdout() -> void

Flush the standard output buffer.

Function rt_flush_stderr

extern func rt_flush_stderr() -> void

Flush the standard error buffer.

Function rt_print

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

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

extern func rt_println() -> void

Print a newline to standard output.

Function rt_println_stderr

extern func rt_println_stderr() -> void

Print a newline to standard error.

Function rt_print_int

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

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

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

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

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

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

extern func rt_abort(message: string) -> void

Abort program execution with a message.

Parameters:

  • message: The abort message.

Function rt_exit

extern func rt_exit(code: int) -> void

Exit the program with the provided code.

Parameters:

  • code: The exit code.

Function rt_srand

extern func rt_srand(seed: int) -> void

Seed the runtime random number generator.

Parameters:

  • seed: The integer seed.

Function rt_rand

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

extern func rt_errno() -> int

Get the last runtime error number.

Returns: The errno value.

Function rt_get_env_var

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

extern func rt_get_argc() -> int

Get the number of command-line arguments.

Returns: The argc value.

Function rt_get_pid

extern func rt_get_pid() -> int

Get the current process identifier.

Returns: The process identifier.

Function rt_get_argv

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

extern func rt_time_unix(out: RtTimeParts*) -> bool

Capture current unix wall time into out .

Parameters:

Returns: True on success, false otherwise.

Function rt_time_monotonic

extern func rt_time_monotonic(out: RtTimeParts*) -> bool

Capture monotonic time into out .

Parameters:

Returns: True on success, false otherwise.

Function rt_time_monotonic_supported

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

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

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

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

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

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

sec: int

RtTimeParts Field nsec

nsec: int

Struct RtFileInfo

Represents basic file metadata used by bootstrap tooling.

RtFileInfo Field exists

exists: bool

RtFileInfo Field is_file

is_file: bool

RtFileInfo Field is_dir

is_dir: bool

RtFileInfo Field size

size: int?

RtFileInfo Field mtime_sec

mtime_sec: int?

RtFileInfo Field mtime_nsec

mtime_nsec: int?