ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/microscheme/scheme-private.h
Revision: 1.1
Committed: Wed Nov 25 05:02:56 2015 UTC (8 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

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