Cyclone Scheme  0.28.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Variables
Objects

Definitions and code for memory-allocated objects. More...

Modules

 Safe pair access macros
 Macros for safe pair access.
 
 Unsafe pair access macros
 Macros for fast - but unsafe - pair access.
 

Data Structures

struct  atomic_type
 The atomic thread synchronization type. More...
 
struct  bignum_type
 Exact integer of unlimited precision. More...
 
struct  boolean_type
 The boolean type: True or False. More...
 
struct  bytevector_type
 Bytevector type. More...
 
struct  c_opaque_type
 C Opaque type - a wrapper around a pointer of any type. More...
 
struct  closure0_type
 A closed-over function with no variables. More...
 
struct  closure1_type
 A closed-over function with one variable. More...
 
struct  closureN_type
 A closed-over function with zero or more closed-over variables. More...
 
union  common_type
 A union of all the constant-size objects. More...
 
struct  complex_num_type
 Complex number. More...
 
struct  cond_var_type
 The condition variable thread synchronization type. More...
 
struct  cvar_type
 C-variable integration type - wrapper around a Cyclone object pointer. More...
 
struct  double_type
 Double-precision floating point type, also known as a flonum. More...
 
struct  integer_type
 Deprecated - boxed integers. More...
 
struct  list_2_type
 
struct  list_3_type
 
struct  list_4_type
 
struct  macro_type
 Closure for a macro. More...
 
struct  mutex_type
 The mutex thread synchronization type. More...
 
struct  pair_type
 The pair (cons) type. More...
 
struct  port_type
 The port object type. More...
 
struct  primitive_type
 A function built into the runtime. More...
 
struct  string_type
 The string type. More...
 
struct  symbol_type
 Symbols are similar to strings, but only one instance of each unique symbol is created, so comparisons are O(1). More...
 
struct  vector_2_type
 
struct  vector_3_type
 
struct  vector_4_type
 
struct  vector_5_type
 
struct  vector_type
 Vector type. More...
 

Macros

#define alloc_bignum(data, p)   bignum_type *p = gc_alloc_bignum((gc_thread_data *)data);
 
#define alloc_bytevector(_data, _bv, _len)
 
#define alloc_string(_data, _s, _len, _num_cp)
 
#define alloca_cell(n, a)   alloca_pair(n,a,NULL)
 
#define alloca_complex_num(n, r, i)
 
#define alloca_double(n, v)
 
#define alloca_empty_bytevector(v)
 
#define alloca_empty_vector(v)
 
#define alloca_pair(n, a, d)
 
#define assign_complex_num(pobj, v)
 
#define assign_double(pobj, v)
 
#define BIGNUM_CALL(x)
 
#define bignum_value(x)   (((bignum_type *) x)->bn)
 
#define boolean_desc(x)   (((boolean_type *) x)->desc)
 
#define complex_num_value(x)   (((complex_num_type *) x)->value)
 
#define CYC_BINARY_PORT_FLAG   0x10
 
#define CYC_IO_BUF_LEN   1024
 
#define defprimitive(name, desc, fnc)
 
#define defsymbol(name)   static object quote_##name = NULL;
 
#define double_value(x)   (((double_type *) x)->value)
 
#define forward(obj)   (((pair_type *) obj)->pair_car)
 
#define integer_value(x)   (((integer_type *) x)->value)
 
#define maclosure0(c, f, na)
 
#define make_boolean(x)   (x ? boolean_t : boolean_f)
 
#define make_c_opaque(var, p)
 
#define make_cell(n, a)   make_pair(n,a,NULL)
 
#define make_complex_num(n, r, i)
 
#define make_cvar(n, v)
 
#define make_double(n, v)
 
#define make_empty_bytevector(v)
 
#define make_empty_vector(v)
 
#define make_input_port(p, f, rl)
 
#define make_pair(n, a, d)
 
#define make_port(p, f, m)
 
#define make_string(cs, s)
 
#define make_string_noalloc(cs, s, length)
 
#define make_string_with_len(cs, s, length)
 
#define make_utf8_string(data, cs, s)
 
#define make_utf8_string_noalloc(cs, s, length)
 
#define make_utf8_string_with_len(cs, s, length, num_code_points)
 
#define mclosure0(c, f)   static closure0_type c = { .hdr.mark = gc_color_red, .hdr.grayed = 0, .tag = closure0_tag, .fn = f, .num_args = -1 }; /* TODO: need a new macro that initializes num_args */
 
#define mclosure1(c, f, a)
 
#define mmacro(c, f)
 
#define opaque_collect_ptr(x)   (((c_opaque)x)->collect_ptr)
 
#define opaque_ptr(x)   (((c_opaque)x)->ptr)
 
#define prim(x)   (x && ((primitive)x)->tag == primitive_tag)
 
#define prim_name(x)   (((primitive_type *) x)->desc)
 
#define return_copy(ptr, o)
 
#define set_cell_as_expr(n, a)   set_pair_as_expr(n,a,NULL)
 
#define set_pair(n, a, d)
 
#define set_pair_as_expr(n, a, d)
 
#define string_len(x)   (((string_type *) x)->len)
 
#define string_num_cp(x)   (((string_type *) x)->num_cp)
 
#define string_str(x)   (((string_type *) x)->str)
 
#define symbol_desc(x)   (((symbol_type *) x)->desc)
 
#define type_of(obj)   (((pair_type *) obj)->tag)
 

Typedefs

typedef atomic_typeatomic
 
typedef boolean_typeboolean
 
typedef bytevector_typebytevector
 
typedef c_opaque_typec_opaque
 
typedef closure0_typeclosure
 
typedef closure0_typeclosure0
 
typedef closure1_typeclosure1
 
typedef closureN_typeclosureN
 
typedef cond_var_typecond_var
 
typedef cvar_typecvar
 
typedef void(* function_type) (void *data, object clo, int argc, object *args)
 
typedef object(* inline_function_type) ()
 
typedef pair_typelist
 
typedef closure0_typemacro
 
typedef mutex_typemutex
 
typedef void * object
 
typedef pair_typepair
 
typedef primitive_typeprimitive
 
typedef void(* primitive_function_type) (void *data, object cont, object args)
 
typedef symbol_typesymbol
 
typedef unsigned char tag_type
 
typedef vector_typevector
 

Enumerations

enum  bn_cmp_type {
  CYC_BN_LTE = -2, CYC_BN_LT = MP_LT, CYC_BN_EQ = MP_EQ, CYC_BN_GT = MP_GT,
  CYC_BN_GTE = 2
}
 
enum  object_tag {
  closure0_tag = 0, closure1_tag = 1, closureN_tag = 2, macro_tag = 3,
  boolean_tag = 4, bytevector_tag = 5, c_opaque_tag = 6, cond_var_tag = 7,
  cvar_tag = 8, double_tag = 9, eof_tag = 10, forward_tag = 11,
  integer_tag = 12, bignum_tag = 13, mutex_tag = 14, pair_tag = 15,
  port_tag = 16, primitive_tag = 17, string_tag = 18, symbol_tag = 19,
  vector_tag = 20, complex_num_tag = 21, atomic_tag = 22, void_tag = 23,
  record_tag = 24
}
 

Variables

const object boolean_f
 
const object boolean_t
 
const object Cyc_EOF
 
const object Cyc_RECORD_MARKER
 
const object Cyc_VOID
 
const object quote_void
 

Detailed Description

Definitions and code for memory-allocated objects.

Most Scheme data types are defined as object types.

Each object type contains a header for garbage collection and a tag that identifies the type of object, as well as any object-specific fields.

Most object types are allocated on the nursery (the C stack) and relocated to the garbage-collected heap during minor GC. It is only safe for an object on the nursery to be used by the thread that created it, as that object could be relocated at any time.

gc_alloc
void * gc_alloc(gc_heap_root *h, size_t size, char *obj, gc_thread_data *thd, int *heap_grown)
Allocate memory on the heap for an object.
Definition: gc.c:1360
bytevector
bytevector_type * bytevector
Definition: types.h:1215
vector_tag
@ vector_tag
Definition: types.h:69
closure0_type
A closed-over function with no variables.
Definition: types.h:1405
complex_num_type
Complex number.
Definition: types.h:846
closure1_type::hdr
gc_header_type hdr
Definition: types.h:1413
gc_color_red
#define gc_color_red
Definition: types.h:297
double_value
#define double_value(x)
Definition: types.h:910
primitive_tag
@ primitive_tag
Definition: types.h:66
string_type::num_cp
int num_cp
Definition: types.h:936
macro_type::hdr
gc_header_type hdr
Definition: types.h:1398
closure1_type
A closed-over function with one variable.
Definition: types.h:1412
primitive_type
A function built into the runtime.
Definition: types.h:1473
port_type
The port object type.
Definition: types.h:1096
c_opaque_type
C Opaque type - a wrapper around a pointer of any type.
Definition: types.h:702
vector_type
Vector type.
Definition: types.h:1170
gc_header_type_t::immutable
unsigned char immutable
Definition: types.h:270
gc_header_type_t::grayed
unsigned char grayed
Definition: types.h:269
string_type::len
int len
Definition: types.h:937
string_type::str
char * str
Definition: types.h:938
pair_type
The pair (cons) type.
Definition: types.h:1247
gc_thread_data_t
Definition: types.h:322
double_type::hdr
gc_header_type hdr
Definition: types.h:878
c_opaque_type::hdr
gc_header_type hdr
Definition: types.h:703
cvar_type::hdr
gc_header_type hdr
Definition: types.h:678
cvar_type
C-variable integration type - wrapper around a Cyclone object pointer.
Definition: types.h:677
bytevector_type
Bytevector type.
Definition: types.h:1209
gc_header_type_t::mark
unsigned char mark
Definition: types.h:268
complex_num_type::hdr
gc_header_type hdr
Definition: types.h:847
macro_type
Closure for a macro.
Definition: types.h:1397
double_tag
@ double_tag
Definition: types.h:58
port_tag
@ port_tag
Definition: types.h:65
string_type::hdr
gc_header_type hdr
Definition: types.h:934
pair
pair_type * pair
Definition: types.h:1254
string_type
The string type.
Definition: types.h:933
is_object_type
#define is_object_type(x)
Definition: types.h:644
type_of
#define type_of(obj)
Definition: types.h:92
c_opaque_tag
@ c_opaque_tag
Definition: types.h:55
closure0_type::hdr
gc_header_type hdr
Definition: types.h:1406
cvar_tag
@ cvar_tag
Definition: types.h:57
string_tag
@ string_tag
Definition: types.h:67
bytevector_type::hdr
gc_header_type hdr
Definition: types.h:1210
common_type
A union of all the constant-size objects.
Definition: types.h:1497
port_type::hdr
gc_header_type hdr
Definition: types.h:1097
pair_type::hdr
gc_header_type hdr
Definition: types.h:1248
MAX_STACK_OBJ
#define MAX_STACK_OBJ
Definition: types.h:513
macro_tag
@ macro_tag
Definition: types.h:52
double_type
Double-precision floating point type, also known as a flonum.
Definition: types.h:877
closure1_tag
@ closure1_tag
Definition: types.h:50
boolean_f
const object boolean_f
Definition: runtime.c:397
CYC_IO_BUF_LEN
#define CYC_IO_BUF_LEN
Definition: types.h:1119
vector_type::hdr
gc_header_type hdr
Definition: types.h:1171
pair_tag
@ pair_tag
Definition: types.h:64
Cyc_utf8_count_code_points
int Cyc_utf8_count_code_points(uint8_t *s)
Count the number of code points in a string. Based on example code from Bjoern Hoehrmann.
Definition: runtime.c:8082
closure0_tag
@ closure0_tag
Definition: types.h:49
bytevector_tag
@ bytevector_tag
Definition: types.h:54
complex_num_tag
@ complex_num_tag
Definition: types.h:70