term.c

Include dependency graph for term.c:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="stdbool.h" tooltip="stdbool.h"]
    "34" [label="stdarg.h" tooltip="stdarg.h"]
    "19" [label="atom.h" tooltip="atom.h"]
    "11" [label="assert.h" tooltip="assert.h"]
    "25" [label="synclist.h" tooltip="synclist.h"]
    "32" [label="tempstack.h" tooltip="tempstack.h"]
    "4" [label="stdint.h" tooltip="stdint.h"]
    "6" [label="stdlib.h" tooltip="stdlib.h"]
    "31" [label="valueshashtable.h" tooltip="valueshashtable.h"]
    "30" [label="exportedfunction.h" tooltip="exportedfunction.h"]
    "21" [label="context.h" tooltip="context.h"]
    "14" [label="utils.h" tooltip="utils.h"]
    "20" [label="atom_table.h" tooltip="atom_table.h"]
    "10" [label="term_typedef.h" tooltip="term_typedef.h"]
    "15" [label="stddef.h" tooltip="stddef.h"]
    "12" [label="limits.h" tooltip="limits.h"]
    "16" [label="refc_binary.h" tooltip="refc_binary.h"]
    "7" [label="string.h" tooltip="string.h"]
    "23" [label="mailbox.h" tooltip="mailbox.h"]
    "28" [label="module.h" tooltip="module.h"]
    "1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/term.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/term.c" fillcolor="#BFBFBF"]
    "2" [label="term.h" tooltip="term.h"]
    "9" [label="erl_nif.h" tooltip="erl_nif.h"]
    "27" [label="interop.h" tooltip="interop.h"]
    "18" [label="resources.h" tooltip="resources.h"]
    "24" [label="smp.h" tooltip="smp.h"]
    "33" [label="ctype.h" tooltip="ctype.h"]
    "29" [label="atomshashtable.h" tooltip="atomshashtable.h"]
    "22" [label="globalcontext.h" tooltip="globalcontext.h"]
    "8" [label="memory.h" tooltip="memory.h"]
    "5" [label="stdio.h" tooltip="stdio.h"]
    "26" [label="timer_list.h" tooltip="timer_list.h"]
    "17" [label="list.h" tooltip="list.h"]
    "13" [label="inttypes.h" tooltip="inttypes.h"]
    "19" -> "4" [dir=forward tooltip="include"]
    "19" -> "6" [dir=forward tooltip="include"]
    "25" -> "17" [dir=forward tooltip="include"]
    "25" -> "5" [dir=forward tooltip="include"]
    "25" -> "24" [dir=forward tooltip="include"]
    "32" -> "10" [dir=forward tooltip="include"]
    "32" -> "14" [dir=forward tooltip="include"]
    "30" -> "2" [dir=forward tooltip="include"]
    "21" -> "22" [dir=forward tooltip="include"]
    "21" -> "17" [dir=forward tooltip="include"]
    "21" -> "23" [dir=forward tooltip="include"]
    "21" -> "24" [dir=forward tooltip="include"]
    "21" -> "2" [dir=forward tooltip="include"]
    "21" -> "26" [dir=forward tooltip="include"]
    "14" -> "15" [dir=forward tooltip="include"]
    "20" -> "3" [dir=forward tooltip="include"]
    "20" -> "19" [dir=forward tooltip="include"]
    "10" -> "11" [dir=forward tooltip="include"]
    "10" -> "12" [dir=forward tooltip="include"]
    "10" -> "13" [dir=forward tooltip="include"]
    "10" -> "4" [dir=forward tooltip="include"]
    "16" -> "3" [dir=forward tooltip="include"]
    "16" -> "6" [dir=forward tooltip="include"]
    "16" -> "17" [dir=forward tooltip="include"]
    "16" -> "18" [dir=forward tooltip="include"]
    "23" -> "3" [dir=forward tooltip="include"]
    "23" -> "17" [dir=forward tooltip="include"]
    "23" -> "10" [dir=forward tooltip="include"]
    "23" -> "14" [dir=forward tooltip="include"]
    "28" -> "3" [dir=forward tooltip="include"]
    "28" -> "4" [dir=forward tooltip="include"]
    "28" -> "19" [dir=forward tooltip="include"]
    "28" -> "20" [dir=forward tooltip="include"]
    "28" -> "29" [dir=forward tooltip="include"]
    "28" -> "21" [dir=forward tooltip="include"]
    "28" -> "30" [dir=forward tooltip="include"]
    "28" -> "22" [dir=forward tooltip="include"]
    "28" -> "2" [dir=forward tooltip="include"]
    "28" -> "31" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "19" [dir=forward tooltip="include"]
    "1" -> "20" [dir=forward tooltip="include"]
    "1" -> "21" [dir=forward tooltip="include"]
    "1" -> "27" [dir=forward tooltip="include"]
    "1" -> "28" [dir=forward tooltip="include"]
    "1" -> "32" [dir=forward tooltip="include"]
    "1" -> "33" [dir=forward tooltip="include"]
    "1" -> "13" [dir=forward tooltip="include"]
    "1" -> "34" [dir=forward tooltip="include"]
    "1" -> "15" [dir=forward tooltip="include"]
    "1" -> "5" [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" -> "16" [dir=forward tooltip="include"]
    "2" -> "14" [dir=forward tooltip="include"]
    "2" -> "10" [dir=forward tooltip="include"]
    "9" -> "10" [dir=forward tooltip="include"]
    "27" -> "21" [dir=forward tooltip="include"]
    "27" -> "2" [dir=forward tooltip="include"]
    "18" -> "6" [dir=forward tooltip="include"]
    "18" -> "9" [dir=forward tooltip="include"]
    "18" -> "17" [dir=forward tooltip="include"]
    "18" -> "8" [dir=forward tooltip="include"]
    "24" -> "3" [dir=forward tooltip="include"]
    "29" -> "19" [dir=forward tooltip="include"]
    "22" -> "4" [dir=forward tooltip="include"]
    "22" -> "19" [dir=forward tooltip="include"]
    "22" -> "20" [dir=forward tooltip="include"]
    "22" -> "9" [dir=forward tooltip="include"]
    "22" -> "17" [dir=forward tooltip="include"]
    "22" -> "23" [dir=forward tooltip="include"]
    "22" -> "24" [dir=forward tooltip="include"]
    "22" -> "25" [dir=forward tooltip="include"]
    "22" -> "2" [dir=forward tooltip="include"]
    "22" -> "26" [dir=forward tooltip="include"]
    "8" -> "9" [dir=forward tooltip="include"]
    "8" -> "10" [dir=forward tooltip="include"]
    "8" -> "14" [dir=forward tooltip="include"]
    "8" -> "4" [dir=forward tooltip="include"]
    "8" -> "6" [dir=forward tooltip="include"]
    "26" -> "3" [dir=forward tooltip="include"]
    "26" -> "4" [dir=forward tooltip="include"]
    "26" -> "17" [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 == BEGIN_MAP_KEY

) {                                                                  \

map_key_nesting++;                                                                       \

other = temp_stack_pop(&temp_stack);                                                       \

}

else if (other == END_MAP_KEY

) {                                                             \

map_key_nesting--;                                                                       \

other = temp_stack_pop(&temp_stack);                                                       \

}                                                                                              \

t = temp_stack_pop(&temp_stack);


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 int 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.

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.

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)

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"]
    "1" [label="SnprintfFun" tooltip="SnprintfFun" fillcolor="#BFBFBF"]
    "2" [label="PrinterFun" tooltip="PrinterFun"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "2" -> "2" [dir=forward tooltip="usage"]
}

Public Members

PrinterFun base
int size
char *buf