main-apidocs-libatomvm-src-term-dot-c.md
Include dependency graph for term.c:
digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "9" [label="atom.h" tooltip="atom.h"] "25" [label="atom_table.h" tooltip="atom_table.h"] "32" [label="bitstring.h" tooltip="bitstring.h"] "26" [label="context.h" tooltip="context.h"] "35" [label="defaultatoms.h" tooltip="defaultatoms.h"] "15" [label="erl_nif.h" tooltip="erl_nif.h"] "28" [label="ets.h" tooltip="ets.h"] "34" [label="exportedfunction.h" tooltip="exportedfunction.h"] "27" [label="globalcontext.h" tooltip="globalcontext.h"] "37" [label="interop.h" tooltip="interop.h"] "10" [label="intn.h" tooltip="intn.h"] "31" [label="jit.h" tooltip="jit.h"] "20" [label="list.h" tooltip="list.h"] "22" [label="mailbox.h" tooltip="mailbox.h"] "14" [label="memory.h" tooltip="memory.h"] "38" [label="module.h" tooltip="module.h"] "19" [label="refc_binary.h" tooltip="refc_binary.h"] "21" [label="resources.h" tooltip="resources.h"] "24" [label="smp.h" tooltip="smp.h"] "23" [label="synclist.h" tooltip="synclist.h"] "1" [label="/__w/AtomVM/AtomVM/src/libAtomVM/term.c" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/term.c" fillcolor="#BFBFBF"] "2" [label="term.h" tooltip="term.h"] "16" [label="term_typedef.h" tooltip="term_typedef.h"] "29" [label="timer_list.h" tooltip="timer_list.h"] "33" [label="unicode.h" tooltip="unicode.h"] "11" [label="utils.h" tooltip="utils.h"] "30" [label="valueshashtable.h" tooltip="valueshashtable.h"] "17" [label="assert.h" tooltip="assert.h"] "40" [label="ctype.h" tooltip="ctype.h"] "36" [label="defaultatoms.def" tooltip="defaultatoms.def"] "12" [label="inttypes.h" tooltip="inttypes.h"] "18" [label="limits.h" tooltip="limits.h"] "41" [label="stdarg.h" tooltip="stdarg.h"] "4" [label="stdbool.h" tooltip="stdbool.h"] "13" [label="stddef.h" tooltip="stddef.h"] "5" [label="stdint.h" tooltip="stdint.h"] "6" [label="stdio.h" tooltip="stdio.h"] "7" [label="stdlib.h" tooltip="stdlib.h"] "8" [label="string.h" tooltip="string.h"] "3" [label="sys/types.h" tooltip="sys/types.h"] "39" [label="tempstack.h" tooltip="tempstack.h"] "9" -> "5" [dir=forward tooltip="include"] "9" -> "7" [dir=forward tooltip="include"] "25" -> "4" [dir=forward tooltip="include"] "25" -> "9" [dir=forward tooltip="include"] "25" -> "11" [dir=forward tooltip="include"] "32" -> "10" [dir=forward tooltip="include"] "32" -> "2" [dir=forward tooltip="include"] "32" -> "33" [dir=forward tooltip="include"] "32" -> "4" [dir=forward tooltip="include"] "32" -> "5" [dir=forward tooltip="include"] "26" -> "27" [dir=forward tooltip="include"] "26" -> "31" [dir=forward tooltip="include"] "26" -> "20" [dir=forward tooltip="include"] "26" -> "22" [dir=forward tooltip="include"] "26" -> "24" [dir=forward tooltip="include"] "26" -> "2" [dir=forward tooltip="include"] "26" -> "29" [dir=forward tooltip="include"] "35" -> "27" [dir=forward tooltip="include"] "35" -> "36" [dir=forward tooltip="include"] "15" -> "16" [dir=forward tooltip="include"] "28" -> "4" [dir=forward tooltip="include"] "28" -> "23" [dir=forward tooltip="include"] "28" -> "2" [dir=forward tooltip="include"] "34" -> "2" [dir=forward tooltip="include"] "27" -> "5" [dir=forward tooltip="include"] "27" -> "9" [dir=forward tooltip="include"] "27" -> "25" [dir=forward tooltip="include"] "27" -> "15" [dir=forward tooltip="include"] "27" -> "28" [dir=forward tooltip="include"] "27" -> "20" [dir=forward tooltip="include"] "27" -> "22" [dir=forward tooltip="include"] "27" -> "24" [dir=forward tooltip="include"] "27" -> "23" [dir=forward tooltip="include"] "27" -> "2" [dir=forward tooltip="include"] "27" -> "29" [dir=forward tooltip="include"] "27" -> "30" [dir=forward tooltip="include"] "37" -> "26" [dir=forward tooltip="include"] "37" -> "2" [dir=forward tooltip="include"] "10" -> "4" [dir=forward tooltip="include"] "10" -> "8" [dir=forward tooltip="include"] "10" -> "11" [dir=forward tooltip="include"] "31" -> "32" [dir=forward tooltip="include"] "31" -> "34" [dir=forward tooltip="include"] "31" -> "2" [dir=forward tooltip="include"] "31" -> "16" [dir=forward tooltip="include"] "31" -> "4" [dir=forward tooltip="include"] "20" -> "4" [dir=forward tooltip="include"] "22" -> "4" [dir=forward tooltip="include"] "22" -> "20" [dir=forward tooltip="include"] "22" -> "16" [dir=forward tooltip="include"] "22" -> "11" [dir=forward tooltip="include"] "14" -> "5" [dir=forward tooltip="include"] "14" -> "7" [dir=forward tooltip="include"] "14" -> "15" [dir=forward tooltip="include"] "14" -> "16" [dir=forward tooltip="include"] "14" -> "11" [dir=forward tooltip="include"] "38" -> "4" [dir=forward tooltip="include"] "38" -> "5" [dir=forward tooltip="include"] "38" -> "9" [dir=forward tooltip="include"] "38" -> "25" [dir=forward tooltip="include"] "38" -> "26" [dir=forward tooltip="include"] "38" -> "34" [dir=forward tooltip="include"] "38" -> "27" [dir=forward tooltip="include"] "38" -> "31" [dir=forward tooltip="include"] "38" -> "2" [dir=forward tooltip="include"] "19" -> "4" [dir=forward tooltip="include"] "19" -> "7" [dir=forward tooltip="include"] "19" -> "20" [dir=forward tooltip="include"] "19" -> "21" [dir=forward tooltip="include"] "21" -> "7" [dir=forward tooltip="include"] "21" -> "15" [dir=forward tooltip="include"] "21" -> "20" [dir=forward tooltip="include"] "21" -> "22" [dir=forward tooltip="include"] "21" -> "14" [dir=forward tooltip="include"] "21" -> "23" [dir=forward tooltip="include"] "24" -> "4" [dir=forward tooltip="include"] "23" -> "6" [dir=forward tooltip="include"] "23" -> "20" [dir=forward tooltip="include"] "23" -> "24" [dir=forward tooltip="include"] "1" -> "2" [dir=forward tooltip="include"] "1" -> "9" [dir=forward tooltip="include"] "1" -> "25" [dir=forward tooltip="include"] "1" -> "26" [dir=forward tooltip="include"] "1" -> "35" [dir=forward tooltip="include"] "1" -> "37" [dir=forward tooltip="include"] "1" -> "10" [dir=forward tooltip="include"] "1" -> "38" [dir=forward tooltip="include"] "1" -> "39" [dir=forward tooltip="include"] "1" -> "11" [dir=forward tooltip="include"] "1" -> "40" [dir=forward tooltip="include"] "1" -> "12" [dir=forward tooltip="include"] "1" -> "41" [dir=forward tooltip="include"] "1" -> "13" [dir=forward tooltip="include"] "1" -> "5" [dir=forward tooltip="include"] "1" -> "6" [dir=forward tooltip="include"] "2" -> "3" [dir=forward tooltip="include"] "2" -> "4" [dir=forward tooltip="include"] "2" -> "5" [dir=forward tooltip="include"] "2" -> "6" [dir=forward tooltip="include"] "2" -> "7" [dir=forward tooltip="include"] "2" -> "8" [dir=forward tooltip="include"] "2" -> "9" [dir=forward tooltip="include"] "2" -> "10" [dir=forward tooltip="include"] "2" -> "14" [dir=forward tooltip="include"] "2" -> "19" [dir=forward tooltip="include"] "2" -> "21" [dir=forward tooltip="include"] "2" -> "11" [dir=forward tooltip="include"] "2" -> "16" [dir=forward tooltip="include"] "16" -> "17" [dir=forward tooltip="include"] "16" -> "18" [dir=forward tooltip="include"] "16" -> "12" [dir=forward tooltip="include"] "16" -> "5" [dir=forward tooltip="include"] "29" -> "4" [dir=forward tooltip="include"] "29" -> "5" [dir=forward tooltip="include"] "29" -> "20" [dir=forward tooltip="include"] "33" -> "4" [dir=forward tooltip="include"] "33" -> "13" [dir=forward tooltip="include"] "33" -> "5" [dir=forward tooltip="include"] "11" -> "12" [dir=forward tooltip="include"] "11" -> "4" [dir=forward tooltip="include"] "11" -> "13" [dir=forward tooltip="include"] "11" -> "6" [dir=forward tooltip="include"] "11" -> "7" [dir=forward tooltip="include"] "30" -> "13" [dir=forward tooltip="include"] "30" -> "5" [dir=forward tooltip="include"] }
Defines
BEGIN_MAP_KEY TERM_RESERVED_MARKER(1)
END_MAP_KEY TERM_RESERVED_MARKER(0)
CMP_POP_AND_CONTINUE()
other = temp_stack_pop(&temp_stack);\
if (other ==
) {\
map_key_nesting++;\
other = temp_stack_pop(&temp_stack); \
} else if (other ==
) {\
map_key_nesting--;\
other = temp_stack_pop(&temp_stack); \
}\
t = temp_stack_pop(&temp_stack);
Enums
enum TermTypeIndex
Values:
enumerator TERM_TYPE_INDEX_INVALID = 0
enumerator TERM_TYPE_INDEX_INTEGER = 1
enumerator TERM_TYPE_INDEX_FLOAT = 2
enumerator TERM_TYPE_INDEX_ATOM = 3
enumerator TERM_TYPE_INDEX_REFERENCE = 4
enumerator TERM_TYPE_INDEX_FUNCTION = 5
enumerator TERM_TYPE_INDEX_PORT = 6
enumerator TERM_TYPE_INDEX_PID = 7
enumerator TERM_TYPE_INDEX_TUPLE = 8
enumerator TERM_TYPE_INDEX_MAP = 9
enumerator TERM_TYPE_INDEX_NIL = 10
enumerator TERM_TYPE_INDEX_NON_EMPTY_LIST = 11
enumerator TERM_TYPE_INDEX_BINARY = 12
Functions
int fprintf_printer(PrinterFun *fun, const char *fmt, ...)
int snprintf_printer(PrinterFun *fun, const char *fmt, ...)
void term_display(FILE *fd, term t, const Context *ctx)
Prints a term to stdout.
Print any term to the given file.
Parameters:
fd – the file where the term will be printed.
t – the term that will be printed.
ctx – the context.
int term_fprint(FILE *stream, term t, const GlobalContext *global)
Prints a term to the given file.
Print any given term to the given file.
Parameters:
fd – the file where the term will be printed.
t – the term that will be printed.
global – the GlobalContext.
Returns:
the number of printed characters.
int term_snprint(char *buf, size_t size, term t, const GlobalContext *global)
Write a term to a string as text.
Print any given term to the given buffer.
Parameters:
buf – the buffer where the term will be printed.
size – the buffer size.
t – the term that will be printed.
global – the GlobalContext.
Returns:
the number of printed characters.
int term_funprint(PrinterFun *fun, term t, const GlobalContext *global)
Prints a term using given printer fun.
Print any given term using a printer fun
Parameters:
pf – function that will handle printing.
t – the term that will be printed.
global – the GlobalContext.
Returns:
the number of printed characters.
static enum TermTypeIndex term_type_to_index(term t)
TermCompareResult term_compare(term t, term other, TermCompareOpts opts, GlobalContext *global)
Compares two terms.
Tells if first term is >, < or == to the second term.
Parameters:
t – the first term.
other – the second term.
opts – a value of 1 will compare exact equality, 0 for less strict equality.
global – the global context.
Returns:
any of TermEquals, TermLessThan, TermGreaterThan or TermCompareMemoryAllocFail error.
void term_get_function_mfa(term fun, term *m, term *f, term *a)
Gets function module name, name and arity.
Allows to retrieve partial information by passing NULL pointers.
Parameters:
fun – function term.
m – module name as an atom.
f – function name as an atom.
a – function arity as an integer.
term term_alloc_refc_binary(size_t size, bool is_const, Heap *heap, GlobalContext *glb)
Create a reference-counted binary on the heap.
This function will create a reference-counted binary on the heap. If the data supplied is “const” (e.g., read from a literal in a BEAM file), then the returned term will point directly to the supplied data, and will not technically be reference-counted. Otherwise, a block of memory will be allocated to contain a copy of the data, in addition to a reference counter, so that the block can be free’d when no other terms reference the created object. (The reference count will be initialized to 1). If the data is non-NULL, it will be copied into the newly allocated block of memory.
Parameters:
size – the size (in bytes) of the data to allocate
is_const – designates whether the data pointed to is “const”, such as a term literal
heap – the heap to allocate the binary in
glb – the global context as refc binaries are global
Returns:
a term (reference) pointing to the newly allocated binary in the process heap or term_invalid_term() if there isn’t enough memory to allocate the refc buffer.
term term_reuse_binary(term src, size_t size, Heap *heap, GlobalContext *glb)
Reuse a binary. If the binary is a refc binary with a ref count of 1, try to reuse it. Otherwise, create a new binary and copy the data.
Try to reuse a binary and return a term pointing to it.
Parameters:
src – binary to reuse.
size – size of binary data buffer.
heap – the heap to allocate memory in
glb – the global context as refc binaries are global
Returns:
a term pointing to the boxed binary pointer.
static term find_binary(term binary_or_state)
term term_alloc_sub_binary(term binary_or_state, size_t offset, size_t len, Heap *heap)
Create a sub-binary.
This function will create a sub-binary on the heap, using the supplied binary, offset into the binary, and length of the sub-binary. This function assumes the length of the referenced binary is greater or equal to offset + len.
Parameters:
binary – the referenced binary
offset – the offset into the referenced binary to start the sub-binary
len – the length (in bytes) of the sub-binary
heap – the heap to allocate the binary in
Returns:
a term (reference) pointing to the newly allocated sub-binary in the process heap.
term term_get_map_assoc(term map, term key, GlobalContext *glb)
avm_float_t term_conv_to_float(term t)
term term_from_resource_type_and_serialize_ref(uint64_t resource_type_ptr, uint64_t resource_serialize_key, Heap *heap, GlobalContext *glb)
Get a resource term from a resource type and a serialization reference number.
Parameters:
resource_type_ptr – pointer to the resource type
resource_serialize_ref – unique reference for serialization
heap – the heap to create the resource term in
glb – the global context
Returns:
a resource term for this resource or a stale reference if the resource cannot be found
term term_from_resource_binary(void *obj, const void *data, size_t size, Heap *heap, GlobalContext *glb)
Create a resource managed binary.
Increment reference count of resource and create a refc binary for the pointer and size.
Parameters:
obj – the managing resource object
data – the pointer to the data
size – the size of the binary
heap – the heap to allocate memory in
glb – the global context
Returns:
a binary term managed by obj
Variables
const term empty_tuple = 0
All empty tuples will reference this.
struct FprintfFun
Collaboration diagram for FprintfFun:
digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "1" [label="FprintfFun" tooltip="FprintfFun" fillcolor="#BFBFBF"] "2" [label="PrinterFun" tooltip="PrinterFun"] "1" -> "2" [dir=forward tooltip="usage"] "2" -> "2" [dir=forward tooltip="usage"] }
Public Members
PrinterFun base
FILE *stream
struct SnprintfFun
Collaboration diagram for SnprintfFun:
digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "2" [label="PrinterFun" tooltip="PrinterFun"] "1" [label="SnprintfFun" tooltip="SnprintfFun" fillcolor="#BFBFBF"] "2" -> "2" [dir=forward tooltip="usage"] "1" -> "2" [dir=forward tooltip="usage"] }
Public Members