package builtin
Allocator :: struct {
data: rawptr
func: (rawptr, AllocationAction, u32, u32, rawptr) -> rawptr
}
Allocator.free :: (a: Allocator, ptr: rawptr) -> void
Helper procedure to free an allocation from an allocator.
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.
Array.alloc_one :: (arr: &[..] $T) -> &T
Appends a zeroed-element to the end of the array, and returns a pointer to it.
Array.clear :: (arr: &[..] $T) -> void
Clears a dynamic array.
Note: This does not clear or free the memory for the dynamic array.
Array.concat :: (arr: &[..] $T, other: [] T) -> void
Array.concat :: (arr: &[..] $T, other: Iterator(T)) -> void
Array.copy :: (arr: &[..] $T, allocator) -> [..] T
Array.copy :: (arr: [] $T, allocator) -> [] T
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 :: (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 :: (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 :: (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 :: 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.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 :: (arr: &[..] $T, idx: u32, x: T) -> bool
Array.insert :: (arr: &[..] $T, idx: u32, new_arr: [] T) -> bool
Array.insert_empty :: (arr: &[..] $T, idx: u32) -> bool
Inserts a zeroed-element at idx
.
Array.make :: ($T: type_expr, capacity, allocator) -> [..] T
Array.make :: (base: [] $T, allocator) -> [..] T
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 :: 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 :: struct {
minimum_level: Log_Level
}
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.
Iterator.close :: (it: Iterator) -> void
Helper function to close an iterator, if a close function is defined.
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 :: (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.comp :: macro (i: Iterator(&$V), value: Code) -> #auto
Iterator.comp :: macro (i: Iterator($V), value: Code) -> #auto
Iterator.comp :: macro (i: $I, value: Code) -> #auto
where Iterable(I)
Iterator.count :: macro (it: $T, cond: $F) -> #auto
where Iterable(T)
Iterator.count :: (it: Iterator($T), cond: (T) -> bool) -> i32
Iterator.counter :: (start: type, $type: type_expr) -> Iterator(type)
Helper function to create an infinite counting iterator.
Use start
to configure the starting value.
Use type
to configure the type used for the iterator.
Iterator.empty :: ($T: type_expr) -> Iterator(T)
Helper function to create an iterator of a type that does not produce an values.
Iterator.enumerate :: macro (it: $T, start_index: i32) -> #auto
where Iterable(T)
Iterator.enumerate :: (it: Iterator($T), start_index: i32) -> Iterator(CALL)
Iterator.every :: macro (it: $T, cond: $F) -> #auto
where Iterable(T)
Iterator.every :: (it: Iterator($T), cond: (T) -> bool) -> bool
Iterator.filter :: (it: Iterator($T), predicate: (T) -> bool) -> #auto
Iterator.filter :: (it: Iterator($T), ctx: $Ctx, predicate: (T, Ctx) -> bool) -> #auto
Iterator.find :: macro (it: $T, predicate: $F) -> #auto
where Iterable(T)
Iterator.find :: (it: Iterator($T), predicate: (T) -> bool) -> ? T
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 :: (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 :: 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 :: macro (it: $T, combine: $S) -> #auto
where Iterable(T)
Iterator.fold1 :: (it: Iterator($T), combine: (T, T) -> T) -> ? T
Iterator.from :: (list: &List) -> #auto
Iterator.from :: (s: &Set) -> #auto
Iterator.from :: (b: &Bucket_Array($T)) -> Iterator(T)
Iterator.from :: (arr: [] $T) -> #auto
where type_is_struct(T)
Iterator.from :: (arr: [] $T, by_pointer: bool) -> #auto
Iterator.from :: (arr: [] $T) -> #auto
Iterator.from :: macro (x: &[..] $T) -> #auto
Iterator.from :: macro (x: &[..] $T, by_pointer: bool) -> #auto
Iterator.from :: (r: range) -> Iterator(i32)
Iterator.from :: (r: range64) -> Iterator(i64)
Iterator.from :: (x: &$T) -> #auto
where ImplicitIterator(T)
Iterator.from :: macro (x: $T) -> #auto
where HasAsIter(T)
Iterator.generator :: (ctx: &$Ctx, gen: (&Ctx) -> ? $T) -> Iterator(T)
Iterator.generator :: (ctx: &$Ctx, gen: (&Ctx) -> ? $T, close: (&Ctx) -> void) -> Iterator(T)
Iterator.generator_no_copy :: (ctx: &$Ctx, gen: (&Ctx) -> ? $T) -> #auto
Iterator.generator_no_copy :: (ctx: &$Ctx, gen: (&Ctx) -> ? $T, close: (&Ctx) -> void) -> #auto
Iterator.group_by :: (it: Iterator($T), cmp: (T, T) -> bool) -> Iterator(CALL)
Groups like elements together using the provided comparison function. cmp
should return true
if the two elements are equal. The items should be sorted in such a way that the equal items appear next to each other.
Iterator.map :: (it: Iterator($T), transform: (T) -> $R) -> #auto
Iterator.map :: (it: Iterator($T), ctx: $Ctx, transform: (T, Ctx) -> $R) -> #auto
Iterator.next :: (it: Iterator) -> ? it.Iter_Type
Helper function to get the next value out of an iterator.
Iterator.next_opt :: (it: Iterator) -> ? it.Iter_Type
Helper function to get the next value out of an iterator, but translated to an optional. Returns None
if the iterator was empty, Some(value)
otherwise.
Iterator.prod :: macro (x: $I, y: $I2) -> #auto
where Iterable(I), Iterable(I2)
Iterator.prod :: (x: $I1, y_iter: Iterator($Y)) -> #auto
where Iterable(I1)
Iterator.scan :: macro (it: $T, init: $R, combine: $S) -> #auto
where Iterable(T)
Iterator.scan :: (it: Iterator($T), initial_value: $R, combine: (T, R) -> R) -> Iterator(R)
Iterator.scan1 :: macro (it: $T, combine: $S) -> #auto
where Iterable(T)
Iterator.scan1 :: (it: Iterator($T), combine: (T, T) -> T) -> Iterator(T)
Iterator.skip :: (it: Iterator($T), count: u32) -> Iterator(T)
Discards the first count
values and yields all remaining values.
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 :: macro (it: $T, cond: $F) -> #auto
where Iterable(T)
Iterator.some :: (it: Iterator($T), cond: (T) -> bool) -> bool
Iterator.sum :: macro (it: $T) -> #auto
where Iterable(T)
Iterator.sum :: (it: Iterator($T)) -> T
Iterator.take :: (it: Iterator($T), count: u32) -> Iterator(T)
Only yields the first count
values, then closes.
Iterator.take_while :: (it: Iterator($T), predicate: (T) -> bool) -> Iterator(T)
Yields values while the predicate returns true.
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.
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.
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.
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 :: (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 :: (arr: [] $T, x: T) -> bool
Slice.contains :: macro (arr: [] $T, $cmp: Code) -> bool
Slice.copy :: (sl: [] $T, allocator) -> [] T
Copies a slice to a new slice, allocated from the provided allocator.
Slice.count_where :: macro (arr: [] $T, predicate: (T) -> bool) -> #auto
Slice.count_where :: macro (arr: [] $T, predicate_body: Code) -> u32
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.every :: macro (arr: [] $T, predicate: (T) -> bool) -> #auto
Slice.every :: macro (arr: [] $T, predicate_body: Code) -> bool
Slice.fill_range :: (arr: [] $T, r: range, value: T) -> void
Sets all elements in the range to be value
.
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 :: macro (arr: [] $T, cond: Code) -> ? T
where type_is_struct(T)
Slice.find_opt :: macro (arr: [] $T, cond: Code) -> ? T
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 :: 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 :: (arr: [] $T, init: $R, f: (T, R) -> R) -> R
Slice.fold :: macro (arr: [] $T, init: $R, body: Code) -> R
Slice.fold1 :: (arr: [] $T, f: (T, T) -> T) -> ? T
Slice.fold1 :: macro (arr: [] $T, body: Code) -> ? T
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 :: (arr: [] $T, idx: i32) -> T
Get an element from a slice, with negative and wrap-around indexing.
Slice.get_opt :: (arr: [] $T, idx: i32) -> ? T
Get an element from a slice, with negative and wrap-around indexing.
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 :: macro (arr: [] $T) -> (i32, T)
Returns the largest element in the array, using >
to compare.
Slice.group_by :: macro (arr: [] $T, comp: (T, T) -> bool, allocator) -> [..] [] T
Slice.group_by :: macro (arr_: [] $T, comp: Code, allocator) -> [..] [] T
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 :: macro (arr: [] $T) -> (i32, T)
Returns the smallest element in the array, using <
to compare.
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.map :: (sl: [] $T, transform: (T) -> $R, allocator) -> [] R
Slice.map :: macro (sl: [] $T, transform: Code, allocator) -> #auto
Slice.map_inplace :: (sl: [] $T, transform: (T) -> T, allocator) -> #auto
Slice.map_inplace :: macro (sl: [] $T, transform: Code, allocator) -> #auto
Slice.product :: (arr: [] $T, start: T) -> T
Uses to multiply all elements in the slice.
Slice.quicksort :: (arr: [] $T, cmp: (T, T) -> i32) -> #auto
Slice.quicksort :: (arr: [] $T, cmp: (&T, &T) -> i32) -> #auto
Slice.scan :: (arr: [] $T, init: $R, f: (T, R) -> R) -> [] R
Slice.scan :: macro (arr: [] $T, init: $R, body: Code) -> [] R
Slice.scan1 :: (arr: [] $T, f: (T, T) -> T) -> [] T
Slice.scan1 :: macro (arr: [] $T, body: Code) -> [] T
Slice.set :: (arr: [] $T, idx: i32, value: T) -> void
Set a value in a slice, with negative and wrap-around indexing.
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 :: (arr: [] $T, cmp: (T, T) -> i32) -> [] T
Slice.sort :: (arr: [] $T, cmp: (&T, &T) -> i32) -> [] T
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 :: (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.
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 any
s and build runtime polymorphism.
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 :: struct {
low: i64
high: i64
step: i64
}
This is the same as the range
type, except with 64-bit integers.
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)'.
Optional.and_then :: (o: ? $T, transform: (T) -> ? $R) -> ? R
Monadic chaining operation.
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 :: (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 :: (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.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.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 :: macro (o: ? $T) -> T
Optional.or_return :: macro (o: ? $T, return_value: $R) -> T
Optional.reset :: (o: &? $T) -> void
Clears the value in the Optional, zeroing the memory of the value.
Optional.transform :: (o: ? $T, transform: (T) -> $R) -> ? R
Changes the value inside the optional, if present.
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 :: (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 :: macro (o: ? $T, default: T) -> #auto
Extracts the value from the Optional, or uses a default if no value is present.
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.
__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 :: 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 :: 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 :: () -> 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 :: 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 :: () -> 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 :: (cond: bool, msg: [] u8, site: CallSite) -> void
Checks if the condition is true. If not, invoke the context's assert handler.
calloc :: (size: u32) -> rawptr
Helper function to allocate using the allocator in the context structure.
cfree :: (ptr: rawptr) -> void
Helper function to free using the allocator in the context structure.
cresize :: (ptr: rawptr, size: u32) -> rawptr
Helper function to resize using the allocator in the context structure.
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 :: (level: Log_Level, msg: [] u8) -> void
log :: (level: Log_Level, module: [] u8, msg: [] u8) -> void
make :: macro ($T: type_expr, allocator) -> #auto
make :: macro ($T: type_expr, n: u32, allocator) -> #auto
make_temp :: macro (T: type_expr) -> unknown
make_temp :: macro (T: type_expr, n: u32) -> unknown
new :: ($T: type_expr, allocator) -> &T
new :: (T: type_expr, allocator: Allocator) -> rawptr
new :: macro (v: $T, allocator) -> &T
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 :: (msg: [] u8, site: CallSite) -> void
Causes a runtime panic with the specified error message.
raw_free :: (a: Allocator, ptr: rawptr) -> void
Helper procedure to free an allocation from an allocator.