2. Built-in runtime

Builtin module is automatically required by any other das file. It includes basic language infrastructure, support for containers, heap, miscellaneous iterators, profiler, and interaction with host application.

2.1. Type aliases

field

bit

value

escapeString

0

1

namesAndDimensions

1

2

typeQualifiers

2

4

refAddresses

3

8

humanReadable

4

16

singleLine

5

32

this bitfield specifies how exactly values are to be printed

2.2. Constants

DAS_MAX_FUNCTION_ARGUMENTS = 32

maximum number of arguments for the function. this is used to pre-allocate stack space for the function arguments

INT_MIN = -2147483648

minimum possible value of ‘int’

INT_MAX = 2147483647

maximum possible value of ‘int’

UINT_MAX = 0xffffffff

maximum possible value of ‘uint’

LONG_MIN = -9223372036854775808

minimum possible value of ‘int64’

LONG_MAX = 9223372036854775807

maximum possible value of ‘int64’

ULONG_MAX = 0xffffffffffffffff

minimum possible value of ‘uint64’

FLT_MIN = 1.17549e-38f

smallest possible non-zero value of ‘float’. if u want minimum possible value use -FLT_MAX

FLT_MAX = 3.40282e+38f

maximum possible value of ‘float’

DBL_MIN = 2.22507e-308lf

smallest possible non-zero value of ‘double’. if u want minimum possible value use -DBL_MAX

DBL_MAX = 1.79769e+308lf

maximum possible value of ‘double’

LOG_CRITICAL = 50000

indicates maximum log level. critial errors, panic, shutdown

LOG_ERROR = 40000

indicates log level recoverable errors

LOG_WARNING = 30000

indicates log level for API misuse, non-fatal errors

LOG_INFO = 20000

indicates log level for miscellaneous informative messages

LOG_DEBUG = 10000

indicates log level for debug messages

LOG_TRACE = 0

indicates log level for the most noisy debug and tracing messages

VEC_SEP = ","

Read-only string constant which is used to separate elements of vectors. By default its “,”

printing flags similar to those used by the ‘debug’ function

2.3. Handled structures

HashBuilder

Helper structure to facilitate calculating hash values.

2.4. Function annotations

marker

marker annotation is used to attach arbitrary marker values to a function (in form of annotation arguments). its typically used for implementation of macros

generic

indicates that the function is generic, regardless of its argument types. generic functions will be instanced in the calling module

_macro

indicates that the function will be called during the macro pass, similar to [init]

macro_function

indicates that the function is part of the macro implementation, and will not be present in the final compiled context, unless explicitly called.

hint

Hints the compiler to use specific optimization.

jit

Explicitly marks (forces) function to be compiled with JIT compiler.

deprecated

deprecated annotation is used to mark a function as deprecated. it will generate a warning during compilation, and will not be callable from the final compiled context

alias_cmres

indicates that function always aliases cmres (copy or move result), and cmres optimizations are disabled.

never_alias_cmres

indicates that function never aliases cmres (copy or move result), and cmres checks will not be performed

export

indicates that function is to be exported to the final compiled context

pinvoke

indicates that the function is a pinvoke function, and will be called via pinvoke machinery

no_lint

indicates that the lint pass should be skipped for the specific function

sideeffects

indicates that the function should be treated as if it has side-effects. for example it will not be optimized out

run

ensures that the function is always evaluated at compilation time

unsafe_operation

indicates that function is unsafe, and will require unsafe keyword to be called

unsafe_outside_of_for

Marks function as unsafe to be called outside of the sources for loop.

no_aot

indicates that the AOT will not be generated for this specific function

init

indicates that the function would be called at the context initialization time

finalize

indicates that the function would be called at the context shutdown time

hybrid

indicates that the function is likely candidate for later patching, and the AOT will generate hybrid calls to it - instead of direct calls. that way modyfing the function will not affect AOT of other functions.

unsafe_deref

optimization, which indicates that pointer dereference, array and string indexing, and few other operations would not check for null or bounds

skip_lock_check

optimization, which indicates that lock checks are not needed in this function.

unused_argument

marks function arguments, which are unused. that way when code policies make unused arguments an error, a workaround can be provided

local_only

indicates that function can only accept local make expressions, like [[make tuple]] and [[make structure]]

expect_any_vector

indicates that function can only accept das::vector templates

builtin_array_sort

indicates sort function for builtin ‘sort’ machinery. used internally

2.5. Call macros

concept_assert

similar to regular assert function, but always happens at compilation time. it would also display the error message from where the asserted function was called from, not the assert line itself.

__builtin_table_set_insert

part of internal implementation for insert of the sets (tables with keys only).

__builtin_table_key_exists

part of internal implementation for key_exists

static_assert

similar to regular assert function, but always happens at compilation time

verify

assert for the expression with side effects. expression will not be optimized out if asserts are disabled

debug

prints value and returns that same value

assert

throws panic if first operand is false. can be disabled. second operand is error message

memzero

initializes section of memory with ‘0’

__builtin_table_find

part of internal implementation for find

invoke

invokes block, function, or lambda

__builtin_table_erase

part of internal implementation for erase

2.6. Reader macros

_esc

returns raw string input, without regards for escape sequences. For example %_esc\n\r%_esc will return 4 character string ‘',’n’,’',’r’

2.7. Typeinfo macros

rtti_classinfo

Generates TypeInfo for the class initialization.

2.8. Handled types

das_string

das::string which is typically std::string or equivalent

clock

das::Time which is a wrapper around time_t

2.9. Structure macros

comment

[comment] macro, which does absolutely nothing but holds arguments.

macro_interface

[macro_interface] specifies that class and its inherited children are used as a macro interfaces, and would not be exported by default.

skip_field_lock_check

optimization, which indicates that the structure does not need lock checks.

cpp_layout

[cpp_layout] specifies that structure uses C++ memory layout rules, as oppose to native Daslang memory layout rules.

persistent

[persistent] annotation specifies that structure is allocated (via new) on the C++ heap, as oppose to Daslang context heap.

2.10. Containers

clear(array: array implicit)

argument

argument type

array

array implicit

clear will clear whole table or array arg. The size of arg after clear is 0.

length(array: array const implicit)

length returns int

argument

argument type

array

array const implicit

length will return current size of table or array arg.

capacity(array: array const implicit)

capacity returns int

argument

argument type

array

array const implicit

capacity will return current capacity of table or array arg. Capacity is the count of elements, allocating (or pushing) until that size won’t cause reallocating dynamic heap.

empty(iterator: iterator const implicit)

empty returns bool

argument

argument type

iterator

iterator const implicit

returns true if iterator is empty, i.e. would not produce any more values or uninitialized

length(table: table const implicit)

length returns int

argument

argument type

table

table const implicit

length will return current size of table or array arg.

capacity(table: table const implicit)

capacity returns int

argument

argument type

table

table const implicit

capacity will return current capacity of table or array arg. Capacity is the count of elements, allocating (or pushing) until that size won’t cause reallocating dynamic heap.

empty(str: string const implicit)

empty returns bool

argument

argument type

str

string const implicit

returns true if iterator is empty, i.e. would not produce any more values or uninitialized

empty(str: das_string const implicit)

empty returns bool

argument

argument type

str

builtin::das_string const implicit

returns true if iterator is empty, i.e. would not produce any more values or uninitialized

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

resize returns auto

argument

argument type

Arr

array<auto(numT)>

newSize

int const

Resize will resize array_arg array to a new size of new_size. If new_size is bigger than current, new elements will be zeroed.

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

resize_no_init returns auto

argument

argument type

Arr

array<auto(numT)>

newSize

int const

Resize will resize array_arg array to a new size of new_size. If new_size is bigger than current, new elements will be left uninitialized.

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

reserve returns auto

argument

argument type

Arr

array<auto(numT)>

newSize

int const

makes sure array has sufficient amount of memory to hold specified number of elements. reserving arrays will speed up pushing to it

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

pop returns auto

argument

argument type

Arr

array<auto(numT)>

removes last element of the array

push(Arr: array<auto(numT)>; value: numT const; at: int const)

push returns auto

argument

argument type

Arr

array<auto(numT)>

value

numT const

at

int const

push will push to dynamic array array_arg the content of value. value has to be of the same type (or const reference to same type) as array values. if at is provided value will be pushed at index at, otherwise to the end of array. The content of value will be copied (assigned) to it.

push(Arr: array<auto(numT)>; value: numT const)

push returns auto

argument

argument type

Arr

array<auto(numT)>

value

numT const

push will push to dynamic array array_arg the content of value. value has to be of the same type (or const reference to same type) as array values. if at is provided value will be pushed at index at, otherwise to the end of array. The content of value will be copied (assigned) to it.

push(Arr: array<auto(numT)>; varr: array<numT> const)

push returns auto

argument

argument type

Arr

array<auto(numT)>

varr

array<numT> const

push will push to dynamic array array_arg the content of value. value has to be of the same type (or const reference to same type) as array values. if at is provided value will be pushed at index at, otherwise to the end of array. The content of value will be copied (assigned) to it.

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

push returns auto

argument

argument type

Arr

array<auto(numT)>

varr

numT const[-1]

push will push to dynamic array array_arg the content of value. value has to be of the same type (or const reference to same type) as array values. if at is provided value will be pushed at index at, otherwise to the end of array. The content of value will be copied (assigned) to it.

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

push returns auto

argument

argument type

Arr

array<auto(numT)[-1]>

varr

numT const[-1]

push will push to dynamic array array_arg the content of value. value has to be of the same type (or const reference to same type) as array values. if at is provided value will be pushed at index at, otherwise to the end of array. The content of value will be copied (assigned) to it.

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

emplace returns auto

argument

argument type

Arr

array<auto(numT)>

value

numT&

at

int const

emplace will push to dynamic array array_arg the content of value. value has to be of the same type (or const reference to same type) as array values. if at is provided value will be pushed at index at, otherwise to the end of array. The content of value will be moved (<-) to it.

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

emplace returns auto

argument

argument type

Arr

array<auto(numT)>

value

numT&

emplace will push to dynamic array array_arg the content of value. value has to be of the same type (or const reference to same type) as array values. if at is provided value will be pushed at index at, otherwise to the end of array. The content of value will be moved (<-) to it.

emplace(Arr: array<auto(numT)>; value: numT[])

emplace returns auto

argument

argument type

Arr

array<auto(numT)>

value

numT[-1]

emplace will push to dynamic array array_arg the content of value. value has to be of the same type (or const reference to same type) as array values. if at is provided value will be pushed at index at, otherwise to the end of array. The content of value will be moved (<-) to it.

emplace(Arr: array<auto(numT)[]>; value: numT[])

emplace returns auto

argument

argument type

Arr

array<auto(numT)[-1]>

value

numT[-1]

emplace will push to dynamic array array_arg the content of value. value has to be of the same type (or const reference to same type) as array values. if at is provided value will be pushed at index at, otherwise to the end of array. The content of value will be moved (<-) to it.

push_clone(Arr: array<auto(numT)>; value: numT const|numT const# const; at: int const)

push_clone returns auto

argument

argument type

Arr

array<auto(numT)>

value

option const

at

int const

similar to push, only values would be cloned instead of copied

push_clone(Arr: array<auto(numT)>; value: numT const|numT const# const)

push_clone returns auto

argument

argument type

Arr

array<auto(numT)>

value

option const

similar to push, only values would be cloned instead of copied

push_clone(Arr: array<auto(numT)>; varr: numT const[])

push_clone returns auto

argument

argument type

Arr

array<auto(numT)>

varr

numT const[-1]

similar to push, only values would be cloned instead of copied

push_clone(Arr: array<auto(numT)[]>; varr: numT const[])

push_clone returns auto

argument

argument type

Arr

array<auto(numT)[-1]>

varr

numT const[-1]

similar to push, only values would be cloned instead of copied

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

push_clone returns auto

argument

argument type

A

auto(CT)

b

option const

similar to push, only values would be cloned instead of copied

back(a: array<auto(TT)> ==const)

back returns TT&

argument

argument type

a

array<auto(TT)>!

returns last element of the array

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

back returns TT&#

argument

argument type

a

array<auto(TT)>#!

returns last element of the array

back(a: array<auto(TT)> const ==const)

back returns TT const&

argument

argument type

a

array<auto(TT)> const!

returns last element of the array

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

back returns TT const&#

argument

argument type

a

array<auto(TT)> const#!

returns last element of the array

back(arr: auto(TT) ==const)

back returns auto&

argument

argument type

arr

auto(TT)!

returns last element of the array

back(arr: auto(TT) const ==const)

back returns auto const&

argument

argument type

arr

auto(TT) const!

returns last element of the array

erase(Arr: array<auto(numT)>; at: int const)

erase returns auto

argument

argument type

Arr

array<auto(numT)>

at

int const

erase will erase at index element in arg array.

erase(Arr: array<auto(numT)>; at: int const; count: int const)

erase returns auto

argument

argument type

Arr

array<auto(numT)>

at

int const

count

int const

erase will erase at index element in arg array.

length(a: auto const[])

length returns int

argument

argument type

a

auto const[-1]

length will return current size of table or array arg.

empty(a: array<auto> const|array<auto> const# const)

empty returns bool

argument

argument type

a

option const

returns true if iterator is empty, i.e. would not produce any more values or uninitialized

empty(a: table<auto;auto> const|table<auto;auto> const# const)

empty returns bool

argument

argument type

a

option const

returns true if iterator is empty, i.e. would not produce any more values or uninitialized

find(Tab: table<auto(keyT);auto(valT)> const|table<auto(keyT);auto(valT)> const# const; at: keyT const; blk: block<(p:valT? const#):void> const)

find returns auto

Warning

This function is deprecated.

argument

argument type

Tab

option const

at

keyT const

blk

block<(p:valT? const#):void> const

will execute block_arg with argument pointer-to-value in table_arg pointing to value indexed by key, or null if key doesn’t exist in table_arg.

find(Tab: table<auto(keyT);void> const; at: keyT const|keyT const# const; blk: block<(p:void? const):void> const)

find returns auto

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);void> const

at

option const

blk

block<(p:void? const):void> const

will execute block_arg with argument pointer-to-value in table_arg pointing to value indexed by key, or null if key doesn’t exist in table_arg.

get(Tab: table<auto(keyT);auto(valT)> const# ==const; at: keyT const; blk: block<(p:valT const&#):void> const)

get returns auto

argument

argument type

Tab

table<auto(keyT);auto(valT)> const#!

at

keyT const

blk

block<(p:valT const&#):void> const

will execute block_arg with argument reference-to-value in table_arg referencing value indexed by key. Will return false if key doesn’t exist in table_arg, otherwise true.

get(Tab: table<auto(keyT);auto(valT)> const ==const; at: keyT const; blk: block<(p:valT const&):void> const)

get returns auto

argument

argument type

Tab

table<auto(keyT);auto(valT)> const!

at

keyT const

blk

block<(p:valT const&):void> const

will execute block_arg with argument reference-to-value in table_arg referencing value indexed by key. Will return false if key doesn’t exist in table_arg, otherwise true.

get(Tab: table<auto(keyT);auto(valT)># ==const; at: keyT const; blk: block<(var p:valT&# -const):void> const)

get returns auto

argument

argument type

Tab

table<auto(keyT);auto(valT)>#!

at

keyT const

blk

block<(p:valT&#):void> const

will execute block_arg with argument reference-to-value in table_arg referencing value indexed by key. Will return false if key doesn’t exist in table_arg, otherwise true.

get(Tab: table<auto(keyT);auto(valT)> ==const; at: keyT const; blk: block<(var p:valT& -const):void> const)

get returns auto

argument

argument type

Tab

table<auto(keyT);auto(valT)>!

at

keyT const

blk

block<(p:valT&):void> const

will execute block_arg with argument reference-to-value in table_arg referencing value indexed by key. Will return false if key doesn’t exist in table_arg, otherwise true.

get(Tab: table<auto(keyT);void> const; at: keyT const|keyT const# const; blk: block<(var p:void? -const):void> const)

get returns auto

argument

argument type

Tab

table<auto(keyT);void> const

at

option const

blk

block<(p:void?):void> const

will execute block_arg with argument reference-to-value in table_arg referencing value indexed by key. Will return false if key doesn’t exist in table_arg, otherwise true.

find_if_exists(Tab: table<auto(keyT);auto(valT)> const; at: keyT const; blk: block<(p:valT const&):void> const)

find_if_exists returns auto

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);auto(valT)> const

at

keyT const

blk

block<(p:valT const&):void> const

similar to find, but the block will only be called, if the key is found

find_if_exists(Tab: table<auto(keyT);auto(valT)> const#; at: keyT const; blk: block<(p:valT const&#):void> const)

find_if_exists returns auto

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);auto(valT)> const#

at

keyT const

blk

block<(p:valT const&#):void> const

similar to find, but the block will only be called, if the key is found

find_if_exists(Tab: table<auto(keyT);void> const; at: keyT const; blk: block<(p:void? const):void> const)

find_if_exists returns auto

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);void> const

at

keyT const

blk

block<(p:void? const):void> const

similar to find, but the block will only be called, if the key is found

find_for_edit(Tab: table<auto(keyT);auto(valT)>; at: keyT const; blk: block<(var p:valT?# -const):void> const)

find_for_edit returns auto

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);auto(valT)>

at

keyT const

blk

block<(p:valT?#):void> const

similar to find, but pointer to the value would be read-write

find_for_edit(Tab: table<auto(keyT);void>; at: keyT const|keyT const# const; blk: block<(var p:void? -const):void> const)

find_for_edit returns auto

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);void>

at

option const

blk

block<(p:void?):void> const

similar to find, but pointer to the value would be read-write

find_for_edit(Tab: table<auto(keyT);auto(valT)> -const|table<auto(keyT);auto(valT)># -const; at: keyT const)

find_for_edit returns valT?

Warning

This is unsafe operation.

Warning

This function is deprecated.

argument

argument type

Tab

option

at

keyT const

similar to find, but pointer to the value would be read-write

find_for_edit(Tab: table<auto(keyT);void>; at: keyT const|keyT const# const)

find_for_edit returns void?

Warning

This is unsafe operation.

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);void>

at

option const

similar to find, but pointer to the value would be read-write

find_for_edit_if_exists(Tab: table<auto(keyT);auto(valT)>#; at: keyT const; blk: block<(var p:valT&# -const):void> const)

find_for_edit_if_exists returns auto

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);auto(valT)>#

at

keyT const

blk

block<(p:valT&#):void> const

similar to find_if_exists, but pointer to the value would be read-write

find_for_edit_if_exists(Tab: table<auto(keyT);auto(valT)>; at: keyT const; blk: block<(var p:valT& -const):void> const)

find_for_edit_if_exists returns auto

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);auto(valT)>

at

keyT const

blk

block<(p:valT&):void> const

similar to find_if_exists, but pointer to the value would be read-write

find_for_edit_if_exists(Tab: table<auto(keyT);void>; at: keyT const|keyT const# const; blk: block<(var p:void? -const):void> const)

find_for_edit_if_exists returns auto

Warning

This function is deprecated.

argument

argument type

Tab

table<auto(keyT);void>

at

option const

blk

block<(p:void?):void> const

similar to find_if_exists, but pointer to the value would be read-write

erase(Tab: table<auto(keyT);auto(valT)>; at: string const#)

erase returns bool

argument

argument type

Tab

table<auto(keyT);auto(valT)>

at

string const#

erase will erase at index element in arg array.

erase(Tab: table<auto(keyT);auto(valT)>; at: keyT const|keyT const# const)

erase returns bool

argument

argument type

Tab

table<auto(keyT);auto(valT)>

at

option const

erase will erase at index element in arg array.

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

insert returns auto

argument

argument type

Tab

table<auto(keyT);void>

at

option const

inserts key into the set (table with no values) Tab

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

key_exists returns bool

argument

argument type

Tab

option const

at

string const#

will return true if element key exists in table table_arg.

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

key_exists returns bool

argument

argument type

Tab

option const

at

option const

will return true if element key exists in table table_arg.

copy_to_local(a: auto(TT) const)

copy_to_local returns TT

argument

argument type

a

auto(TT) const

copies value and returns it as local value on stack. used to work around aliasing issues

move_to_local(a: auto(TT)&)

move_to_local returns TT

argument

argument type

a

auto(TT)&

moves value and returns it as local value on stack. used to work around aliasing issues

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

keys returns iterator<keyT const&>

argument

argument type

a

option const

returns iterator to all keys of the table

values(a: table<auto(keyT);void> const ==const|table<auto(keyT);void> const# ==const const)

values returns auto

argument

argument type

a

option const

returns iterator to all values of the table

values(a: table<auto(keyT);void> ==const -const|table<auto(keyT);void># ==const -const)

values returns auto

argument

argument type

a

option

returns iterator to all values of the table

values(a: table<auto(keyT);auto(valT)> const ==const|table<auto(keyT);auto(valT)> const# ==const const)

values returns iterator<valT const&>

argument

argument type

a

option const

returns iterator to all values of the table

values(a: table<auto(keyT);auto(valT)> ==const -const|table<auto(keyT);auto(valT)># ==const -const)

values returns iterator<valT&>

argument

argument type

a

option

returns iterator to all values of the table

lock(Tab: table<auto(keyT);auto(valT)> const|table<auto(keyT);auto(valT)> const# const; blk: block<(t:table<keyT;valT> const#):void> const)

lock returns auto

argument

argument type

Tab

option const

blk

block<(t:table<keyT;valT> const#):void> const

locks array or table for the duration of the block invocation, so that it can’t be resized. values can’t be pushed or popped, etc.

lock_forever(Tab: table<auto(keyT);auto(valT)> -const|table<auto(keyT);auto(valT)># -const)

lock_forever returns table<keyT;valT>#

argument

argument type

Tab

option

locks array or table forever

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

next returns bool

argument

argument type

it

iterator<auto(TT)> const

value

TT&

returns next element in the iterator as the ‘value’. result is true if there is element returned, or false if iterator is null or empty

each(rng: range const)

each returns iterator<int>

argument

argument type

rng

range const

returns iterator, which iterates though each element of the object. object can be range, static or dynamic array, another iterator.

each(str: string const)

each returns iterator<int>

argument

argument type

str

string const

returns iterator, which iterates though each element of the object. object can be range, static or dynamic array, another iterator.

each(a: auto(TT) const[])

each returns iterator<TT&>

argument

argument type

a

auto(TT) const[-1]

returns iterator, which iterates though each element of the object. object can be range, static or dynamic array, another iterator.

each(a: array<auto(TT)> const)

each returns iterator<TT&>

argument

argument type

a

array<auto(TT)> const

returns iterator, which iterates though each element of the object. object can be range, static or dynamic array, another iterator.

each(a: array<auto(TT)> const#)

each returns iterator<TT&#>

argument

argument type

a

array<auto(TT)> const#

returns iterator, which iterates though each element of the object. object can be range, static or dynamic array, another iterator.

each(lam: lambda<(var arg:auto(argT) -const):bool> const)

each returns iterator<argT>

argument

argument type

lam

lambda<(arg:auto(argT)):bool> const

returns iterator, which iterates though each element of the object. object can be range, static or dynamic array, another iterator.

each_ref(lam: lambda<(var arg:auto(argT)? -const):bool> const)

each_ref returns iterator<argT&>

argument

argument type

lam

lambda<(arg:auto(argT)?):bool> const

similar to each, but iterator returns references instead of values

each_enum(tt: auto(TT) const)

each_enum returns iterator<TT>

argument

argument type

tt

auto(TT) const

iterates over each element in the enumeration

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

nothing returns iterator<TT>

argument

argument type

it

iterator<auto(TT)>

returns empty iterator

to_array(it: iterator<auto(TT)> const)

to_array returns array<TT>

argument

argument type

it

iterator<auto(TT)> const

will convert argument (static array, iterator, another dynamic array) to an array. argument elements will be cloned

to_array(a: auto(TT) const[])

to_array returns array<TT>

argument

argument type

a

auto(TT) const[-1]

will convert argument (static array, iterator, another dynamic array) to an array. argument elements will be cloned

to_array_move(a: auto(TT)[])

to_array_move returns array<TT>

argument

argument type

a

auto(TT)[-1]

will convert argument (static array, iterator, another dynamic array) to an array. argument elements will be copied or moved

to_array_move(a: auto(TT))

to_array_move returns array<TT>

argument

argument type

a

auto(TT)

will convert argument (static array, iterator, another dynamic array) to an array. argument elements will be copied or moved

to_table(a: tuple<auto(keyT);auto(valT)> const[])

to_table returns table<keyT;valT>

argument

argument type

a

tuple<auto(keyT);auto(valT)> const[-1]

will convert an array of key-value tuples into a table<key;value> type. arguments will be cloned

to_table(a: auto(keyT) const[])

to_table returns table<keyT;void>

argument

argument type

a

auto(keyT) const[-1]

will convert an array of key-value tuples into a table<key;value> type. arguments will be cloned

to_table_move(a: auto(keyT)[])

to_table_move returns table<keyT;void>

argument

argument type

a

auto(keyT)[-1]

will convert an array of key-value tuples into a table<key;value> type. arguments will be copied or moved

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

to_table_move returns table<keyT;valT>

argument

argument type

a

tuple<auto(keyT);auto(valT)>[-1]

will convert an array of key-value tuples into a table<key;value> type. arguments will be copied or moved

sort(a: auto(TT)[] -const|auto(TT)[]# -const)

sort returns auto

argument

argument type

a

option

sorts an array in ascending order.

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

sort returns auto

argument

argument type

a

option

sorts an array in ascending order.

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

sort returns auto

argument

argument type

a

option

cmp

block<(x:TT const;y:TT const):bool> const

sorts an array in ascending order.

sort(a: array<auto(TT)> -const|array<auto(TT)># -const; cmp: block<(x:TT const;y:TT const):bool> const)

sort returns auto

argument

argument type

a

option

cmp

block<(x:TT const;y:TT const):bool> const

sorts an array in ascending order.

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

lock returns auto

argument

argument type

a

option

blk

block<(x:array<TT>#):auto> const

locks array or table for the duration of the block invocation, so that it can’t be resized. values can’t be pushed or popped, etc.

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

lock returns auto

argument

argument type

a

option const

blk

block<(x:array<TT> const#):auto> const

locks array or table for the duration of the block invocation, so that it can’t be resized. values can’t be pushed or popped, etc.

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

find_index returns auto

argument

argument type

arr

option const

key

TT const

returns index of they key in the array

find_index(arr: auto(TT) const[]|auto(TT) const[]# const; key: TT const)

find_index returns auto

argument

argument type

arr

option const

key

TT const

returns index of they key in the array

find_index(arr: iterator<auto(TT)> const; key: TT const)

find_index returns auto

argument

argument type

arr

iterator<auto(TT)> const

key

TT const

returns index of they key in the array

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

find_index_if returns auto

argument

argument type

arr

option const

blk

block<(key:TT const):bool> const

returns index of the key in the array, where key is checked via compare block

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

find_index_if returns auto

argument

argument type

arr

option const

blk

block<(key:TT const):bool> const

returns index of the key in the array, where key is checked via compare block

find_index_if(arr: iterator<auto(TT)> const; blk: block<(key:TT const -&):bool> const)

find_index_if returns auto

argument

argument type

arr

iterator<auto(TT)> const

blk

block<(key:TT const):bool> const

returns index of the key in the array, where key is checked via compare block

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

has_value returns auto

argument

argument type

a

auto const

key

auto const

returns true if iterable a (array, dim, etc) contains key

subarray(a: auto(TT) const[]; r: range const)

subarray returns auto

argument

argument type

a

auto(TT) const[-1]

r

range const

returns new array which is copy of a slice of range of the source array

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

subarray returns auto

argument

argument type

a

auto(TT) const[-1]

r

urange const

returns new array which is copy of a slice of range of the source array

subarray(a: array<auto(TT)> const; r: range const)

subarray returns auto

argument

argument type

a

array<auto(TT)> const

r

range const

returns new array which is copy of a slice of range of the source array

subarray(a: array<auto(TT)> const; r: urange const)

subarray returns auto

argument

argument type

a

array<auto(TT)> const

r

urange const

returns new array which is copy of a slice of range of the source array

move_to_ref(a: auto&; b: auto)

move_to_ref returns auto

argument

argument type

a

auto&

b

auto

moves b into a. if b is value, it will be copied to a instead

clear(t: table<auto(KT);auto(VT)>)

clear returns auto

argument

argument type

t

table<auto(KT);auto(VT)>

clear will clear whole table or array arg. The size of arg after clear is 0.

2.11. das::string manipulation

peek(src: das_string const implicit; block: block<(arg0:string const#):void> const implicit)

argument

argument type

src

builtin::das_string const implicit

block

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

returns contents of the das::string as temporary string value. this is fastest way to access contents of das::string as string

2.12. String builder

write(arg0: HashBuilder implicit; arg1: string const implicit)

argument

argument type

arg0

builtin::HashBuilder implicit

arg1

string const implicit

writes string to a hash-builder.

2.13. Heap reporting

heap_bytes_allocated()

heap_bytes_allocated returns uint64

will return bytes allocated on heap (i.e. really used, not reserved)

heap_depth()

heap_depth returns int

returns number of generations in the regular heap

string_heap_bytes_allocated()

string_heap_bytes_allocated returns uint64

returns number of bytes allocated in the string heap

string_heap_depth()

string_heap_depth returns int

returns number of generations in the string heap

string_heap_collect(validate: bool const)

Warning

This is unsafe operation.

argument

argument type

validate

bool const

calls garbage collection on the string heap

heap_collect(string_heap: bool const; validate: bool const)

Warning

This is unsafe operation.

argument

argument type

string_heap

bool const

validate

bool const

calls garbage collection on the regular heap

string_heap_report()

reports string heap usage and allocations

heap_report()

reports heap usage and allocations

memory_report(errorsOnly: bool const)

argument

argument type

errorsOnly

bool const

reports memory allocation, optionally GC errors only

2.14. GC0 infrastructure

gc0_save_ptr(name: string const implicit; data: void? const implicit)

argument

argument type

name

string const implicit

data

void? const implicit

saves pointer to gc0 storage by specifying name

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

argument

argument type

name

string const implicit

data

smart_ptr<void> const implicit

saves smart_ptr to gc0 storage by specifying name

gc0_restore_ptr(name: string const implicit)

gc0_restore_ptr returns void?

argument

argument type

name

string const implicit

restores pointer from gc0 storage by name

gc0_restore_smart_ptr(name: string const implicit)

gc0_restore_smart_ptr returns smart_ptr<void>

argument

argument type

name

string const implicit

restores smart_ptr from gc0 storage name

gc0_reset()

resets gc0 storage. stored pointers will no longer be accessible

2.15. Smart ptr infrastructure

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

argument

argument type

dest

smart_ptr<void>& implicit

src

smart_ptr<void> const implicit

Moves the new [[…]] value into smart_ptr.

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

argument

argument type

dest

smart_ptr<void>& implicit

src

void? const implicit

Moves one smart_ptr into another. Semantic equivalent of move(a,b) => a := null, a <- b

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

argument

argument type

dest

smart_ptr<void>& implicit

src

smart_ptr<void>& implicit

Moves one smart_ptr into another. Semantic equivalent of move(a,b) => a := null, a <- b

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

argument

argument type

dest

smart_ptr<void>& implicit

src

void? const implicit

clones smart_ptr, internal use-count is incremented

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

argument

argument type

dest

smart_ptr<void>& implicit

src

smart_ptr<void> const implicit

clones smart_ptr, internal use-count is incremented

smart_ptr_use_count(ptr: smart_ptr<void> const implicit)

smart_ptr_use_count returns uint

argument

argument type

ptr

smart_ptr<void> const implicit

returns internal use-count for the smart_ptr

smart_ptr_is_valid(dest: smart_ptr<void> const implicit)

smart_ptr_is_valid returns bool

argument

argument type

dest

smart_ptr<void> const implicit

checks if smart pointer points to a valid data.

get_ptr(src: smart_ptr<auto(TT)> const)

get_ptr returns TT?

argument

argument type

src

smart_ptr<auto(TT)> const

returns regular pointer from the smart_ptr

get_const_ptr(src: smart_ptr<auto(TT)> const)

get_const_ptr returns TT? const

argument

argument type

src

smart_ptr<auto(TT)> const

return constant pointer from regular pointer

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

add_ptr_ref returns smart_ptr<TT>

argument

argument type

src

smart_ptr<auto(TT)> const

increases reference count of the smart pointer.

2.16. Macro infrastructure

is_compiling()

is_compiling returns bool

returns true if context is being compiled

is_compiling_macros()

is_compiling_macros returns bool

returns true if context is being compiled and the compiler is currently executing macro pass

is_compiling_macros_in_module(name: string const implicit)

is_compiling_macros_in_module returns bool

argument

argument type

name

string const implicit

returns true if context is being compiled, its macro pass, and its in the specific module

is_reporting_compilation_errors()

is_reporting_compilation_errors returns bool

returns true if context failed to compile, and infer pass is reporting compilation errors

is_in_completion()

is_in_completion returns bool

returns true if compiler is currently generating completion, i.e. lexical representation of the program for the text editor’s text completion system.

is_folding()

is_folding returns bool

returns true if context is beeing folded, i.e during constant folding pass

2.17. Profiler

reset_profiler()

resets counters in the built-in profiler

dump_profile_info()

dumps use counts of all lines collected by built-in profiler

collect_profile_info()

collect_profile_info returns string

enabling collecting of the use counts by built-in profiler

profile(count: int const; category: string const implicit; block: block<> const implicit)

profile returns float

argument

argument type

count

int const

category

string const implicit

block

block<> const implicit

profiles specified block by evaluating it count times and returns minimal time spent in the block in seconds, as well as prints it.

2.18. System infastructure

get_das_root()

get_das_root returns string

returns path to where daslib and other libraries exist. this is typically root folder of the Daslang main repository

panic(text: string const implicit)

argument

argument type

text

string const implicit

will cause panic. The program will be determinated if there is no recover. Panic is not a 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 correcly shut-down or report fatal error. If there is no recover withing script, it will be called in calling eval (in C++ callee code).

print(text: string const implicit)

argument

argument type

text

string const implicit

outputs string into current context log output

error(text: string const implicit)

argument

argument type

text

string const implicit

similar to ‘print’ but outputs to context error output

sprint(value: any; flags: print_flags)

sprint returns string

argument

argument type

value

any

flags

print_flags

similar to ‘print’ but returns string instead of printing it

sprint_json(value: any; humanReadable: bool const)

sprint_json returns string

argument

argument type

value

any

humanReadable

bool const

similar to ‘write_json’ but skips intermediate representation. this is faster but less flexible

terminate()

terminates current context execution

breakpoint()

breakpoint will call os_debugbreakpoint, which is link-time unresolved dependency. It’s supposed to call breakpoint in debugger tool, as sample implementation does.

stackwalk(args: bool const; vars: bool const)

argument

argument type

args

bool const

vars

bool const

stackwalk prints call stack and local variables values

is_in_aot()

is_in_aot returns bool

returns true if compiler is currently generating AOT

to_log(level: int const; text: string const implicit)

argument

argument type

level

int const

text

string const implicit

similar to print but output goes to the logging infrastructure. arg0 specifies log level, i.e. LOG_… constants

to_compiler_log(text: string const implicit)

argument

argument type

text

string const implicit

Output text to compiler log, usually from the macro.

2.19. Memory manipulation

variant_index(arg0: variant<> const implicit)

variant_index returns int

argument

argument type

arg0

variant<> const implicit

returns internal index of the variant value

set_variant_index(variant: variant<> implicit; index: int const)

Warning

This is unsafe operation.

argument

argument type

variant

variant<> implicit

index

int const

sets internal index of the variant value

hash(data: any)

hash returns uint64

argument

argument type

data

any

returns hash value of the data. current implementation uses FNV64a hash.

hash(data: string const implicit)

hash returns uint64

argument

argument type

data

string const implicit

returns hash value of the data. current implementation uses FNV64a hash.

memcpy(left: void? const implicit; right: void? const implicit; size: int const)

Warning

This is unsafe operation.

argument

argument type

left

void? const implicit

right

void? const implicit

size

int const

copies size bytes of memory from right to left

memcmp(left: void? const implicit; right: void? const implicit; size: int const)

memcmp returns int

Warning

This is unsafe operation.

argument

argument type

left

void? const implicit

right

void? const implicit

size

int const

similar to C ‘memcmp’, compares size bytes of left` and right memory. returns -1 if left is less, 1 if left is greater, and 0 if left is same as right

intptr(p: void? const)

intptr returns uint64

argument

argument type

p

void? const

returns int64 representation of a pointer

intptr(p: smart_ptr<auto> const)

intptr returns uint64

argument

argument type

p

smart_ptr<auto> const

returns int64 representation of a pointer

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

lock_data returns auto

argument

argument type

a

option

blk

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

locks array and invokes block with a pointer to array’s data

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

lock_data returns auto

argument

argument type

a

option const

blk

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

locks array and invokes block with a pointer to array’s data

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

map_to_array returns auto

Warning

This is unsafe operation.

argument

argument type

data

void? const

len

int const

blk

block<(arg:array<auto(TT)>#):auto> const

builds temporary array from the specified memory

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

map_to_ro_array returns auto

Warning

This is unsafe operation.

argument

argument type

data

void? const

len

int const

blk

block<(arg:array<auto(TT)> const#):auto> const

same as map_to_array but array is read-only

2.20. Binary serializer

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

binary_save returns auto

argument

argument type

obj

auto const

subexpr

block<(data:array<uint8> const):void> const

saves any data to array<uint8>. obsolete, use daslib/archive instead

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

binary_load returns auto

argument

argument type

obj

auto

data

array<uint8> const

loads any data from array<uint8>. obsolete, use daslib/archive instead

2.21. Path and command line

get_command_line_arguments()

get_command_line_arguments returns array<string>

returns array of command line arguments.

2.22. Time and date

get_clock()

get_clock returns builtin::clock

return a current calendar time. The value returned generally represents the number of seconds since 00:00 hours, Jan 1, 1970 UTC (i.e., the current unix timestamp).

ref_time_ticks()

ref_time_ticks returns int64

returns current time in ticks

get_time_usec(arg0: int64 const)

get_time_usec returns int

argument

argument type

arg0

int64 const

returns time interval in usec, since the specified reft (usually from ref_time_ticks)

get_time_nsec(arg0: int64 const)

get_time_nsec returns int64

argument

argument type

arg0

int64 const

returns time interval in nsec, since the specified reft (usually from ref_time_ticks)

2.23. Lock checking

lock_count(array: array const implicit)

lock_count returns int

argument

argument type

array

array const implicit

returns internal lock count for the array or table

set_verify_array_locks(array: array implicit; check: bool const)

set_verify_array_locks returns bool

Warning

This is unsafe operation.

argument

argument type

array

array implicit

check

bool const

runtime optimization, which indicates that the array does not need lock checks.

set_verify_table_locks(table: table implicit; check: bool const)

set_verify_table_locks returns bool

Warning

This is unsafe operation.

argument

argument type

table

table implicit

check

bool const

runtime optimization, which indicates that the table does not need lock checks.

2.24. Lock checking internals

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

_move_with_lockcheck returns auto

argument

argument type

a

auto(valA)&

b

auto(valB)&

moves b into a, checks if a or b is locked, recursively for each lockable element of a and b

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

_return_with_lockcheck returns valT&

argument

argument type

a

auto(valT)&!

returns a. check if a is locked, recursively for each lockable element of a

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

_return_with_lockcheck returns valT&

argument

argument type

a

auto(valT) const&!

returns a. check if a is locked, recursively for each lockable element of a

_at_with_lockcheck(Tab: table<auto(keyT);auto(valT)>; at: keyT const|keyT const# const)

_at_with_lockcheck returns valT&

argument

argument type

Tab

table<auto(keyT);auto(valT)>

at

option const

returns element of the table Tab, also checks if Tab is locked, recursively for each lockable element of Tab

2.25. Bit operations

clz(bits: uint const)

clz returns uint

argument

argument type

bits

uint const

count leading zeros

clz(bits: uint64 const)

clz returns uint64

argument

argument type

bits

uint64 const

count leading zeros

ctz(bits: uint const)

ctz returns uint

argument

argument type

bits

uint const

count trailing zeros

ctz(bits: uint64 const)

ctz returns uint64

argument

argument type

bits

uint64 const

count trailing zeros

popcnt(bits: uint const)

popcnt returns uint

argument

argument type

bits

uint const

count number of set bits

popcnt(bits: uint64 const)

popcnt returns uint64

argument

argument type

bits

uint64 const

count number of set bits

2.26. Intervals

interval(arg0: int const; arg1: int const)

interval returns range

argument

argument type

arg0

int const

arg1

int const

returns range(‘arg0’,’arg1’)

interval(arg0: uint const; arg1: uint const)

interval returns urange

argument

argument type

arg0

uint const

arg1

uint const

returns range(‘arg0’,’arg1’)

interval(arg0: int64 const; arg1: int64 const)

interval returns range64

argument

argument type

arg0

int64 const

arg1

int64 const

returns range(‘arg0’,’arg1’)

interval(arg0: uint64 const; arg1: uint64 const)

interval returns urange64

argument

argument type

arg0

uint64 const

arg1

uint64 const

returns range(‘arg0’,’arg1’)

2.27. RTTI

class_rtti_size(ptr: void? const implicit)

class_rtti_size returns int

argument

argument type

ptr

void? const implicit

returns size of specific TypeInfo for the class

2.28. Lock verification

set_verify_context_locks(check: bool const)

set_verify_context_locks returns bool

Warning

This is unsafe operation.

argument

argument type

check

bool const

Enables or disables array or table lock runtime verification per context

2.29. Initialization and finalization

using(arg0: block<(var arg0:das_string explicit):void> const implicit)

argument

argument type

arg0

block<( builtin::das_string ):void> const implicit

Creates temporary das_string.

2.30. Algorithms

count(start: int const; step: int const)

count returns iterator<int>

argument

argument type

start

int const

step

int const

returns iterator which iterates from start value by incrementing it by step value. It is the intended way to have counter together with other values in the for loop.

ucount(start: uint const; step: uint const)

ucount returns iterator<uint>

argument

argument type

start

uint const

step

uint const

returns iterator which iterates from start value by incrementing it by step value. It is the intended way to have counter together with other values in the for loop.

iter_range(foo: auto const)

iter_range returns auto

argument

argument type

foo

auto const

returns range(foo)

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

swap returns auto

argument

argument type

a

auto(TT)&

b

auto(TT)&

swaps two values a and ‘b’

2.31. Memset

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

Warning

This is unsafe operation.

argument

argument type

left

void? const implicit

value

uint8 const

count

int const

Effecitvely C memset.

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

Warning

This is unsafe operation.

argument

argument type

left

void? const implicit

value

uint16 const

count

int const

Similar to memset, but fills values with 16 bit words.

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

Warning

This is unsafe operation.

argument

argument type

left

void? const implicit

value

uint const

count

int const

Similar to memset, but fills values with 32 bit words.

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

Warning

This is unsafe operation.

argument

argument type

left

void? const implicit

value

uint64 const

count

int const

Similar to memset, but fills values with 64 bit words.

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

Warning

This is unsafe operation.

argument

argument type

left

void? const implicit

value

uint4 const

count

int const

Similar to memset, but fills values with 128 bit vector type values.

2.32. Malloc

malloc(size: uint64 const)

malloc returns void?

Warning

This is unsafe operation.

argument

argument type

size

uint64 const

C-style malloc

free(ptr: void? const implicit)

Warning

This is unsafe operation.

argument

argument type

ptr

void? const implicit

C-style free to be coupled with C-style malloc

malloc_usable_size(ptr: void? const implicit)

malloc_usable_size returns uint64

Warning

This is unsafe operation.

argument

argument type

ptr

void? const implicit

returns size of the allocated memory block

2.33. Uncategorized

is_intern_strings()

is_intern_strings returns bool

returns true if string interning is enabled

build_hash(block: block<(var arg0:HashBuilder):void> const implicit)

build_hash returns uint64

argument

argument type

block

block<( builtin::HashBuilder ):void> const implicit

returns hash value out of hash-builder.

eval_main_loop(block: block<bool> const implicit)

argument

argument type

block

block<> const implicit

executes main loop for the application. has specific implementation in EMSCRIPTEN, otherwise invoke until false.

remove_value(arr: array<auto(TT)> -const|array<auto(TT)># -const; key: TT const)

remove_value returns bool

argument

argument type

arr

option

key

TT const

removes first occurance of the key from the array.