struct {
FILE *file;
int closeit;
-#if SHOW_ERROR_LINE
- int curr_line;
- char *filename;
-#endif
} stdio;
struct {
char *start;
char *curr;
} string;
} rep;
+#if SHOW_ERROR_LINE
+ pointer curr_line;
+ pointer filename;
+#endif
} port;
/* cell structure */
struct cell *_cdr;
} _cons;
struct {
+ size_t _length;
+ pointer _elements[0];
+ } _vector;
+ struct {
char *_data;
const foreign_object_vtable *_vtable;
} _foreign_object;
} _object;
};
+#if USE_HISTORY
+/* The history is a two-dimensional ring buffer. A donut-shaped data
+ * structure. This data structure is inspired by MIT/GNU Scheme. */
+struct history {
+ /* Number of calls to store. Must be a power of two. */
+ size_t N;
+
+ /* Number of tail-calls to store in each call frame. Must be a
+ * power of two. */
+ size_t M;
+
+ /* Masks for fast index calculations. */
+ size_t mask_N;
+ size_t mask_M;
+
+ /* A vector of size N containing calls. */
+ pointer callstack;
+
+ /* A vector of size N containing vectors of size M containing tail
+ * calls. */
+ pointer tailstacks;
+
+ /* Our current position. */
+ size_t n;
+ size_t *m;
+};
+#endif
+
struct scheme {
/* arrays for segments */
func_alloc malloc;
#ifndef CELL_NSEGMENT
#define CELL_NSEGMENT 10 /* # of segments for cells */
#endif
-char *alloc_seg[CELL_NSEGMENT];
+void *alloc_seg[CELL_NSEGMENT];
pointer cell_seg[CELL_NSEGMENT];
int last_cell_seg;
pointer code; /* register for current code */
pointer dump; /* stack register for next evaluation */
+#if USE_HISTORY
+struct history history; /* we keep track of the call history for
+ * error messages */
+#endif
+
int interactive_repl; /* are we in an interactive REPL? */
struct cell _sink;
pointer COLON_HOOK; /* *colon-hook* */
pointer ERROR_HOOK; /* *error-hook* */
pointer SHARP_HOOK; /* *sharp-hook* */
+#if USE_COMPILE_HOOK
pointer COMPILE_HOOK; /* *compile-hook* */
+#endif
+
+#if USE_SMALL_INTEGERS
+/* A fixed allocation of small integers. */
+void *integer_alloc;
+pointer integer_cells;
+#endif
pointer free_cell; /* pointer to top of free cells */
long fcells; /* # of free cells */
+size_t inhibit_gc; /* nesting of gc_disable */
+size_t reserved_cells; /* # of reserved cells */
+#ifndef NDEBUG
+int reserved_lineno; /* location of last reservation */
+#endif
pointer inport;
pointer outport;
int print_flag;
pointer value;
int op;
+unsigned int flags;
void *ext_data; /* For the benefit of foreign functions */
long gensym_cnt;
struct scheme_interface *vptr;
-void *dump_base; /* pointer to base of allocated dump stack */
-int dump_size; /* number of frames allocated for dump stack */
};
/* operator code */