2.1. Built-in runtime

The BUILTIN module contains core runtime functions available in all daslang programs without explicit require. It includes:

  • Heap and memory management (heap_bytes_allocated, heap_report, memory_report)

  • Debug output (print, debug, stackwalk)

  • Panic and error handling (panic, terminate, assert)

  • Pointer and memory operations (intptr, malloc, free)

  • Profiling (profile)

  • Type conversion (string)

All functions and symbols are in “builtin” module, use require to get access to it.

require builtin

Example:

[export]
    def main() {
        print("hello, world!\n")
        assert(1 + 1 == 2)
        let s = string(42)
        print("string(42) = {s}\n")
        let name = "daslang"
        print("welcome to {name}\n")
        var arr : array<int>
        arr |> push(10)
        arr |> push(20)
        print("length = {length(arr)}\n")
        print("arr[0] = {arr[0]}\n")
    }
    // output:
    // hello, world!
    // string(42) = 42
    // welcome to daslang
    // length = 2
    // arr[0] = 10

2.1.1. Type aliases

This bitfield specifies how exactly values are to be printed

Fields
  • escapeString (0x1) - if string is to be escaped

  • namesAndDimensions (0x2) - names of the fields and dimensions of the arrays

  • typeQualifiers (0x4) - type qualifiers for the specific types like double and uint64

  • refAddresses (0x8) - addresses in hexadecimal of each reference value

  • singleLine (0x10) - human readable vs single line

  • fixedPoint (0x20) - always output fixed point precision for floating point values

2.1.2. Constants

_builtin::DAS_MAX_FUNCTION_ARGUMENTS = 32

Maximum number of arguments a function can accept, used to pre-allocate stack space for function call arguments.

_builtin::INT_MIN = -2147483648

Minimum representable value of a signed 32-bit integer (int), equal to -2147483648.

_builtin::INT_MAX = 2147483647

Maximum representable value of a signed 32-bit integer (int), equal to 2147483647.

_builtin::UINT_MAX = 0xffffffff

Maximum representable value of an unsigned 32-bit integer (uint), equal to 4294967295.

_builtin::LONG_MIN = -9223372036854775808

Minimum representable value of a signed 64-bit integer (int64).

_builtin::LONG_MAX = 9223372036854775807

Maximum representable value of a signed 64-bit integer (int64).

_builtin::ULONG_MAX = 0xffffffffffffffff

Maximum representable value of an unsigned 64-bit integer (uint64).

FLT_MIN = 1.1754944e-38f

Smallest positive non-zero normalized value of the float type; for the most negative value use -FLT_MAX.

FLT_MAX = 3.4028235e+38f

Maximum finite representable value of the float (32-bit floating-point) type.

DBL_MIN = 2.2250738585072014e-308lf

Smallest positive non-zero normalized value of the double type; for the most negative value use -DBL_MAX.

DBL_MAX = 1.7976931348623157e+308lf

Maximum finite representable value of the double (64-bit floating-point) type.

_builtin::LOG_CRITICAL = 50000

Log level constant for critical errors such as panics, fatal failures, and shutdown notifications.

_builtin::LOG_ERROR = 40000

Log level constant for recoverable error conditions that do not require immediate shutdown.

_builtin::LOG_WARNING = 30000

Log level constant for warnings about potential problems, API misuse, or non-fatal error conditions.

_builtin::LOG_INFO = 20000

Log level constant for general informational messages about normal program operation.

_builtin::LOG_DEBUG = 10000

Log level constant for debug-level diagnostic messages useful during development.

_builtin::LOG_TRACE = 0

Log level constant for the most verbose tracing and diagnostic output, typically used for detailed debugging.

_builtin::VEC_SEP = ","

Read-only string constant used as the separator between vector components when printing; defaults to “,”.

_builtin::print_flags_debugger = bitfield

Predefined set of print_flags configured to match the output formatting used by the debug function.

2.1.3. Handled structures

_builtin::HashBuilder

Helper structure to facilitate calculating hash values.

2.1.4. Function annotations

_builtin::marker

Attaches arbitrary key-value annotation arguments to a function, typically used by macros to tag functions with metadata.

_builtin::generic

Forces a function to be treated as generic regardless of its argument types, causing it to be instanced in each calling module.

_builtin::_macro

Marks a function to be executed during the macro compilation pass, similar to [init] but running at macro time.

_builtin::macro_function

Marks a function as part of the macro subsystem, excluding it from the final compiled context unless it is explicitly referenced.

_builtin::hint

Provides optimization hints to the compiler for the annotated function via annotation arguments.

_builtin::jit

Explicitly forces the annotated function to be compiled using the JIT compiler, overriding default compilation decisions.

_builtin::no_jit

Prevents JIT compilation for the annotated function, forcing it to run in interpreted mode.

_builtin::nodiscard

Enforces that the return value of the function must be used by the caller; discarding the result produces a compilation error.

_builtin::deprecated

Marks a function as deprecated, causing a compilation warning when referenced and excluding it from the final compiled context.

_builtin::alias_cmres

Declares that the function always aliases cmres (copy-or-move result), disabling cmres return optimizations for it.

_builtin::never_alias_cmres

Declares that the function never aliases cmres (copy-or-move result), disabling aliasing safety checks for the return value.

_builtin::export

Forces a function to be exported and retained in the final compiled context, even if it is not directly called.

_builtin::pinvoke

Marks a function as a platform invoke (pinvoke) entry, routing its calls through the pinvoke interop machinery.

_builtin::no_lint

Skips all lint-pass checks for the annotated function, suppressing any lint warnings or errors it would produce.

_builtin::sideeffects

Declares that the function has side effects, preventing the compiler from optimizing away or reordering its calls.

_builtin::run

Forces the function to be evaluated at compile time, ensuring its body executes during compilation rather than at runtime.

_builtin::unsafe_operation

Marks a function as an unsafe operation, requiring callers to wrap the call in an unsafe block.

_builtin::unsafe_outside_of_for

Marks a function as unsafe to call outside of a source-level for loop, enforcing iterator-context usage.

_builtin::unsafe_when_not_clone_array

Marks a function as unsafe to call outside of an array clone operation, restricting its usage context.

_builtin::no_aot

Prevents ahead-of-time (AOT) C++ code generation for the annotated function, keeping it interpreted only.

_builtin::init

Registers a function to be called automatically during context initialization, before any user code runs.

_builtin::finalize

Registers a function to be called automatically when the context is shut down, for cleanup and resource release.

_builtin::hybrid

Marks a function as a hybrid call target so that AOT generates indirect calls to it, allowing the function to be patched without recompiling dependent AOT code.

_builtin::unsafe_deref

Optimization annotation that removes null-pointer checks, bounds checks on array and string indexing, and similar safety validations.

_builtin::skip_lock_check

Optimization annotation that disables runtime lock-check validation for the annotated function.

_builtin::unused_argument

Suppresses unused-argument warnings or errors for specific function parameters, providing a workaround when strict code policies are enabled.

_builtin::local_only

Restricts a function to accept only local make expressions such as structure initializers and tuple constructors.

_builtin::expect_any_vector

Contract annotation restricting a function argument to accept only das::vector template types.

_builtin::expect_dim

Contract annotation requiring a function argument to be a fixed-size (statically dimensioned) array.

_builtin::expect_ref

Contract annotation requiring a function argument to be passed by reference.

_builtin::type_function

Marks a function as a type function, meaning it operates on types at compile time and does not generate runtime code.

_builtin::builtin_array_sort

Internal function annotation that provides the sorting implementation used by the built-in sort function.

2.1.5. Call macros

_builtin::make_function_unsafe

Propagates the unsafe requirement to the calling function, making any function that calls it also require an unsafe block.

_builtin::concept_assert

Compile-time assertion that reports the error at the call site of the asserted function rather than at the assert line itself.

_builtin::__builtin_table_set_insert

Internal function annotation that implements the low-level key insertion for set-style tables (tables with keys only).

_builtin::__builtin_table_key_exists

Internal function annotation that implements the low-level key presence check for the key_exists operation.

_builtin::static_assert

Compile-time assertion that produces a compilation error with an optional message when the condition is false.

_builtin::verify

Assertion that preserves the evaluated expression even when asserts are disabled, ensuring side effects are never optimized out.

_builtin::debug

Prints the human-readable representation of a value to the log and returns that same value, allowing inline debugging in expressions.

_builtin::assert

Runtime assertion that panics with an optional error message when the first argument evaluates to false; can be disabled globally.

_builtin::memzero

Fills a region of memory with zeros, used internally for default-initializing values.

_builtin::__builtin_table_find

Internal function annotation that implements the low-level table lookup for the find operation.

_builtin::invoke

Invokes a block, function pointer, or lambda, dispatching the call through the appropriate calling convention.

_builtin::__builtin_table_erase

Internal function annotation that implements the low-level table entry removal for the erase operation.

2.1.6. Reader macros

_builtin::_esc

Reader macro that returns the raw string content without processing escape sequences, e.g. %_esc~nr~%_esc yields the literal four characters `, `n, `, `r.

2.1.7. Typeinfo macros

_builtin::rtti_classinfo

Typeinfo macro that generates RTTI TypeInfo metadata required for class initialization and reflection.

2.1.8. Handled types

_builtin::das_string

Handled type wrapping das::string (typically std::string), providing heap-allocated mutable string storage.

_builtin::clock

Handled type wrapping das::Time, which encapsulates the C time_t value for calendar time representation.

2.1.9. Structure macros

_builtin::comment

No-op structure annotation that holds annotation arguments as metadata without affecting code generation.

_builtin::no_default_initializer

Prevents the compiler from generating a default initializer for the annotated structure.

_builtin::macro_interface

Marks a class hierarchy as a macro interface, preventing it and its descendants from being exported by default.

_builtin::skip_field_lock_check

Optimization annotation that disables runtime lock checks when accessing fields of the annotated structure.

_builtin::cpp_layout

Forces the structure to use C++ memory layout rules (alignment and padding) instead of native daslang layout.

_builtin::safe_when_uninitialized

Declares that the structure is safe to access before explicit initialization, suppressing uninitialized-use errors.

_builtin::persistent

Allocates the structure on the C++ heap (via new) instead of the daslang context heap, allowing it to outlive the context.

2.1.10. Containers

2.1.10.1. back

_builtin::back(a: array<auto(TT)>#) : TT const&#()

Accesses and returns a const temporary reference to the last element of the temporary dynamic array a.

Arguments
  • a : array<auto(TT)>#!

_builtin::back(a: array<auto(TT)>) : TT()
_builtin::back(a: array<auto(TT)>#) : TT&#()
_builtin::back(arr: auto(TT) ==const) : auto&()
_builtin::back(arr: auto(TT) ==const) : auto()
_builtin::back(a: array<auto(TT)>) : TT&()

2.1.10.2. capacity

_builtin::capacity(table: table<anything, anything>) : int()

Returns the current capacity of the table — the number of key-value pairs it can hold before triggering a reallocation.

Arguments
  • table : table implicit

_builtin::capacity(array: array<anything>) : int()

2.1.10.3. clear

_builtin::clear(array: array<anything>)

Removes all elements from the dynamic array, leaving it empty with a size of 0.

Arguments
  • array : array implicit

_builtin::clear(t: table<auto(KT), auto(VT)>) : auto()

_builtin::copy_to_local(a: auto(TT)) : TT()

Copies the value a and returns it as a new local value on the stack, which can be used to work around aliasing issues where a reference might be invalidated.

Arguments
  • a : auto(TT)

2.1.10.4. each

_builtin::each(a: array<auto(TT)>#) : iterator<TT&#>()

Creates an iterator that yields temporary references to each element of the temporary dynamic array a.

Arguments
  • a : array<auto(TT)>#

_builtin::each(str: string) : iterator<int>()
_builtin::each(a: array<auto(TT)>) : iterator<TT&>()
_builtin::each(a: auto(TT)[]) : iterator<TT&>()
_builtin::each(lam: lambda<(var arg:auto(argT)):bool>) : iterator<argT>()
_builtin::each(rng: range) : iterator<int>()
_builtin::each(rng: urange64) : iterator<uint64>()
_builtin::each(rng: range64) : iterator<int64>()
_builtin::each(rng: urange) : iterator<uint>()

_builtin::each_enum(tt: auto(TT)) : iterator<TT>()

Warning

This function is deprecated.

Creates an iterator that yields every value of the enumeration type inferred from tt, allowing iteration over all members of an enum.

Arguments
  • tt : auto(TT)

_builtin::each_ref(lam: lambda<(var arg:auto(argT)?):bool>) : iterator<argT&>()

Wraps a lambda lam — which receives a mutable pointer argument and returns a bool indicating whether to continue — into an iterator that yields references to each value rather than copies.

Arguments
  • lam : lambda<(arg:auto(argT)?):bool>

2.1.10.5. emplace

_builtin::emplace(Arr: array<auto(numT)>; value: numT&; at: int) : auto()

Moves value into the dynamic array Arr at index at using move semantics, shifting subsequent elements forward.

Arguments
  • Arr : array<auto(numT)>

  • value : numT&

  • at : int

_builtin::emplace(Arr: array<auto(numT)>; value: numT&) : auto()
_builtin::emplace(Tab: table<auto(keyT), auto(valT)[]>; at: keyT|keyT#; val: valT[]&) : auto()
_builtin::emplace(Tab: table<auto, auto>; key: auto; value: auto) : auto()
_builtin::emplace(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#; val: valT&) : auto()
_builtin::emplace(Tab: table<auto(keyT), smart_ptr<auto(valT)>>; at: keyT|keyT#; val: smart_ptr<valT>&) : auto()
_builtin::emplace(a: array<auto>; value: auto) : auto()
_builtin::emplace(Arr: array<auto(numT)>; value: numT[]) : auto()
_builtin::emplace(Arr: array<auto(numT)[]>; value: numT[]) : auto()

_builtin::emplace_default(tab: table<auto(keyT), auto(valT)>; key: keyT|keyT#)

Constructs a new default-initialized element in the table tab at the given key, only if that key does not already exist.

Arguments
  • tab : table<auto(keyT);auto(valT)>

  • key : option<keyT| keyT#>

2.1.10.6. emplace_new

_builtin::emplace_new(Arr: array<smart_ptr<auto(numT)>>; value: smart_ptr<numT>) : auto()

Moves a smart pointer value into the end of the array Arr, constructing the entry in-place and returning a reference to it.

Arguments
  • Arr : array<smart_ptr<auto(numT)>>

  • value : smart_ptr<numT>

_builtin::emplace_new(tab: table<auto(kT), smart_ptr<auto(vT)>>; key: kT; value: smart_ptr<vT>) : auto()

2.1.10.7. empty

_builtin::empty(str: string) : bool()

Checks whether the das_string is empty (has zero length) and returns true if so.

Arguments
  • str : string implicit

_builtin::empty(str: das_string) : bool()
_builtin::empty(a: table<auto;auto>|table<auto;auto>#) : bool()
_builtin::empty(a: array<auto>|array<auto>#) : bool()
_builtin::empty(iterator: iterator) : bool()

2.1.10.8. erase

_builtin::erase(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#) : bool()

Removes the entry with key at from the table Tab, returning true if the key was found and erased.

Arguments
  • Tab : table<auto(keyT);auto(valT)>

  • at : option<keyT| keyT#>

_builtin::erase(Arr: array<auto(numT)>; at: int) : auto()
_builtin::erase(Arr: array<auto(numT)>; at: int; count: int) : auto()
_builtin::erase(Tab: table<auto(keyT), auto(valT)>; at: string#) : bool()

_builtin::erase_if(arr: array<auto(TT)>; blk: block<(key:TT const):bool>|block<(var key:TT&):bool>) : auto()

Iterates over the array arr and removes all elements for which the block blk returns true.

Arguments
  • arr : array<auto(TT)>

  • blk : option<block<(key:TT):bool>| block<(key:TT&):bool>>

2.1.10.9. find_index

_builtin::find_index(arr: array<auto(TT)>|array<auto(TT)>#; key: TT) : auto()

Searches the dynamic array arr for the first occurrence of key and returns its index, or -1 if not found.

Arguments
  • arr : option<array<auto(TT)>| array<auto(TT)>#>

  • key : TT

_builtin::find_index(arr: iterator<auto(TT)>; key: TT) : auto()
_builtin::find_index(arr: auto(TT)[]|auto(TT)[]#; key: TT) : auto()

2.1.10.10. find_index_if

_builtin::find_index_if(arr: iterator<auto(TT)>; blk: block<(key:TT):bool>) : auto()

Consumes elements from the iterator arr and returns the index of the first element for which the block blk returns true, or -1 if no match is found.

Arguments
  • arr : iterator<auto(TT)>

  • blk : block<(key:TT):bool>

_builtin::find_index_if(arr: array<auto(TT)>|array<auto(TT)>#; blk: block<(key:TT):bool>) : auto()
_builtin::find_index_if(arr: auto(TT)[]|auto(TT)[]#; blk: block<(key:TT):bool>) : auto()

2.1.10.11. get

_builtin::get(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#; blk: block<(p:valT):void>) : auto()

Looks up at in the table Tab and, if found, invokes blk with a reference to the value; returns true if the key existed, false otherwise.

Arguments
  • Tab : table<auto(keyT);auto(valT)>!

  • at : option<keyT| keyT#>

  • blk : block<(p:valT&):void>

_builtin::get(Tab: table<auto(keyT), auto(valT)>#; at: keyT|keyT#; blk: block<(p:valT const&#):void>) : auto()
_builtin::get(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#; blk: block<(var p:valT&):void>) : auto()
_builtin::get(Tab: table<auto(keyT), auto(valT)>#; at: keyT|keyT#; blk: block<(var p:valT&#):void>) : auto()
_builtin::get(Tab: table<auto(keyT), auto(valT)[]>#; at: keyT|keyT#; blk: block<(p:valT const[-2]&#):void>) : auto()
_builtin::get(Tab: table<auto(keyT), auto(valT)[]>; at: keyT|keyT#; blk: block<(var p:valT[-2]&):void>) : auto()
_builtin::get(Tab: table<auto(keyT), auto(valT)[]>; at: keyT|keyT#; blk: block<(p:valT const[-2]&):void>) : auto()
_builtin::get(Tab: table<auto(keyT), void>; at: keyT|keyT#; blk: block<(var p:void?):void>) : auto()
_builtin::get(Tab: table<auto(keyT), auto(valT)[]>#; at: keyT|keyT#; blk: block<(var p:valT[-2]&#):void>) : auto()

2.1.10.12. get_value

_builtin::get_value(Tab: table<auto(keyT), auto(valT)[]>; at: keyT|keyT#) : valT[-2]()

Retrieves the fixed-size array value associated with key at from the mutable table Tab.

Arguments
  • Tab : table<auto(keyT);auto(valT)[-1]>

  • at : option<keyT| keyT#>

_builtin::get_value(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#) : valT()
_builtin::get_value(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#) : valT()
_builtin::get_value(Tab: table<auto(keyT), smart_ptr<auto(valT)>>; at: keyT|keyT#) : smart_ptr<valT>()

_builtin::get_with_default(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#; blk: block<(var p:valT&):void>)

Looks up key at in the table Tab, inserting a default-initialized entry if the key is absent, then invokes blk with a mutable reference to the value.

Arguments
  • Tab : table<auto(keyT);auto(valT)>!

  • at : option<keyT| keyT#>

  • blk : block<(p:valT&):void>

2.1.10.13. has_value

_builtin::has_value(a: iterator<auto>; key: auto) : auto()

Consumes elements from the iterator a and returns true if any element equals key.

Arguments
  • a : iterator<auto>

  • key : auto

_builtin::has_value(a: auto; key: auto) : auto()

2.1.10.14. insert

_builtin::insert(Tab: table<auto(keyT), void>; at: keyT|keyT#) : auto()

Inserts the key at into the set-style table Tab (a table with void values), effectively adding to a set.

Arguments
  • Tab : table<auto(keyT);void>

  • at : option<keyT| keyT#>

_builtin::insert(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#; val: valT ==const|valT const# ==const) : auto()
_builtin::insert(Tab: table<auto(keyT), auto(valT)[]>; at: keyT|keyT#; val: valT[] ==const|valT[]# ==const) : auto()
_builtin::insert(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#; val: valT ==const|valT# ==const) : auto()
_builtin::insert(Tab: table<auto(keyT), auto(valT)[]>; at: keyT|keyT#; val: valT const[] ==const|valT const[]# ==const) : auto()

2.1.10.15. insert_clone

_builtin::insert_clone(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#; val: valT ==const|valT# ==const) : auto()

Inserts or updates an entry in the table Tab at key at by cloning the mutable value val into the table.

Arguments
  • Tab : table<auto(keyT);auto(valT)>

  • at : option<keyT| keyT#>

  • val : option<valT!| valT#!>

_builtin::insert_clone(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#; val: valT ==const|valT const# ==const) : auto()
_builtin::insert_clone(Tab: table<auto(keyT), auto(valT)[]>; at: keyT|keyT#; val: valT[] ==const|valT[]# ==const) : auto()
_builtin::insert_clone(Tab: table<auto(keyT), auto(valT)[]>; at: keyT|keyT#; val: valT const[] ==const|valT const[]# ==const) : auto()

2.1.10.16. insert_default

_builtin::insert_default(tab: table<auto(keyT), auto(valT)>; key: keyT|keyT#; value: valT ==const|valT const# ==const)

Inserts key key with the given const value into table tab only if the key does not already exist; existing entries are left unchanged.

Arguments
  • tab : table<auto(keyT);auto(valT)>

  • key : option<keyT| keyT#>

  • value : option<valT!| valT#!>

_builtin::insert_default(tab: table<auto(keyT), auto(valT)>; key: keyT|keyT#)
_builtin::insert_default(tab: table<auto(TT), auto(QQ)>; key: TT|TT#; value: QQ ==const|QQ# ==const)

2.1.10.17. key_exists

_builtin::key_exists(Tab: table<auto(keyT);auto(valT)>|table<auto(keyT);auto(valT)>#; at: keyT|keyT#) : bool()

Checks whether the key at exists in the table Tab and returns true if found.

Arguments
  • Tab : option<table<auto(keyT);auto(valT)>| table<auto(keyT);auto(valT)>#>

  • at : option<keyT| keyT#>

_builtin::key_exists(Tab: table<auto(keyT);auto(valT)>|table<auto(keyT);auto(valT)>#; at: string#) : bool()

2.1.10.18. keys

_builtin::keys(a: table<auto(keyT);auto(valT)> ==const|table<auto(keyT);auto(valT)># ==const) : iterator<keyT>()

Creates an iterator over all keys of the mutable table a, allowing enumeration of the table’s key set.

Arguments
  • a : option<table<auto(keyT);auto(valT)>!| table<auto(keyT);auto(valT)>#!>

_builtin::keys(a: table<auto(keyT);auto(valT)> ==const|table<auto(keyT);auto(valT)> const# ==const) : iterator<keyT>()

2.1.10.19. length

_builtin::length(a: auto|auto#) : int()

Returns the number of elements currently stored in a table or dynamic array a.

Arguments
  • a : option<auto| auto#>

_builtin::length(array: array<anything>) : int()
_builtin::length(table: table<anything, anything>) : int()

2.1.10.20. lock

_builtin::lock(a: array<auto(TT)> ==const|array<auto(TT)> const# ==const; blk: block<(x:array<TT>#):auto>) : auto()

Locks a constant array for the duration of blk, preventing structural modifications while providing read-only access through a temporary reference.

Arguments
  • a : option<array<auto(TT)>!| array<auto(TT)>#!>

  • blk : block<(x:array<TT>#):auto>

_builtin::lock(a: array<auto(TT)> ==const|array<auto(TT)># ==const; blk: block<(var x:array<TT>#):auto>) : auto()
_builtin::lock(Tab: table<auto(keyT);auto(valT)>|table<auto(keyT);auto(valT)>#; blk: block<(t:table<keyT, valT>#):void>) : auto()

_builtin::lock_forever(Tab: table<auto(keyT);auto(valT)>|table<auto(keyT);auto(valT)>#) : table<keyT, valT>#()

Permanently locks a table, preventing any future insertions, deletions, or structural modifications, and returns a temporary reference to it.

Arguments
  • Tab : option<table<auto(keyT);auto(valT)>| table<auto(keyT);auto(valT)>#>

_builtin::modify(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#; blk: block<(p:valT):valT>)

Looks up at in Tab and, if found, invokes blk with the current value, replacing it with the value returned by the block.

Arguments
  • Tab : table<auto(keyT);auto(valT)>!

  • at : option<keyT| keyT#>

  • blk : block<(p:valT&):valT>

_builtin::move_to_local(a: auto(TT)&) : TT()

Moves the value referenced by a onto the stack as a local copy and returns it, clearing the original; useful for resolving aliasing issues.

Arguments
  • a : auto(TT)&

_builtin::move_to_ref(a: auto&; b: auto) : auto()

Moves b into the reference a; if b is a value type rather than a reference, it is copied instead of moved.

Arguments
  • a : auto&

  • b : auto

_builtin::next(it: iterator<auto(TT)>; value: TT&) : bool()

Advances the iterator it and stores the next element in value, returning true if an element was retrieved or false if the iterator is exhausted or null.

Arguments
  • it : iterator<auto(TT)>

  • value : TT&

_builtin::nothing(it: iterator<auto(TT)>) : iterator<TT>()

Produces an empty iterator of the same element type as it that yields no elements.

Arguments
  • it : iterator<auto(TT)>

_builtin::pop(Arr: array<auto(numT)>) : auto()

Removes and discards the last element of Arr, reducing its length by one.

Arguments
  • Arr : array<auto(numT)>

2.1.10.21. push

_builtin::push(Arr: array<auto(numT)[]>; varr: numT const[] ==const) : auto()

Appends a constant fixed-size array element varr to the end of Arr, an array of fixed-size arrays.

Arguments
  • Arr : array<auto(numT)[-1]>

  • varr : numT[-1]!

_builtin::push(Arr: array<auto(numT)>; varr: numT[]) : auto()
_builtin::push(Arr: array<auto(numT)[]>; varr: numT[] ==const) : auto()
_builtin::push(Arr: array<auto(numT)>; varr: array<numT>) : auto()
_builtin::push(Arr: array<auto(numT)>; value: numT ==const) : auto()
_builtin::push(Arr: array<auto(numT)>; value: numT ==const; at: int) : auto()
_builtin::push(Arr: array<auto(numT)>; value: numT ==const) : auto()
_builtin::push(Arr: array<auto(numT)>; varr: array<numT>) : auto()
_builtin::push(Arr: array<auto(numT)>; value: numT ==const; at: int) : auto()

2.1.10.22. push_clone

_builtin::push_clone(A: auto(CT); b: auto(TT)|auto(TT)#) : auto()

Clones and appends element b to the container A, using deep copy semantics rather than move or shallow copy.

Arguments
  • A : auto(CT)

  • b : option<auto(TT)| auto(TT)#>

_builtin::push_clone(Arr: array<auto(numT)[]>; varr: numT[]) : auto()
_builtin::push_clone(Arr: array<auto(numT)>; varr: numT const[] ==const) : auto()
_builtin::push_clone(Arr: array<auto(numT)>; value: numT ==const|numT# ==const) : auto()
_builtin::push_clone(Arr: array<auto(numT)>; varr: numT[] ==const) : auto()
_builtin::push_clone(Arr: array<auto(numT)>; value: numT ==const|numT# ==const; at: int) : auto()
_builtin::push_clone(Arr: array<auto(numT)>; value: numT ==const|numT const# ==const; at: int) : auto()
_builtin::push_clone(Arr: array<auto(numT)>; value: numT ==const|numT const# ==const) : auto()
_builtin::push_clone(Arr: array<auto(numT)[]>; varr: numT const[] ==const) : auto()

_builtin::remove_value(arr: array<auto(TT)>|array<auto(TT)>#; key: TT) : bool()

Searches arr for the first element equal to key and removes it, returning true if an element was found and removed or false otherwise.

Arguments
  • arr : option<array<auto(TT)>| array<auto(TT)>#>

  • key : TT

2.1.10.23. reserve

_builtin::reserve(Tab: table<auto(keyT), auto>; newSize: int) : auto()

Pre-allocates memory in Tab to hold at least newSize entries without rehashing, improving performance of subsequent insertions.

Arguments
  • Tab : table<auto(keyT);auto>

  • newSize : int

_builtin::reserve(Arr: array<auto(numT)>; newSize: int) : auto()

_builtin::resize(Arr: array<auto(numT)>; newSize: int) : auto()

Resizes dynamic array Arr to newSize elements; new elements beyond the previous length are zero-initialized, and excess elements are removed.

Arguments
  • Arr : array<auto(numT)>

  • newSize : int

2.1.10.24. resize_and_init

_builtin::resize_and_init(Arr: array<auto(numT)>; newSize: int; initValue: numT) : auto()

Resizes dynamic array Arr to newSize elements, initializing any newly added elements with the provided initValue.

Arguments
  • Arr : array<auto(numT)>

  • newSize : int

  • initValue : numT

_builtin::resize_and_init(Arr: array<auto(numT)>; newSize: int) : auto()

_builtin::resize_no_init(Arr: array<auto(numT)>; newSize: int) : auto()

Resizes dynamic array Arr to newSize elements without initializing newly added entries, leaving their memory contents undefined.

Arguments
  • Arr : array<auto(numT)>

  • newSize : int

2.1.10.25. sort

_builtin::sort(a: array<auto(TT)>|array<auto(TT)>#) : auto()

Sorts a dynamic array in place in ascending order using the default comparison for its element type.

Arguments
  • a : option<array<auto(TT)>| array<auto(TT)>#>

_builtin::sort(a: array<auto(TT)>|array<auto(TT)>#; cmp: block<(x:TT;y:TT):bool>) : auto()
_builtin::sort(a: auto(TT)[]|auto(TT)[]#) : auto()
_builtin::sort(a: auto(TT)[]|auto(TT)[]#; cmp: block<(x:TT;y:TT):bool>) : auto()

2.1.10.26. subarray

_builtin::subarray(a: auto(TT)[]; r: urange) : auto()

Creates and returns a new dynamic array containing a copy of elements from fixed-size array a within the unsigned range r.

Arguments
  • a : auto(TT)[-1]

  • r : urange

_builtin::subarray(a: array<auto(TT)>; r: urange) : auto()
_builtin::subarray(a: array<auto(TT)>; r: range) : auto()
_builtin::subarray(a: array<auto(TT)>; r: range) : auto()
_builtin::subarray(a: auto(TT)[]; r: range) : auto()

2.1.10.27. to_array

_builtin::to_array(a: auto(TT)[]) : array<TT>()

Converts a fixed-size array a into a new dynamic array by cloning each element.

Arguments
  • a : auto(TT)[-1]

_builtin::to_array(it: iterator<auto(TT)>) : array<TT>()

2.1.10.28. to_array_move

_builtin::to_array_move(a: auto(TT) ==const) : array<TT>()

Converts a mutable container a into a new dynamic array, moving elements when possible instead of cloning.

Arguments
  • a : auto(TT)!

_builtin::to_array_move(a: auto(TT)[]) : array<TT>()
_builtin::to_array_move(a: auto(TT) ==const) : array<TT>()

2.1.10.29. to_table

_builtin::to_table(a: tuple<auto(keyT);auto(valT)>[]) : table<keyT, valT>()

Converts a fixed-size array of key-value tuples a into a table<keyT, valT> by cloning each key and value.

Arguments
  • a : tuple<auto(keyT);auto(valT)>[-1]

_builtin::to_table(a: auto(keyT)[]) : table<keyT, void>()

2.1.10.30. to_table_move

_builtin::to_table_move(a: tuple<auto(keyT);auto(valT)>[]) : table<keyT, valT>()

Converts a mutable fixed-size array of key-value tuples a into a table<keyT, valT>, moving elements when possible.

Arguments
  • a : tuple<auto(keyT);auto(valT)>[-1]

_builtin::to_table_move(a: tuple<auto(keyT);auto(valT)>) : table<keyT, valT>()
_builtin::to_table_move(a: array<tuple<auto(keyT);auto(valT)>>) : table<keyT, valT>()
_builtin::to_table_move(a: auto(keyT)[]) : table<keyT, void>()
_builtin::to_table_move(a: array<auto(keyT)>) : table<keyT, void>()
_builtin::to_table_move(a: auto(keyT)) : table<keyT, void>()

2.1.10.31. values

_builtin::values(a: table<auto(keyT);auto(valT)[]> ==const|table<auto(keyT);auto(valT)[]># ==const) : iterator<valT[-2]&>()

Returns a mutable iterator over all fixed-size array values in a mutable table<keyT, valT[]>, yielding each array by reference.

Arguments
  • a : option<table<auto(keyT);auto(valT)[-1]>!| table<auto(keyT);auto(valT)[-1]>#!>

_builtin::values(a: table<auto(keyT);auto(valT)[]> ==const|table<auto(keyT);auto(valT)[]> const# ==const) : iterator<valT const[-2]&>()
_builtin::values(a: table<auto(keyT);auto(valT)> ==const|table<auto(keyT);auto(valT)> const# ==const) : iterator<valT const&>()
_builtin::values(a: table<auto(keyT);void> ==const|table<auto(keyT);void> const# ==const) : auto()
_builtin::values(a: table<auto(keyT);void> ==const|table<auto(keyT);void># ==const) : auto()
_builtin::values(a: table<auto(keyT);auto(valT)> ==const|table<auto(keyT);auto(valT)># ==const) : iterator<valT&>()

2.1.11. das::string manipulation

_builtin::peek(src: das_string; block: block<(string#):void>)

Provides zero-copy read access to the contents of a das_string by invoking block with a temporary string reference, avoiding allocation.

Arguments
  • src : das_string implicit

  • block : block<(string#):void> implicit

2.1.12. Heap reporting

_builtin::heap_allocation_count() : uint64()

Returns the total number of heap allocations performed by the current context since it was created.

_builtin::heap_allocation_stats() : urange64()

Returns heap allocation statistics as a urange64, where the x component is total bytes allocated and the y component is total bytes freed.

_builtin::heap_bytes_allocated() : uint64()

Returns the number of bytes currently in use on the heap (allocated minus freed), not counting reserved but unused memory.

_builtin::heap_collect(string_heap: bool = true; validate: bool = false)

Warning

This is unsafe operation.

Triggers garbage collection on the context heap; when string_heap is true the string heap is also collected, and when validate is true additional validation checks are performed.

Arguments
  • string_heap : bool

  • validate : bool

_builtin::heap_depth() : int()

Returns the number of generations (depth of the allocation chain) in the context’s regular heap.

_builtin::heap_report()

Prints a diagnostic report of current heap usage and allocation statistics to the output log.

_builtin::memory_report(errorsOnly: bool)

Prints a report of memory allocations for the current context; when errorsOnly is true, only GC-related errors are included.

Arguments
  • errorsOnly : bool

_builtin::string_heap_allocation_count() : uint64()

Returns the total number of individual string allocations performed on the current context’s string heap.

_builtin::string_heap_allocation_stats() : urange64()

Returns string heap allocation statistics as a urange64 where x is total bytes allocated and y is total bytes deleted.

_builtin::string_heap_bytes_allocated() : uint64()

Returns the total number of bytes currently allocated in the current context’s string heap.

_builtin::string_heap_depth() : int()

Returns the number of generational layers (depth) in the current context’s string heap.

_builtin::string_heap_report()

Prints a detailed report of string heap usage, including allocation counts and byte statistics, to the log output.

2.1.13. GC0 infrastructure

_builtin::gc0_reset()

Clears the entire gc0 storage, invalidating all previously saved pointers and smart pointers stored within it.

_builtin::gc0_restore_ptr(name: string) : void?()

Retrieves a raw pointer previously saved in gc0 storage under the specified name, returning null if not found.

Arguments
  • name : string implicit

_builtin::gc0_restore_smart_ptr(name: string) : smart_ptr<void>()

Retrieves a smart_ptr<void> previously saved in gc0 storage under the specified name.

Arguments
  • name : string implicit

_builtin::gc0_save_ptr(name: string; data: void?)

Stores a raw pointer data into gc0 storage under the specified name, allowing it to be retrieved later with gc0_restore_ptr.

Arguments
  • name : string implicit

  • data : void? implicit

_builtin::gc0_save_smart_ptr(name: string; data: smart_ptr<void>)

Stores a smart_ptr<void> data into gc0 storage under the specified name, allowing it to be retrieved later with gc0_restore_smart_ptr.

Arguments
  • name : string implicit

  • data : smart_ptr<void> implicit

2.1.14. Smart ptr infrastructure

2.1.14.1. add_ptr_ref

_builtin::add_ptr_ref(src: auto(TT)?) : smart_ptr<TT>()

Wraps a raw pointer src of type TT? into a smart_ptr<TT> by incrementing the reference count. Commonly used to bridge AST node fields (which are raw pointers like Structure?, Enumeration?) to API functions that expect smart_ptr<T>. The overload accepting smart_ptr<auto(TT)> adds an additional reference to an existing smart pointer, returning a new smart_ptr<TT> that shares ownership.

Arguments
  • src : auto(TT)?

_builtin::add_ptr_ref(src: smart_ptr<auto(TT)>) : smart_ptr<TT>()

_builtin::get_const_ptr(src: smart_ptr<auto(TT)>) : TT?()

Extracts a constant raw pointer of type TT? from the given smart_ptr<TT>, without affecting reference counting.

Arguments
  • src : smart_ptr<auto(TT)>

2.1.14.2. get_ptr

_builtin::get_ptr(src: smart_ptr<auto(TT)> ==const) : TT?()

Extracts a mutable raw pointer of type TT? from the given mutable smart_ptr<TT>, without affecting reference counting.

Arguments
  • src : smart_ptr<auto(TT)>!

_builtin::get_ptr(src: smart_ptr<auto(TT)> ==const) : TT?()

2.1.14.3. move

_builtin::move(dest: smart_ptr<void>&; src: void?)

Moves a raw pointer src into the smart pointer dest, nullifying the previous contents of dest and transferring ownership of src.

Arguments
  • dest : smart_ptr<void>& implicit

  • src : void? implicit

_builtin::move(dest: smart_ptr<void>&; src: smart_ptr<void>&)

_builtin::move_new(dest: smart_ptr<void>&; src: smart_ptr<void>)

Moves a newly constructed smart pointer value src into dest, used to initialize a smart_ptr from a new expression.

Arguments
  • dest : smart_ptr<void>& implicit

  • src : smart_ptr<void> implicit

2.1.14.4. smart_ptr_clone

_builtin::smart_ptr_clone(dest: smart_ptr<void>&; src: void?)

Clones a raw pointer src into smart pointer dest, incrementing the internal reference count to share ownership.

Arguments
  • dest : smart_ptr<void>& implicit

  • src : void? implicit

_builtin::smart_ptr_clone(dest: smart_ptr<void>&; src: smart_ptr<void>)

_builtin::smart_ptr_is_valid(dest: smart_ptr<void>) : bool()

Checks whether the smart pointer dest holds a non-null reference to valid data, returning true if it does.

Arguments
  • dest : smart_ptr<void> implicit

_builtin::smart_ptr_use_count(ptr: smart_ptr<void>) : uint()

Returns the current reference count of the object managed by ptr, indicating how many smart pointers share ownership.

Arguments
  • ptr : smart_ptr<void> implicit

2.1.15. Macro infrastructure

_builtin::is_compiling() : bool()

Returns true if the current context is in the process of being compiled, allowing compile-time logic to distinguish from runtime execution.

_builtin::is_compiling_macros() : bool()

Returns true if the current context is being compiled and the compiler is currently executing the macro pass.

_builtin::is_compiling_macros_in_module(name: string) : bool()

Returns true if the current context is being compiled during the macro pass and the compiler is processing the module specified by name.

Arguments
  • name : string implicit

_builtin::is_folding() : bool()

Returns true if the compiler is currently performing its constant folding optimization pass.

_builtin::is_in_completion() : bool()

Returns true if the compiler is running in completion mode, generating lexical information for a text editor’s code-completion system.

_builtin::is_reporting_compilation_errors() : bool()

Returns true if the context failed to compile and the inference pass is currently reporting compilation errors.

2.1.16. Profiler

_builtin::collect_profile_info() : string()

Collects profiling information gathered by the built-in line profiler and returns it as a formatted string containing execution counts and timing data.

_builtin::dump_profile_info()

Prints the execution counts and timing data for all lines collected by the built-in line profiler to the standard output.

_builtin::profile(count: int; category: string; block: block<():void>) : float()

Executes block a total of count times under the given category label, prints the timing, and returns the minimum elapsed time in seconds across all iterations.

Arguments
  • count : int

  • category : string implicit

  • block : block<void> implicit

_builtin::reset_profiler()

Resets all counters and accumulated data in the built-in profiler to zero.

2.1.17. System infrastructure

_builtin::aot_enabled() : bool()

Checks whether ahead-of-time (AOT) compilation is enabled for the current program and returns true if it is.

_builtin::breakpoint()

Triggers a debugger breakpoint by calling os_debugbreakpoint, which is a link-time dependency expected to be provided by the host application or debugger tool.

_builtin::error(text: string)

Outputs the string text to the context’s error stream, similar to print but directed to the error output channel.

Arguments
  • text : string implicit

_builtin::eval_main_loop(block: block<():void>)

Executes the application main loop by repeatedly invoking block until it returns false; on Emscripten targets, uses the platform-specific main loop mechanism instead.

Arguments
  • block : block<void> implicit

_builtin::feint(text: string)

No-op replacement for print. Has the same signature and side-effect annotations as print, but intentionally does nothing. Use feint in tests where print-like behavior is needed to prevent the call from being optimized out, but no actual output is desired.

Arguments
  • text : string implicit

_builtin::get_das_root() : string()

Returns the file-system path to the daslang root directory, where daslib and other standard libraries are located.

_builtin::is_in_aot() : bool()

Returns true if the compiler is currently generating ahead-of-time (AOT) compiled code.

_builtin::is_intern_strings() : bool()

Returns true if string interning is enabled in the current context, meaning identical strings share the same memory.

_builtin::panic(text: string)

will cause panic. The program will be terminated if there is no recover. Panic is not an error handling mechanism and can not be used as such. It is indeed panic, fatal error. It is not supposed that program can completely correctly recover from panic, recover construction is provided so program can try to correctly shut-down or report fatal error. If there is no recover within the script, it will be called in calling eval (in C++ callee code).

Arguments
  • text : string implicit

_builtin::print(text: string)

Outputs text to the current context’s log, typically printing to standard output.

Arguments
  • text : string implicit

Converts value to its string representation using the specified flags to control formatting, and returns the result as a string.

Arguments
_builtin::sprint_json(value: any; humanReadable: bool) : string()

Serializes value directly to a JSON string, bypassing intermediate representation for speed; set humanReadable to true for indented output.

Arguments
  • value : any

  • humanReadable : bool

_builtin::stackwalk(args: bool = true; vars: bool = true)

Prints the current call stack to the log; set args to include function arguments and vars to include local variable values in the output.

Arguments
  • args : bool

  • vars : bool

_builtin::terminate()

Immediately terminates execution of the current daslang context.

_builtin::to_compiler_log(text: string)

Outputs text to the compiler’s log stream, typically used from within macro code during compilation.

Arguments
  • text : string implicit

_builtin::to_log(level: int; text: string)

Outputs text to the logging infrastructure at the specified level (e.g. LOG_INFO, LOG_ERROR), rather than to standard output.

Arguments
  • level : int

  • text : string implicit

2.1.18. Memory manipulation

2.1.18.1. hash

_builtin::hash(value: int8) : uint64()

Computes a 64-bit FNV-1a hash of the given int8 value and returns it as uint64.

Arguments
  • value : int8

_builtin::hash(data: any) : uint64()
_builtin::hash(data: string) : uint64()
_builtin::hash(value: int) : uint64()
_builtin::hash(value: int16) : uint64()
_builtin::hash(value: uint8) : uint64()
_builtin::hash(value: uint16) : uint64()
_builtin::hash(value: double) : uint64()
_builtin::hash(value: int64) : uint64()
_builtin::hash(value: uint) : uint64()
_builtin::hash(value: uint64) : uint64()
_builtin::hash(value: void?) : uint64()
_builtin::hash(value: float) : uint64()
_builtin::hash(value: das_string) : uint64()

2.1.18.2. intptr

_builtin::intptr(p: smart_ptr<auto>) : uint64()

Converts a smart_ptr p to its uint64 integer representation, useful for pointer arithmetic or serialization.

Arguments
  • p : smart_ptr<auto>

_builtin::intptr(p: void?) : uint64()

2.1.18.3. lock_data

_builtin::lock_data(a: array<auto(TT)> ==const|array<auto(TT)> const# ==const; blk: block<(p:TT const?#;s:int):auto>) : auto()

Locks a constant array and invokes blk with a read-only pointer p to the array’s contiguous data and its size s, allowing direct memory-level read access.

Arguments
  • a : option<array<auto(TT)>!| array<auto(TT)>#!>

  • blk : block<(p:TT?#;s:int):auto>

_builtin::lock_data(a: array<auto(TT)> ==const|array<auto(TT)># ==const; blk: block<(var p:TT?#;s:int):auto>) : auto()

_builtin::map_to_array(data: void?; len: int; blk: block<(var arg:array<auto(TT)>#):auto>) : auto()

Warning

This is unsafe operation.

Constructs a temporary mutable array of type TT over raw memory at data with len elements, and passes it to blk without copying the underlying data.

Arguments
  • data : void?

  • len : int

  • blk : block<(arg:array<auto(TT)>#):auto>

_builtin::map_to_ro_array(data: void?; len: int; blk: block<(arg:array<auto(TT)>#):auto>) : auto()

Warning

This is unsafe operation.

Constructs a temporary read-only array of type TT over raw memory at data with len elements, and passes it to blk without copying the underlying data.

Arguments
  • data : void?

  • len : int

  • blk : block<(arg:array<auto(TT)>#):auto>

_builtin::memcmp(left: void?; right: void?; size: int) : int()

Warning

This is unsafe operation.

Compares size bytes of memory at left and right, returning -1 if left is less, 1 if left is greater, or 0 if both regions are identical.

Arguments
  • left : void? implicit

  • right : void? implicit

  • size : int

_builtin::memcpy(left: void?; right: void?; size: int)

Warning

This is unsafe operation.

Copies size bytes of memory from the address pointed to by right into the address pointed to by left.

Arguments
  • left : void? implicit

  • right : void? implicit

  • size : int

_builtin::set_variant_index(variant: variant<>; index: int)

Warning

This is unsafe operation.

Overwrites the internal type discriminator of variant to index, changing which alternative the variant is considered to hold.

Arguments
  • variant : variant<> implicit

  • index : int

_builtin::variant_index(arg0: variant<>) : int()

Returns the zero-based index indicating which alternative the variant currently holds.

Arguments
  • arg0 : variant<> implicit

2.1.19. Binary serializer

_builtin::binary_load(obj: auto; data: array<uint8>) : auto()

Deserializes obj from the binary representation stored in data (an array of uint8 bytes). Obsolete — use daslib/archive instead.

Arguments
  • obj : auto

  • data : array<uint8> implicit

_builtin::binary_save(obj: auto; subexpr: block<(data:array<uint8>#):void>) : auto()

Serializes obj into a binary representation and passes the resulting uint8 byte array to the block subexpr. Obsolete — use daslib/archive instead.

Arguments
  • obj : auto

  • subexpr : block<(data:array<uint8>#):void>

2.1.20. Path and command line

_builtin::get_command_line_arguments() : array<string>()

Returns an array of strings containing the command-line arguments passed to the program.

2.1.21. Time and date

_builtin::get_clock() : clock()

Returns the current calendar time as a clock value representing the number of seconds since 00:00 UTC, January 1, 1970 (the Unix epoch).

_builtin::get_time_nsec(ref: int64) : int64()

Computes the elapsed time in nanoseconds since the reference point ref, which is typically obtained from ref_time_ticks.

Arguments
  • ref : int64

_builtin::get_time_usec(ref: int64) : int()

Computes the elapsed time in microseconds since the reference point ref, which is typically obtained from ref_time_ticks.

Arguments
  • ref : int64

_builtin::mktime(year: int; month: int; mday: int; hour: int; min: int; sec: int) : clock()

Converts the calendar date and time specified by year, month, mday, hour, min, and sec into a clock value representing time since epoch.

Arguments
  • year : int

  • month : int

  • mday : int

  • hour : int

  • min : int

  • sec : int

_builtin::ref_time_ticks() : int64()

Captures the current high-resolution time in ticks, suitable for measuring elapsed intervals with get_time_usec.

2.1.22. Platform queries

_builtin::das_is_dll_build() : bool()

Checks whether the current build is configured as a DLL (dynamic library) build, which determines if daslib symbols are available for the JIT compiler.

_builtin::get_architecture_name() : string()

Returns the name of the CPU architecture the program is running on, such as “x86_64”, “x86”, “arm64”, “arm”, “wasm32”, or “unknown”.

_builtin::get_context_share_counter() : uint64()

Returns the use-count of the shared context, which is incremented each time a thread accesses it; useful for tracking concurrent context usage.

_builtin::get_platform_name() : string()

Returns the name of the operating system the program is running on, such as “windows”, “linux”, “darwin”, “emscripten”, or “unknown”.

2.1.23. String formatting

2.1.23.1. fmt

_builtin::fmt(format: string; value: uint8) : string()

Formats a uint8 value as a string using the given format specifier (following libfmt / C++20 std::format syntax).

Arguments
  • format : string implicit

  • value : uint8

_builtin::fmt(format: string; value: int8) : string()
_builtin::fmt(format: string; value: uint16) : string()
_builtin::fmt(format: string; value: int16) : string()
_builtin::fmt(format: string; value: int64) : string()
_builtin::fmt(format: string; value: uint) : string()
_builtin::fmt(format: string; value: uint64) : string()
_builtin::fmt(format: string; value: int) : string()
_builtin::fmt(format: string; value: double) : string()
_builtin::fmt(format: string; value: float) : string()

2.1.24. Argument consumption

_builtin::consume_argument(a: auto(TT)&) : TT&()

Marks argument a as consumed, signaling to the compiler that it will not be used after this call, which enables move optimizations and avoids unnecessary clones. Equivalent to the <-arg syntax.

Arguments
  • a : auto(TT)&

2.1.25. Lock checking

_builtin::lock_count(array: array<anything>) : int()

Returns the current internal lock count for the given array, indicating how many active locks prevent it from being resized.

Arguments
  • array : array implicit

_builtin::set_verify_array_locks(array: array<anything>; check: bool) : bool()

Warning

This is unsafe operation.

Enables or disables runtime lock verification for the given array; when check is false, lock safety checks are skipped as a performance optimization.

Arguments
  • array : array implicit

  • check : bool

_builtin::set_verify_table_locks(table: table<anything, anything>; check: bool) : bool()

Warning

This is unsafe operation.

Enables or disables runtime lock verification for the given table; when check is false, lock safety checks are skipped as a performance optimization.

Arguments
  • table : table implicit

  • check : bool

2.1.26. Lock checking internals

_builtin::_at_with_lockcheck(Tab: table<auto(keyT), auto(valT)>; at: keyT|keyT#) : valT&()

Looks up and returns a reference to the element at key at in the table Tab, while verifying that Tab and its lockable sub-elements are not locked.

Arguments
  • Tab : table<auto(keyT);auto(valT)>

  • at : option<keyT| keyT#>

_builtin::_move_with_lockcheck(a: auto(valA)&; b: auto(valB)&) : auto()

Moves the contents of b into a, verifying that neither a nor b (nor any of their lockable sub-elements) is currently locked.

Arguments
  • a : auto(valA)&

  • b : auto(valB)&

2.1.26.1. _return_with_lockcheck

_builtin::_return_with_lockcheck(a: auto(valT)& ==const) : auto&()

Passes through and returns a mutable reference to a, verifying that a and all of its lockable sub-elements are not currently locked.

Arguments
  • a : auto(valT)&!

_builtin::_return_with_lockcheck(a: auto(valT) const& ==const) : auto&()

2.1.27. Bit operations

2.1.27.1. __bit_set

_builtin::__bit_set(value: bitfield&; mask: bitfield; on: bool)

Sets or clears the bits specified by mask in the 16-bit bitfield value, turning them on if on is true or off if on is false.

Arguments
  • value : bitfield<>& implicit

  • mask : bitfield<>

  • on : bool

_builtin::__bit_set(value: bitfield8:uint8<>&; mask: bitfield8:uint8<>; on: bool)
_builtin::__bit_set(value: bitfield64:uint64<>&; mask: bitfield64:uint64<>; on: bool)
_builtin::__bit_set(value: bitfield16:uint16<>&; mask: bitfield16:uint16<>; on: bool)

2.1.27.2. clz

_builtin::clz(bits: uint64) : uint64()

Counts the number of leading zero bits in the 64-bit unsigned integer bits, returning 64 if the value is zero.

Arguments
  • bits : uint64

_builtin::clz(bits: uint) : uint()

2.1.27.3. ctz

_builtin::ctz(bits: uint64) : uint64()

Counts the number of trailing zero bits in the 64-bit unsigned integer bits, returning 64 if the value is zero.

Arguments
  • bits : uint64

_builtin::ctz(bits: uint) : uint()

_builtin::mul128(a: uint64; b: uint64) : urange64()

Multiplies two 64-bit unsigned integers a and b, returning the full 128-bit result as a urange64 containing the low and high 64-bit halves.

Arguments
  • a : uint64

  • b : uint64

2.1.27.4. popcnt

_builtin::popcnt(bits: uint64) : uint64()

Counts and returns the number of set (1) bits in the 64-bit unsigned integer bits.

Arguments
  • bits : uint64

_builtin::popcnt(bits: uint) : uint()

2.1.28. Intervals

2.1.28.1. interval

_builtin::interval(arg0: uint; arg1: uint) : urange()

Constructs a urange value from the two uint endpoints arg0 (inclusive) and arg1 (exclusive).

Arguments
  • arg0 : uint

  • arg1 : uint

_builtin::interval(arg0: int; arg1: int) : range()
_builtin::interval(arg0: uint64; arg1: uint64) : urange64()
_builtin::interval(arg0: int64; arg1: int64) : range64()

2.1.29. RTTI

_builtin::class_rtti_size(ptr: void?) : int()

Examines the RTTI (runtime type information) associated with the class at ptr and returns the size in bytes of its TypeInfo structure.

Arguments
  • ptr : void? implicit

2.1.30. Lock verification

_builtin::set_verify_context_locks(check: bool) : bool()

Warning

This is unsafe operation.

Enables or disables runtime lock verification for all arrays and tables in the current context; returns the previous verification state.

Arguments
  • check : bool

2.1.31. Initialization and finalization

_builtin::using(arg0: block<(das_string):void>)

Creates a temporary das_string and passes it to the block, automatically managing its lifetime for the duration of the call.

Arguments

2.1.32. Algorithms

_builtin::count(start: int = 0; step: int = 1) : iterator<int>()

Creates an infinite iterator that yields integer values starting from start and incrementing by step on each iteration, intended for use as a counter alongside other sequences in a for loop.

Arguments
  • start : int

  • step : int

_builtin::iter_range(foo: auto) : auto()

Creates a range from 0 to the length of the given iterable foo, useful for index-based iteration over containers.

Arguments
  • foo : auto

_builtin::swap(a: auto(TT)&; b: auto(TT)&) : auto()

Exchanges the values of a and b in place, leaving each variable holding the other’s former value.

Arguments
  • a : auto(TT)&

  • b : auto(TT)&

_builtin::ucount(start: uint = 0x0; step: uint = 0x1) : iterator<uint>()

Creates an infinite iterator over unsigned integers beginning at start and incrementing by step on each iteration.

Arguments
  • start : uint

  • step : uint

2.1.33. Memset

_builtin::memset128(left: void?; value: uint4; count: int)

Warning

This is unsafe operation.

Fills memory at left with count copies of the 128-bit uint4 vector value.

Arguments
  • left : void? implicit

  • value : uint4

  • count : int

_builtin::memset16(left: void?; value: uint16; count: int)

Warning

This is unsafe operation.

Fills memory at left with count copies of the 16-bit value.

Arguments
  • left : void? implicit

  • value : uint16

  • count : int

_builtin::memset32(left: void?; value: uint; count: int)

Warning

This is unsafe operation.

Fills memory at left with count copies of the 32-bit value.

Arguments
  • left : void? implicit

  • value : uint

  • count : int

_builtin::memset64(left: void?; value: uint64; count: int)

Warning

This is unsafe operation.

Fills memory at left with count copies of the 64-bit value.

Arguments
  • left : void? implicit

  • value : uint64

  • count : int

_builtin::memset8(left: void?; value: uint8; count: int)

Warning

This is unsafe operation.

Fills memory at left with count copies of the 8-bit value, equivalent to the C memset function.

Arguments
  • left : void? implicit

  • value : uint8

  • count : int

2.1.34. Malloc

_builtin::free(ptr: void?)

Warning

This is unsafe operation.

Frees memory previously allocated with malloc, following C-style manual memory management semantics.

Arguments
  • ptr : void? implicit

_builtin::malloc(size: uint64) : void?()

Warning

This is unsafe operation.

Allocates a block of uninitialized memory of the specified size in bytes, C-style, and returns a raw pointer to it; must be freed with free.

Arguments
  • size : uint64

_builtin::malloc_usable_size(ptr: void?) : uint64()

Warning

This is unsafe operation.

Returns the usable size in bytes of the memory block pointed to by ptr, as reported by the underlying allocator.

Arguments
  • ptr : void? implicit

2.1.35. Compilation and AOT

_builtin::compiling_file_name() : string()

Returns the file name of the source file currently being compiled, useful for compile-time metaprogramming and diagnostics.

_builtin::compiling_module_name() : string()

Returns the name of the module currently being compiled, useful for compile-time metaprogramming and diagnostics.

_builtin::reset_aot()

Notifies the compiler that ahead-of-time code generation has finished, restoring normal compilation mode.

_builtin::set_aot()

Notifies the compiler that ahead-of-time code generation is now in progress.