core

Foundational types, numeric limits, status codes, and the allocator interface shared by core packages. Includes slice allocation, hashing, and equality helpers.

1 structs · 35 functions · Public API

Structs

Allocator

struct
Allocator : struct {
    policy : RawPtr = null
    alloc_fn : funcptr(RawPtr, AllocatorOp, i64, i64, RawPtr ) -> [RawPtr, MemoryStatus]
}
Allocator is the interface that represent any kind of allocator type
             (Permanent, Arena, HeapPages, etc). User must call Allocator.alloc_fn to
             communicate with the real allocator

Functions

allocate

func
allocate : func(self : ^Allocator, size : i64) -> [RawPtr, MemoryStatus]
Allocates a raw block of memory through the allocator's concrete policy.

Parameters:
  self : ^Allocator - allocator used to reserve the storage.
  size : i64        - requested size in bytes.

Returns:
  [RawPtr, MemoryStatus] - allocated storage and operation status.

allocate_aligned

func
allocate_aligned : func(self : ^Allocator, size : i64, alignment : i64 ) -> [RawPtr, MemoryStatus]
Requests a raw block of memory with the requested alignment.

Parameters:
  self      : ^Allocator - allocator used to reserve the storage.
  size      : i64        - requested size in bytes.
  alignment : i64        - requested byte alignment.

Returns:
  [RawPtr, MemoryStatus] - allocated storage and operation status.

Notes:
  - Alignment behavior is defined by the allocator's concrete policy.

clear

func
clear : func(self : ^Allocator) -> [RawPtr, MemoryStatus]
Resets reusable storage owned by the allocator's concrete policy.

Parameters:
  self : ^Allocator - allocator whose reusable storage is reset.

Returns:
  [RawPtr, MemoryStatus] - policy result pointer and operation status.

Notes:
  - Existing pointers may be overwritten by subsequent allocations.

free

func
free :  func(self : ^Allocator, ptr : RawPtr ) -> [RawPtr, MemoryStatus]
Releases a raw pointer through the allocator's concrete policy.

Parameters:
  self : ^Allocator - allocator that owns the storage.
  ptr  : RawPtr     - pointer submitted for release.

Returns:
  [RawPtr, MemoryStatus] - policy result pointer and operation status.

Notes:
  - Permanent and arena allocators do not reclaim individual allocations.

destroy

func
destroy : func(self : ^Allocator) -> [RawPtr, MemoryStatus]
Destroys the allocator's concrete policy and its owned backing storage.

Parameters:
  self : ^Allocator - allocator to destroy.

Returns:
  [RawPtr, MemoryStatus] - policy result pointer and operation status.

Notes:
  - Outstanding heap allocations must be freed individually before destruction.
  - The allocator must not be used after this call.

allocate

func
allocate : func<T>(self : ^Allocator) -> ^T
Allocates enough memory for one value of type T and returns the typed pointer.

Parameters:
  self : ^Allocator - allocator used to reserve the storage.

Returns:
  ^T - typed pointer to the allocated storage.

Notes:
  - The caller owns the returned storage.
  - Release it through the same allocator, for example with deallocate<T>.

deallocate

func
deallocate : func<T>(allocator : ^Allocator, ptr : ^^T)
Frees a pointer previously allocated through the allocator, then clears the
caller's pointer slot to null.

Parameters:
  allocator : ^Allocator - allocator that owns the storage.
  ptr       : ^^T        - address of the caller's typed pointer.

get_hash

func
get_hash : func(self : u64) -> i64
familly func

get_hash

func
get_hash : func(self : i64) -> i64

get_hash

func
get_hash : func(self : i8) -> i64

get_hash

func
get_hash : func(self : u8) -> i64

get_hash

func
get_hash : func(self : i16) -> i64

get_hash

func
get_hash : func(self : u16) -> i64

get_hash

func
get_hash : func(self : i32) -> i64

get_hash

func
get_hash : func(self : char) -> i64

get_hash

func
get_hash : func(self : u32) -> i64

get_hash

func
get_hash : func(self : rune) -> i64

get_hash

func
get_hash : func(self : bool) -> i64

are_equals

func
are_equals : func(a : i8, b : i8) -> bool
family funcs

are_equals

func
are_equals : func(a : i16, b : i16) -> bool

are_equals

func
are_equals : func(a : i32, b : i32) -> bool

are_equals

func
are_equals : func(a : i64, b : i64) -> bool

are_equals

func
are_equals : func(a : u8, b : u8) -> bool

are_equals

func
are_equals : func(a : u16, b : u16) -> bool

are_equals

func
are_equals : func(a : u32, b : u32) -> bool

are_equals

func
are_equals : func(a : u64, b : u64) -> bool

are_equals

func
are_equals : func(a : f32, b : f32) -> bool

are_equals

func
are_equals : func(a : f64, b : f64) -> bool

are_equals

func
are_equals : func(a : bool, b : bool) -> bool

are_equals

func
are_equals : func(a : char, b : char) -> bool

are_equals

func
are_equals : func(a : rune, b : rune) -> bool

are_equals

func
are_equals : func<T>(s1 : []T, s2 : []T) -> bool

make_slice

func
make_slice : func<T>(count : i64, allocator : ^Allocator) -> []T

make_slice

func
make_slice : func<T>(buffer : RawPtr, count : i64) -> []T

free_slice

func
free_slice : func<T>(slice : ^[]T, allocator : ^Allocator) -> void