Packages

builtin
cbindgen
core
core.alloc
core.alloc.arena
core.alloc.atomic
core.alloc.fixed
core.alloc.gc
core.alloc.heap
core.alloc.log
core.alloc.memdebug
core.alloc.pool
core.alloc.ring
core.arg_parse
core.array
core.avl_tree
core.bucket_array
core.conv
core.doc
core.encoding
core.encoding.base64
core.encoding.csv
core.encoding.hex
core.encoding.json
core.encoding.kdl
core.encoding.osad
core.encoding.utf8
core.hash
core.hash.md5
core.hash.sha1
core.hash.sha256
core.heap
core.intrinsics
core.intrinsics.atomics
core.intrinsics.onyx
core.intrinsics.types
core.intrinsics.wasm
core.io
core.io.binary
core.iter
core.js
core.list
core.map
core.math
core.memory
core.misc
core.net
core.os
core.random
core.set
core.slice
core.string
core.sync
core.test
core.thread
core.time
main
runtime
runtime.info
runtime.platform
runtime.vars
simd

package builtin

Allocator
Allocator :: struct {
    data: rawptr;
    func: (rawptr, AllocationAction, u32, u32, rawptr) -> rawptr;
}
Methods
Allocator.alloc
Allocator.alloc :: (a: Allocator, size: u32, alignment: i32) -> rawptr
Allocator.free
Allocator.free :: (a: Allocator, ptr: rawptr) -> void

Helper procedure to free an allocation from an allocator.

Allocator.move
Allocator.move :: macro (a: Allocator, v: $V) -> &V
Allocator.resize
Allocator.resize :: (a: Allocator, ptr: rawptr, size: u32, alignment: i32) -> rawptr

Helper procedure to resize an allocation from an allocator.

Array
Array :: struct (T: type_expr) {
    data: [&] T;
    count: i32;
    capacity: i32;
    allocator: Allocator;
}

This structure represents the dynamic array types, ..] T. This structure exists to allow for placing methods onto dynamic arrays. See core/container/array.onyx for examples.

Methods
Array.alloc_one
Array.alloc_one :: (arr: &[..] $T) -> &T

Appends a zeroed-element to the end of the array, and returns a pointer to it.

Array.clear
Array.clear :: (arr: &[..] $T) -> void

Clears a dynamic array.

Note: This does not clear or free the memory for the dynamic array.

Array.concat
Array.concat :: (arr: &[..] $T, other: [] T) -> void
Array.concat :: (arr: &[..] $T, other: Iterator(T)) -> void
Array.copy
Array.copy :: (arr: &[..] $T, allocator) -> [..] T
Array.copy :: (arr: [] $T, allocator) -> [] T
Array.copy_range
Array.copy_range :: (arr: &[..] $T, r: range, allocator) -> [..] T

Copies a sub-array of a dynamic-array.

arr := array.make(.[ 2, 3, 5, 7, 11 ]);
sub := array.copy_range(&arr, 2 .. 5);
println(sub); // 5, 7, 11
Array.delete
Array.delete :: (arr: &[..] $T, idx: u32) -> T

Removes the element at index idx from the array and returns it.

Maintains order of the array.

Array.ensure_capacity
Array.ensure_capacity :: (arr: &[..] $T, capacity: u32) -> bool

Resizes a dynamic array if it does not have enough capacity.

If this procedure returns true, arr.capacity will be greater than or equal to capacity.

Array.fast_delete
Array.fast_delete :: (arr: &[..] $T, idx: u32) -> T

Removes the element at index idx from the array and returns it.

Order is not guaranteed to be preserved.

Array.filter
Array.filter :: macro (arr: &[..] $T, body: Code) -> void

Removes all elements for which the given predicate does not hold.

arr := array.make(.[ 1, 2, 3, 4, 5 ]);
array.filter(&arr, [v](v % 2 == 0));
println(arr); // 2, 4
Array.free
Array.free :: (arr: &[..] $T) -> void

Frees a dynamic array.

Array.init
Array.init :: (arr: &[..] $T, capacity, allocator) -> void

Creates a dynamic array of type T with an initial capacity of capacity, from the allocator. Creates a new dynamic array as a copy of the provided array. Initializes a dynamic array.

Array.insert
Array.insert :: (arr: &[..] $T, idx: u32, x: T) -> bool
Array.insert :: (arr: &[..] $T, idx: u32, new_arr: [] T) -> bool
Array.insert_empty
Array.insert_empty :: (arr: &[..] $T, idx: u32) -> bool

Inserts a zeroed-element at idx.

Array.make
Array.make :: ($T: type_expr, capacity, allocator) -> [..] T
Array.make :: (base: [] $T, allocator) -> [..] T
Array.pop
Array.pop :: (arr: &[..] $T, n) -> T

Removes n elements from the end of the array.

Array.push
Array.push :: (arr: &[..] $T, x: T) -> bool

Appends x to the end of the array.

Array.remove
Array.remove :: (arr: &[..] $T, elem: T) -> void

Removes all instances of elem from the array.

Uses == to test for equality.

CallSite
CallSite :: struct {
    file: [] u8;
    line: u32;
    column: u32;
}

This structure represents the result of a '#callsite' expression. Currently, #callsite is only valid (and parsed) as a default value for a procedure parameter. It allows the function to get the address of the calling site, which can be used for error printing, unique hashes, and much more.

Code
Code :: struct {
    _: i32;
}

Represents a code block that can be passed around at compile-time. This is commonly used with macros or polymorphic procedures to create very power extensions to the syntax.

Default_Logger
Default_Logger :: struct {
    minimum_level: Log_Level;
}
Methods
Default_Logger.log
Default_Logger.log :: (logger: &Default_Logger, level: Log_Level, msg: [] u8, module: [] u8) -> void
Iterator
Iterator :: struct (Iter_Type: type_expr) {
    data: rawptr;
    next: (rawptr) -> Optional(Iter_Type);
    close: (rawptr) -> void;
    remove: (rawptr) -> void;
}

Represents a generic "iterator" or "generator" of a specific type. Can be used in a for-loop natively.

data is used for contextual information and is passed to the next, close, and remove procedures.

next is used to extract the next value out of the iterator. It returns the next value, and a continuation flag. If the flag is false, the value should be ignored and iteration should stop.

close should called when the iterator has ended. This is done automatically in for-loops, and in the core.iter library. In for-loops, close is called no matter which way the for-loop exits (break, return, etc). Using this rule, iterator can be used to create "resources" that automatically close when you are done with them.

remove is used to tell the iterator to remove the last value returned from some underlying data store. Invoked automatically using the #remove directive in a for-loop.

Methods
Iterator.collect
Iterator.collect :: (it: Iterator($T), allocator) -> [..] T

Places all yielded values into a dynamically allocated array, using the allocator provided (context.allocator by default).

Iterator.collect_map
Iterator.collect_map :: (it: Iterator(CALL), allocator) -> Map(K, V)

Places all yielded values into a Map, with the first member being the key, and the second member being the value.

Iterator.count
Iterator.count :: macro (it: $T, cond: $F) -> #auto
    where Iterable(T)
Iterator.count :: (it: Iterator($T), cond: (T) -> bool) -> i32
Iterator.enumerate
Iterator.enumerate :: macro (it: $T, start_index: i32) -> #auto
    where Iterable(T)
Iterator.enumerate :: (it: Iterator($T), start_index: i32) -> Iterator(CALL)
Iterator.every
Iterator.every :: macro (it: $T, cond: $F) -> #auto
    where Iterable(T)
Iterator.every :: (it: Iterator($T), cond: (T) -> bool) -> bool
Iterator.filter
Iterator.filter :: (it: Iterator($T), predicate: (T) -> bool) -> #auto
Iterator.filter :: (it: Iterator($T), ctx: $Ctx, predicate: (T, Ctx) -> bool) -> #auto
Iterator.find
Iterator.find :: macro (it: $T, predicate: $F) -> #auto
    where Iterable(T)
Iterator.find :: (it: Iterator($T), predicate: (T) -> bool) -> ? T
Iterator.flat_map
Iterator.flat_map :: (it: Iterator($T), transform: (T) -> Iterator($R)) -> #auto
Iterator.flat_map :: (it: Iterator($T), ctx: $Ctx, transform: (T, Ctx) -> Iterator($R)) -> #auto
Iterator.flatten
Iterator.flatten :: (i: Iterator($T), f: (T) -> ? $R) -> Iterator(R)

Filters and maps at the same time.

If the provided function returns a None variant of Optional, then the entry is discarded.

If the provided function returns Some(x), then x is yielded.

Iterator.fold
Iterator.fold :: macro (it: $T, init: $R, combine: $S) -> #auto
    where Iterable(T)
Iterator.fold :: (it: Iterator($T), initial_value: $R, combine: (T, R) -> R) -> R
Iterator.fold1
Iterator.fold1 :: macro (it: $T, combine: $S) -> #auto
    where Iterable(T)
Iterator.fold1 :: (it: Iterator($T), combine: (T, T) -> T) -> ? T
Iterator.map
Iterator.map :: (it: Iterator($T), transform: (T) -> $R) -> #auto
Iterator.map :: (it: Iterator($T), ctx: $Ctx, transform: (T, Ctx) -> $R) -> #auto
Iterator.skip
Iterator.skip :: (it: Iterator($T), count: u32) -> Iterator(T)

Discards the first count values and yields all remaining values.

Iterator.skip_while
Iterator.skip_while :: (it: Iterator($T), predicate: (T) -> bool) -> Iterator(T)
Iterator.skip_while :: (it: Iterator($T), ctx: $Ctx, predicate: (T, Ctx) -> bool) -> Iterator(T)
Iterator.some
Iterator.some :: macro (it: $T, cond: $F) -> #auto
    where Iterable(T)
Iterator.some :: (it: Iterator($T), cond: (T) -> bool) -> bool
Iterator.sum
Iterator.sum :: macro (it: $T) -> #auto
    where Iterable(T)
Iterator.sum :: (it: Iterator($T)) -> T
Iterator.take
Iterator.take :: (it: Iterator($T), count: u32) -> Iterator(T)

Only yields the first count values, then closes.

Iterator.take_while
Iterator.take_while :: (it: Iterator($T), predicate: (T) -> bool) -> Iterator(T)

Yields values while the predicate returns true.

Iterator.zip
Iterator.zip :: (left_iterator: Iterator($T), right_iterator: Iterator($R)) -> Iterator(CALL)

Combines two iterators into one by yielding a Pair of the value from each of the iterators.

Link_Options
Link_Options :: struct {
    stack_size: i32;
    stack_alignment: i32;
    null_reserve_size: i32;
    import_memory: bool;
    import_memory_module_name: [] u8;
    import_memory_import_name: [] u8;
    export_memory: bool;
    export_memory_name: [] u8;
    export_func_table: bool;
    export_func_table_name: [] u8;
    memory_min_size: i32;
    memory_max_size: i32;
}

Defines all options for changing the memory layout, imports and exports, and more of an Onyx binary.

Logger
Logger :: struct {
    func: (rawptr, Log_Level, [] u8, [] u8) -> void;
    data: rawptr;
}
OnyxContext
OnyxContext :: struct {
    allocator: Allocator;
    temp_allocator: Allocator;
    closure_allocate: (i32) -> rawptr;
    logger: Logger;
    assert_handler: ([] u8, CallSite) -> void;
    thread_id: i32;
    user_data: rawptr;
    user_data_type: type_expr;
}

This is the type of the 'context' global variable.

Methods
OnyxContext.get_user_data
OnyxContext.get_user_data :: macro (c: &OnyxContext, $T: type_expr) -> &T
OnyxContext.set_user_data
OnyxContext.set_user_data :: macro (c: &OnyxContext, data: &$T) -> void
Slice
Slice :: struct (T: type_expr) {
    data: [&] T;
    count: i32;
}

This structure represents the slice types, ] T. While slices are a special type in Onyx, and therefore need extra compiler support, this structure exists to allow for placing methods onto slices. See core/container/slice.onyx for examples.

Methods
Slice.average
Slice.average :: (arr: [] $T) -> T

Uses + to add the elements together. Then use / i32 to divide by the number of elements. Both of these are assumed to work.

Slice.chunks
Slice.chunks :: (arr: [] $T, width: i32) -> Iterator([] T)

Creates an iterator of chunks over the elements of the slice. Each chunk has size width, with the last chunk having size arr.count % width.

Slice.contains
Slice.contains :: (arr: [] $T, x: T) -> bool
Slice.contains :: macro (arr: [] $T, $cmp: Code) -> bool
Slice.copy
Slice.copy :: (sl: [] $T, allocator) -> [] T

Copies a slice to a new slice, allocated from the provided allocator.

Slice.count_where
Slice.count_where :: macro (arr: [] $T, predicate: (T) -> bool) -> #auto
Slice.count_where :: macro (arr: [] $T, predicate_body: Code) -> u32
Slice.empty
Slice.empty :: (arr: [] $T) -> #auto

Tests if the slice is empty.

Normally this is unneeded, as arrays have a 'truthiness' that depends on their count. For example, instead of saying:

if slice.empty(arr) { ... }

You can simply say:

if !arr { ... }
Slice.equal
Slice.equal :: (arr1: [] $T, arr2: [] T) -> bool
    where HasEquals(T)
Slice.every
Slice.every :: macro (arr: [] $T, predicate: (T) -> bool) -> #auto
Slice.every :: macro (arr: [] $T, predicate_body: Code) -> bool
Slice.fill
Slice.fill :: (arr: [] $T, value: T) -> void

Sets all elements in a slice to be value.

Slice.fill_range
Slice.fill_range :: (arr: [] $T, r: range, value: T) -> void

Sets all elements in the range to be value.

Slice.find
Slice.find :: (arr: [] $T, value: T) -> i32
Slice.find :: macro (arr: [] $T, pred: Code) -> i32
    where type_is_struct(T)
Slice.find :: macro (arr: [] $T, pred: Code) -> i32
Slice.find_opt
Slice.find_opt :: macro (arr: [] $T, cond: Code) -> ? T
    where type_is_struct(T)
Slice.find_opt :: macro (arr: [] $T, cond: Code) -> ? T
Slice.find_ptr
Slice.find_ptr :: (arr: [] $T, value: T) -> &T

Returns a pointer to the first element that equals value, compared using ==.

Returns null if no matching element is found.

Slice.first
Slice.first :: macro (arr: [] $T, predicate: (T) -> bool) -> &T
Slice.first :: macro (arr: [] $T, predicate_body: Code) -> &T
    where type_is_struct(T)
Slice.first :: macro (arr: [] $T, predicate_body: Code) -> &T
Slice.fold
Slice.fold :: (arr: [] $T, init: $R, f: (T, R) -> R) -> R
Slice.fold :: macro (arr: [] $T, init: $R, body: Code) -> R
Slice.free
Slice.free :: (sl: &[] $T, allocator) -> void

Frees the data inside the slice. The slice is taken by pointer because this procedure also sets the data pointer to null, and the length to 0, to prevent accidental future use of the slice.

Slice.get
Slice.get :: (arr: [] $T, idx: i32) -> T

Get an element from a slice, with negative and wrap-around indexing.

Slice.get_ptr
Slice.get_ptr :: (arr: [] $T, idx: i32) -> &T

Get a pointer to an element from a slice, with negative and wrap-around indexing.

Slice.greatest
Slice.greatest :: macro (arr: [] $T) -> (i32, T)

Returns the largest element in the array, using > to compare.

Slice.group_by
Slice.group_by :: macro (arr: [] $T, comp: (T, T) -> bool, allocator) -> [..] [] T
Slice.group_by :: macro (arr_: [] $T, comp: Code, allocator) -> [..] [] T
Slice.init
Slice.init :: (sl: &[] $T, length: u32, allocator) -> void

Initializes a slice of type T to have a length of length, using the allocator provided.

use core {slice, println}
sl: [] i32;
slice.init(&sl, 10);
println(sl);
// 0 0 0 0 0 0 0 0 0 0
Slice.least
Slice.least :: macro (arr: [] $T) -> (i32, T)

Returns the smallest element in the array, using < to compare.

Slice.make
Slice.make :: ($T: type_expr, length: u32, allocator) -> [] T

Creates a zeroed slice of type T and length length, using the allocator provided.

use core {slice, println}
sl := slice.make(i32, 10);
println(sl);
// 0 0 0 0 0 0 0 0 0 0
Slice.product
Slice.product :: (arr: [] $T, start: T) -> T

Uses to multiply all elements in the slice.

Slice.quicksort
Slice.quicksort :: (arr: [] $T, cmp: (T, T) -> i32) -> #auto
Slice.quicksort :: (arr: [] $T, cmp: (&T, &T) -> i32) -> #auto
Slice.reverse
Slice.reverse :: (arr: [] $T) -> void

Reverses a slice in-place.

Slice.set
Slice.set :: (arr: [] $T, idx: i32, value: T) -> void

Set a value in a slice, with negative and wrap-around indexing.

Slice.some
Slice.some :: macro (arr: [] $T, predicate: (T) -> bool) -> #auto
Slice.some :: macro (arr: [] $T, predicate_body: Code) -> bool
    where type_is_struct(T)
Slice.some :: macro (arr: [] $T, predicate_body: Code) -> bool
Slice.sort
Slice.sort :: (arr: [] $T, cmp: (T, T) -> i32) -> [] T
Slice.sort :: (arr: [] $T, cmp: (&T, &T) -> i32) -> [] T
Slice.sum
Slice.sum :: (arr: [] $T, start: T) -> T

Uses + to sum all elements in the slice.

Slice.to_list
Slice.to_list :: (arr: [] $T, allocator) -> List(T)

Converts a slice to a linked list.

Slice.transplant
Slice.transplant :: (arr: [] $T, old_index: i32, new_index: i32) -> bool

Moves an element to a new index, ensuring that order of other elements is retained.

use core {slice, println}
arr := i32.[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// Move element at index 4 to index 8
slice.transplant(arr, 4, 8);
println(arr);
// 1 2 3 4 6 7 8 9 5 10
Slice.unique
Slice.unique :: (arr: &[] $T) -> void

Shrinks a slice, removing all duplicates of elements, using == to compare elements.

This assumes that the elements are sorted in some fashion, such that equal elements would be next to each other.

Slice.windows
Slice.windows :: (arr: [] $T, width: i32) -> Iterator([] T)

Creates an iterator of a sliding window over the elements of the slice, with width width.

any
any :: struct {
    data: rawptr;
    type: type_expr;
}

This structure is used to represent any value in the language. It contains a pointer to the data, and the type of the value. Using the core.misc library, you can easily manipulate anys and build runtime polymorphism.

range
range :: struct {
    low: i32;
    high: i32;
    step: i32;
}

This is the type of a range literal (i.e. 1 .. 5). This is a special type that the compiler knows how to iterator through. So, one can simply write:

 for x in 1 .. 5 { ... }

Although not controllable from the literal syntax, there is a step member that allows you control how many numbers to advance each iteration. For example, range.{ 0, 100, 2 } would iterate over the even numbers, and range.{ 100, 0, -1 } would count backwards from 100 to 0 (and including 0).

range64
range64 :: struct {
    low: i64;
    high: i64;
    step: i64;
}

This is the same as the range type, except with 64-bit integers.

AllocationAction
AllocationAction :: enum {
    Alloc :: 0;
    Free :: 1;
    Resize :: 2;
}
Log_Level
Log_Level :: enum {
    Debug :: 0;
    Info :: 1;
    Warning :: 2;
    Error :: 3;
    Critical :: 4;
}
Optional
Optional :: union (Value_Type: type_expr) {
    None: void;
    Some: Value_Type;
}

Optional represents the possibility of a value being empty, without resorting to pointers and null-pointers. Most of the functionality for Optional is defined in core/containers/optional.onyx. This definition exists here because the compiler use it as the template for types like '? i32'. In other words, '? i32' is equivalent to 'Optional(i32)'.

Methods
Optional.and_then
Optional.and_then :: (o: ? $T, transform: (T) -> ? $R) -> ? R

Monadic chaining operation.

Optional.catch
Optional.catch :: macro (o: ? $T, body: Code) -> T
Optional.empty
Optional.empty :: macro (T: type_expr) -> unknown

Create an empty Optional of a certain type. This procedure is mostly useless, because you can use .{} in type inferred places to avoid having to specify the type.

Optional.expect
Optional.expect :: (o: ? $T, message: str) -> T

Returns the value inside the optional, if there is one. If not, an assertion is thrown and the context's assert handler must take care of it.

Optional.expect_ptr
Optional.expect_ptr :: (o: &? $T, message: str) -> &T

Returns a pointer to the value inside the optional, if there is one. If not, an assertion is thrown and the context's assert handler must take care of it.

Optional.flatten
Optional.flatten :: (o1: ? Optional($T)) -> ? T

Flattens nested optionals.

Optional.from_ptr
Optional.from_ptr :: macro (p: &$T) -> ? T

Converts a pointer to an optional by defining null to be None, and a non-null pointer to be Some. This dereferences the valid pointer to return the data stored at the pointer's address.

Optional.hash
Optional.hash :: (o: ? $T) -> #auto
    where core.hash.Hashable(T)
Optional.make
Optional.make :: (x: $T) -> #auto
Optional.make :: ($T: type_expr, x: T) -> #auto
Optional.or_else
Optional.or_else :: (o: ? $T, generate: () -> ? T) -> ? T

Like value_or, but instead of providing a value, you provide a function to generate a value.

Optional.or_return
Optional.or_return :: macro (o: ? $T) -> T
Optional.or_return :: macro (o: ? $T, return_value: $R) -> T
Optional.reset
Optional.reset :: (o: &? $T) -> void

Clears the value in the Optional, zeroing the memory of the value.

Optional.set
Optional.set :: (o: &? $T, value: T) -> void

Sets the value in the Optional.

Optional.transform
Optional.transform :: (o: ? $T, transform: (T) -> $R) -> ? R

Changes the value inside the optional, if present.

Optional.unwrap
Optional.unwrap :: (o: ? $T) -> T

Returns the value inside the optional, if there is one. If not, an assertion is thrown and the context's assert handler must take care of it.

Optional.unwrap_ptr
Optional.unwrap_ptr :: (o: &? $T) -> &T

Returns a pointer to the value inside the optional, if there is one. If not, an assertion is thrown and the context's assert handler must take care of it.

Optional.value_or
Optional.value_or :: (o: ? $T, default: T) -> #auto

Extracts the value from the Optional, or uses a default if no value is present.

Optional.with
Optional.with :: macro (o: ? $T, body: Code) -> void
package_id
package_id :: #distinct u32

Special type used to represent a package at runtime. For example,

x: package_id = package main

Currently, there is not much you can do with this; it is only used by the runtime.info library if you want to filter tags based on which package they are coming from.

__array_op_array
__array_op_array :: macro (l: ARRAY TYPE, r: ARRAY TYPE, $body: Code) -> ARRAY TYPE
__array_op_scalar
__array_op_scalar :: macro (l: ARRAY TYPE, r: T, $body: Code) -> ARRAY TYPE
__closure_block_allocate
__closure_block_allocate :: (size: i32) -> rawptr

Internal procedure to allocate space for the captures in a closure. This will be soon changed to a configurable way, but for now it simply allocates out of the heap allocator.

__dispose_used_local
__dispose_used_local :: macro (file: &File) -> void
__dispose_used_local :: (sp: &StringPool) -> void
__dispose_used_local :: (bs: &BufferStream) -> void
__dispose_used_local :: (reader: &Reader) -> void
__dispose_used_local :: (w: &Writer) -> void
__dispose_used_local :: (v: Value) -> void
__dispose_used_local :: (map: &Map) -> void
__dispose_used_local :: (set: &Set) -> void
__dispose_used_local :: (h: &Heap) -> void
__dispose_used_local :: macro (x: &[] $T, allocator) -> void
__dispose_used_local :: (d: Document) -> void
__dispose_used_local :: (v: Value, allocator: Allocator) -> void
__dispose_used_local :: (j: Json) -> void
__dispose_used_local :: (v: Value, allocator: Allocator) -> void
__dispose_used_local :: (j: Json) -> void
__dispose_used_local :: macro (x: &[..] $T) -> void
__dispose_used_local :: macro (x: &$T) -> void
    where Destroyable(T)
__dispose_used_local :: (sp: &StringPool) -> void
__dispose_used_local :: (bs: &BufferStream) -> void
__dispose_used_local :: (reader: &Reader) -> void
__dispose_used_local :: (w: &Writer) -> void
__dispose_used_local :: (v: Value) -> void
__dispose_used_local :: (map: &Map) -> void
__dispose_used_local :: (set: &Set) -> void
__dispose_used_local :: (h: &Heap) -> void
__dispose_used_local :: macro (x: &[] $T, allocator) -> void
__dispose_used_local :: (d: Document) -> void
__dispose_used_local :: (v: Value, allocator: Allocator) -> void
__dispose_used_local :: (j: Json) -> void
__dispose_used_local :: (v: Value, allocator: Allocator) -> void
__dispose_used_local :: (j: Json) -> void
__dispose_used_local :: macro (x: &[..] $T) -> void
__dispose_used_local :: macro (x: &$T) -> void
    where Destroyable(T)
__implicit_bool_cast
__implicit_bool_cast :: macro (r: Result($O, $E)) -> #auto
__implicit_bool_cast :: macro (o: ? $T) -> #auto

This overloaded procedure allows you to define an implicit rule for how to convert any value into a boolean. A default is provided for ALL pointer types and array types, but this can be used for structures or distinct types.

__initialize_data_segments
__initialize_data_segments :: () -> void

This procedure is a special compiler generated procedure that initializes all the data segments in the program. It should only be called once, by the main thread, at the start of execution. It is undefined behaviour if it is called more than once.

__make_overload
__make_overload :: macro (x: &Map($K, $V), allocator) -> #auto
__make_overload :: (_: &List($T), allocator) -> List(T)
__make_overload :: macro (x: &Set, allocator: Allocator) -> #auto
__make_overload :: macro (_: &Heap($T), allocator: Allocator) -> Heap(T)
__make_overload :: macro (_: &[] $T, count: u32, allocator) -> [] T
__make_overload :: macro (_: &[..] $T, allocator) -> [..] T
__make_overload :: macro (_: &[..] $T, capacity: u32, allocator) -> [..] T

This is a rather unique way of using the type matching system to select an overload. What is desired here is that when you say:

make(Foo)

You match the overload for make that is designed for making a Foo. However, you cannot use the type matching system to match by value. In order to get around this, make will pass a null pointer to this match procedure, that is casted to be a pointer to the desired type. Therefore, if you want to add your own make overload, you have to add a match to __make_overload that takes a pointer to the desired type as the first argument, and then an allocator as the second. Optionally, you can take a parameter between them that is an integer, useful when constructing things like arrays.

See core/container/array.onyx for an example.

__run_init_procedures
__run_init_procedures :: () -> void

This is a special compiler generated procedure that calls all procedures specified with #init in the specified order. It should theoretically only be called once on the main thread.

assert
assert :: (cond: bool, msg: [] u8, site: CallSite) -> void

Checks if the condition is true. If not, invoke the context's assert handler.

calloc
calloc :: (size: u32) -> rawptr

Helper function to allocate using the allocator in the context structure.

cfree
cfree :: (ptr: rawptr) -> void

Helper function to free using the allocator in the context structure.

cresize
cresize :: (ptr: rawptr, size: u32) -> rawptr

Helper function to resize using the allocator in the context structure.

default_log_level
default_log_level :: (level: Log_Level) -> void
delete
delete :: (sp: &StringPool) -> void
delete :: (bs: &BufferStream) -> void
delete :: (reader: &Reader) -> void
delete :: (w: &Writer) -> void
delete :: (v: Value) -> void
delete :: (map: &Map) -> void
delete :: (set: &Set) -> void
delete :: (h: &Heap) -> void
delete :: macro (x: &[] $T, allocator) -> void
delete :: (d: Document) -> void
delete :: (v: Value, allocator: Allocator) -> void
delete :: (j: Json) -> void
delete :: (v: Value, allocator: Allocator) -> void
delete :: (j: Json) -> void
delete :: macro (x: &[..] $T) -> void
delete :: macro (x: &$T) -> void
    where Destroyable(T)
log
log :: (level: Log_Level, msg: [] u8) -> void
log :: (level: Log_Level, module: [] u8, msg: [] u8) -> void
make
make :: macro ($T: type_expr, allocator) -> #auto
make :: macro ($T: type_expr, n: u32, allocator) -> #auto
make_temp
make_temp :: macro (T: type_expr) -> unknown
make_temp :: macro (T: type_expr, n: u32) -> unknown
memory_equal
memory_equal :: (a: rawptr, b: rawptr, count: i32) -> bool
new
new :: ($T: type_expr, allocator) -> &T
new :: (T: type_expr, allocator: Allocator) -> rawptr
new :: macro (v: $T, allocator) -> &T
new_temp
new_temp :: macro (T: $__type_T) -> #auto
null_proc
null_proc :: () -> void

null_proc is a special function that breaks the normal rules of type checking. null_proc, or any procedure marked with #null, is assignable to any function type, regardless of if the types match. For example,

f: (i32) -> i32 = null_proc;

Even though null_proc is a () -> void function, it bypasses that check and gets assigned to f. If f is called, there will be a runtime exception. This is by design.

panic
panic :: (msg: [] u8, site: CallSite) -> void

Causes a runtime panic with the specified error message.

raw_alloc
raw_alloc :: (a: Allocator, size: u32, alignment: i32) -> rawptr
raw_free
raw_free :: (a: Allocator, ptr: rawptr) -> void

Helper procedure to free an allocation from an allocator.

raw_resize
raw_resize :: (a: Allocator, ptr: rawptr, size: u32, alignment: i32) -> rawptr

Helper procedure to resize an allocation from an allocator.