term.c
Include dependency graph for term.c:
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:
-
struct SnprintfFun
Collaboration diagram for SnprintfFun: