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