Reduct  v1.0.4-3-gdaf0d70
A functional and immutable language.
Loading...
Searching...
No Matches
Item

Detailed Description

An item is a generic container for all data types and heap alloacted structures within Reduct.

To optimize memory cacheing and reduce fragmentation, all items are 64 bytes and aligned to cache lines.

Data Structures

struct  reduct_item_t
 Item structure. More...
 
struct  reduct_item_block_t
 Item block structure. More...
 

Macros

#define REDUCT_ITEM_TYPE_NONE   0
 No type.
 
#define REDUCT_ITEM_TYPE_ATOM   1
 An atom.
 
#define REDUCT_ITEM_TYPE_LIST   2
 A list.
 
#define REDUCT_ITEM_TYPE_FUNCTION   3
 A function.
 
#define REDUCT_ITEM_TYPE_CLOSURE   4
 A closure.
 
#define REDUCT_ITEM_TYPE_LIST_NODE   5
 A list node.
 
#define REDUCT_ITEM_FLAG_NONE   0
 No flags.
 
#define REDUCT_ITEM_FLAG_FALSY   (1 << 0)
 Item is falsy.
 
#define REDUCT_ITEM_FLAG_INT_SHAPED   (1 << 1)
 Item is an integer shaped atom.
 
#define REDUCT_ITEM_FLAG_FLOAT_SHAPED   (1 << 2)
 Item is a float shaped atom.
 
#define REDUCT_ITEM_FLAG_INTRINSIC   (1 << 3)
 Item is an atom and a intrinsic.
 
#define REDUCT_ITEM_FLAG_NATIVE   (1 << 4)
 Item is an atom and a native function.
 
#define REDUCT_ITEM_FLAG_QUOTED   (1 << 5)
 Item is a quoted atom.
 
#define REDUCT_ITEM_FLAG_GC_MARK   (1 << 6)
 Item is marked by GC.
 
#define REDUCT_ITEM_PAYLOAD_MAX   48
 The maximum size of the item payload.
 
#define REDUCT_ITEM_BLOCK_MAX   255
 The maximum number of items in a block.
 

Typedefs

typedef reduct_uint8_t reduct_item_type_t
 Item type enumeration.
 
typedef reduct_uint8_t reduct_item_flags_t
 Item flags enumeration.
 

Functions

REDUCT_API reduct_item_treduct_item_new (struct reduct *reduct)
 Allocate a new Reduct item.
 
REDUCT_API void reduct_item_free (struct reduct *reduct, reduct_item_t *item)
 Free an Reduct item.
 
REDUCT_API reduct_int64_t reduct_item_get_int (reduct_item_t *item)
 Get the integer value of an item if it is number shaped.
 
REDUCT_API reduct_float_t reduct_item_get_float (reduct_item_t *item)
 Get the float value of an item if it is number shaped.
 
REDUCT_API const char * reduct_item_type_str (reduct_item_type_t type)
 Get the string representation of an Reduct item type.
 

Macro Definition Documentation

◆ REDUCT_ITEM_TYPE_NONE

#define REDUCT_ITEM_TYPE_NONE   0

No type.

Definition at line 26 of file item.h.

◆ REDUCT_ITEM_TYPE_ATOM

#define REDUCT_ITEM_TYPE_ATOM   1

An atom.

Definition at line 27 of file item.h.

◆ REDUCT_ITEM_TYPE_LIST

#define REDUCT_ITEM_TYPE_LIST   2

A list.

Definition at line 28 of file item.h.

◆ REDUCT_ITEM_TYPE_FUNCTION

#define REDUCT_ITEM_TYPE_FUNCTION   3

A function.

Definition at line 29 of file item.h.

◆ REDUCT_ITEM_TYPE_CLOSURE

#define REDUCT_ITEM_TYPE_CLOSURE   4

A closure.

Definition at line 30 of file item.h.

◆ REDUCT_ITEM_TYPE_LIST_NODE

#define REDUCT_ITEM_TYPE_LIST_NODE   5

A list node.

Definition at line 31 of file item.h.

◆ REDUCT_ITEM_FLAG_NONE

#define REDUCT_ITEM_FLAG_NONE   0

No flags.

Definition at line 37 of file item.h.

◆ REDUCT_ITEM_FLAG_FALSY

#define REDUCT_ITEM_FLAG_FALSY   (1 << 0)

Item is falsy.

Definition at line 38 of file item.h.

◆ REDUCT_ITEM_FLAG_INT_SHAPED

#define REDUCT_ITEM_FLAG_INT_SHAPED   (1 << 1)

Item is an integer shaped atom.

Definition at line 39 of file item.h.

◆ REDUCT_ITEM_FLAG_FLOAT_SHAPED

#define REDUCT_ITEM_FLAG_FLOAT_SHAPED   (1 << 2)

Item is a float shaped atom.

Definition at line 40 of file item.h.

◆ REDUCT_ITEM_FLAG_INTRINSIC

#define REDUCT_ITEM_FLAG_INTRINSIC   (1 << 3)

Item is an atom and a intrinsic.

Definition at line 41 of file item.h.

◆ REDUCT_ITEM_FLAG_NATIVE

#define REDUCT_ITEM_FLAG_NATIVE   (1 << 4)

Item is an atom and a native function.

Definition at line 42 of file item.h.

◆ REDUCT_ITEM_FLAG_QUOTED

#define REDUCT_ITEM_FLAG_QUOTED   (1 << 5)

Item is a quoted atom.

Definition at line 43 of file item.h.

◆ REDUCT_ITEM_FLAG_GC_MARK

#define REDUCT_ITEM_FLAG_GC_MARK   (1 << 6)

Item is marked by GC.

Definition at line 44 of file item.h.

◆ REDUCT_ITEM_PAYLOAD_MAX

#define REDUCT_ITEM_PAYLOAD_MAX   48

The maximum size of the item payload.

Definition at line 46 of file item.h.

◆ REDUCT_ITEM_BLOCK_MAX

#define REDUCT_ITEM_BLOCK_MAX   255

The maximum number of items in a block.

Definition at line 80 of file item.h.

Typedef Documentation

◆ reduct_item_type_t

Item type enumeration.

Definition at line 25 of file item.h.

◆ reduct_item_flags_t

Item flags enumeration.

Definition at line 36 of file item.h.

Function Documentation

◆ reduct_item_new()

REDUCT_API reduct_item_t * reduct_item_new ( struct reduct *  reduct)

Allocate a new Reduct item.

Parameters
reductPointer to the Reduct structure.
Returns
A pointer to the newly created item.
Here is the caller graph for this function:

◆ reduct_item_free()

REDUCT_API void reduct_item_free ( struct reduct *  reduct,
reduct_item_t item 
)

Free an Reduct item.

Parameters
reductPointer to the Reduct structure.
itemPointer to the item to free.
Here is the caller graph for this function:

◆ reduct_item_get_int()

REDUCT_API reduct_int64_t reduct_item_get_int ( reduct_item_t item)

Get the integer value of an item if it is number shaped.

Parameters
itemPointer to the item.
Returns
The integer value, or 0 if not number shaped.

Definition at line 113 of file item_impl.h.

Here is the caller graph for this function:

◆ reduct_item_get_float()

REDUCT_API reduct_float_t reduct_item_get_float ( reduct_item_t item)

Get the float value of an item if it is number shaped.

Parameters
itemPointer to the item.
Returns
The float value, or 0.0 if not number shaped.

Definition at line 126 of file item_impl.h.

Here is the caller graph for this function:

◆ reduct_item_type_str()

REDUCT_API const char * reduct_item_type_str ( reduct_item_type_t  type)

Get the string representation of an Reduct item type.

Parameters
typeThe item type.
Returns
The string representation of the item type.

Definition at line 139 of file item_impl.h.

Here is the caller graph for this function: