Cyber API

v0.4-dev 482-830adda
core modules
std modules

mod core

const NullId = (1 << 32) - 1
fn @await_(fut &FutureValue[%T])
fn @bitCast(T type, x %S) -> T
fn @bitTrunc(T type, src Code) -> T
fn @call(func funcptr_t[%Sig], args &FnTuple[Sig]) -> Sig.ret()
fn @cmp(a Code, b Code) -> bool
Compare like a primitive.
fn @compute_int_max(T type) -> T
fn @compute_int_min(T type) -> T
fn @consume(a Code)
Consumes a local. Does not invoke destructor.
fn @copy(src Ptr[%T]) -> T
Generic copy for any type. Marked unsafe to allow copying borrow containers.
fn @copyStruct(T type, src_ptr Code) -> T
Marked unsafe to allow copying borrow containers.
fn @deinitObject[T Any](obj Ptr[void])
fn @destruct(T type, val Ptr[T])
Generic destructor for any type.
fn @destruct_span(span PtrSpan[%T])
fn @destructBox(ptr Ptr[void])
Exposed for VM.
fn @enumToInt(val %T) -> int
fn @eq(a &%T, b &T) -> bool
This is invoked for the comparison operator for non primitive types. Comparing references returns true if they refer to the same instance.
fn @floatToInt(F type, x Code) -> int
fn @freeObject(ref Ptr[void], size int)
fn @getDeinitObject(obj Ptr[void]) -> ?DeinitFn
Returns a function to release and destroy for a object runtime type. Returns `none` if the function is a no-op. Panics if the function could not be found.
fn @getTypeDtor(type_id int) -> ?DeinitFn
Returns `@destruct` for the given type.
fn @init_astr_undef(len int) -> str
fn @init_astr_undef(thread Thread, len int) -> str
fn @init_ustr_undef(len int) -> str
fn @init_ustr_undef(thread Thread, len int) -> str
fn @intToEnum(T type, val int) -> T
fn @intToEnumResult(T type, val int) -> !T
fn @intToFloat(F type, x Code) -> F
fn @isUniqueRef(ptr Ptr[void]) -> bool
fn @memByteEqs(a PtrSpan[byte], b PtrSpan[byte]) -> bool
fn @memcpy(dst Ptr[byte], src Ptr[byte], len int)
Assumes no-alias `dst` and `src` regions.
fn @memeq(a []%T, b []T) -> bool
fn @memEqs(a PtrSpan[%T], b PtrSpan[T]) -> bool
fn @memmove(dst Ptr[byte], src Ptr[byte], len int)
fn @memset(dst Ptr[byte], val Ptr[byte], val_len int, n int)
fn @new_object_undef(type_id int, nbytes int) -> Ptr[void]
fn @new_object_undef(thread Thread, type_id int, nbytes int) -> Ptr[void]
fn @new_shared_state() -> Ptr[byte]
fn @new_thread() -> Thread
fn @nop(label str)
Insert a nop IR with a label.
fn @notifyFutureComplete(f Future[%T])
fn @partial_destruct(T type, Layout PartialStructLayout, val Ptr[T])
Partial destructor.
fn @ptr_init(ptr Ptr[%T], value T)
fn @ref_addr(ref ^%T) -> int
fn @refCount(obj Object) -> int
Returns the current reference count of an object.
fn @releaseOnly(obj Ptr[void]) -> bool
fn @retain(obj Ptr[void])
fn @scope_ptr_to_borrow(scope_param str, ptr Ptr[%T]) -> &T
fn @send(dst Thread, src Ptr[%T]) -> T
fn @sext(T type, src Code) -> T
Sign extension.
fn @start_thread(thread Thread, entry funcptr_t[%EntrySig], func funcptr_t[%Sig], args_size int, args FnTuple[Sig], future ^FutureValue[Sig.ret()], ret_size int)
fn @thread_entry[Sig FuncSig](result_thread Thread, func funcptr_t[Sig], args FnTuple[Sig]) -> Sig.ret()
fn @trackMainLocal(name str, type_id int, addr Ptr[void])
fn @unsafeCast(T type, src Code) -> T
Casting without compatibility checking.
fn @zext(T type, src %S) -> T
Zero extension.
fn abort(err str) -> never
Terminate program with an error message.
fn alloc(T type) -> Ptr[T]
fn alloc(T type, n int) -> PtrSpan[T]
Unsafe. Allocate memory using the default allocator.
fn assert(pred bool)
fn assert(exp %T, act T)
fn atof(x str) -> float
fn atof32(x str) -> f32
fn AutoEq[K Any](a K, b K) -> bool
fn AutoHash[K Any](key K) -> int
fn binary_search(len int, needle %T, compare &OpaqueFunc[CompareIndexFn[T]]) -> ?int
Assumes a sorted span in ascending order.
fn binary_search_lower(len int, needle %T, compare &OpaqueFunc[CompareIndexFn[T]]) -> int
Assumes a sorted span in ascending order. Returns the lowest index where the element at the index is greater than or equal to the needle. If no such element exists, the index after the last element is returned.
fn dump(val %T) -> str
Deep dump of a value.
fn eprint(x %T)
Prints a value to the error stream.
fn eprints(x %T)
fn f32_fmt(x f32) -> str
fn f32_to_f64(x f32) -> float
fn f64_fmt(x float) -> str
fn f64_to_f32(x float) -> f32
fn float_pow(x, y float) -> float
fn float_pow32(x, y float) -> f32
fn free(ptr Ptr[void])
Unsafe. Frees memory allocated by the default allocator.
fn int_fmt(x int, format NumberFormat) -> str
fn log(x %T)
Logs a value to the host. Thread-safe.
fn max(a %T, b T) -> T
Returns the largest of two values.
fn min(a %T, b T) -> T
Returns the smallest of two values.
fn new_slice_buffer(T type, cap int) -> ^RawBuffer[byte]
fn panic(msg str) -> never
Builds a stack trace and aborts the current thread.
fn panic_unwrap_error(err error) -> never
fn print(x %T)
Prints a value to the output stream. Not thread-safe.
fn prints(x %T)
fn raw_fmt(x r64, format NumberFormat) -> str
fn Result_unwrap(T type, res Code) -> T
fn spawn(func funcptr_t[%Sig], args FnTuple[Sig]) -> Future[Sig.ret()]
fn splitmix64_hash(x_ int) -> int
fn to_print_string(x %T) -> str
fn utf8Check(s Ptr[byte], remaining int) -> bool
Source: https://github.com/sheredom/utf8.h
fn utf8Decode(s Ptr[byte]) -> r32
fn utf8SeqLen(first byte) -> int
type AcquireBorrowKind enum:
  case acquired
  case borrowed
  case ex_borrowed
type Any _
type Array[T Any] struct
    with NoCopy, AsSpan[T]
A dynamically sized data structure that contains a sequence of elements. Can be cloned or sliced into mutable spans. Any operation that resizes the array requires an exclusive borrow.
fn Array[] :: @init(n int, val T) -> Self
Creates an array with initial length and capacity of `n` and values set to `val`.
fn Array[] :: @init_sequence(init [&]T) -> Self
fn (&Array[]) @acquire_borrow() -> AcquireBorrowKind
fn (&Array[]) @acquire_ex_borrow() -> bool
fn (&Array[]) @deinit()
fn (&Array[]) @index(idx int) -> T
fn (scope &Array[]) @index_addr(idx int) -> scope &T
fn (&Array[]) @release_borrow()
fn (&Array[]) @release_ex_borrow()
fn (&Array[]) @set_index(idx int, val T)
fn (scope &Array[]) @slice() -> scope [&]T
fn (scope &Array[]) @slice(start int) -> scope [&]T
fn (scope &Array[]) @slice(start int, end int) -> scope [&]T
fn (&&Array[]) `<<`(val T)
Alias for `append`.
fn (&&Array[]) `<<`(span [&]T)
Alias for `append`.
fn (&&Array[]) `<<`(arr AsSpan[T])
Alias for `append`.
fn (&&Array[]) append(val T)
Appends a value to the end of the array.
fn (&&Array[]) append(span [&]T)
Appends the elements of a span to the end of this array.
fn (&&Array[]) append(arr AsSpan[T])
Appends the elements of a `AsSpan` to the end of this array.
fn (Array[]) as_buffer() -> Buffer[T]
fn (&Array[]) cap() -> int
fn (&&Array[]) clear()
fn (&Array[]) clone() -> Self
fn (&Array[]) contains(needle T) -> bool
fn (&&Array[]) ensure_cap(new_cap int)
fn (&&Array[]) ensureUnusedCap(unused int)
fn (&Array[]) index(needle T) -> ?int
Returns the first index of `needle` in the array or `none` if not found.
fn (&&Array[]) insert(idx int, val T)
Inserts a value at index `idx`.
fn (&Array[]) iterator() -> int
Returns a new iterator over the slice elements.
fn (&Array[]) join(sep str) -> str
Returns a new string that joins the elements with `separator`.
fn (&Array[]) last() -> T
fn (&Array[]) len() -> int
fn (&Array[]) next(idx &int) -> ?T
fn (&Array[]) own_msb() -> int
fn (&&Array[]) remove(idx int)
Removes an element at index `idx`.
fn (&Array[]) setLast(val T) -> void
fn (&&Array[]) size_down(new_len int)
Decreases the size of the array to `new_len` elements. If the new size is smaller, elements at the end of the array are removed.
fn (&&Array[]) size_up(new_len int, init T)
Increases the size of the array to `new_len` elements. If the new size is bigger, `init` values are appended to the array.
fn (&Array[]) sort(less &OpaqueFunc[LessFn[T]])
Sorts the array with the given `less` function. If element `a` should be ordered before `b`, the function should return `true` otherwise `false`.
fn (scope &Array[]) span() -> scope [&]T
type ArrayStore[T Any] struct
    with NoCopy
A dynamically sized data structure that contains a sequence of elements. Meant for storing and retrieving small value types such as primitives and references. Cannot be sliced and does not allow referencing to the elements. These constraints allow resizing operations without an exclusive borrow.
fn ArrayStore[] :: @init_sequence(init [&]T) -> Self
fn (&ArrayStore[]) @deinit()
fn (&ArrayStore[]) @index(idx int) -> T
fn (&ArrayStore[]) @set_index(idx int, val T)
fn (&ArrayStore[]) `<<`(val T)
Alias for `append`.
fn (&ArrayStore[]) `<<`(arr AsSpan[T])
Alias for `append`.
fn (&ArrayStore[]) append(val T)
Appends a value to the end of the array.
fn (&ArrayStore[]) append(slice [&]T)
Appends the elements of a `Span` to the end of this `ArrayStore`.
fn (&ArrayStore[]) append(arr AsSpan[T])
Appends the elements of a `AsSpan` to the end of this `ArrayStore`.
fn (&ArrayStore[]) ensure_cap(new_cap int)
fn (&ArrayStore[]) len() -> int
type AsSpan[T Any] trait
fn span() -> scope [&]T
type bool _
fn bool :: @init(val int) -> bool
fn bool :: @init(val float) -> bool
fn bool :: @init(val str) -> bool
fn (bool) `!`() -> bool
type Borrow[T Any] _
type Buffer[T Any] struct
    with NoCopy, AsSpan[T]
A data structure that holds sequential elements up to a maximum capacity. `len()` indicates which elements are initialized. `cap()` is the total number of elements the buffer can hold.
fn Buffer[] :: @init(nelems int) -> Self
fn Buffer[] :: @init(n int, value T) -> Self
fn Buffer[] :: @init_sequence(init [&]T) -> Self
fn (&Buffer[]) @acquire_borrow() -> AcquireBorrowKind
fn (&Buffer[]) @acquire_ex_borrow() -> bool
fn (&Buffer[]) @deinit()
fn (scope &Buffer[]) @index_addr(idx int) -> scope &T
fn (&Buffer[]) @release_borrow()
fn (&Buffer[]) @release_ex_borrow()
fn (scope &Buffer[]) @slice() -> scope [&]T
fn (scope &Buffer[]) @slice(start int) -> scope [&]T
fn (scope &Buffer[]) @slice(start int, end int) -> scope [&]T
fn (&&Buffer[]) `<<`(elem T)
fn (&Buffer[]) cap() -> int
fn (&Buffer[]) iterator() -> int
fn (&Buffer[]) last() -> T
fn (&Buffer[]) len() -> int
fn (&Buffer[]) next(idx &int) -> ?T
fn (&&Buffer[]) size_down(new_len int)
Decreases the size of the Buffer to `new_len` elements. If the new size is smaller, elements at the end of the Buffer are removed.
fn (scope &Buffer[]) span() -> scope [&]T
type byte = Raw[8]
type ClosureData struct
type Code = meta.Code
type CompareIndexFn[Context Any] = fn(cx Context, idx int) -> CompareOrder
type CompareOrder enum:
  case eq
  case lt
  case gt
type Const trait
An implicit trait that conforms to a const eligible type.
fn Const :: @predicate(T type) -> bool
type ConstSpan[T Const] struct
TODO: A `ConstSpan` behaves like a `Span` except it can only perform read operations. The element type `T` is restricted to be a const eligible type.
type Copyable trait
An implicit trait that describes a type that allows implicit copying. A type is `Copyable` if these two conditions are met: 1. All its members are `Copyable` or the `@copy` method is implemented. 2. The type does not also implement `NoCopy`.
fn Copyable :: @predicate(T type) -> bool
type DeinitFn = fn(Ptr[void]) -> void
type dependent _
type Dyn[T Any] _
Wraps generic traits for dynamic dispatch. `Dyn` is an opaque type.
type Endian enum:
  case little
  case big
type EqFn[T Any] = fnsym(T, T) -> bool
type error _
fn error :: @init(val symbol) -> error
Create an error from symbol.
fn (error) sym() -> symbol
Return the underlying `symbol`.
type Ex[T Any] struct
Exclusive borrow container. Allows exclusive borrowing to a child `T` in a shared reference `^Ex[T]`. Defers borrow checking to runtime.
fn (&Ex[]) borrow() -> RtBorrow[T]
fn (&Ex[]) ex_borrow() -> RtExBorrow[T]
type ExBorrow[T Any] _
type ExDefaultInner[T Any] struct
type ExInner[T Any] const
type f32 = Float[32]
type f64 = Float[64]
type float = Float[64]
type Float[Bits int_lit] _
fn Float[] :: @init(x Self) -> Self
fn Float[] :: @init(x int) -> Self
fn Float[] :: @init(x %T) -> Self
fn (Float[]) `%`(right Self) -> Self
fn (Float[]) `**`(right Self) -> Self
fn (Float[]) `*`(right Self) -> Self
fn (Float[]) `+`(right Self) -> Self
fn (Float[]) `-`() -> Self
fn (Float[]) `-`(right Self) -> Self
fn (Float[]) `/`(right Self) -> Self
fn (Float[]) `<=`(right Self) -> bool
fn (Float[]) `<`(right Self) -> bool
fn (Float[]) `>=`(right Self) -> bool
fn (Float[]) `>`(right Self) -> bool
fn (Float[]) abs() -> Self
fn (Float[]) fmt() -> str
type FnTuple[Sig FuncSig] const
type Func[SIG Any] _
Function union. Requires a `funcptr_t` parameter. Can contain static functions or closures.
fn (Func[]) @size() -> int
type funcptr_t[SIG FuncSig] _
Function pointer.
type FuncSig _
fn (FuncSig) num_params() -> int
fn (FuncSig) param_at(i int) -> meta.FuncParam
fn (FuncSig) ret() -> type
type funcsym_t[SIG FuncSig] _
type Future[T Any] struct
fn Future :: @init(T type) -> Future[T]
fn Future :: complete(val %T) -> Future[T]
Returns a `Future[T]` that has a completed value.
fn (&Future[]) await() -> T
type FutureResolver[T Any] struct
fn FutureResolver :: new(T type) -> FutureResolver[T]
fn (&FutureResolver[]) complete(val T)
fn (&FutureResolver[]) future() -> Future[T]
type FutureValue[T Any] struct
type Generator[FnPtr Any] struct
A generator is a stackless coroutine that can `yield` values back to the dispatcher. For an isolated execution context, consider using threads.
fn (&Generator[]) @deinit()
fn (&Generator[]) @size() -> int
fn (&Generator[]) deinit()
fn (&Generator[]) end()
fn (&Generator[]) next() -> ?(type.fn_ret(FnPtr))
fn (&Generator[]) status() -> GeneratorStatus
type GeneratorStatus enum:
  case paused
  case running
  case done
type GenericVector[T Any] _
type HashFn[T Any] = fnsym(T) -> int
type HashMap[K Any, V Any, HASH HashFn[K], EQ EqFn[K]] struct
    with NoCopy
Generic hash map implemented with open addressing and linear probing.
fn HashMap[] :: @init_record(pairs [&]Pair[K, V]) -> Self
const HashMap :: LoadFactor = 75
fn (&HashMap[]) @deinit()
fn (&HashMap[]) @index(key K) -> V
fn (&HashMap[]) @set_index(key K, val V)
fn (&HashMap[]) clear()
fn (&HashMap[]) contains(key K) -> bool
Returns whether there is a value mapped to `key`.
fn (&HashMap[]) findSlot(key K) -> int
Returns -1 if not found.
fn (&HashMap[]) get(key K) -> ?V
Returns value mapped to `key` or returns `none`.
fn (&HashMap[]) grow()
fn (&HashMap[]) iterator() -> int
Iterates over the map elements.
fn (&HashMap[]) keys() -> []K
fn (&HashMap[]) next(idx &int) -> ?MapEntry[K, V]
fn (&HashMap[]) remove(key K)
Removes the element with the given key `key` or panic.
fn (&HashMap[]) resize(new_cap int)
Perform rehashing.
fn (&HashMap[]) set(key K, val V)
fn (&HashMap[]) size() -> int
fn (&HashMap[]) try_remove(key K) -> bool
Removes the element with the given key `key`.
type i16 = Int[16]
type i32 = Int[32]
type i64 = Int[64]
type i8 = Int[8]
type Infer _
type int = Int[64]
type Int[Bits int_lit] _
A two's complement signed integer for bit widths: 8, 16, 32, and 64.
fn Int[] :: @init(x Self) -> Self
fn Int[] :: @init(x %T) -> Self
fn Int[] :: decode(ptr Ptr[byte]) -> Self
fn Int[] :: decode(ptr Ptr[byte], endian Endian) -> Self
Returns the integer value starting from the pointer with the given endian.
const Int[] :: max = @compute_int_max(Self)
const Int[] :: min = @compute_int_min(Self)
fn Int[] :: parse(s str) -> !Self
const Int[] :: umax Self = -1
const Int[] :: umin Self = 0
fn Int[] :: unsigned(x %T) -> Self
fn (Int[]) `%`(right Self) -> Self
fn (Int[]) `&&`(right Self) -> Self
fn (Int[]) `**`(e Self) -> Self
fn (Int[]) `*`(right Self) -> Self
fn (Int[]) `+`(right Self) -> Self
fn (Int[]) `-`() -> Self
fn (Int[]) `-`(right Self) -> Self
fn (Int[]) `/`(right Self) -> Self
fn (Int[]) `<<`(right Self) -> Self
fn (Int[]) `<=`(right Self) -> bool
fn (Int[]) `<`(right Self) -> bool
fn (Int[]) `>=`(right Self) -> bool
fn (Int[]) `>>`(right Self) -> Self
fn (Int[]) `>`(right Self) -> bool
fn (Int[]) `||`(right Self) -> Self
fn (Int[]) `~`() -> Self
fn (Int[]) `~`(right Self) -> Self
fn (Int[]) asr(right Self) -> Self
fn (Int[]) fmt() -> str
fn (Int[]) fmt(format NumberFormat) -> str
Formats the integer using a NumberFormat.
fn (Int[]) udiv(right Self) -> Self
fn (Int[]) ufmt() -> str
fn (Int[]) ufmt(format NumberFormat) -> str
Formats the integer (interpreted as unsigned) using a NumberFormat.
fn (Int[]) uge(right Self) -> bool
fn (Int[]) ugt(right Self) -> bool
fn (Int[]) ule(right Self) -> bool
fn (Int[]) ult(right Self) -> bool
fn (Int[]) umod(right Self) -> Self
fn (Int[]) umul(right Self) -> Self
type int_lit _
type LessFn[T Any] = fn(T, T) -> bool
type Map[K Any, V Any] struct
fn Map[] :: @init_record(pairs [&]Pair[K, V]) -> Self
fn (&Map[]) @index(key K) -> V
fn (&Map[]) @set_index(key K, val V)
fn (&Map[]) clear()
fn (&Map[]) contains(key K) -> bool
fn (&Map[]) get(key K) -> ?V
fn (&Map[]) iterator() -> int
fn (&Map[]) keys() -> []K
fn (&Map[]) next(idx &int) -> ?MapEntry[K, V]
fn (&Map[]) remove(key K)
fn (&Map[]) set(key K, val V)
fn (&Map[]) size() -> int
fn (&Map[]) try_remove(key K) -> bool
type MapEntry[K Any, V Any] struct
type never _
type NoCopy trait
Describes a type that forbids implicit copying disregarding whether the type is implicitly `Copyable`.
type NumberFormat enum:
  case ch
  case bin
  case dec
  case hex
  case oct
type NumberFormatConfig struct
type Object struct
fn Object :: @init(ref ^%T) -> Object
fn (&Object) @copy() -> Self
fn (&Object) @deinit()
fn (&Object) downcast(Ref type) -> Ref
fn (&Object) toString() -> str
fn (&Object) type() -> int
type OpaqueFunc[SIG Any] _
Opaque function union. Cannot be moved or copied. These constraints allow it to contain a pinned closure which can capture locals as well as references. A `Func` can be implicitly converted to an `OpaqueFunc`.
fn (OpaqueFunc[]) @size() -> int
type Option[T Any] _
fn Option[] :: @init(x Self) -> Self
type Pair[K Any, V Any] struct
type PartialStructLayout = meta.PartialStructLayout
type PartialVector[T Any, N int] _
fn (scope &PartialVector[]) @index_addr(idx int) -> scope &T
fn (&PartialVector[]) `<<`(x T)
Alias for `append`.
fn (&PartialVector[]) append(x T)
fn (&PartialVector[]) len() -> int
Returns the number of elements in the partial array.
fn (&PartialVector[]) setLength(len int)
type Ptr[T Any] _
Unsafe pointer type. NOTE: Should not have any regular methods because they could shadow child methods.
fn (Ptr[]) @index_addr(idx int) -> Ptr[T]
fn (Ptr[]) @slice(start int, end int) -> PtrSpan[T]
fn (Ptr[]) `+`(offset int) -> Ptr[T]
fn (Ptr[]) `-`(right Self) -> int
fn (Ptr[]) `<`(right Self) -> bool
type PtrSpan[T Any] struct
    with AsSpan[T]
fn (&PtrSpan[]) @index_addr(idx int) -> Ptr[T]
fn (&PtrSpan[]) @set_index(idx int, val T)
fn (&PtrSpan[]) @slice(start int) -> PtrSpan[T]
fn (&PtrSpan[]) @slice(start int, end int) -> PtrSpan[T]
fn (&PtrSpan[]) ends_with(suffix PtrSpan[T]) -> bool
Returns whether the array ends with `suffix`.
fn (&PtrSpan[]) index(needle T) -> ?int
Returns the first index of `needle` in the slice or `none` if not found.
fn (&PtrSpan[]) init(o Self)
fn (&PtrSpan[]) init(val T)
fn (&PtrSpan[]) iterator() -> int
fn (&PtrSpan[]) len() -> int
fn (&PtrSpan[]) next(idx &int) -> ?T
fn (&PtrSpan[]) set(o Self)
fn (&PtrSpan[]) set(val T)
fn (&PtrSpan[]) set_backwards(o Self)
fn (&PtrSpan[]) span() -> [&]T
fn (&PtrSpan[]) starts_with(target PtrSpan[T]) -> bool
Returns whether the `PtrSpan` starts with `target`.
fn (&PtrSpan[]) toBytes() -> PtrSpan[byte]
type r16 = Raw[16]
type r32 = Raw[32]
type r64 = Raw[64]
type r8 = Raw[8]
type Range struct
type Raw[Bits int_lit] _
Represents a raw integer value with bits of widths 8, 16, 32, or 64.
fn Raw[] :: @init(x Self) -> Self
fn Raw[] :: @init(x %T) -> Self
const Raw[] :: ones Self = ~0
const Raw[] :: zero Self = 0
fn (Raw[]) `%`(right Self) -> Self
fn (Raw[]) `&&`(right Self) -> Self
fn (Raw[]) `*`(right Self) -> Self
fn (Raw[]) `+`(right Self) -> Self
fn (Raw[]) `-`(right Self) -> Self
fn (Raw[]) `/`(right Self) -> Self
fn (Raw[]) `<<`(right Self) -> Self
fn (Raw[]) `<=`(right Self) -> bool
fn (Raw[]) `<`(right Self) -> bool
fn (Raw[]) `>=`(right Self) -> bool
fn (Raw[]) `>>`(right Self) -> Self
fn (Raw[]) `>`(right Self) -> bool
fn (Raw[]) `||`(right Self) -> Self
fn (Raw[]) `~`() -> Self
fn (Raw[]) `~`(right Self) -> Self
fn (Raw[]) fmt() -> str
fn (Raw[]) fmt(format NumberFormat) -> str
Formats the integer (interpreted as unsigned) using a NumberFormat.
type RawBuffer[T Any] struct
Can only be created as an object. Unsafe because elements are not guaranteed to be initialized.
fn RawBuffer[] :: @init(nelems int) -> ^Self
fn (&RawBuffer[]) @deinit()
fn (&RawBuffer[]) @size() -> int
fn (&RawBuffer[]) elems() -> PtrSpan[T]
fn (&RawBuffer[]) elems_ptr() -> Ptr[T]
fn (&RawBuffer[]) len() -> int
type Ref[T Any] _
type RefChild[P Any, T Any] struct
type Result[T Any] _
fn Result[] :: @init(x Self) -> Self
fn (&Result[]) unwrap() -> T
Returns the Result's successful value case or panics.
fn (&Result[]) unwrapError() -> error
Returns the Result's error case or panics.
type RtBorrow[T Any] struct
fn (&RtBorrow[]) @deinit()
type RtExBorrow[T Any] struct
fn (&RtExBorrow[]) @deinit()
type Slice[T Any] struct
    with AsSpan[T]
A dynamically sized data structure that contains a sequence of elements. Two copies initially point to the same element buffer and allow read/write to the elements. However, any resize operation on a slice that is shared results in a clone of the underlying buffer. Any resize operation on a sub-slice clones the underlying buffer regardless if it's shared.
fn Slice[] :: @init(n int, val T) -> Self
Creates a `Slice` with initial length and capacity of `n` and values set to `val`.
fn Slice[] :: @init_sequence(init [&]T) -> Self
fn (&Slice[]) @deinit()
fn (&Slice[]) @index(idx int) -> T
fn (scope &Slice[]) @index_addr(idx int) -> scope &T
fn (&Slice[]) @set_index(idx int, val T)
fn (&Slice[]) @slice() -> []T
fn (&Slice[]) @slice(start int) -> []T
fn (&Slice[]) @slice(start int, end int) -> []T
fn (&Slice[]) `<<`(val T) -> Self
Alias for `append`.
fn (&Slice[]) `<<`(slice [&]T) -> Self
Alias for `append`.
fn (&Slice[]) `<<`(arr AsSpan[T]) -> Self
Alias for `append`.
fn (&Slice[]) append(val T) -> Self
Appends a value to the end of the `Slice`.
fn (&Slice[]) append(span [&]T) -> Self
Appends the elements of a `Span` to the end of this `Slice`.
fn (&Slice[]) append(arr AsSpan[T]) -> Self
Appends the elements of a `AsSpan` to the end of this array.
fn (&Slice[]) as_ptr_span() -> PtrSpan[byte]
fn (&Slice[]) clear() -> Self
fn (&Slice[]) clone_on_resize(new_cap int) -> Self
fn (&Slice[]) contains(needle T) -> bool
fn (&Slice[]) index(needle T) -> ?int
Returns the first index of `needle` in the array or `none` if not found.
fn (&Slice[]) insert(idx int, val T) -> Self
Inserts a value at index `idx`.
fn (&Slice[]) iterator() -> int
Returns a new iterator over the slice elements.
fn (&Slice[]) join(sep str) -> str
Returns a new string that joins the elements with `separator`.
fn (&Slice[]) last() -> T
fn (&Slice[]) len() -> int
fn (&Slice[]) next(idx &int) -> ?T
fn (&Slice[]) remove(idx int) -> Self
Removes an element at index `idx`.
fn (&Slice[]) set(o Self)
fn (&Slice[]) set_last(val T) -> void
fn (&Slice[]) size_down(new_len int) -> Self
Decreases the size of the `Slice` to `new_len` elements. If the new size is smaller, elements at the end of the `Slice` are removed.
fn (&Slice[]) size_up(new_len int, init T) -> Self
Increases the size of the `Slice` to `new_len` elements. If the new size is bigger, `init` values are appended to the `Slice`.
fn (&Slice[]) sort(less &OpaqueFunc[LessFn[T]])
Sorts the array with the given `less` function. If element `a` should be ordered before `b`, the function should return `true` otherwise `false`.
fn (scope &Slice[]) span() -> scope [&]T
type Span[T Any] struct
    with AsSpan[T]
A `Span` is a borrowed view over a sequence of elements. It can also be denoted as `[&]T` where `T` is the element type.
fn Span[] :: @init_sequence(scope span [&]T) -> scope [&]T
fn (&Span[]) @index_addr(idx int) -> Ptr[T]
fn (scope &Span[]) @slice() -> scope [&]T
fn (scope &Span[]) @slice(start int) -> scope [&]T
fn (scope &Span[]) @slice(start int, end int) -> scope [&]T
fn (&Span[]) `==`(o Self) -> bool
fn (scope &Span[]) as_bytes() -> scope [&]byte
fn (&Span[]) contains(needle T) -> bool
fn (&Span[]) ends_with(target Self) -> bool
Returns whether the `Span` ends with `target`.
fn (&Span[]) index(needle T) -> ?int
fn (&Span[]) init(o Self)
fn (&Span[]) init(val T)
fn (&Span[]) iterator() -> int
fn (&Span[]) len() -> int
fn (&Span[]) next(idx &int) -> ?T
fn (&Span[]) set(o Self)
fn (&Span[]) set(val T)
fn (&Span[]) sort(less &OpaqueFunc[LessFn[T]])
Sorts the span with the given `less` function. If element `a` should be ordered before `b`, the function should return `true` otherwise `false`.
fn (scope &Span[]) span() -> scope [&]T
fn (&Span[]) starts_with(target Self) -> bool
Returns whether the `Span` starts with `target`.
type StaticMap[K type, V type, HASH HashFn[K], EQ EqFn[K]] struct
NOTE: Unused, may be redesigned or removed. A precomputed hash map from an initial set of entries. Insertions and deletions are not allowed. Implemented with open addressing and linear probing.
type StaticMap :: Auto = StaticMap[K, V, AutoHash[K], AutoEq[K]]
fn StaticMap[] :: init(pairs []Pair[K, V]) -> Self
fn StaticMap[] :: init(nslots int, pairs []Pair[K, V]) -> Self
fn (&StaticMap[]) @index(key K) -> Ptr[V]
fn (&StaticMap[]) get(key K) -> ?Ptr[V]
fn (&StaticMap[]) is_vacant(slot int) -> bool
fn (&StaticMap[]) set(key K, val V)
type Str struct
TODO: Mutable string type.
type str struct
Immutable string type. Short strings are interned.
fn str :: @init(slice []byte) -> str
fn str :: @init(span [&]byte) -> str
fn str :: @init(span PtrSpan[byte]) -> str
Returns a `str` copied from the byte slice.
fn str :: @init(x %T) -> str
fn str :: ascii_lower(ch byte) -> byte
fn str :: ascii_upper(ch byte) -> byte
fn str :: initRune(val int) -> str
Converts a rune to a string.
fn str :: initz(src str) -> str
Reallocates with zero sentinel for C compatibility. The sentinel does not count as a character in the string.
fn str :: interpolate(strs [&]str, args [&]str) -> str
fn str :: is_ascii_alpha(ch byte) -> bool
Returns whether a byte is an ASCII alphabetic letter.
fn str :: is_ascii_digit(ch byte) -> bool
Returns whether a byte is an ASCII digit.
fn str :: is_ascii_lower(ch byte) -> bool
fn str :: is_ascii_upper(ch byte) -> bool
fn (&str) @index(idx int) -> byte
Returns the byte value (0-255) at the given index `idx`.
fn (&str) @send(thread Thread) -> str
fn (&str) @slice(start int) -> str
Returns a substring from `start` (inclusive) to `end` (exclusive) byte indexes.
fn (&str) @slice(start int, end int) -> str
Returns a substring from `start` (inclusive) to `end` (exclusive) byte indexes.
fn (&str) `**`(n int) -> str
fn (&str) `+`(s str) -> str
Returns a new string that concats this string and `s`.
fn (&str) as_ptr_span() -> PtrSpan[byte]
fn (&str) beforeLast() -> str
fn (str) compare(right str) -> CompareOrder
fn (&str) concat(s str) -> str
Returns a new string that concats this string and `s`.
fn (&str) contains(needle str) -> bool
fn (&str) count() -> int
Returns the number of runes in the string.
fn (&str) ends_with(suffix str) -> bool
Returns whether the string ends with `suffix`.
fn (&str) fmt(args %T) -> str
Replaces each placeholder `{}` from the receiver string with the corresponding value in `args` converted to a string. TODO: This should accept tuple instead of []Object.
fn (&str) fmt(placeholder str, args %T) -> str
fn (&str) fmtBytes(format NumberFormat) -> str
Formats each byte in the string using a NumberFormat. Each byte is zero padded.
fn (&str) hasAsciiFlag() -> bool
fn (&str) i32At(idx int) -> i32
fn (&str) i32At(idx int, endian Endian) -> i32
fn (&str) index(needle str) -> ?int
Returns the first byte index of substring `needle` in the string or `none` if not found. SIMD accelerated.
fn (&str) index(b byte) -> ?int
Returns the first index of `byte` in the array or `none` if not found.
fn (&str) index_any(set [&]byte) -> ?int
Returns the first index of any byte in `set` or `none` if not found.
fn (&str) index_any(set AsSpan[byte]) -> ?int
fn (&str) index_any_rune(runes [&]int) -> ?int
Returns the first byte index of any rune in `runes` or `none` if not found. SIMD accelerated.
fn (&str) index_any_rune(runes AsSpan[int]) -> ?int
fn (&str) index_newline() -> ?int
Returns the first byte index of `\n` or `\r` or `none`. SIMD accelerated.
fn (&str) index_rune(needle int) -> ?int
Returns the first byte index of a rune `needle` in the string or `none` if not found. SIMD accelerated.
fn (&str) insert(idx int, s str) -> str
Returns a new string with `str` inserted at byte index `idx`.
fn (&str) insert(idx int, b byte) -> str
Returns a new array with `byte` inserted at index `idx`.
fn (&str) intAt(idx int) -> int
fn (&str) intAt(idx int, endian Endian) -> int
fn (&str) isAscii() -> bool
Returns whether the string contains all ASCII runes. Every time this function is called a full scan is performed.
fn (&str) iterator() -> int
fn (&str) last() -> byte
fn (&str) lastIndexOf(needle str) -> ?int
fn (&str) len() -> int
Returns the byte length of the string. See `count()` to obtain the number of runes.
fn (str) less(other str) -> bool
Returns whether this string is lexicographically before `other`.
fn (&str) lower() -> str
Returns this string in lowercase.
fn (&str) next(idx &int) -> ?byte
fn (&str) repeat(n int) -> str
Returns a new string with this string repeated `n` times.
fn (&str) replace(needle str, replacement str) -> str
Returns a new string with all occurrences of `needle` replaced with `replacement`.
fn (&str) rune_at(idx int) -> r32
Returns the rune at byte index `idx`. The replacement character (0xFFFD) is returned for an invalid UTF-8 rune.
fn (&str) runeStrAt(idx int) -> str
Returns the UTF-8 rune starting at byte index `idx` as a string.
fn (&str) seek(n int) -> r32
Returns the n'th rune.
fn (&str) seek_pos(n int) -> int
Returns the starting byte index for the n'th rune.
fn (&str) set(idx int, x byte) -> str
fn (&str) split(sep str) -> []str
Returns a list of UTF-8 strings split at occurrences of `sep`.
fn (&str) starts_with(prefix str) -> bool
Returns whether the `str` starts with `prefix`.
fn (&str) to_bytes() -> []byte
fn (&str) trim(delim str) -> str
Returns the string with both ends trimmed.
fn (&str) trim(delims AsSpan[str]) -> str
fn (&str) trimLeft(delim str) -> str
fn (&str) trimLeft(delims AsSpan[str]) -> str
fn (&str) trimRight(delim str) -> str
fn (&str) trimRight(delims AsSpan[str]) -> str
fn (&str) upper() -> str
Returns this string in uppercase.
type str_lit struct
fn str_lit :: @init(x Self) -> Self
type StrBuffer struct
fn (&StrBuffer) @size() -> int
type symbol _
fn (symbol) name() -> str
type SystemKind enum:
  case linux
  case macos
  case windows
type Table struct
type TaskCallback = fn() -> void
type TccState struct
type Thread _
Handle to a thread. Should only be used internally and in `@send` implementations.
type TraitStruct struct
type type = meta.type
type VaList[T Any] _
type Vector[T Any, N int] _
fn Vector[] :: @init(elem T) -> Self
fn (&Vector[]) @copy() -> Self
fn (scope &Vector[]) @index_addr(idx int) -> scope &T
fn (scope &Vector[]) @slice() -> scope [&]T
fn (scope &Vector[]) @slice(start int) -> scope [&]T
fn (scope &Vector[]) @slice(start int, end int) -> scope [&]T
Returns a slice of this vector from `start` (inclusive) to `end` (exclusive) indexes.
fn (&Vector[]) `**`(M int) -> Vector[T, N * M]
fn (&Vector[]) `+`(o Vector[T, %M]) -> Vector[T, N + M]
fn (&Vector[]) as_ptr_span() -> PtrSpan[T]
fn (&Vector[]) ct_repeat(M int) -> Vector[T, N * M]
fn (&Vector[]) iterator() -> int
Returns a new iterator over the array.
fn (&Vector[]) len() -> int
Returns the number of elements in the array.
fn (&Vector[]) next(idx &int) -> ?T
type void _
type Wyhash struct
Wyhash implementation ported from Zig's std.
fn Wyhash :: @init(seed int) -> Wyhash
fn Wyhash :: hash(seed int, input AsSpan[byte]) -> int
fn Wyhash :: mix(a int, b int) -> int
fn Wyhash :: mum(a Ptr[int], b Ptr[int])
32-bit mum
fn Wyhash :: readI32(ptr Ptr[byte]) -> i32
fn Wyhash :: readInt(ptr Ptr[byte]) -> int
fn Wyhash :: rot(x int) -> int
global Wyhash :: secret [4]int = { 0xa0761d6478bd642f, 0xe7037ed1a0b428db, 0x8ebc6af09c88c6e3, 0x589965cc75374cc3, }
fn (&Wyhash) final() -> int
fn (&Wyhash) final0()
fn (&Wyhash) final1(input_lb [&]byte, start_pos int)
input_lb must be at least 16-bytes long (in shorter key cases the smallKey function will be used instead). We use an index into a slice to for comptime processing as opposed to if we used pointers.
fn (&Wyhash) final2() -> int
fn (&Wyhash) round(input Ptr[byte])
fn (&Wyhash) shallowCopy() -> Self
Copies the core wyhash state but not any internal buffers.
fn (&Wyhash) smallKey(input [&]byte)
fn (&Wyhash) update(input [&]byte)
This is subtly different from other hash function update calls. Wyhash requires the last full 48-byte block to be run through final1 if is exactly aligned to 48-bytes.

mod c

fn @initBindLib() -> void
Invoked by the program's initializer to start binding libs to `extern` declarations.
fn bind_lib(path ?str)
Declares that the extern declarations in the current source file is to be binded at runtime to a dynamic library. When `path == none`, the symbols will be searched from the host exe.
fn flag(s str) -> void
fn from_strz(ptr Ptr[byte]) -> str
Returns a `str` from a null terminated C string.
fn include(spec str) -> void
fn to_strz(s str) -> Ptr[byte]
Returns an allocated null terminated C string.
type c_char = byte
type c_int = i32
type c_long = i64
type c_longlong = i64
type c_short = i16
type c_uint = r32
type c_ulong = r64
type c_ulonglong = r64
type c_ushort = r16
type size_t = r64
type ssize_t = i64
type variadic _

mod cy

const Await = 1
const ErrorCompile = 2
const ErrorPanic = 3
const Success = 0
const TypeBool = 2
const TypeF64 = 13
const TypeFloat = TypeF64
const TypeI64 = 6
const TypeInt = TypeI64
const TypeStr = 23
const TypeVoid = 0
fn _new_parser() -> Ptr[void]
fn _parser_comments(parser Ptr[void], buffer_t int) -> []Comment
fn destroy_parser(parser Ptr[void])
fn eval(src str) -> !Object
Evaluates source code in an isolated VM. If the last statement is an expression, a primitive or a string can be returned.
fn from_znode(znode Ptr[ZNode]) -> ?^Node
fn from_znode_auto(Tag Node.Tag, znode Ptr[ZNode]) -> ^Node
fn from_znodes(znodes ZNodes) -> []^Node
fn is_adjacent_stmt(src str, a_end int, b_start int) -> bool
fn new_parser() -> ZParser
fn parse(src str) -> ParseResult
Parses Cyber source.
fn parser_comments(parser Ptr[void]) -> []Comment
fn repl(read_line ReadLineFn) -> void
Starts an isolated REPL session. The callback `read_line(prefix string) string` is responsible for obtaining the input.
type AccessExpr struct
type AsExpr struct
type Attribute struct
type AttributeKind enum:
  case bind
  case extern
  case call
  case generator
type Backend enum:
  case vm
  case jit
  case tcc
  case cc
  case llvm
type BinaryExprOp enum:
  case index
  case plus
  case minus
  case star
  case pow
  case slash
  case percent
  case bitwiseAnd
  case bitwiseOr
  case bitwiseXor
  case bitwiseLeftShift
  case bitwiseRightShift
  case bang_equal
  case less
  case less_equal
  case greater
  case greater_equal
  case equal_equal
  case and_op
  case or_op
  case cast
  case range
  case reverse_range
  case dummy
type BinExpr struct
type BorrowExpr struct
type CallExpr struct
type CaseBodyData enum:
  case block []^Node
  case expr ^Node
  case fallthrough void
type CaseData enum:
  case _case CaseDataCase
  case _else CaseDataElse
type CaseDataCase struct
type CaseDataElse struct
type CaseStmt struct
type Comment struct
type ConstDecl struct
type CUnionDecl struct
type CustomTypeDecl struct
type EnumDecl struct
type EnumMember struct
type EvalConfig struct
type EvalResult struct
type ExBorrow struct
type FuncDecl struct
type FuncParam struct
type FuncSigKind enum:
  case func
  case infer
  case method
type FuncType struct
type GenericExpand struct
type GenericVectorType struct
type GlobalDecl struct
type Group struct
type Ident struct
fn (&Ident) end() -> int
type ImplDecl struct
type ImportStmt struct
type IndexExpr struct
type InitLit struct
type Literal struct
fn (&Literal) end() -> int
type Node enum:
  case null void
  case access_expr AccessExpr
  case all void
  case as_expr AsExpr
  case assign_stmt void
  case at_lit Literal
  case attribute void
  case begin_stmt void
  case bin_expr BinExpr
  case binLit void
  case borrow BorrowExpr
  case breakStmt void
  case case_stmt CaseStmt
  case call_expr CallExpr
  case catchStmt void
  case const_decl ConstDecl
  case continueStmt void
  case cstruct_decl StructDecl
  case ct_stmt void
  case cunion_decl CUnionDecl
  case custom_type_decl CustomTypeDecl
  case dec_lit Literal
  case dec_u void
  case deref void
  case dollar void
  case dollar_lit void
  case dot void
  case dot_lit Literal
  case else_block void
  case elseif_block void
  case enum_decl EnumDecl
  case enum_member EnumMember
  case error_lit void
  case ex_borrow ExBorrow
  case expand_lit void
  case exprStmt void
  case falseLit void
  case for_iter_stmt void
  case for_range_stmt void
  case float_lit Literal
  case func_decl FuncDecl
  case func_param FuncParam
  case fn_type FuncType
  case fnsym_type FuncType
  case generic_expand GenericExpand
  case generic_vector_type GenericVectorType
  case global_decl GlobalDecl
  case group Group
  case hex_lit Literal
  case ident Ident
  case if_expr void
  case if_stmt void
  case if_unwrap_stmt void
  case impl_decl ImplDecl
  case import_stmt ImportStmt
  case index_expr IndexExpr
  case infer_param PrefixLit
  case init_expr void
  case init_lit InitLit
  case keyValue void
  case label_decl void
  case lambda_cont_expr void
  case lambda_cont void
  case lambda_expr void
  case lambda_multi void
  case move_expr void
  case namedArg void
  case noneLit void
  case octLit void
  case op_assign_stmt void
  case option_type OptionType
  case partial_vector_type void
  case pass_stmt void
  case ptr PtrExpr
  case range Range
  case raw_string_lit Literal
  case raw_string_multi_lit void
  case ref RefExpr
  case return_expr_stmt ReturnExprStmt
  case return_stmt void
  case root Root
  case seqDestructure void
  case slice_type SliceType
  case span_type SpanType
  case special_string_lit void
  case sq_string_lit Literal
  case sq_string_multi_lit Literal
  case string_lit Literal
  case string_multi_lit Literal
  case stringt void
  case stringt_multi void
  case stringt_part void
  case stringt_expr void
  case struct_decl StructDecl
  case struct_field void
  case switch_expr SwitchBlock
  case switch_stmt SwitchBlock
  case template TemplateDecl
  case trait_decl TraitDecl
  case true_lit void
  case tryStmt void
  case type_alias_decl TypeAliasDecl
  case type_const_decl TypeConstDecl
  case unary_expr Unary
  case undef_lit void
  case union_case void
  case unwrap void
  case unwrap_choice void
  case unwrap_or void
  case unwrap_or_block void
  case unwrap_res void
  case unwrap_res_or void
  case unwrap_res_or_block void
  case use_alias void
  case var_decl VarDecl
  case vector_type VectorType
  case void_lit Token
  case whileCondStmt void
  case whileInfStmt void
  case while_unwrap_stmt void
  case with With
  case yield_stmt void
fn (&Node) decl_name() -> str
fn (&Node) end() -> int
fn (&Node) name() -> str
fn (&Node) pos() -> int
type OptionType struct
type ParseResult struct
fn (&ParseResult) node_text(node ^Node) -> str
fn (&ParseResult) stmt_docs(stmt ^Node) -> ?str
type PrefixLit struct
type PtrExpr struct
type Range struct
type ReadLineFn = fn(prefix str) -> Future[str]
type RefExpr struct
type REPL struct
fn REPL :: new() -> REPL
fn (&REPL) eval_print(code str)
fn (&REPL) prefix() -> str
fn (&REPL) print_intro()
fn (&REPL) read(read_line ReadLineFn) -> ?str
type ReturnExprStmt struct
type Root struct
type SliceType struct
type SpanType struct
type StructDecl struct
type SwitchBlock struct
type TemplateDecl struct
type Thread struct
fn (&Thread) deinit_str(value Value)
type Token struct
type TraitDecl struct
type TypeAliasDecl struct
type TypeConstDecl struct
type TypeValue struct
type Unary struct
type UnaryOp enum:
  case minus
  case lnot
  case bit_not
  case addr_of
  case dummy
type Value struct
fn (&Value) as_bool() -> bool
fn (&Value) as_float() -> float
fn (&Value) as_int() -> int
fn (&Value) as_str() -> str
fn (&Value) object_type() -> int
fn (&Value) to_host(val_t int) -> Object
type VarDecl struct
type VectorType struct
type VM struct
fn VM :: @init() -> VM
Create an isolated VM.
fn (&VM) @deinit()
fn (&VM) compile_error_summary() -> str
fn (&VM) eval(code str) -> EvalResult
fn (&VM) eval(uri str, code str, config EvalConfig) -> EvalResult
fn (&VM) main_thread() -> Thread
fn (&VM) panic_summary() -> str
fn (&VM) value_desc(val_t int, value Value) -> str
type With struct
type ZCaseBodyData cunion
type ZCaseData cunion
type ZCaseStmt struct
type ZNode struct
fn (&ZNode) type() -> Node.Tag
type ZNodePayload[T Any] const
type ZNodes struct
type ZParser struct
fn (&ZParser) @deinit()
type ZStr struct

mod meta

fn access(rec Code, field str) -> Any
Access a receiver with a given field as a string.
fn access_choice_case(T type, rec Code, Tag T.Tag) -> CasePayload[T, Tag]
fn access_option_payload(T type, rec Code) -> OptionChild[T]
Unwraps an option type without runtime checks.
fn access_result_error(rec Code) -> error
fn access_result_payload(T type, rec Code) -> ResultChild[T]
fn build_flag(name str) -> bool
Returns whether a build flag is set.
fn build_mode() -> BuildMode
fn build_option(name str) -> ?str
Returns a build option's value.
fn choice_tag(T type, choice &T) -> T.Tag
TODO: Remove redundant `T` param.
fn cpu() -> str
The current build's target cpu arch.
fn cy_full_version() -> str
Returns the version of the Cyber compiler.
fn dump_frame()
fn endian() -> Endian
The current arch's endianness.
fn enum_case(enum_value %T) -> EnumCase
fn enum_int_values(T type) -> Buffer[int]
fn enum_name(enum_value %T) -> str
fn enum_values(T type) -> Buffer[T]
fn error(msg str) -> never
Raise compile-time error.
fn eval(code Code) -> Any
Equivalent to the compile-time expression `#{}`.
fn event() -> int
For debugging. Returns the current event ID.
fn get_closure_data(func Ptr[void]) -> ?Ptr[ClosureData]
fn has_decl(parent Code, name str) -> bool
Returns whether a type has a `name` declaration.
fn init_choice(T type, Tag T.Tag, payload Code) -> T
fn init_type(T type, init Code) -> T
Equivalent to the default T{} initializer. When `$initRecord` is overloaded, this can be used to emit the default initializer.
fn is_inline_eval() -> bool
fn is_none(option Code) -> bool
Returns whether an option or a reference to an option is `none`.
fn is_result_error(result Code) -> bool
fn is_vm_target() -> bool
Whether source is being compiled for the VM.
fn load(path str) -> str
Load a file relative to the project root (main source file). TODO: This should restrict loading files above the project root.
fn log(x %T)
Log to stderr at compile-time.
fn mod_uri() -> str
fn new_struct(init [%N]StructField, config StructConfig) -> type
Creates a new `struct` type. `StructField.offset` is ignored when computing field offsets.
fn reachable() -> bool
Returns whether the current statement is reachable.
fn stack_trace() -> str
fn system() -> SystemKind
The current build's target operating system.
fn trace_releases() -> int
fn trace_retains() -> int
fn unsupported() -> never
Raise compile-time error.
type BorrowInfo struct
type BorrowTraitInfo struct
type BuildMode enum:
  case debug
  case release
type CasePayload[ChoiceT Any, Tag ChoiceT.Tag] = _
type ChoiceCase struct
type ChoiceInfo struct
type Code _
type CStructInfo struct
type CUnionCase struct
type CUnionInfo struct
type DynTraitInfo struct
type EnumCase struct
type EnumInfo struct
type FloatInfo struct
type FnParamsTuple[Sig FuncSig] const
type FuncInfo struct
type FuncKind enum:
  case ptr
  case union
  case sym
type FuncParam struct
type IntInfo struct
type OptionChild[OptionT Any] = _
type OptionInfo struct
type PartialStructLayout _
fn (PartialStructLayout) field_layout(state_offset int, state_len int) -> ?PartialStructLayout
fn (PartialStructLayout) is_field_active(state_offset int) -> bool
type PointerInfo struct
type RawInfo struct
type RefTraitInfo struct
type ResultChild[Result Any] = _
type ResultInfo struct
type StructConfig struct
type StructField struct
type StructInfo struct
type TraitInfo struct
type type _
fn type :: @init(s str) -> type
fn type :: field(T type, s str) -> StructField
fn type :: fn_ret(T type) -> type
fn type :: id(T type) -> int
Returns a unique ID for this type.
fn type :: implements(T type, Trait type) -> bool
fn type :: info(T type) -> TypeInfo
Returns info about a type.
fn type :: is_const(T type) -> bool
Returns whether the type is const eligible.
fn type :: is_copyable(T type) -> bool
Returns whether a type is copyable. A type can be copyable if it does not implement `NoCopy` and contains members that are all copyable.
fn type :: is_instance_of(T type, Template Code) -> bool
Returns whether a type is an instance of a template.
fn type :: managed(T type) -> bool
Returns whether the type is managed. Managed types either have a builtin destructor or a custom `T.$deinit`.
fn type :: name(T type) -> str
fn type :: name_rt(id int) -> str
Returns the runtime type name. This is only available in trace mode.
fn type :: of(expr Code) -> type
Returns the type of an expression.
fn type :: offset(T type, s str) -> int_lit
fn type :: size(T type) -> int_lit
fn type :: struct_state_len(T type) -> int_lit
type TypeInfo enum:
  case int IntInfo
  case raw RawInfo
  case vector VectorInfo
  case partial_vector VectorInfo
  case bool void
  case choice ChoiceInfo
  case enum EnumInfo
  case error void
  case float FloatInfo
  case func FuncInfo
  case result ResultInfo
  case option OptionInfo
  case ptr PointerInfo
  case ref PointerInfo
  case borrow BorrowInfo
  case struct StructInfo
  case cstruct CStructInfo
  case cunion CUnionInfo
  case trait TraitInfo
  case borrow_trait BorrowTraitInfo
  case ref_trait RefTraitInfo
  case dyn_trait DynTraitInfo
  case type void
  case void void
  case never void
type VectorInfo struct

mod cli

fn repl() -> void
Starts an isolated REPL session. Invokes `cy.repl(replReadLine)`.
fn replReadLine(prefix str) -> str
fn replReadLine_(prefix str) -> Future[str]

mod libc

const EACCES = c_int(13)
const EBADF = c_int(9)
const EFAULT = c_int(14)
const EINVAL = c_int(22)
const ENOENT = c_int(2)
const EPERM = c_int(1)
const O_CLOEXEC = switch meta.system(): case .macos => O(0x1000000) case .linux => O(0x80000) else => 0
const O_CREAT = switch meta.system(): case .macos => O(0x0200) case .linux => O(0x0040) else => 0
const O_DIRECTORY = switch meta.system(): case .macos => O(0x100000) case .linux => O(0x10000) else => 0
const O_NONBLOCK = switch meta.system(): case .macos => O(0x0004) case .linux => O(0x0800) else => 0
const O_RDONLY = switch meta.system(): case .macos => O(0x0000) case .linux => O(0x0000) else => 0
const O_RDWR = switch meta.system(): case .macos => O(0x0002) case .linux => O(0x0002) else => 0
const O_TRUNC = switch meta.system(): case .macos => O(0x0400) case .linux => O(0x0200) else => 0
const O_WRONLY = switch meta.system(): case .macos => O(0x0001) case .linux => O(0x0001) else => 0
const PATH_MAX = switch meta.system(): case .macos => 1024 case .linux => 4096 else => 0
const SEEK_CUR = c_int(1)
const SEEK_END = c_int(2)
const SEEK_SET = c_int(0)
global errno c_int
fn access(pathname Ptr[byte], mode c_int) -> c_int
fn chdir(path Ptr[byte]) -> c_int
fn clock_gettime(clockid clockid_t, tp Ptr[timespec]) -> c_int
fn close(fd fd_t) -> c_int
fn exit(status c_int) -> never
fn fclose(stream Ptr[FILE]) -> c_int
fn fcntl(fd fd_t, op c_int, arg c.variadic) -> c_int
fn feof(stream Ptr[FILE]) -> c_int
fn ferror(stream Ptr[FILE]) -> c_int
fn fopen(path Ptr[byte], mode Ptr[byte]) -> Ptr[FILE]
fn fread(ptr Ptr[void], size size_t, n size_t, stream Ptr[FILE]) -> size_t
fn free(ptr Ptr[void]) -> void
fn fstat(fd fd_t, statbuf Ptr[void]) -> c_int
fn fwrite(ptr Ptr[void], size size_t, n size_t, stream Ptr[FILE]) -> size_t
fn getcwd(buf Ptr[byte], size size_t) -> Ptr[byte]
fn getenv(name Ptr[byte]) -> Ptr[byte]
fn lseek(fd fd_t, offset off_t, whence c_int) -> off_t
fn malloc(size size_t) -> Ptr[void]
fn mkdir(pathname Ptr[byte], mode mode_t) -> c_int
fn nanosleep(duration Ptr[timespec], rem Ptr[timespec]) -> c_int
fn open(pathname Ptr[byte], flags O, mode c.variadic) -> c_int
fn printf(format Ptr[byte], args c.variadic) -> c_int
fn read(fd fd_t, buf Ptr[void], count size_t) -> ssize_t
fn readlink(path Ptr[byte], buf Ptr[byte], bufsiz size_t) -> ssize_t
fn rmdir(pathname Ptr[byte]) -> c_int
fn setenv(name Ptr[byte], value Ptr[byte], overwrite c_int) -> c_int
fn stat(pathname Ptr[byte], statbuf Ptr[Stat]) -> c_int
fn unlink(pathname Ptr[byte]) -> c_int
fn unsetenv(name Ptr[byte]) -> c_int
fn write(fd fd_t, buf Ptr[void], count size_t) -> ssize_t
type c_int = c.c_int
type clockid_t = switch meta.system(): case .macos => i32 case .linux => r32 else => void
type cpu_set_t = switch meta.system(): case .linux => linux.cpu_set_t else => void
type fd_t = switch meta.system(): case .macos => i32 case .linux => i32 else => void
type FILE = void
type mode_t = switch meta.system(): case .macos => i16 case .linux => r32 else => void
type O = switch meta.system(): case .macos => i32 case .linux => r32 else => void
type off_t = switch meta.system(): case .macos => i64 case .linux => i64 else => void
type pid_t = switch meta.system(): case .macos => i32 case .linux => i32 else => void
type size_t = c.size_t
type ssize_t = c.ssize_t
type Stat = switch meta.system(): case .macos => macos.Stat case .linux => linux.Stat else => void
type timespec = switch meta.system(): case .macos => macos.timespec case .linux => linux.timespec else => void

mod io

fn indexOfNewLine(buf [&]byte) -> ?int
SIMD accelerated.
type NextRange struct
type Reader trait
fn read(bytes [&]byte) -> !int
fn Reader :: @init(s str) -> StrReader
type Scanner[T Reader] struct
fn Scanner :: @init(scope reader &%T) -> scope Scanner[T]
fn Scanner :: @init(scope reader &%T, buf_size int) -> scope Scanner[T]
const Scanner :: DefaultBufferSize = 8192
fn (&Scanner[]) next(next_fn ScannerNextFn) -> !?[]byte
fn (&Scanner[]) next_line() -> !?[]byte
Returns the next line that ends with `\n`, `\r`, `\r\n`, or until the EOF. The line returned does not include the new line character(s).
fn (&Scanner[]) read_full() -> !void
type ScannerNextFn = fn([&]byte) -> !?NextRange
type SpanReader struct
type StrReader struct
    with Reader
fn (&StrReader) read(buf [&]byte) -> !int
type Writer trait
fn write(bytes [&]byte) -> !int

mod math

const e = 2.71828182845904523536028747135266249775724709369995
Euler's number and the base of natural logarithms; approximately 2.718.
const inf = as[float] 0x7ff0000000000000
Infinity.
const ln10 = 2.302585092994045684017991454684364208
Natural logarithm of 10; approximately 2.303.
const ln2 = 0.693147180559945309417232121458176568
Natural logarithm of 2; approximately 0.693.
const log10e = 0.434294481903251827651128918916605082
Base-10 logarithm of E; approximately 0.434.
const log2e = 1.442695040888963407359924681001892137
Base-2 logarithm of E; approximately 1.443.
const maxSafeInt = 9007199254740991.0
The maximum integer value that can be safely represented as a float. 2^53-1 or 9007199254740991.
const minSafeInt = -9007199254740991.0
The minumum integer value that can be safely represented as a float. -(2^53-1) or -9007199254740991.
const nan = as[float] 0x7ff8000000000000
Not a number. Note that nan == nan. However, if a nan came from an arithmetic operation, the comparison is undefined. Use `isNaN` instead.
const neginf = as[float] 0xfff0000000000000
Negative infinity.
const pi = 3.14159265358979323846264338327950288419716939937510
Ratio of a circle's circumference to its diameter; approximately 3.14159.
const pi2 = pi * 2
const piHalf = pi * 0.5
const sqrt1_2 = 0.707106781186547524400844362104849039
Square root of ½; approximately 0.707.
const sqrt2 = 1.414213562373095048801688724209698079
Square root of 2; approximately 1.414.
fn abs(a float) -> float
Returns the absolute value of x.
fn acos(a float) -> float
Returns the arccosine of x.
fn acosh(a float) -> float
Returns the hyperbolic arccosine of x.
fn asin(a float) -> float
Returns the arcsine of x.
fn asinh(a float) -> float
Returns the hyperbolic arcsine of a number.
fn atan(a float) -> float
Returns the arctangent of x.
fn atan2(y float, x float) -> float
Returns the arctangent of the quotient of its arguments.
fn atanh(a float) -> float
Returns the hyperbolic arctangent of x.
fn cbrt(a float) -> float
Returns the cube root of x.
fn ceil(a float) -> float
Returns the smallest integer greater than or equal to x.
fn clz32(a float) -> float
Returns the number of leading zero bits of the 32-bit integer x.
fn copysign(mag float, sign float) -> float
fn cos(x int) -> float
Returns the cosine of x.
fn cos(x %T) -> T
fn cosh(a float) -> float
Returns the hyperbolic cosine of x.
fn degToRad(deg f32) -> f32
fn exp(a float) -> float
Returns e^x, where x is the argument, and e is Euler's number (2.718…, the base of the natural logarithm).
fn expm1(a float) -> float
Returns subtracting 1 from exp(x).
fn floor(a float) -> float
Returns the largest integer less than or equal to x.
fn frac(a float) -> float
Returns the fractional or decimal part of a float value.
fn hypot(a float, b float) -> float
Returns the square root of the sum of squares of its arguments.
fn isInf(a float) -> bool
fn isInt(a float) -> bool
Returns true if the float has no fractional part, otherwise false.
fn isNaN(a float) -> bool
Returns whether x is not a number.
fn ln(a float) -> float
Returns the natural logarithm (㏒e; also, ㏑) of x.
fn log(x float, y float) -> float
Returns the logarithm of y with base x.
fn log10(a float) -> float
Returns the base-10 logarithm of x.
fn log1p(a float) -> float
Returns the natural logarithm (㏒e; also ㏑) of 1 + x for the number x.
fn log2(a float) -> float
Returns the base-2 logarithm of x.
fn max(a %T, b T) -> T
Returns the largest of two numbers.
fn max_f64(a float, b float) -> float
fn min(a %T, b T) -> T
Returns the smallest of two numbers.
fn min_f64(a float, b float) -> float
fn mul32(a float, b float) -> float
Returns the result of the 32-bit integer multiplication of x and y. Integer overflow is allowed.
fn pow(a float, b float) -> float
Returns base x to the exponent power y (that is, x^y).
fn random() -> float
Returns a pseudo-random number between 0 and 1.
fn round(a float) -> float
Returns the value of the number x rounded to the nearest integer.
fn sign(a float) -> float
Returns the sign of the x, indicating whether x is positive, negative, or zero.
fn sin(x int) -> float
Returns the sine of x.
fn sin(x %T) -> T
fn sinh(a float) -> float
Returns the hyperbolic sine of x.
fn sqrt(a float) -> float
Returns the positive square root of x.
fn tan(x int) -> float
Returns the tangent of x.
fn tan(x %T) -> T
fn tanh(a float) -> float
Returns the hyperbolic tangent of x.
fn trunc(a float) -> float
Returns the integer portion of x, removing any fractional digits.
type Mat1x3[T Any] struct
fn (Mat1x3[]) `*`(m Mat3x3) -> Mat3x1
type Mat1x4[T Any] struct
fn (Mat1x4[]) `*`(m Mat4[T]) -> Mat4x1[T]
type Mat3[T Any] struct
fn (Mat3[]) `*`(m Self) -> Self
type Mat3x1[T Any] struct
type Mat4[T Any] struct
fn Mat4[] :: @init(inner [16]T) -> Self
fn Mat4[] :: identity() -> Self
fn Mat4[] :: zero() -> Self
fn (Mat4[]) `*`(m Self) -> Self
type Mat4x1[T Any] struct
type Transform3D[T Any] struct
fn Transform3D[] :: @init(mat [16]T) -> Self
fn Transform3D[] :: @init(mat Mat4[T]) -> Self
fn Transform3D[] :: identity() -> Self
fn Transform3D[] :: rotation(x, y, z Vec3[T]) -> Self
fn Transform3D[] :: rotationX(rad T) -> Self
fn Transform3D[] :: rotationY(rad T) -> Self
fn Transform3D[] :: rotationZ(rad T) -> Self
fn Transform3D[] :: scaling(x, y T) -> Self
fn Transform3D[] :: scaling(x, y, z T) -> Self
fn Transform3D[] :: translation(x, y T) -> Self
fn Transform3D[] :: translation(x, y, z T) -> Self
fn Transform3D[] :: zero() -> Self
fn (&Transform3D[]) `*`(x Self) -> Self
fn (&Transform3D[]) scale(x f32, y f32) -> Self
fn (&Transform3D[]) scale(x f32, y f32, z f32) -> Self
fn (&Transform3D[]) translate(x f32, y f32) -> Self
type Vec2[T Any] struct
fn Vec2[] :: @init(x, y T) -> Self
const Vec2[] :: unit_x = Self(1, 0)
const Vec2[] :: unit_y = Self(0, 1)
fn (Vec2[]) `*`(scale T) -> Self
fn (Vec2[]) `*`(v Self) -> Self
fn (Vec2[]) `+`(v Self) -> Self
fn (Vec2[]) `-`() -> Self
fn (Vec2[]) `-`(v Self) -> Self
fn (Vec2[]) `/`(scale T) -> Self
fn (Vec2[]) cross(v Self) -> T
fn (Vec2[]) dot(v Self) -> T
fn (Vec2[]) len() -> T
fn (Vec2[]) lenSq() -> T
fn (Vec2[]) normalize() -> T
fn (Vec2[]) scaleTo(len T) -> Self
type Vec3[T Any] struct
fn Vec3[] :: @init(x, y, z T) -> Self
const Vec3[] :: unit_x = Self(1, 0, 0)
const Vec3[] :: unit_y = Self(0, 1, 0)
const Vec3[] :: unit_z = Self(0, 0, 1)
fn (Vec3[]) `*`(s T) -> Self
fn (Vec3[]) `+`(v Self) -> Self
fn (Vec3[]) `+`(v Self, x, y, z T) -> Self
fn (Vec3[]) cross(v Self) -> Self
fn (Vec3[]) dot(v Self) -> T
fn (Vec3[]) len() -> T
fn (Vec3[]) lerp(v Self, tt T) -> Self
fn (Vec3[]) normalize() -> Self
fn (Vec3[]) rotateAxis(axis Self, rad T) -> Self
fn (Vec3[]) rotateY(rad T) -> Self
type Vec4[T Any] struct
fn Vec4[] :: @init(x, y, z, w T) -> Self
fn (Vec4[]) `*`(s T) -> Self
fn (Vec4[]) `+`(v Self) -> Self
fn (Vec4[]) `/`(s T) -> Self
fn (Vec4[]) divW() -> Self
fn (Vec4[]) dot(v Self) -> T

mod os

const AccessExecute = c_int(1)
const AccessExists = c_int(0)
const AccessRead = c_int(4)
const AccessWrite = c_int(2)
const DefaultDirMode = switch meta.system(): case .macos => lc.mode_t(0o755) case .linux => lc.mode_t(0o755) else => 0
Default mode when creating a directory.
const DefaultFileMode = switch meta.system(): case .macos => lc.mode_t(0o666) case .linux => lc.mode_t(0o666) else => 0
Default mode when creating a file.
const ns_per_ms = 1000 * ns_per_us
const ns_per_s = 1000 * ns_per_ms
const ns_per_us = 1000
global vecBitSize int
Default SIMD vector bit size.
fn _args(buffer_t int) -> []str
fn accessFile(path str, mode AccessMode) -> !void
Attempts to access a file at the given `path` with `mode`.
fn args() -> []str
Returns the command line arguments.
fn baseName(path str) -> str
fn cacheUrl(url str) -> str
Returns the path of a locally cached file of `url`. If no such file exists locally, it's fetched from `url`.
fn chdir(path str) -> !void
Change the current working directory.
fn copy_file(src_path str, dst_path str) -> !void
Copies a file to a destination path.
fn createDir(path str) -> !void
Creates the directory at `path`.
fn createFile(path str) -> !File
fn createFile(path str, truncate bool) -> !File
Creates and opens the file at `path`. If `truncate` is true, an existing file will be truncated.
fn cwd() -> !str
Returns the current working directory.
fn dirname(path str) -> ?str
Returns the given path with its last component removed.
fn exec(args []str) -> ExecResult
Runs a shell command and returns the stdout/stderr.
fn exit(status int) -> never
Exits the program with a status code.
fn fetchUrl(url str) -> str
Fetches the contents at `url` using the HTTP GET request method.
fn fileExists(path str) -> bool
Checks whether the file at the given `path` exists.
fn fileInfo(path str) -> !FileInfo
fn fileInfo(stat Ptr[lc.Stat]) -> FileInfo
fn free(ptr Ptr[void])
Frees the memory located at `ptr`.
fn fromErrno() -> error
fn get_env(key str) -> ?str
Returns an environment variable by key.
fn getEnvAll() -> ^Map[str, str]
Returns all environment variables as a map.
fn malloc(size int) -> !Ptr[void]
Allocates `size` bytes of memory and returns a pointer.
fn nanoTime() -> !int
Returns the current time in nanoseconds since the Epoch.
fn now() -> !int
High resolution timestamp. Returns a relative up-time in nanoseconds.
fn num_cpus() -> int
Returns the number of CPU cores on the current machine.
fn open_dir(path str) -> !Dir
fn open_dir(path str, iterable bool) -> !Dir
Opens a directory at the given `path`. `iterable` indicates that the directory's entries can be iterated.
fn open_file(path str) -> !File
fn open_file(path str, mode OpenMode) -> !File
Opens a file at the given `path` with an `OpenMode`.
fn openLib(path ?str) -> DynLib
Creates a handle to a dynamic library.
fn parseArgs(opts []str) -> ArgsResult
Returns a result that can be used to query args. `opts`: The name of options to match excluding the hyphen prefix. eg. `-path`
fn read_file(path str) -> ![]byte
Reads the file contents from `path`.
fn read_file_str(path str) -> !str
fn removeDir(path str) -> !void
Removes an empty directory at `path`.
fn removeFile(path str) -> !void
Removes the file at `path`.
fn resolve_exe_path() -> !str
Returns the current executable's path.
fn resolve_path(path str) -> !str
Returns the absolute path of the given path.
fn set_env(key str, val str) -> !void
Sets an environment variable by key.
fn sleep(nsecs int) -> !void
Pauses the current thread for `nsecs` nanoseconds.
fn stderr() -> File
Returns the standard error handle.
fn stdin() -> File
Returns the standard input handle.
fn stdout() -> File
Returns the standard output handle.
fn unset_env(key str) -> !void
Removes an environment variable by key.
fn write_file(path str, contents str) -> !void
Writes `contents` as a string or bytes to a file.
fn write_file(path str, contents []byte) -> !void
type AccessMode = c_int
type ArgOption struct
type ArgsResult struct
fn (&ArgsResult) at(name str) -> str
fn (&ArgsResult) contains(name str) -> bool
fn (&ArgsResult) get(name str) -> ?str
fn (&ArgsResult) getAll(name str) -> []str
type c_int = c.c_int
type Dir struct
    with NoCopy
fn (&Dir) @deinit()
fn (&Dir) close()
fn (&Dir) info() -> !FileInfo
Returns info about the directory.
fn (&Dir) iterator() -> DirIterator
Returns a new iterator over the directory entries. If this directory was not opened with the iterable flag, `error.NotAllowed` is returned instead.
fn (&Dir) walk() -> DirIterator
Returns a new iterator over the directory recursive entries. If this directory was not opened with the iterable flag, `error.NotAllowed` is returned instead.
type DirEntry struct
type DirIterator struct
fn (&DirIterator) next(dir &Dir) -> !?DirEntry
Returns the next directory entry.
type DirIteratorImpl = switch meta.system(): case .macos => macos.DirIteratorImpl case .linux => linux.DirIteratorImpl case .windows => windows.DirIteratorImpl else => void
type DynLib struct
type ExecResult struct
type File struct
    with io.Reader, io.Writer, NoCopy
fn (&File) @deinit()
fn (&File) close() -> void
Closes the file handle. File ops invoked afterwards will return `error.Closed`.
fn (&File) info() -> !FileInfo
Returns info about the file.
fn (&File) read(buf [&]byte) -> !int
Returns number of bytes read. If 0 is returned, then the file has reached the end.
fn (&File) read(bytes int) -> ![]byte
fn (&File) read_all() -> ![]byte
Reads to the end of the file.
fn (&File) read_fill(as_buf AsSpan[byte]) -> !int
Returns number of bytes read to the buffer `to`. If read bytes is less than `to.len()`, the end of file was reached.
fn (&File) readLine() -> !str
Reads until a new line as a `str`. For bulk line reading, consider using `Scanner.nextLine`.
fn (&File) seek(n int) -> !void
Seeks the read/write position by `pos` bytes from the current position.
fn (&File) seekFromEnd(n int) -> !void
Seeks the read/write position by `pos` bytes from the end. Positive `pos` is invalid.
fn (&File) seekFromStart(n int) -> !void
Seeks the read/write position to `pos` bytes from the start. Negative `pos` is invalid.
fn (&File) write(val str) -> !int
Writes a string to the current file position.
fn (&File) write(buf []byte) -> !int
Writes `buf` to the file and returns the number of bytes written.
fn (&File) write_all(val str) -> !void
fn (&File) write_all(as_val AsSpan[byte]) -> !void
type FileHandle = switch meta.system(): case .windows => Ptr[void] else => lc.fd_t
type FileInfo struct
type FileKind enum:
  case block_device
  case character_device
  case directory
  case named_pipe
  case sym_link
  case file
  case unix_domain_socket
  case whiteout
  case door
  case event_port
  case unknown
type OpenMode enum:
  case read
  case write
  case read_write

mod test

fn assert(pred bool)
Panics if `pred` is `false`.
fn eq(exp %T, act T)
Returns whether two values are equal. Panics with `error.AssertError` if types or values do not match up.
fn eq_slice(exp []%T, act []T)
This will be deprecated once `eq_span` can accept `AsSpan[%T]`.
fn eq_span(exp [&]%T, act [&]T)
Returns `true` if two spans have the same size and the elements are equal as if `eq` was called on those corresponding elements.
fn eqNear(exp float, act float)
fn eqNear(exp float, act float, epsilon float)
fn eqType(exp type, act type)
fn fail()
fn fail(msg str)