x-engine-c v0.2.13
The C engine for x-lang
Loading...
Searching...
No Matches
prim.h File Reference

Object-level primitive operations (make, call, write, etc.). More...

#include "x-obj.h"

Go to the source code of this file.

Functions

x_char_tx_obj_prim_name (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_units (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_length (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_make (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_free (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_clone (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_dump (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_call (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_eval (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_convert (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_identify (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_read (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_obj_prim_write (x_obj_t *p_base, x_obj_t *p_args)
 

Detailed Description

Object-level primitive operations (make, call, write, etc.).

Author
Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)

Function Documentation

◆ x_obj_prim_call()

x_obj_t * x_obj_prim_call ( x_obj_t p_base,
x_obj_t p_args 
)

Invoke an object's type-dispatch call handler.

Invoke an object's type-dispatch call handler.

Looks up the call field on the object's type struct and dispatches. For procedure-typed call handlers, invokes via x_type_procedure_call to support closures as type callbacks.

Parameters
p_basex_obj_t* – Base (execution context)
p_argsx_obj_t* – (callable . args)
Returns
Result of the call, or NULL if no call handler

◆ x_obj_prim_clone()

x_obj_t * x_obj_prim_clone ( x_obj_t p_base,
x_obj_t p_args 
)

Clone (shallow copy) a heap object.

◆ x_obj_prim_convert()

x_obj_t * x_obj_prim_convert ( x_obj_t p_base,
x_obj_t p_args 
)

Convert an object to a different type.

◆ x_obj_prim_dump()

x_obj_t * x_obj_prim_dump ( x_obj_t p_base,
x_obj_t p_args 
)

Debug-dump an object's raw representation.

◆ x_obj_prim_eval()

x_obj_t * x_obj_prim_eval ( x_obj_t p_base,
x_obj_t p_args 
)

Evaluate an object via its type's eval handler.

◆ x_obj_prim_free()

x_obj_t * x_obj_prim_free ( x_obj_t p_base,
x_obj_t p_args 
)

Free a heap object.

◆ x_obj_prim_identify()

x_obj_t * x_obj_prim_identify ( x_obj_t p_base,
x_obj_t p_args 
)

Return the type identifier object for a value.

◆ x_obj_prim_length()

x_obj_t * x_obj_prim_length ( x_obj_t p_base,
x_obj_t p_args 
)

Return the logical length of an object.

Primitive: dispatch an object's logical length by type.

Returns x_pair_prim_length() for pairs and x_atom_prim_length() for atoms or nil-typed objects; for other types the base's length hook (x_base_field_hook_length()) is consulted.

Parameters
p_baseBase (execution context).
p_argsPair list whose first element is the subject object.
Returns
An integer atom with the logical length, or NULL.

◆ x_obj_prim_make()

x_obj_t * x_obj_prim_make ( x_obj_t p_base,
x_obj_t p_args 
)

Construct a new object via its type's make callback.

Construct a new object via its type's make callback.

Dispatches to the appropriate constructor based on the object's type (static atom, static pair, or registered type with make handler).

Parameters
p_basex_obj_t* – Base (execution context)
p_argsx_obj_t* – (prototype-obj flags data...)
Returns
Newly allocated object, or NULL on failure

◆ x_obj_prim_name()

x_char_t * x_obj_prim_name ( x_obj_t p_base,
x_obj_t p_args 
)

Return the type name string for an object.

◆ x_obj_prim_read()

x_obj_t * x_obj_prim_read ( x_obj_t p_base,
x_obj_t p_args 
)

Read an object from the token stream.

◆ x_obj_prim_units()

x_obj_t * x_obj_prim_units ( x_obj_t p_base,
x_obj_t p_args 
)

Return the number of heap units occupied by an object.

Primitive: dispatch an object's data-unit count by type.

Returns x_pair_prim_units() for pairs and x_atom_prim_units() for atoms or nil-typed objects; for other types the base's units hook (x_base_field_hook_units()) is consulted.

Parameters
p_baseBase (execution context).
p_argsPair list whose first element is the subject object.
Returns
An integer atom with the unit count, or NULL.

◆ x_obj_prim_write()

x_obj_t * x_obj_prim_write ( x_obj_t p_base,
x_obj_t p_args 
)

Write an object's external representation.