3 #ifndef _SCHEME_PRIVATE_H
4 #define _SCHEME_PRIVATE_H
7 /*------------------ Ugly internals -----------------------------------*/
8 /*------------------ Of interest only to FFI users --------------------*/
14 enum scheme_port_kind {
60 const foreign_object_vtable *_vtable;
66 /* The history is a two-dimensional ring buffer. A donut-shaped data
67 * structure. This data structure is inspired by MIT/GNU Scheme. */
69 /* Number of calls to store. Must be a power of two. */
72 /* Number of tail-calls to store in each call frame. Must be a
76 /* Masks for fast index calculations. */
80 /* A vector of size N containing calls. */
83 /* A vector of size N containing vectors of size M containing tail
87 /* Our current position. */
94 /* arrays for segments */
104 #define CELL_SEGSIZE 5000 /* # of cells in one segment */
106 #ifndef CELL_NSEGMENT
107 #define CELL_NSEGMENT 10 /* # of segments for cells */
109 void *alloc_seg[CELL_NSEGMENT];
110 pointer cell_seg[CELL_NSEGMENT];
113 /* We use 4 registers. */
114 pointer args; /* register for arguments of function */
115 pointer envir; /* stack register for current environment */
116 pointer code; /* register for current code */
117 pointer dump; /* stack register for next evaluation */
120 struct history history; /* we keep track of the call history for
124 int interactive_repl; /* are we in an interactive REPL? */
127 pointer sink; /* when mem. alloc. fails */
129 pointer NIL; /* special cell representing empty cell */
131 pointer T; /* special cell representing #t */
133 pointer F; /* special cell representing #f */
134 struct cell _EOF_OBJ;
135 pointer EOF_OBJ; /* special cell representing end-of-file object */
136 pointer oblist; /* pointer to symbol table */
137 pointer global_env; /* pointer to global environment */
138 pointer c_nest; /* stack for nested calls from C */
140 /* global pointers to special symbols */
141 pointer LAMBDA; /* pointer to syntax lambda */
142 pointer QUOTE; /* pointer to syntax quote */
144 pointer QQUOTE; /* pointer to symbol quasiquote */
145 pointer UNQUOTE; /* pointer to symbol unquote */
146 pointer UNQUOTESP; /* pointer to symbol unquote-splicing */
147 pointer FEED_TO; /* => */
148 pointer COLON_HOOK; /* *colon-hook* */
149 pointer ERROR_HOOK; /* *error-hook* */
150 pointer SHARP_HOOK; /* *sharp-hook* */
152 pointer COMPILE_HOOK; /* *compile-hook* */
155 #if USE_SMALL_INTEGERS
156 /* A fixed allocation of small integers. */
158 pointer integer_cells;
161 pointer free_cell; /* pointer to top of free cells */
162 long fcells; /* # of free cells */
163 size_t inhibit_gc; /* nesting of gc_disable */
164 size_t reserved_cells; /* # of reserved cells */
166 int reserved_lineno; /* location of last reservation */
177 port load_stack[MAXFIL]; /* Stack of open files for port -1 (LOADing) */
178 int nesting_stack[MAXFIL];
182 char gc_verbose; /* if gc_verbose is not zero, print gc status */
183 char no_memory; /* Whether mem. alloc. has failed */
186 #define LINESIZE 1024
188 char linebuff[LINESIZE];
190 #define STRBUFFSIZE 256
201 void *ext_data; /* For the benefit of foreign functions */
204 struct scheme_interface *vptr;
208 enum scheme_opcodes {
209 #define _OP_DEF(A,B,C,D,E,OP) OP,
210 #include "opdefines.h"
215 #define cons(sc,a,b) _cons(sc,a,b,0)
216 #define immutable_cons(sc,a,b) _cons(sc,a,b,1)
218 int is_string(pointer p);
219 char *string_value(pointer p);
220 int is_number(pointer p);
221 num nvalue(pointer p);
222 long ivalue(pointer p);
223 double rvalue(pointer p);
224 int is_integer(pointer p);
225 int is_real(pointer p);
226 int is_character(pointer p);
227 long charvalue(pointer p);
228 int is_vector(pointer p);
230 int is_port(pointer p);
232 int is_pair(pointer p);
233 pointer pair_car(pointer p);
234 pointer pair_cdr(pointer p);
235 pointer set_car(pointer p, pointer q);
236 pointer set_cdr(pointer p, pointer q);
238 int is_symbol(pointer p);
239 char *symname(pointer p);
240 int hasprop(pointer p);
242 int is_syntax(pointer p);
243 int is_proc(pointer p);
244 int is_foreign(pointer p);
245 char *syntaxname(pointer p);
246 int is_closure(pointer p);
248 int is_macro(pointer p);
250 pointer closure_code(pointer p);
251 pointer closure_env(pointer p);
253 int is_continuation(pointer p);
254 int is_promise(pointer p);
255 int is_environment(pointer p);
256 int is_immutable(pointer p);
257 void setimmutable(pointer p);
259 int is_foreign_object(pointer p);
260 const foreign_object_vtable *get_foreign_object_vtable(pointer p);
261 void *get_foreign_object_data(pointer p);