raw
asciilifeform_shi...    1 /* scheme-private.h */
asciilifeform_shi... 2
asciilifeform_shi... 3 #ifndef _SCHEME_PRIVATE_H
asciilifeform_shi... 4 #define _SCHEME_PRIVATE_H
asciilifeform_shi... 5
asciilifeform_shi... 6 #include "scheme.h"
asciilifeform_shi... 7 /*------------------ Ugly internals -----------------------------------*/
asciilifeform_shi... 8 /*------------------ Of interest only to FFI users --------------------*/
asciilifeform_shi... 9
asciilifeform_shi... 10 #ifdef __cplusplus
asciilifeform_shi... 11 extern "C" {
asciilifeform_shi... 12 #endif
asciilifeform_shi... 13
asciilifeform_shi... 14 enum scheme_port_kind {
asciilifeform_shi... 15 port_free=0,
asciilifeform_shi... 16 port_file=1,
asciilifeform_shi... 17 port_string=2,
asciilifeform_shi... 18 port_srfi6=4,
asciilifeform_shi... 19 port_input=16,
asciilifeform_shi... 20 port_output=32,
asciilifeform_shi... 21 port_saw_EOF=64
asciilifeform_shi... 22 };
asciilifeform_shi... 23
asciilifeform_shi... 24 typedef struct port {
asciilifeform_shi... 25 unsigned char kind;
asciilifeform_shi... 26 union {
asciilifeform_shi... 27 struct {
asciilifeform_shi... 28 FILE *file;
asciilifeform_shi... 29 int interactive;
asciilifeform_shi... 30 int closeit;
asciilifeform_shi... 31 #if SHOW_ERROR_LINE
asciilifeform_shi... 32 int curr_line;
asciilifeform_shi... 33 char *filename;
asciilifeform_shi... 34 #endif
asciilifeform_shi... 35 } stdio;
asciilifeform_shi... 36 struct {
asciilifeform_shi... 37 char *start;
asciilifeform_shi... 38 char *past_the_end;
asciilifeform_shi... 39 char *curr;
asciilifeform_shi... 40 } string;
asciilifeform_shi... 41 } rep;
asciilifeform_shi... 42 } port;
asciilifeform_shi... 43
asciilifeform_shi... 44 /* cell structure */
asciilifeform_shi... 45 struct cell {
asciilifeform_shi... 46 unsigned int _flag;
asciilifeform_shi... 47 union {
asciilifeform_shi... 48 struct {
asciilifeform_shi... 49 char *_svalue;
asciilifeform_shi... 50 int _length;
asciilifeform_shi... 51 } _string;
asciilifeform_shi... 52 num _number;
asciilifeform_shi... 53 port *_port;
asciilifeform_shi... 54 foreign_func _ff;
asciilifeform_shi... 55 struct {
asciilifeform_shi... 56 struct cell *_car;
asciilifeform_shi... 57 struct cell *_cdr;
asciilifeform_shi... 58 } _cons;
asciilifeform_shi... 59 } _object;
asciilifeform_shi... 60 };
asciilifeform_shi... 61
asciilifeform_shi... 62 struct scheme {
asciilifeform_shi... 63 /* arrays for segments */
asciilifeform_shi... 64 func_alloc malloc;
asciilifeform_shi... 65 func_dealloc free;
asciilifeform_shi... 66
asciilifeform_shi... 67 /* return code */
asciilifeform_shi... 68 int retcode;
asciilifeform_shi... 69 int tracing;
asciilifeform_shi... 70
asciilifeform_shi... 71
asciilifeform_shi... 72 #define CELL_SEGSIZE 5000 /* # of cells in one segment */
asciilifeform_shi... 73 #define CELL_NSEGMENT 10 /* # of segments for cells */
asciilifeform_shi... 74 char *alloc_seg[CELL_NSEGMENT];
asciilifeform_shi... 75 pointer cell_seg[CELL_NSEGMENT];
asciilifeform_shi... 76 int last_cell_seg;
asciilifeform_shi... 77
asciilifeform_shi... 78 /* We use 4 registers. */
asciilifeform_shi... 79 pointer args; /* register for arguments of function */
asciilifeform_shi... 80 pointer envir; /* stack register for current environment */
asciilifeform_shi... 81 pointer code; /* register for current code */
asciilifeform_shi... 82 pointer dump; /* stack register for next evaluation */
asciilifeform_shi... 83
asciilifeform_shi... 84 int interactive_repl; /* are we in an interactive REPL? */
asciilifeform_shi... 85
asciilifeform_shi... 86 struct cell _sink;
asciilifeform_shi... 87 pointer sink; /* when mem. alloc. fails */
asciilifeform_shi... 88 struct cell _NIL;
asciilifeform_shi... 89 pointer NIL; /* special cell representing empty cell */
asciilifeform_shi... 90 struct cell _HASHT;
asciilifeform_shi... 91 pointer T; /* special cell representing #t */
asciilifeform_shi... 92 struct cell _HASHF;
asciilifeform_shi... 93 pointer F; /* special cell representing #f */
asciilifeform_shi... 94 struct cell _EOF_OBJ;
asciilifeform_shi... 95 pointer EOF_OBJ; /* special cell representing end-of-file object */
asciilifeform_shi... 96 pointer oblist; /* pointer to symbol table */
asciilifeform_shi... 97 pointer global_env; /* pointer to global environment */
asciilifeform_shi... 98 pointer c_nest; /* stack for nested calls from C */
asciilifeform_shi... 99
asciilifeform_shi... 100 /* global pointers to special symbols */
asciilifeform_shi... 101 pointer LAMBDA; /* pointer to syntax lambda */
asciilifeform_shi... 102 pointer QUOTE; /* pointer to syntax quote */
asciilifeform_shi... 103
asciilifeform_shi... 104 pointer QQUOTE; /* pointer to symbol quasiquote */
asciilifeform_shi... 105 pointer UNQUOTE; /* pointer to symbol unquote */
asciilifeform_shi... 106 pointer UNQUOTESP; /* pointer to symbol unquote-splicing */
asciilifeform_shi... 107 pointer FEED_TO; /* => */
asciilifeform_shi... 108 pointer COLON_HOOK; /* *colon-hook* */
asciilifeform_shi... 109 pointer ERROR_HOOK; /* *error-hook* */
asciilifeform_shi... 110 pointer SHARP_HOOK; /* *sharp-hook* */
asciilifeform_shi... 111 pointer COMPILE_HOOK; /* *compile-hook* */
asciilifeform_shi... 112
asciilifeform_shi... 113 pointer free_cell; /* pointer to top of free cells */
asciilifeform_shi... 114 long fcells; /* # of free cells */
asciilifeform_shi... 115
asciilifeform_shi... 116 pointer inport;
asciilifeform_shi... 117 pointer outport;
asciilifeform_shi... 118 pointer save_inport;
asciilifeform_shi... 119 pointer loadport;
asciilifeform_shi... 120
asciilifeform_shi... 121 #define MAXFIL 64
asciilifeform_shi... 122 port load_stack[MAXFIL]; /* Stack of open files for port -1 (LOADing) */
asciilifeform_shi... 123 int nesting_stack[MAXFIL];
asciilifeform_shi... 124 int file_i;
asciilifeform_shi... 125 int nesting;
asciilifeform_shi... 126
asciilifeform_shi... 127 char gc_verbose; /* if gc_verbose is not zero, print gc status */
asciilifeform_shi... 128 char no_memory; /* Whether mem. alloc. has failed */
asciilifeform_shi... 129
asciilifeform_shi... 130 #define LINESIZE 1024
asciilifeform_shi... 131 char linebuff[LINESIZE];
asciilifeform_shi... 132 #define STRBUFFSIZE 256
asciilifeform_shi... 133 char strbuff[STRBUFFSIZE];
asciilifeform_shi... 134
asciilifeform_shi... 135 FILE *tmpfp;
asciilifeform_shi... 136 int tok;
asciilifeform_shi... 137 int print_flag;
asciilifeform_shi... 138 pointer value;
asciilifeform_shi... 139 int op;
asciilifeform_shi... 140
asciilifeform_shi... 141 void *ext_data; /* For the benefit of foreign functions */
asciilifeform_shi... 142 long gensym_cnt;
asciilifeform_shi... 143
asciilifeform_shi... 144 struct scheme_interface *vptr;
asciilifeform_shi... 145 void *dump_base; /* pointer to base of allocated dump stack */
asciilifeform_shi... 146 int dump_size; /* number of frames allocated for dump stack */
asciilifeform_shi... 147 };
asciilifeform_shi... 148
asciilifeform_shi... 149 /* operator code */
asciilifeform_shi... 150 enum scheme_opcodes {
asciilifeform_shi... 151 #define _OP_DEF(A,B,C,D,E,OP) OP,
asciilifeform_shi... 152 #include "opdefines.h"
asciilifeform_shi... 153 OP_MAXDEFINED
asciilifeform_shi... 154 };
asciilifeform_shi... 155
asciilifeform_shi... 156
asciilifeform_shi... 157 #define cons(sc,a,b) _cons(sc,a,b,0)
asciilifeform_shi... 158 #define immutable_cons(sc,a,b) _cons(sc,a,b,1)
asciilifeform_shi... 159
asciilifeform_shi... 160 int is_string(pointer p);
asciilifeform_shi... 161 char *string_value(pointer p);
asciilifeform_shi... 162 int is_number(pointer p);
asciilifeform_shi... 163 num nvalue(pointer p);
asciilifeform_shi... 164 long ivalue(pointer p);
asciilifeform_shi... 165 double rvalue(pointer p);
asciilifeform_shi... 166 int is_integer(pointer p);
asciilifeform_shi... 167 int is_real(pointer p);
asciilifeform_shi... 168 int is_character(pointer p);
asciilifeform_shi... 169 long charvalue(pointer p);
asciilifeform_shi... 170 int is_vector(pointer p);
asciilifeform_shi... 171
asciilifeform_shi... 172 int is_port(pointer p);
asciilifeform_shi... 173
asciilifeform_shi... 174 int is_pair(pointer p);
asciilifeform_shi... 175 pointer pair_car(pointer p);
asciilifeform_shi... 176 pointer pair_cdr(pointer p);
asciilifeform_shi... 177 pointer set_car(pointer p, pointer q);
asciilifeform_shi... 178 pointer set_cdr(pointer p, pointer q);
asciilifeform_shi... 179
asciilifeform_shi... 180 int is_symbol(pointer p);
asciilifeform_shi... 181 char *symname(pointer p);
asciilifeform_shi... 182 int hasprop(pointer p);
asciilifeform_shi... 183
asciilifeform_shi... 184 int is_syntax(pointer p);
asciilifeform_shi... 185 int is_proc(pointer p);
asciilifeform_shi... 186 int is_foreign(pointer p);
asciilifeform_shi... 187 char *syntaxname(pointer p);
asciilifeform_shi... 188 int is_closure(pointer p);
asciilifeform_shi... 189 #ifdef USE_MACRO
asciilifeform_shi... 190 int is_macro(pointer p);
asciilifeform_shi... 191 #endif
asciilifeform_shi... 192 pointer closure_code(pointer p);
asciilifeform_shi... 193 pointer closure_env(pointer p);
asciilifeform_shi... 194
asciilifeform_shi... 195 int is_continuation(pointer p);
asciilifeform_shi... 196 int is_promise(pointer p);
asciilifeform_shi... 197 int is_environment(pointer p);
asciilifeform_shi... 198 int is_immutable(pointer p);
asciilifeform_shi... 199 void setimmutable(pointer p);
asciilifeform_shi... 200
asciilifeform_shi... 201 #ifdef __cplusplus
asciilifeform_shi... 202 }
asciilifeform_shi... 203 #endif
asciilifeform_shi... 204
asciilifeform_shi... 205 #endif
asciilifeform_shi... 206
asciilifeform_shi... 207 /*
asciilifeform_shi... 208 Local variables:
asciilifeform_shi... 209 c-file-style: "k&r"
asciilifeform_shi... 210 End:
asciilifeform_shi... 211 */