Provides the data structures for LISP, like cells. More...

Data Structures

struct  cell
 Basic Lisp entity. More...
 
struct  cell_block
 
struct  cell_space
 

Typedefs

typedef struct cell cell
 Basic Lisp entity. More...
 

Enumerations

enum  {
  TYPE_CONS = 0, TYPE_SYM, TYPE_NUM, TYPE_STR,
  TYPE_FREE, TYPE_BUILTINLAMBDA, TYPE_BUILTINMACRO, TYPE_KEYWORD
}
 Identifies the type of a cell. More...
 

Functions

void unsafe_cell_remove (cell *c)
 
cell_blockcell_block_create (size_t s)
 
void cell_block_free (cell_block *cb)
 
void init_memory ()
 
void free_memory ()
 
cell_spacecell_space_create ()
 
cellcell_space_get_cell (cell_space *cs)
 
cellcell_space_is_symbol_allocated (cell_space *cs, char *symbol)
 
void cell_space_init (cell_space *cs)
 
void cell_space_grow (cell_space *cs)
 
void cell_space_double_capacity_if_full (cell_space *cs)
 
void cell_space_mark_cell_as_free (cell_space *cs, cell *c)
 
void cell_space_free (cell_space *cs)
 
bool cell_space_is_full (cell_space *cs)
 
cellget_cell ()
 
cellmk_num (int n)
 
cellmk_str (char *s)
 
cellmk_cons (cell *car, cell *cdr)
 
cellmk_sym (char *symbol)
 
cellmk_builtin_lambda (char *symbol, cell *(*function)(cell *), void(*builtin_stack)(size_t, unsigned char))
 
cellmk_builtin_macro (char *symbol, cell *(*function)(cell *, cell *))
 
cellcopy_cell (cell *c)
 
void free_cell_pointed_memory (cell *c)
 
bool is_num (cell *c)
 
bool is_str (cell *c)
 
bool is_cons (cell *c)
 
bool is_sym (cell *c)
 
bool is_keyword (cell *c)
 
bool is_builtin (cell *c)
 
bool is_builtin_lambda (cell *c)
 
bool is_builtin_macro (cell *c)
 
cellis_symbol_builtin_lambda (char *symbol)
 
cellis_symbol_builtin_macro (char *symbol)
 
bool cell_is_in_global_env (cell *global_env, cell *c)
 
void cell_push (cell *val)
 
void cell_remove (cell *val)
 
void cell_push_recursive (cell *c)
 
void cell_remove_recursive (cell *c)
 
void cell_remove_args (cell *args)
 
void cell_remove_pairlis (cell *new_env, cell *old_env)
 
void cell_remove_cars (cell *list)
 
void cell_remove_pairlis_deep (cell *new_env, cell *old_env)
 
void collect_garbage (cell_space *cs)
 
void deep_collect_garbage (cell_space *cs)
 
void mark_memory (cell_space *cs)
 
void mark (cell *root)
 
void sweep (cell_space *cs)
 
void deep_sweep (cell_space *cs)
 

Variables

size_t stack_pointer
 
cellstack [STACK_LIMIT]
 
cell_spacememory
 

Detailed Description

Provides the data structures for LISP, like cells.

Typedef Documentation

typedef struct cell cell

Basic Lisp entity.

Every cell has a type identifier (referred to the type enum). It identifies the type of the cell. marked and marks are fields used to collect garbage.

Enumeration Type Documentation

anonymous enum

Identifies the type of a cell.

Enumerator
TYPE_CONS 
TYPE_SYM 
TYPE_NUM 
TYPE_STR 
TYPE_FREE 
TYPE_BUILTINLAMBDA 
TYPE_BUILTINMACRO 

represents a builtin lisp function (e.g. car, cdr...)

TYPE_KEYWORD 

represents a builtin lisp macro (e.g. dotimes, defun...)

Function Documentation

cell_block* cell_block_create ( size_t  s)
void cell_block_free ( cell_block cb)
bool cell_is_in_global_env ( cell global_env,
cell c 
)
void cell_push ( cell val)
void cell_push_recursive ( cell c)
void cell_remove ( cell val)
void cell_remove_args ( cell args)
void cell_remove_cars ( cell list)
void cell_remove_pairlis ( cell new_env,
cell old_env 
)
void cell_remove_pairlis_deep ( cell new_env,
cell old_env 
)
void cell_remove_recursive ( cell c)
cell_space* cell_space_create ( )
void cell_space_double_capacity_if_full ( cell_space cs)
void cell_space_free ( cell_space cs)
cell* cell_space_get_cell ( cell_space cs)
void cell_space_grow ( cell_space cs)
void cell_space_init ( cell_space cs)
bool cell_space_is_full ( cell_space cs)
cell* cell_space_is_symbol_allocated ( cell_space cs,
char *  symbol 
)
void cell_space_mark_cell_as_free ( cell_space cs,
cell c 
)
void collect_garbage ( cell_space cs)
cell* copy_cell ( cell c)
void deep_collect_garbage ( cell_space cs)
void deep_sweep ( cell_space cs)
void free_cell_pointed_memory ( cell c)
void free_memory ( )
cell* get_cell ( )
void init_memory ( )
bool is_builtin ( cell c)
bool is_builtin_lambda ( cell c)
bool is_builtin_macro ( cell c)
bool is_cons ( cell c)
bool is_keyword ( cell c)
bool is_num ( cell c)
bool is_str ( cell c)
bool is_sym ( cell c)
cell* is_symbol_builtin_lambda ( char *  symbol)
cell* is_symbol_builtin_macro ( char *  symbol)
void mark ( cell root)
void mark_memory ( cell_space cs)
cell* mk_builtin_lambda ( char *  symbol,
cell *(*)(cell *)  function,
void(*)(size_t, unsigned char)  builtin_stack 
)
cell* mk_builtin_macro ( char *  symbol,
cell *(*)(cell *, cell *)  function 
)
cell* mk_cons ( cell car,
cell cdr 
)
cell* mk_num ( int  n)
cell* mk_str ( char *  s)
cell* mk_sym ( char *  symbol)
void sweep ( cell_space cs)
void unsafe_cell_remove ( cell c)

Variable Documentation

cell_space* memory
cell* stack[STACK_LIMIT]
size_t stack_pointer