… | |
… | |
16 | * (MINISCM) This is a revised and modified version by Akira KIDA. |
16 | * (MINISCM) This is a revised and modified version by Akira KIDA. |
17 | * (MINISCM) current version is 0.85k4 (15 May 1994) |
17 | * (MINISCM) current version is 0.85k4 (15 May 1994) |
18 | * |
18 | * |
19 | */ |
19 | */ |
20 | |
20 | |
|
|
21 | #define EXPERIMENT 1 |
|
|
22 | |
|
|
23 | #if 1 |
21 | #define PAGE_SIZE 4096 /* does not work on sparc/alpha */ |
24 | #define PAGE_SIZE 4096 /* does not work on sparc/alpha */ |
22 | #include "malloc.c" |
25 | #include "malloc.c" |
|
|
26 | #endif |
23 | |
27 | |
24 | #define SCHEME_SOURCE |
28 | #define SCHEME_SOURCE |
25 | #include "scheme-private.h" |
29 | #include "scheme-private.h" |
26 | #ifndef WIN32 |
30 | #ifndef WIN32 |
27 | # include <unistd.h> |
31 | # include <unistd.h> |
… | |
… | |
34 | |
38 | |
35 | #include <sys/types.h> |
39 | #include <sys/types.h> |
36 | #include <sys/stat.h> |
40 | #include <sys/stat.h> |
37 | #include <fcntl.h> |
41 | #include <fcntl.h> |
38 | |
42 | |
|
|
43 | #if !USE_ERROR_CHECKING |
|
|
44 | # define NDEBUG |
|
|
45 | #endif |
|
|
46 | |
|
|
47 | #include <assert.h> |
|
|
48 | #include <stdlib.h> |
39 | #include <string.h> |
49 | #include <string.h> |
40 | #include <stdlib.h> |
|
|
41 | |
50 | |
42 | #include <limits.h> |
51 | #include <limits.h> |
43 | #include <inttypes.h> |
52 | #include <inttypes.h> |
44 | #include <float.h> |
53 | #include <float.h> |
45 | //#include <ctype.h> |
54 | //#include <ctype.h> |
|
|
55 | |
|
|
56 | #if '1' != '0' + 1 \ |
|
|
57 | || '2' != '0' + 2 || '3' != '0' + 3 || '4' != '0' + 4 || '5' != '0' + 5 \ |
|
|
58 | || '6' != '0' + 6 || '7' != '0' + 7 || '8' != '0' + 8 || '9' != '0' + 9 \ |
|
|
59 | || 'b' != 'a' + 1 || 'c' != 'a' + 2 || 'd' != 'a' + 3 || 'e' != 'a' + 4 \ |
|
|
60 | || 'f' != 'a' + 5 |
|
|
61 | # error "execution character set digits not consecutive" |
|
|
62 | #endif |
46 | |
63 | |
47 | enum { |
64 | enum { |
48 | TOK_EOF, |
65 | TOK_EOF, |
49 | TOK_LPAREN, |
66 | TOK_LPAREN, |
50 | TOK_RPAREN, |
67 | TOK_RPAREN, |
51 | TOK_DOT, |
68 | TOK_DOT, |
52 | TOK_ATOM, |
69 | TOK_ATOM, |
|
|
70 | TOK_DOTATOM, /* atom name starting with '.' */ |
|
|
71 | TOK_STRATOM, /* atom name enclosed in | */ |
53 | TOK_QUOTE, |
72 | TOK_QUOTE, |
54 | TOK_DQUOTE, |
73 | TOK_DQUOTE, |
55 | TOK_BQUOTE, |
74 | TOK_BQUOTE, |
56 | TOK_COMMA, |
75 | TOK_COMMA, |
57 | TOK_ATMARK, |
76 | TOK_ATMARK, |
… | |
… | |
59 | TOK_SHARP_CONST, |
78 | TOK_SHARP_CONST, |
60 | TOK_VEC |
79 | TOK_VEC |
61 | }; |
80 | }; |
62 | |
81 | |
63 | #define BACKQUOTE '`' |
82 | #define BACKQUOTE '`' |
64 | #define DELIMITERS "()\";\f\t\v\n\r " |
83 | #define WHITESPACE " \t\r\n\v\f" |
|
|
84 | #define DELIMITERS "()\";" WHITESPACE |
65 | |
85 | |
66 | #define NIL (&SCHEME_V->xNIL) //TODO: make this 0? |
86 | #define NIL POINTER (&SCHEME_V->xNIL) |
67 | #define S_T (&SCHEME_V->xT) //TODO: magic ptr value? |
87 | #define S_T POINTER (&SCHEME_V->xT) |
68 | #define S_F (&SCHEME_V->xF) //TODO: magic ptr value? |
88 | #define S_F POINTER (&SCHEME_V->xF) |
69 | #define S_SINK (&SCHEME_V->xsink) |
89 | #define S_SINK POINTER (&SCHEME_V->xsink) |
70 | #define S_EOF (&SCHEME_V->xEOF_OBJ) |
90 | #define S_EOF POINTER (&SCHEME_V->xEOF_OBJ) |
71 | |
91 | |
72 | #if !USE_MULTIPLICITY |
92 | #if !USE_MULTIPLICITY |
73 | static scheme sc; |
93 | static scheme sc; |
74 | #endif |
94 | #endif |
75 | |
95 | |
… | |
… | |
174 | # define prompt "ts> " |
194 | # define prompt "ts> " |
175 | #endif |
195 | #endif |
176 | |
196 | |
177 | #ifndef InitFile |
197 | #ifndef InitFile |
178 | # define InitFile "init.scm" |
198 | # define InitFile "init.scm" |
179 | #endif |
|
|
180 | |
|
|
181 | #ifndef FIRST_CELLSEGS |
|
|
182 | # define FIRST_CELLSEGS 3 |
|
|
183 | #endif |
199 | #endif |
184 | |
200 | |
185 | enum scheme_types |
201 | enum scheme_types |
186 | { |
202 | { |
187 | T_INTEGER, |
203 | T_INTEGER, |
… | |
… | |
248 | static int is_zero_rvalue (RVALUE x); |
264 | static int is_zero_rvalue (RVALUE x); |
249 | |
265 | |
250 | static num num_zero; |
266 | static num num_zero; |
251 | static num num_one; |
267 | static num num_one; |
252 | |
268 | |
|
|
269 | /* convert "pointer" to cell* / cell* to pointer */ |
|
|
270 | #define CELL(p) ((struct cell *)(p) + 0) |
|
|
271 | #define POINTER(c) ((void *)((c) - 0)) |
|
|
272 | |
253 | /* macros for cell operations */ |
273 | /* macros for cell operations */ |
254 | #define typeflag(p) ((p)->flag + 0) |
274 | #define typeflag(p) (CELL(p)->flag + 0) |
255 | #define set_typeflag(p,v) ((p)->flag = (v)) |
275 | #define set_typeflag(p,v) (CELL(p)->flag = (v)) |
256 | #define type(p) (typeflag (p) & T_MASKTYPE) |
276 | #define type(p) (typeflag (p) & T_MASKTYPE) |
257 | |
277 | |
258 | INTERFACE int |
278 | INTERFACE int |
259 | is_string (pointer p) |
279 | is_string (pointer p) |
260 | { |
280 | { |
261 | return type (p) == T_STRING; |
281 | return type (p) == T_STRING; |
262 | } |
282 | } |
263 | |
283 | |
264 | #define strvalue(p) ((p)->object.string.svalue) |
284 | #define strvalue(p) (CELL(p)->object.string.svalue) |
265 | #define strlength(p) ((p)->object.string.length) |
285 | #define strlength(p) (CELL(p)->object.string.length) |
266 | |
286 | |
267 | INTERFACE int |
287 | INTERFACE int |
268 | is_vector (pointer p) |
288 | is_vector (pointer p) |
269 | { |
289 | { |
270 | return type (p) == T_VECTOR; |
290 | return type (p) == T_VECTOR; |
271 | } |
291 | } |
272 | |
292 | |
273 | #define vecvalue(p) ((p)->object.vector.vvalue) |
293 | #define vecvalue(p) (CELL(p)->object.vector.vvalue) |
274 | #define veclength(p) ((p)->object.vector.length) |
294 | #define veclength(p) (CELL(p)->object.vector.length) |
275 | INTERFACE void fill_vector (pointer vec, uint32_t start, pointer obj); |
295 | INTERFACE void fill_vector (pointer vec, uint32_t start, pointer obj); |
276 | INTERFACE pointer vector_get (pointer vec, uint32_t ielem); |
296 | INTERFACE pointer vector_get (pointer vec, uint32_t ielem); |
277 | INTERFACE void vector_set (pointer vec, uint32_t ielem, pointer a); |
297 | INTERFACE void vector_set (pointer vec, uint32_t ielem, pointer a); |
278 | |
298 | |
279 | INTERFACE int |
299 | INTERFACE int |
… | |
… | |
305 | string_value (pointer p) |
325 | string_value (pointer p) |
306 | { |
326 | { |
307 | return strvalue (p); |
327 | return strvalue (p); |
308 | } |
328 | } |
309 | |
329 | |
310 | #define ivalue_unchecked(p) (p)->object.ivalue |
330 | #define ivalue_unchecked(p) CELL(p)->object.ivalue |
311 | #define set_ivalue(p,v) (p)->object.ivalue = (v) |
331 | #define set_ivalue(p,v) CELL(p)->object.ivalue = (v) |
312 | |
332 | |
313 | #if USE_REAL |
333 | #if USE_REAL |
314 | #define rvalue_unchecked(p) (p)->object.rvalue |
334 | #define rvalue_unchecked(p) CELL(p)->object.rvalue |
315 | #define set_rvalue(p,v) (p)->object.rvalue = (v) |
335 | #define set_rvalue(p,v) CELL(p)->object.rvalue = (v) |
316 | #else |
336 | #else |
317 | #define rvalue_unchecked(p) (p)->object.ivalue |
337 | #define rvalue_unchecked(p) CELL(p)->object.ivalue |
318 | #define set_rvalue(p,v) (p)->object.ivalue = (v) |
338 | #define set_rvalue(p,v) CELL(p)->object.ivalue = (v) |
319 | #endif |
339 | #endif |
320 | |
340 | |
321 | INTERFACE long |
341 | INTERFACE long |
322 | charvalue (pointer p) |
342 | charvalue (pointer p) |
323 | { |
343 | { |
324 | return ivalue_unchecked (p); |
344 | return ivalue_unchecked (p); |
325 | } |
345 | } |
326 | |
346 | |
|
|
347 | #define port(p) CELL(p)->object.port |
|
|
348 | #define set_port(p,v) port(p) = (v) |
327 | INTERFACE int |
349 | INTERFACE int |
328 | is_port (pointer p) |
350 | is_port (pointer p) |
329 | { |
351 | { |
330 | return type (p) == T_PORT; |
352 | return type (p) == T_PORT; |
331 | } |
353 | } |
332 | |
354 | |
333 | INTERFACE int |
355 | INTERFACE int |
334 | is_inport (pointer p) |
356 | is_inport (pointer p) |
335 | { |
357 | { |
336 | return is_port (p) && p->object.port->kind & port_input; |
358 | return is_port (p) && port (p)->kind & port_input; |
337 | } |
359 | } |
338 | |
360 | |
339 | INTERFACE int |
361 | INTERFACE int |
340 | is_outport (pointer p) |
362 | is_outport (pointer p) |
341 | { |
363 | { |
342 | return is_port (p) && p->object.port->kind & port_output; |
364 | return is_port (p) && port (p)->kind & port_output; |
343 | } |
365 | } |
344 | |
366 | |
345 | INTERFACE int |
367 | INTERFACE int |
346 | is_pair (pointer p) |
368 | is_pair (pointer p) |
347 | { |
369 | { |
348 | return type (p) == T_PAIR; |
370 | return type (p) == T_PAIR; |
349 | } |
371 | } |
350 | |
372 | |
351 | #define car(p) ((p)->object.cons.car + 0) |
373 | #define car(p) (POINTER (CELL(p)->object.cons.car)) |
352 | #define cdr(p) ((p)->object.cons.cdr + 0) |
374 | #define cdr(p) (POINTER (CELL(p)->object.cons.cdr)) |
353 | |
375 | |
354 | static pointer caar (pointer p) { return car (car (p)); } |
376 | static pointer caar (pointer p) { return car (car (p)); } |
355 | static pointer cadr (pointer p) { return car (cdr (p)); } |
377 | static pointer cadr (pointer p) { return car (cdr (p)); } |
356 | static pointer cdar (pointer p) { return cdr (car (p)); } |
378 | static pointer cdar (pointer p) { return cdr (car (p)); } |
357 | static pointer cddr (pointer p) { return cdr (cdr (p)); } |
379 | static pointer cddr (pointer p) { return cdr (cdr (p)); } |
… | |
… | |
361 | static pointer cdaar (pointer p) { return cdr (car (car (p))); } |
383 | static pointer cdaar (pointer p) { return cdr (car (car (p))); } |
362 | |
384 | |
363 | INTERFACE void |
385 | INTERFACE void |
364 | set_car (pointer p, pointer q) |
386 | set_car (pointer p, pointer q) |
365 | { |
387 | { |
366 | p->object.cons.car = q; |
388 | CELL(p)->object.cons.car = CELL (q); |
367 | } |
389 | } |
368 | |
390 | |
369 | INTERFACE void |
391 | INTERFACE void |
370 | set_cdr (pointer p, pointer q) |
392 | set_cdr (pointer p, pointer q) |
371 | { |
393 | { |
372 | p->object.cons.cdr = q; |
394 | CELL(p)->object.cons.cdr = CELL (q); |
373 | } |
395 | } |
374 | |
396 | |
375 | INTERFACE pointer |
397 | INTERFACE pointer |
376 | pair_car (pointer p) |
398 | pair_car (pointer p) |
377 | { |
399 | { |
… | |
… | |
391 | } |
413 | } |
392 | |
414 | |
393 | INTERFACE char * |
415 | INTERFACE char * |
394 | symname (pointer p) |
416 | symname (pointer p) |
395 | { |
417 | { |
396 | return strvalue (car (p)); |
418 | return strvalue (p); |
397 | } |
419 | } |
398 | |
420 | |
399 | #if USE_PLIST |
421 | #if USE_PLIST |
|
|
422 | #error plists are broken because symbols are no longer pairs |
|
|
423 | #define symprop(p) cdr(p) |
400 | SCHEME_EXPORT int |
424 | SCHEME_EXPORT int |
401 | hasprop (pointer p) |
425 | hasprop (pointer p) |
402 | { |
426 | { |
403 | return typeflag (p) & T_SYMBOL; |
427 | return typeflag (p) & T_SYMBOL; |
404 | } |
428 | } |
405 | |
|
|
406 | # define symprop(p) cdr(p) |
|
|
407 | #endif |
429 | #endif |
408 | |
430 | |
409 | INTERFACE int |
431 | INTERFACE int |
410 | is_syntax (pointer p) |
432 | is_syntax (pointer p) |
411 | { |
433 | { |
… | |
… | |
425 | } |
447 | } |
426 | |
448 | |
427 | INTERFACE char * |
449 | INTERFACE char * |
428 | syntaxname (pointer p) |
450 | syntaxname (pointer p) |
429 | { |
451 | { |
430 | return strvalue (car (p)); |
452 | return strvalue (p); |
431 | } |
453 | } |
432 | |
454 | |
433 | #define procnum(p) ivalue_unchecked (p) |
455 | #define procnum(p) ivalue_unchecked (p) |
434 | static const char *procname (pointer x); |
456 | static const char *procname (pointer x); |
435 | |
457 | |
… | |
… | |
651 | #endif |
673 | #endif |
652 | |
674 | |
653 | static int file_push (SCHEME_P_ const char *fname); |
675 | static int file_push (SCHEME_P_ const char *fname); |
654 | static void file_pop (SCHEME_P); |
676 | static void file_pop (SCHEME_P); |
655 | static int file_interactive (SCHEME_P); |
677 | static int file_interactive (SCHEME_P); |
656 | ecb_inline int is_one_of (char *s, int c); |
678 | ecb_inline int is_one_of (const char *s, int c); |
657 | static int alloc_cellseg (SCHEME_P_ int n); |
679 | static int alloc_cellseg (SCHEME_P); |
658 | ecb_inline pointer get_cell (SCHEME_P_ pointer a, pointer b); |
680 | ecb_inline pointer get_cell (SCHEME_P_ pointer a, pointer b); |
659 | static void finalize_cell (SCHEME_P_ pointer a); |
681 | static void finalize_cell (SCHEME_P_ pointer a); |
660 | static int count_consecutive_cells (pointer x, int needed); |
682 | static int count_consecutive_cells (pointer x, int needed); |
661 | static pointer find_slot_in_env (SCHEME_P_ pointer env, pointer sym, int all); |
683 | static pointer find_slot_in_env (SCHEME_P_ pointer env, pointer sym, int all); |
662 | static pointer mk_number (SCHEME_P_ const num n); |
684 | static pointer mk_number (SCHEME_P_ const num n); |
… | |
… | |
678 | static void mark (pointer a); |
700 | static void mark (pointer a); |
679 | static void gc (SCHEME_P_ pointer a, pointer b); |
701 | static void gc (SCHEME_P_ pointer a, pointer b); |
680 | static int basic_inchar (port *pt); |
702 | static int basic_inchar (port *pt); |
681 | static int inchar (SCHEME_P); |
703 | static int inchar (SCHEME_P); |
682 | static void backchar (SCHEME_P_ int c); |
704 | static void backchar (SCHEME_P_ int c); |
683 | static char *readstr_upto (SCHEME_P_ char *delim); |
705 | static char *readstr_upto (SCHEME_P_ int skip, const char *delim); |
684 | static pointer readstrexp (SCHEME_P); |
706 | static pointer readstrexp (SCHEME_P_ char delim); |
685 | ecb_inline int skipspace (SCHEME_P); |
707 | ecb_inline int skipspace (SCHEME_P); |
686 | static int token (SCHEME_P); |
708 | static int token (SCHEME_P); |
687 | static void printslashstring (SCHEME_P_ char *s, int len); |
709 | static void printslashstring (SCHEME_P_ char *s, int len); |
688 | static void atom2str (SCHEME_P_ pointer l, int f, char **pp, int *plen); |
710 | static void atom2str (SCHEME_P_ pointer l, int f, char **pp, int *plen); |
689 | static void printatom (SCHEME_P_ pointer l, int f); |
711 | static void printatom (SCHEME_P_ pointer l, int f); |
… | |
… | |
896 | #endif |
918 | #endif |
897 | } |
919 | } |
898 | |
920 | |
899 | /* allocate new cell segment */ |
921 | /* allocate new cell segment */ |
900 | static int |
922 | static int |
901 | alloc_cellseg (SCHEME_P_ int n) |
923 | alloc_cellseg (SCHEME_P) |
902 | { |
924 | { |
903 | pointer newp; |
925 | struct cell *newp; |
904 | pointer last; |
926 | struct cell *last; |
905 | pointer p; |
927 | struct cell *p; |
906 | char *cp; |
928 | char *cp; |
907 | long i; |
929 | long i; |
908 | int k; |
930 | int k; |
909 | |
931 | |
910 | static int segsize = CELL_SEGSIZE >> 1; |
932 | static int segsize = CELL_SEGSIZE >> 1; |
911 | segsize <<= 1; |
933 | segsize <<= 1; |
912 | |
934 | |
913 | for (k = 0; k < n; k++) |
|
|
914 | { |
|
|
915 | if (SCHEME_V->last_cell_seg >= CELL_NSEGMENT - 1) |
|
|
916 | return k; |
|
|
917 | |
|
|
918 | cp = malloc (segsize * sizeof (struct cell)); |
935 | cp = malloc (segsize * sizeof (struct cell)); |
919 | |
936 | |
920 | if (!cp && USE_ERROR_CHECKING) |
937 | if (!cp && USE_ERROR_CHECKING) |
921 | return k; |
938 | return k; |
922 | |
939 | |
923 | i = ++SCHEME_V->last_cell_seg; |
940 | i = ++SCHEME_V->last_cell_seg; |
924 | SCHEME_V->alloc_seg[i] = cp; |
941 | SCHEME_V->alloc_seg[i] = cp; |
925 | |
942 | |
926 | newp = (pointer)cp; |
943 | newp = (struct cell *)cp; |
927 | SCHEME_V->cell_seg[i] = newp; |
944 | SCHEME_V->cell_seg[i] = newp; |
928 | SCHEME_V->cell_segsize[i] = segsize; |
945 | SCHEME_V->cell_segsize[i] = segsize; |
929 | SCHEME_V->fcells += segsize; |
946 | SCHEME_V->fcells += segsize; |
930 | last = newp + segsize - 1; |
947 | last = newp + segsize - 1; |
931 | |
948 | |
932 | for (p = newp; p <= last; p++) |
949 | for (p = newp; p <= last; p++) |
933 | { |
950 | { |
|
|
951 | pointer cp = POINTER (p); |
934 | set_typeflag (p, T_PAIR); |
952 | set_typeflag (cp, T_PAIR); |
935 | set_car (p, NIL); |
953 | set_car (cp, NIL); |
936 | set_cdr (p, p + 1); |
954 | set_cdr (cp, POINTER (p + 1)); |
937 | } |
955 | } |
938 | |
956 | |
939 | set_cdr (last, SCHEME_V->free_cell); |
957 | set_cdr (POINTER (last), SCHEME_V->free_cell); |
940 | SCHEME_V->free_cell = newp; |
958 | SCHEME_V->free_cell = POINTER (newp); |
941 | } |
|
|
942 | |
959 | |
943 | return n; |
960 | return 1; |
944 | } |
961 | } |
945 | |
962 | |
946 | /* get new cell. parameter a, b is marked by gc. */ |
963 | /* get new cell. parameter a, b is marked by gc. */ |
947 | ecb_inline pointer |
964 | ecb_inline pointer |
948 | get_cell_x (SCHEME_P_ pointer a, pointer b) |
965 | get_cell_x (SCHEME_P_ pointer a, pointer b) |
… | |
… | |
952 | if (SCHEME_V->no_memory && USE_ERROR_CHECKING) |
969 | if (SCHEME_V->no_memory && USE_ERROR_CHECKING) |
953 | return S_SINK; |
970 | return S_SINK; |
954 | |
971 | |
955 | if (SCHEME_V->free_cell == NIL) |
972 | if (SCHEME_V->free_cell == NIL) |
956 | { |
973 | { |
957 | const int min_to_be_recovered = SCHEME_V->last_cell_seg < 128 ? 128 * 8 : SCHEME_V->last_cell_seg * 8; |
974 | const int min_to_be_recovered = SCHEME_V->cell_segsize [SCHEME_V->last_cell_seg] >> 1; |
958 | |
975 | |
959 | gc (SCHEME_A_ a, b); |
976 | gc (SCHEME_A_ a, b); |
960 | |
977 | |
961 | if (SCHEME_V->fcells < min_to_be_recovered || SCHEME_V->free_cell == NIL) |
978 | if (SCHEME_V->fcells < min_to_be_recovered || SCHEME_V->free_cell == NIL) |
962 | { |
979 | { |
963 | /* if only a few recovered, get more to avoid fruitless gc's */ |
980 | /* if only a few recovered, get more to avoid fruitless gc's */ |
964 | if (!alloc_cellseg (SCHEME_A_ 1) && SCHEME_V->free_cell == NIL) |
981 | if (!alloc_cellseg (SCHEME_A) && SCHEME_V->free_cell == NIL) |
965 | { |
982 | { |
966 | #if USE_ERROR_CHECKING |
983 | #if USE_ERROR_CHECKING |
967 | SCHEME_V->no_memory = 1; |
984 | SCHEME_V->no_memory = 1; |
968 | return S_SINK; |
985 | return S_SINK; |
969 | #endif |
986 | #endif |
… | |
… | |
981 | } |
998 | } |
982 | } |
999 | } |
983 | |
1000 | |
984 | /* To retain recent allocs before interpreter knows about them - |
1001 | /* To retain recent allocs before interpreter knows about them - |
985 | Tehom */ |
1002 | Tehom */ |
986 | |
|
|
987 | static void |
1003 | static void |
988 | push_recent_alloc (SCHEME_P_ pointer recent, pointer extra) |
1004 | push_recent_alloc (SCHEME_P_ pointer recent, pointer extra) |
989 | { |
1005 | { |
990 | pointer holder = get_cell_x (SCHEME_A_ recent, extra); |
1006 | pointer holder = get_cell_x (SCHEME_A_ recent, extra); |
991 | |
1007 | |
… | |
… | |
1013 | } |
1029 | } |
1014 | |
1030 | |
1015 | static pointer |
1031 | static pointer |
1016 | get_vector_object (SCHEME_P_ uint32_t len, pointer init) |
1032 | get_vector_object (SCHEME_P_ uint32_t len, pointer init) |
1017 | { |
1033 | { |
1018 | pointer v = get_cell_x (SCHEME_A_ 0, 0); |
1034 | pointer v = get_cell_x (SCHEME_A_ NIL, NIL); |
1019 | pointer *e = malloc (len * sizeof (pointer)); |
1035 | pointer *e = malloc (len * sizeof (pointer)); |
1020 | |
1036 | |
1021 | if (!e && USE_ERROR_CHECKING) |
1037 | if (!e && USE_ERROR_CHECKING) |
1022 | return S_SINK; |
1038 | return S_SINK; |
1023 | |
1039 | |
1024 | /* Record it as a vector so that gc understands it. */ |
1040 | /* Record it as a vector so that gc understands it. */ |
1025 | set_typeflag (v, T_VECTOR | T_ATOM); |
1041 | set_typeflag (v, T_VECTOR | T_ATOM); |
1026 | |
1042 | |
1027 | v->object.vector.vvalue = e; |
1043 | CELL(v)->object.vector.vvalue = e; |
1028 | v->object.vector.length = len; |
1044 | CELL(v)->object.vector.length = len; |
1029 | fill_vector (v, 0, init); |
1045 | fill_vector (v, 0, init); |
1030 | push_recent_alloc (SCHEME_A_ v, NIL); |
1046 | push_recent_alloc (SCHEME_A_ v, NIL); |
1031 | |
1047 | |
1032 | return v; |
1048 | return v; |
1033 | } |
1049 | } |
… | |
… | |
1077 | set_cdr (x, b); |
1093 | set_cdr (x, b); |
1078 | |
1094 | |
1079 | return x; |
1095 | return x; |
1080 | } |
1096 | } |
1081 | |
1097 | |
1082 | /* ========== oblist implementation ========== */ |
|
|
1083 | |
|
|
1084 | static pointer |
1098 | static pointer |
1085 | generate_symbol (SCHEME_P_ const char *name) |
1099 | generate_symbol (SCHEME_P_ const char *name) |
1086 | { |
1100 | { |
1087 | pointer x = mk_string (SCHEME_A_ name); |
1101 | pointer x = mk_string (SCHEME_A_ name); |
1088 | setimmutable (x); |
1102 | setimmutable (x); |
1089 | x = immutable_cons (x, NIL); |
|
|
1090 | set_typeflag (x, T_SYMBOL); |
1103 | set_typeflag (x, T_SYMBOL | T_ATOM); |
1091 | return x; |
1104 | return x; |
1092 | } |
1105 | } |
|
|
1106 | |
|
|
1107 | /* ========== oblist implementation ========== */ |
1093 | |
1108 | |
1094 | #ifndef USE_OBJECT_LIST |
1109 | #ifndef USE_OBJECT_LIST |
1095 | |
1110 | |
1096 | static int |
1111 | static int |
1097 | hash_fn (const char *key, int table_size) |
1112 | hash_fn (const char *key, int table_size) |
… | |
… | |
1184 | |
1199 | |
1185 | /* returns the new symbol */ |
1200 | /* returns the new symbol */ |
1186 | static pointer |
1201 | static pointer |
1187 | oblist_add_by_name (SCHEME_P_ const char *name) |
1202 | oblist_add_by_name (SCHEME_P_ const char *name) |
1188 | { |
1203 | { |
1189 | pointer x = mk_string (SCHEME_A_ name); |
1204 | pointer x = generate_symbol (SCHEME_A_ name); |
1190 | set_typeflag (x, T_SYMBOL); |
|
|
1191 | setimmutable (x); |
|
|
1192 | SCHEME_V->oblist = immutable_cons (x, SCHEME_V->oblist); |
1205 | SCHEME_V->oblist = immutable_cons (x, SCHEME_V->oblist); |
1193 | return x; |
1206 | return x; |
1194 | } |
1207 | } |
1195 | |
1208 | |
1196 | static pointer |
1209 | static pointer |
… | |
… | |
1206 | mk_port (SCHEME_P_ port *p) |
1219 | mk_port (SCHEME_P_ port *p) |
1207 | { |
1220 | { |
1208 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1221 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1209 | |
1222 | |
1210 | set_typeflag (x, T_PORT | T_ATOM); |
1223 | set_typeflag (x, T_PORT | T_ATOM); |
1211 | x->object.port = p; |
1224 | set_port (x, p); |
1212 | |
1225 | |
1213 | return x; |
1226 | return x; |
1214 | } |
1227 | } |
1215 | #endif |
1228 | #endif |
1216 | |
1229 | |
1217 | pointer |
1230 | pointer |
1218 | mk_foreign_func (SCHEME_P_ foreign_func f) |
1231 | mk_foreign_func (SCHEME_P_ foreign_func f) |
1219 | { |
1232 | { |
1220 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1233 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1221 | |
1234 | |
1222 | set_typeflag (x, (T_FOREIGN | T_ATOM)); |
1235 | set_typeflag (x, T_FOREIGN | T_ATOM); |
1223 | x->object.ff = f; |
1236 | CELL(x)->object.ff = f; |
1224 | |
1237 | |
1225 | return x; |
1238 | return x; |
1226 | } |
1239 | } |
1227 | |
1240 | |
1228 | INTERFACE pointer |
1241 | INTERFACE pointer |
1229 | mk_character (SCHEME_P_ int c) |
1242 | mk_character (SCHEME_P_ int c) |
1230 | { |
1243 | { |
1231 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1244 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1232 | |
1245 | |
1233 | set_typeflag (x, (T_CHARACTER | T_ATOM)); |
1246 | set_typeflag (x, T_CHARACTER | T_ATOM); |
1234 | set_ivalue (x, c & 0xff); |
1247 | set_ivalue (x, c & 0xff); |
1235 | |
1248 | |
1236 | return x; |
1249 | return x; |
1237 | } |
1250 | } |
1238 | |
1251 | |
1239 | /* get number atom (integer) */ |
1252 | /* get number atom (integer) */ |
1240 | INTERFACE pointer |
1253 | INTERFACE pointer |
1241 | mk_integer (SCHEME_P_ long n) |
1254 | mk_integer (SCHEME_P_ long n) |
1242 | { |
1255 | { |
|
|
1256 | pointer p = 0; |
|
|
1257 | pointer *pp = &p; |
|
|
1258 | |
|
|
1259 | #if USE_INTCACHE |
|
|
1260 | if (n >= INTCACHE_MIN && n <= INTCACHE_MAX) |
|
|
1261 | pp = &SCHEME_V->intcache[n - INTCACHE_MIN]; |
|
|
1262 | #endif |
|
|
1263 | |
|
|
1264 | if (!*pp) |
|
|
1265 | { |
1243 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1266 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1244 | |
1267 | |
1245 | set_typeflag (x, (T_INTEGER | T_ATOM)); |
1268 | set_typeflag (x, T_INTEGER | T_ATOM); |
|
|
1269 | setimmutable (x); /* shouldn't do anythi9ng, doesn't cost anything */ |
1246 | set_ivalue (x, n); |
1270 | set_ivalue (x, n); |
1247 | |
1271 | |
|
|
1272 | *pp = x; |
|
|
1273 | } |
|
|
1274 | |
1248 | return x; |
1275 | return *pp; |
1249 | } |
1276 | } |
1250 | |
1277 | |
1251 | INTERFACE pointer |
1278 | INTERFACE pointer |
1252 | mk_real (SCHEME_P_ RVALUE n) |
1279 | mk_real (SCHEME_P_ RVALUE n) |
1253 | { |
1280 | { |
1254 | #if USE_REAL |
1281 | #if USE_REAL |
1255 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1282 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1256 | |
1283 | |
1257 | set_typeflag (x, (T_REAL | T_ATOM)); |
1284 | set_typeflag (x, T_REAL | T_ATOM); |
1258 | set_rvalue (x, n); |
1285 | set_rvalue (x, n); |
1259 | |
1286 | |
1260 | return x; |
1287 | return x; |
1261 | #else |
1288 | #else |
1262 | return mk_integer (SCHEME_A_ n); |
1289 | return mk_integer (SCHEME_A_ n); |
… | |
… | |
1286 | SCHEME_V->no_memory = 1; |
1313 | SCHEME_V->no_memory = 1; |
1287 | return SCHEME_V->strbuff; |
1314 | return SCHEME_V->strbuff; |
1288 | } |
1315 | } |
1289 | |
1316 | |
1290 | if (str) |
1317 | if (str) |
1291 | { |
1318 | memcpy (q, str , len_str); /* caller must ensure that *str has length len_str */ |
1292 | int l = strlen (str); |
|
|
1293 | |
|
|
1294 | if (l > len_str) |
|
|
1295 | l = len_str; |
|
|
1296 | |
|
|
1297 | memcpy (q, str, l); |
|
|
1298 | q[l] = 0; |
|
|
1299 | } |
|
|
1300 | else |
1319 | else |
1301 | { |
|
|
1302 | memset (q, fill, len_str); |
1320 | memset (q, fill, len_str); |
|
|
1321 | |
1303 | q[len_str] = 0; |
1322 | q[len_str] = 0; |
1304 | } |
|
|
1305 | |
1323 | |
1306 | return q; |
1324 | return q; |
1307 | } |
1325 | } |
1308 | |
1326 | |
1309 | INTERFACE pointer |
1327 | INTERFACE pointer |
… | |
… | |
1323 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1341 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1324 | |
1342 | |
1325 | set_typeflag (x, T_STRING | T_ATOM); |
1343 | set_typeflag (x, T_STRING | T_ATOM); |
1326 | strvalue (x) = store_string (SCHEME_A_ len, str, 0); |
1344 | strvalue (x) = store_string (SCHEME_A_ len, str, 0); |
1327 | strlength (x) = len; |
1345 | strlength (x) = len; |
|
|
1346 | |
1328 | return x; |
1347 | return x; |
1329 | } |
1348 | } |
1330 | |
1349 | |
1331 | INTERFACE pointer |
1350 | INTERFACE pointer |
1332 | mk_string (SCHEME_P_ const char *str) |
1351 | mk_string (SCHEME_P_ const char *str) |
… | |
… | |
1345 | { |
1364 | { |
1346 | int i; |
1365 | int i; |
1347 | |
1366 | |
1348 | for (i = start; i < veclength (vec); i++) |
1367 | for (i = start; i < veclength (vec); i++) |
1349 | vecvalue (vec)[i] = obj; |
1368 | vecvalue (vec)[i] = obj; |
|
|
1369 | } |
|
|
1370 | |
|
|
1371 | INTERFACE void |
|
|
1372 | vector_resize (pointer vec, uint32_t newsize, pointer fill) |
|
|
1373 | { |
|
|
1374 | uint32_t oldsize = veclength (vec); |
|
|
1375 | vecvalue (vec) = realloc (vecvalue (vec), newsize * sizeof (pointer)); |
|
|
1376 | veclength (vec) = newsize; |
|
|
1377 | fill_vector (vec, oldsize, fill); |
1350 | } |
1378 | } |
1351 | |
1379 | |
1352 | INTERFACE pointer |
1380 | INTERFACE pointer |
1353 | vector_get (pointer vec, uint32_t ielem) |
1381 | vector_get (pointer vec, uint32_t ielem) |
1354 | { |
1382 | { |
… | |
… | |
1377 | INTERFACE pointer |
1405 | INTERFACE pointer |
1378 | gensym (SCHEME_P) |
1406 | gensym (SCHEME_P) |
1379 | { |
1407 | { |
1380 | pointer x; |
1408 | pointer x; |
1381 | char name[40] = "gensym-"; |
1409 | char name[40] = "gensym-"; |
1382 | xnum (name + 7, SCHEME_V->gensym_cnt); |
1410 | xnum (name + 7, ++SCHEME_V->gensym_cnt); |
1383 | |
1411 | |
1384 | return generate_symbol (SCHEME_A_ name); |
1412 | return generate_symbol (SCHEME_A_ name); |
|
|
1413 | } |
|
|
1414 | |
|
|
1415 | static int |
|
|
1416 | is_gensym (SCHEME_P_ pointer x) |
|
|
1417 | { |
|
|
1418 | return is_symbol (x) && oblist_find_by_name (SCHEME_A_ strvalue (x)) != x; |
1385 | } |
1419 | } |
1386 | |
1420 | |
1387 | /* make symbol or number atom from string */ |
1421 | /* make symbol or number atom from string */ |
1388 | static pointer |
1422 | static pointer |
1389 | mk_atom (SCHEME_P_ char *q) |
1423 | mk_atom (SCHEME_P_ char *q) |
… | |
… | |
1598 | |
1632 | |
1599 | /* garbage collection. parameter a, b is marked. */ |
1633 | /* garbage collection. parameter a, b is marked. */ |
1600 | static void |
1634 | static void |
1601 | gc (SCHEME_P_ pointer a, pointer b) |
1635 | gc (SCHEME_P_ pointer a, pointer b) |
1602 | { |
1636 | { |
1603 | pointer p; |
|
|
1604 | int i; |
1637 | int i; |
1605 | |
1638 | |
1606 | if (SCHEME_V->gc_verbose) |
1639 | if (SCHEME_V->gc_verbose) |
1607 | putstr (SCHEME_A_ "gc..."); |
1640 | putstr (SCHEME_A_ "gc..."); |
1608 | |
1641 | |
… | |
… | |
1624 | /* Mark recent objects the interpreter doesn't know about yet. */ |
1657 | /* Mark recent objects the interpreter doesn't know about yet. */ |
1625 | mark (car (S_SINK)); |
1658 | mark (car (S_SINK)); |
1626 | /* Mark any older stuff above nested C calls */ |
1659 | /* Mark any older stuff above nested C calls */ |
1627 | mark (SCHEME_V->c_nest); |
1660 | mark (SCHEME_V->c_nest); |
1628 | |
1661 | |
|
|
1662 | #if USE_INTCACHE |
|
|
1663 | /* mark intcache */ |
|
|
1664 | for (i = INTCACHE_MIN; i <= INTCACHE_MAX; ++i) |
|
|
1665 | if (SCHEME_V->intcache[i - INTCACHE_MIN]) |
|
|
1666 | mark (SCHEME_V->intcache[i - INTCACHE_MIN]); |
|
|
1667 | #endif |
|
|
1668 | |
1629 | /* mark variables a, b */ |
1669 | /* mark variables a, b */ |
1630 | mark (a); |
1670 | mark (a); |
1631 | mark (b); |
1671 | mark (b); |
1632 | |
1672 | |
1633 | /* garbage collect */ |
1673 | /* garbage collect */ |
1634 | clrmark (NIL); |
1674 | clrmark (NIL); |
1635 | SCHEME_V->fcells = 0; |
1675 | SCHEME_V->fcells = 0; |
1636 | SCHEME_V->free_cell = NIL; |
1676 | SCHEME_V->free_cell = NIL; |
1637 | |
1677 | |
1638 | /* free-list is kept sorted by address so as to maintain consecutive |
1678 | if (SCHEME_V->gc_verbose) |
1639 | ranges, if possible, for use with vectors. Here we scan the cells |
1679 | xwrstr ("freeing..."); |
1640 | (which are also kept sorted by address) downwards to build the |
1680 | |
1641 | free-list in sorted order. |
1681 | uint32_t total = 0; |
1642 | */ |
1682 | |
|
|
1683 | /* Here we scan the cells to build the free-list. */ |
1643 | for (i = SCHEME_V->last_cell_seg; i >= 0; i--) |
1684 | for (i = SCHEME_V->last_cell_seg; i >= 0; i--) |
1644 | { |
1685 | { |
1645 | p = SCHEME_V->cell_seg[i] + SCHEME_V->cell_segsize [i]; |
1686 | struct cell *end = SCHEME_V->cell_seg[i] + SCHEME_V->cell_segsize [i]; |
|
|
1687 | struct cell *p; |
|
|
1688 | total += SCHEME_V->cell_segsize [i]; |
1646 | |
1689 | |
1647 | while (--p >= SCHEME_V->cell_seg[i]) |
1690 | for (p = SCHEME_V->cell_seg[i]; p < end; ++p) |
1648 | { |
1691 | { |
|
|
1692 | pointer c = POINTER (p); |
|
|
1693 | |
1649 | if (is_mark (p)) |
1694 | if (is_mark (c)) |
1650 | clrmark (p); |
1695 | clrmark (c); |
1651 | else |
1696 | else |
1652 | { |
1697 | { |
1653 | /* reclaim cell */ |
1698 | /* reclaim cell */ |
1654 | if (typeflag (p) != T_PAIR) |
1699 | if (typeflag (c) != T_PAIR) |
1655 | { |
1700 | { |
1656 | finalize_cell (SCHEME_A_ p); |
1701 | finalize_cell (SCHEME_A_ c); |
1657 | set_typeflag (p, T_PAIR); |
1702 | set_typeflag (c, T_PAIR); |
1658 | set_car (p, NIL); |
1703 | set_car (c, NIL); |
1659 | } |
1704 | } |
1660 | |
1705 | |
1661 | ++SCHEME_V->fcells; |
1706 | ++SCHEME_V->fcells; |
1662 | set_cdr (p, SCHEME_V->free_cell); |
1707 | set_cdr (c, SCHEME_V->free_cell); |
1663 | SCHEME_V->free_cell = p; |
1708 | SCHEME_V->free_cell = c; |
1664 | } |
1709 | } |
1665 | } |
1710 | } |
1666 | } |
1711 | } |
1667 | |
1712 | |
1668 | if (SCHEME_V->gc_verbose) |
1713 | if (SCHEME_V->gc_verbose) |
1669 | { |
1714 | { |
1670 | xwrstr ("done: "); xwrnum (SCHEME_V->fcells); xwrstr (" cells were recovered.\n"); |
1715 | xwrstr ("done: "); xwrnum (SCHEME_V->fcells); xwrstr (" out of "); xwrnum (total); xwrstr (" cells were recovered.\n"); |
1671 | } |
1716 | } |
1672 | } |
1717 | } |
1673 | |
1718 | |
1674 | static void |
1719 | static void |
1675 | finalize_cell (SCHEME_P_ pointer a) |
1720 | finalize_cell (SCHEME_P_ pointer a) |
1676 | { |
1721 | { |
1677 | /* TODO, fast bitmap check? */ |
1722 | /* TODO, fast bitmap check? */ |
1678 | if (is_string (a)) |
1723 | if (is_string (a) || is_symbol (a)) |
1679 | free (strvalue (a)); |
1724 | free (strvalue (a)); |
1680 | else if (is_vector (a)) |
1725 | else if (is_vector (a)) |
1681 | free (vecvalue (a)); |
1726 | free (vecvalue (a)); |
1682 | #if USE_PORTS |
1727 | #if USE_PORTS |
1683 | else if (is_port (a)) |
1728 | else if (is_port (a)) |
1684 | { |
1729 | { |
1685 | if (a->object.port->kind & port_file && a->object.port->rep.stdio.closeit) |
1730 | if (port(a)->kind & port_file && port (a)->rep.stdio.closeit) |
1686 | port_close (SCHEME_A_ a, port_input | port_output); |
1731 | port_close (SCHEME_A_ a, port_input | port_output); |
1687 | |
1732 | |
1688 | free (a->object.port); |
1733 | free (port (a)); |
1689 | } |
1734 | } |
1690 | #endif |
1735 | #endif |
1691 | } |
1736 | } |
1692 | |
1737 | |
1693 | /* ========== Routines for Reading ========== */ |
1738 | /* ========== Routines for Reading ========== */ |
… | |
… | |
1709 | SCHEME_V->load_stack[SCHEME_V->file_i].unget = -1; |
1754 | SCHEME_V->load_stack[SCHEME_V->file_i].unget = -1; |
1710 | SCHEME_V->load_stack[SCHEME_V->file_i].kind = port_file | port_input; |
1755 | SCHEME_V->load_stack[SCHEME_V->file_i].kind = port_file | port_input; |
1711 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.file = fin; |
1756 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.file = fin; |
1712 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.closeit = 1; |
1757 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.closeit = 1; |
1713 | SCHEME_V->nesting_stack[SCHEME_V->file_i] = 0; |
1758 | SCHEME_V->nesting_stack[SCHEME_V->file_i] = 0; |
1714 | SCHEME_V->loadport->object.port = SCHEME_V->load_stack + SCHEME_V->file_i; |
1759 | set_port (SCHEME_V->loadport, SCHEME_V->load_stack + SCHEME_V->file_i); |
1715 | |
1760 | |
1716 | #if SHOW_ERROR_LINE |
1761 | #if SHOW_ERROR_LINE |
1717 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.curr_line = 0; |
1762 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.curr_line = 0; |
1718 | |
1763 | |
1719 | if (fname) |
1764 | if (fname) |
… | |
… | |
1736 | SCHEME_V->nesting = SCHEME_V->nesting_stack[SCHEME_V->file_i]; |
1781 | SCHEME_V->nesting = SCHEME_V->nesting_stack[SCHEME_V->file_i]; |
1737 | #if USE_PORTS |
1782 | #if USE_PORTS |
1738 | port_close (SCHEME_A_ SCHEME_V->loadport, port_input); |
1783 | port_close (SCHEME_A_ SCHEME_V->loadport, port_input); |
1739 | #endif |
1784 | #endif |
1740 | SCHEME_V->file_i--; |
1785 | SCHEME_V->file_i--; |
1741 | SCHEME_V->loadport->object.port = SCHEME_V->load_stack + SCHEME_V->file_i; |
1786 | set_port (SCHEME_V->loadport, SCHEME_V->load_stack + SCHEME_V->file_i); |
1742 | } |
1787 | } |
1743 | } |
1788 | } |
1744 | |
1789 | |
1745 | static int |
1790 | static int |
1746 | file_interactive (SCHEME_P) |
1791 | file_interactive (SCHEME_P) |
1747 | { |
1792 | { |
1748 | #if USE_PORTS |
1793 | #if USE_PORTS |
1749 | return SCHEME_V->file_i == 0 |
1794 | return SCHEME_V->file_i == 0 |
1750 | && SCHEME_V->load_stack[0].rep.stdio.file == STDIN_FILENO |
1795 | && SCHEME_V->load_stack[0].rep.stdio.file == STDIN_FILENO |
1751 | && (SCHEME_V->inport->object.port->kind & port_file); |
1796 | && (port (SCHEME_V->inport)->kind & port_file); |
1752 | #else |
1797 | #else |
1753 | return 0; |
1798 | return 0; |
1754 | #endif |
1799 | #endif |
1755 | } |
1800 | } |
1756 | |
1801 | |
… | |
… | |
1890 | } |
1935 | } |
1891 | |
1936 | |
1892 | static void |
1937 | static void |
1893 | port_close (SCHEME_P_ pointer p, int flag) |
1938 | port_close (SCHEME_P_ pointer p, int flag) |
1894 | { |
1939 | { |
1895 | port *pt = p->object.port; |
1940 | port *pt = port (p); |
1896 | |
1941 | |
1897 | pt->kind &= ~flag; |
1942 | pt->kind &= ~flag; |
1898 | |
1943 | |
1899 | if ((pt->kind & (port_input | port_output)) == 0) |
1944 | if ((pt->kind & (port_input | port_output)) == 0) |
1900 | { |
1945 | { |
… | |
… | |
1921 | /* get new character from input file */ |
1966 | /* get new character from input file */ |
1922 | static int |
1967 | static int |
1923 | inchar (SCHEME_P) |
1968 | inchar (SCHEME_P) |
1924 | { |
1969 | { |
1925 | int c; |
1970 | int c; |
1926 | port *pt; |
1971 | port *pt = port (SCHEME_V->inport); |
1927 | |
|
|
1928 | pt = SCHEME_V->inport->object.port; |
|
|
1929 | |
1972 | |
1930 | if (pt->kind & port_saw_EOF) |
1973 | if (pt->kind & port_saw_EOF) |
1931 | return EOF; |
1974 | return EOF; |
1932 | |
1975 | |
1933 | c = basic_inchar (pt); |
1976 | c = basic_inchar (pt); |
… | |
… | |
2000 | port *pt; |
2043 | port *pt; |
2001 | |
2044 | |
2002 | if (c == EOF) |
2045 | if (c == EOF) |
2003 | return; |
2046 | return; |
2004 | |
2047 | |
2005 | pt = SCHEME_V->inport->object.port; |
2048 | pt = port (SCHEME_V->inport); |
2006 | pt->unget = c; |
2049 | pt->unget = c; |
2007 | #else |
2050 | #else |
2008 | if (c == EOF) |
2051 | if (c == EOF) |
2009 | return; |
2052 | return; |
2010 | |
2053 | |
… | |
… | |
2038 | |
2081 | |
2039 | INTERFACE void |
2082 | INTERFACE void |
2040 | putstr (SCHEME_P_ const char *s) |
2083 | putstr (SCHEME_P_ const char *s) |
2041 | { |
2084 | { |
2042 | #if USE_PORTS |
2085 | #if USE_PORTS |
2043 | port *pt = SCHEME_V->outport->object.port; |
2086 | port *pt = port (SCHEME_V->outport); |
2044 | |
2087 | |
2045 | if (pt->kind & port_file) |
2088 | if (pt->kind & port_file) |
2046 | write (pt->rep.stdio.file, s, strlen (s)); |
2089 | write (pt->rep.stdio.file, s, strlen (s)); |
2047 | else |
2090 | else |
2048 | for (; *s; s++) |
2091 | for (; *s; s++) |
… | |
… | |
2058 | |
2101 | |
2059 | static void |
2102 | static void |
2060 | putchars (SCHEME_P_ const char *s, int len) |
2103 | putchars (SCHEME_P_ const char *s, int len) |
2061 | { |
2104 | { |
2062 | #if USE_PORTS |
2105 | #if USE_PORTS |
2063 | port *pt = SCHEME_V->outport->object.port; |
2106 | port *pt = port (SCHEME_V->outport); |
2064 | |
2107 | |
2065 | if (pt->kind & port_file) |
2108 | if (pt->kind & port_file) |
2066 | write (pt->rep.stdio.file, s, len); |
2109 | write (pt->rep.stdio.file, s, len); |
2067 | else |
2110 | else |
2068 | { |
2111 | { |
… | |
… | |
2082 | |
2125 | |
2083 | INTERFACE void |
2126 | INTERFACE void |
2084 | putcharacter (SCHEME_P_ int c) |
2127 | putcharacter (SCHEME_P_ int c) |
2085 | { |
2128 | { |
2086 | #if USE_PORTS |
2129 | #if USE_PORTS |
2087 | port *pt = SCHEME_V->outport->object.port; |
2130 | port *pt = port (SCHEME_V->outport); |
2088 | |
2131 | |
2089 | if (pt->kind & port_file) |
2132 | if (pt->kind & port_file) |
2090 | { |
2133 | { |
2091 | char cc = c; |
2134 | char cc = c; |
2092 | write (pt->rep.stdio.file, &cc, 1); |
2135 | write (pt->rep.stdio.file, &cc, 1); |
… | |
… | |
2105 | #endif |
2148 | #endif |
2106 | } |
2149 | } |
2107 | |
2150 | |
2108 | /* read characters up to delimiter, but cater to character constants */ |
2151 | /* read characters up to delimiter, but cater to character constants */ |
2109 | static char * |
2152 | static char * |
2110 | readstr_upto (SCHEME_P_ char *delim) |
2153 | readstr_upto (SCHEME_P_ int skip, const char *delim) |
2111 | { |
2154 | { |
2112 | char *p = SCHEME_V->strbuff; |
2155 | char *p = SCHEME_V->strbuff + skip; |
2113 | |
2156 | |
2114 | while ((p - SCHEME_V->strbuff < sizeof (SCHEME_V->strbuff)) && !is_one_of (delim, (*p++ = inchar (SCHEME_A)))); |
2157 | while ((p - SCHEME_V->strbuff < sizeof (SCHEME_V->strbuff)) && !is_one_of (delim, (*p++ = inchar (SCHEME_A)))); |
2115 | |
2158 | |
2116 | if (p == SCHEME_V->strbuff + 2 && p[-2] == '\\') |
2159 | if (p == SCHEME_V->strbuff + 2 && p[-2] == '\\') |
2117 | *p = 0; |
2160 | *p = 0; |
… | |
… | |
2124 | return SCHEME_V->strbuff; |
2167 | return SCHEME_V->strbuff; |
2125 | } |
2168 | } |
2126 | |
2169 | |
2127 | /* read string expression "xxx...xxx" */ |
2170 | /* read string expression "xxx...xxx" */ |
2128 | static pointer |
2171 | static pointer |
2129 | readstrexp (SCHEME_P) |
2172 | readstrexp (SCHEME_P_ char delim) |
2130 | { |
2173 | { |
2131 | char *p = SCHEME_V->strbuff; |
2174 | char *p = SCHEME_V->strbuff; |
2132 | int c; |
2175 | int c; |
2133 | int c1 = 0; |
2176 | int c1 = 0; |
2134 | enum |
|
|
2135 | { st_ok, st_bsl, st_x1, st_x2, st_oct1, st_oct2 } state = st_ok; |
2177 | enum { st_ok, st_bsl, st_x1, st_x2, st_oct1, st_oct2 } state = st_ok; |
2136 | |
2178 | |
2137 | for (;;) |
2179 | for (;;) |
2138 | { |
2180 | { |
2139 | c = inchar (SCHEME_A); |
2181 | c = inchar (SCHEME_A); |
2140 | |
2182 | |
… | |
… | |
2142 | return S_F; |
2184 | return S_F; |
2143 | |
2185 | |
2144 | switch (state) |
2186 | switch (state) |
2145 | { |
2187 | { |
2146 | case st_ok: |
2188 | case st_ok: |
2147 | switch (c) |
2189 | if (ecb_expect_false (c == delim)) |
2148 | { |
|
|
2149 | case '\\': |
|
|
2150 | state = st_bsl; |
|
|
2151 | break; |
|
|
2152 | |
|
|
2153 | case '"': |
|
|
2154 | *p = 0; |
|
|
2155 | return mk_counted_string (SCHEME_A_ SCHEME_V->strbuff, p - SCHEME_V->strbuff); |
2190 | return mk_counted_string (SCHEME_A_ SCHEME_V->strbuff, p - SCHEME_V->strbuff); |
2156 | |
2191 | |
2157 | default: |
2192 | if (ecb_expect_false (c == '\\')) |
|
|
2193 | state = st_bsl; |
|
|
2194 | else |
2158 | *p++ = c; |
2195 | *p++ = c; |
2159 | break; |
|
|
2160 | } |
|
|
2161 | |
2196 | |
2162 | break; |
2197 | break; |
2163 | |
2198 | |
2164 | case st_bsl: |
2199 | case st_bsl: |
2165 | switch (c) |
2200 | switch (c) |
… | |
… | |
2195 | case 'r': |
2230 | case 'r': |
2196 | *p++ = '\r'; |
2231 | *p++ = '\r'; |
2197 | state = st_ok; |
2232 | state = st_ok; |
2198 | break; |
2233 | break; |
2199 | |
2234 | |
2200 | case '"': |
|
|
2201 | *p++ = '"'; |
|
|
2202 | state = st_ok; |
|
|
2203 | break; |
|
|
2204 | |
|
|
2205 | default: |
2235 | default: |
2206 | *p++ = c; |
2236 | *p++ = c; |
2207 | state = st_ok; |
2237 | state = st_ok; |
2208 | break; |
2238 | break; |
2209 | } |
2239 | } |
2210 | |
2240 | |
2211 | break; |
2241 | break; |
2212 | |
2242 | |
2213 | case st_x1: |
2243 | case st_x1: |
2214 | case st_x2: |
2244 | case st_x2: |
2215 | c = toupper (c); |
2245 | c = tolower (c); |
2216 | |
2246 | |
2217 | if (c >= '0' && c <= 'F') |
2247 | if (c >= '0' && c <= '9') |
2218 | { |
|
|
2219 | if (c <= '9') |
|
|
2220 | c1 = (c1 << 4) + c - '0'; |
2248 | c1 = (c1 << 4) + c - '0'; |
2221 | else |
2249 | else if (c >= 'a' && c <= 'f') |
2222 | c1 = (c1 << 4) + c - 'A' + 10; |
2250 | c1 = (c1 << 4) + c - 'a' + 10; |
2223 | |
|
|
2224 | if (state == st_x1) |
|
|
2225 | state = st_x2; |
|
|
2226 | else |
|
|
2227 | { |
|
|
2228 | *p++ = c1; |
|
|
2229 | state = st_ok; |
|
|
2230 | } |
|
|
2231 | } |
|
|
2232 | else |
2251 | else |
2233 | return S_F; |
2252 | return S_F; |
|
|
2253 | |
|
|
2254 | if (state == st_x1) |
|
|
2255 | state = st_x2; |
|
|
2256 | else |
|
|
2257 | { |
|
|
2258 | *p++ = c1; |
|
|
2259 | state = st_ok; |
|
|
2260 | } |
2234 | |
2261 | |
2235 | break; |
2262 | break; |
2236 | |
2263 | |
2237 | case st_oct1: |
2264 | case st_oct1: |
2238 | case st_oct2: |
2265 | case st_oct2: |
… | |
… | |
2242 | backchar (SCHEME_A_ c); |
2269 | backchar (SCHEME_A_ c); |
2243 | state = st_ok; |
2270 | state = st_ok; |
2244 | } |
2271 | } |
2245 | else |
2272 | else |
2246 | { |
2273 | { |
2247 | if (state == st_oct2 && c1 >= 32) |
2274 | if (state == st_oct2 && c1 >= ' ') |
2248 | return S_F; |
2275 | return S_F; |
2249 | |
2276 | |
2250 | c1 = (c1 << 3) + (c - '0'); |
2277 | c1 = (c1 << 3) + (c - '0'); |
2251 | |
2278 | |
2252 | if (state == st_oct1) |
2279 | if (state == st_oct1) |
… | |
… | |
2257 | state = st_ok; |
2284 | state = st_ok; |
2258 | } |
2285 | } |
2259 | } |
2286 | } |
2260 | |
2287 | |
2261 | break; |
2288 | break; |
2262 | |
|
|
2263 | } |
2289 | } |
2264 | } |
2290 | } |
2265 | } |
2291 | } |
2266 | |
2292 | |
2267 | /* check c is in chars */ |
2293 | /* check c is in chars */ |
2268 | ecb_inline int |
2294 | ecb_inline int |
2269 | is_one_of (char *s, int c) |
2295 | is_one_of (const char *s, int c) |
2270 | { |
2296 | { |
2271 | if (c == EOF) |
|
|
2272 | return 1; |
|
|
2273 | |
|
|
2274 | return !!strchr (s, c); |
2297 | return c == EOF || !!strchr (s, c); |
2275 | } |
2298 | } |
2276 | |
2299 | |
2277 | /* skip white characters */ |
2300 | /* skip white characters */ |
2278 | ecb_inline int |
2301 | ecb_inline int |
2279 | skipspace (SCHEME_P) |
2302 | skipspace (SCHEME_P) |
… | |
… | |
2281 | int c, curr_line = 0; |
2304 | int c, curr_line = 0; |
2282 | |
2305 | |
2283 | do |
2306 | do |
2284 | { |
2307 | { |
2285 | c = inchar (SCHEME_A); |
2308 | c = inchar (SCHEME_A); |
|
|
2309 | |
2286 | #if SHOW_ERROR_LINE |
2310 | #if SHOW_ERROR_LINE |
2287 | if (c == '\n') |
2311 | if (ecb_expect_false (c == '\n')) |
2288 | curr_line++; |
2312 | curr_line++; |
2289 | #endif |
2313 | #endif |
|
|
2314 | |
|
|
2315 | if (ecb_expect_false (c == EOF)) |
|
|
2316 | return c; |
2290 | } |
2317 | } |
2291 | while (c == ' ' || c == '\n' || c == '\r' || c == '\t'); |
2318 | while (is_one_of (WHITESPACE, c)); |
2292 | |
2319 | |
2293 | /* record it */ |
2320 | /* record it */ |
2294 | #if SHOW_ERROR_LINE |
2321 | #if SHOW_ERROR_LINE |
2295 | if (SCHEME_V->load_stack[SCHEME_V->file_i].kind & port_file) |
2322 | if (SCHEME_V->load_stack[SCHEME_V->file_i].kind & port_file) |
2296 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.curr_line += curr_line; |
2323 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.curr_line += curr_line; |
2297 | #endif |
2324 | #endif |
2298 | |
2325 | |
2299 | if (c != EOF) |
|
|
2300 | { |
|
|
2301 | backchar (SCHEME_A_ c); |
2326 | backchar (SCHEME_A_ c); |
2302 | return 1; |
2327 | return 1; |
2303 | } |
|
|
2304 | else |
|
|
2305 | return EOF; |
|
|
2306 | } |
2328 | } |
2307 | |
2329 | |
2308 | /* get token */ |
2330 | /* get token */ |
2309 | static int |
2331 | static int |
2310 | token (SCHEME_P) |
2332 | token (SCHEME_P) |
… | |
… | |
2326 | return TOK_RPAREN; |
2348 | return TOK_RPAREN; |
2327 | |
2349 | |
2328 | case '.': |
2350 | case '.': |
2329 | c = inchar (SCHEME_A); |
2351 | c = inchar (SCHEME_A); |
2330 | |
2352 | |
2331 | if (is_one_of (" \n\t", c)) |
2353 | if (is_one_of (WHITESPACE, c)) |
2332 | return TOK_DOT; |
2354 | return TOK_DOT; |
2333 | else |
2355 | else |
2334 | { |
2356 | { |
2335 | //TODO: ungetc twice in a row is not supported in C |
|
|
2336 | backchar (SCHEME_A_ c); |
2357 | backchar (SCHEME_A_ c); |
2337 | backchar (SCHEME_A_ '.'); |
|
|
2338 | return TOK_ATOM; |
2358 | return TOK_DOTATOM; |
2339 | } |
2359 | } |
|
|
2360 | |
|
|
2361 | case '|': |
|
|
2362 | return TOK_STRATOM; |
2340 | |
2363 | |
2341 | case '\'': |
2364 | case '\'': |
2342 | return TOK_QUOTE; |
2365 | return TOK_QUOTE; |
2343 | |
2366 | |
2344 | case ';': |
2367 | case ';': |
… | |
… | |
2476 | } |
2499 | } |
2477 | |
2500 | |
2478 | putcharacter (SCHEME_A_ '"'); |
2501 | putcharacter (SCHEME_A_ '"'); |
2479 | } |
2502 | } |
2480 | |
2503 | |
2481 | |
|
|
2482 | /* print atoms */ |
2504 | /* print atoms */ |
2483 | static void |
2505 | static void |
2484 | printatom (SCHEME_P_ pointer l, int f) |
2506 | printatom (SCHEME_P_ pointer l, int f) |
2485 | { |
2507 | { |
2486 | char *p; |
2508 | char *p; |
2487 | int len; |
2509 | int len; |
2488 | |
2510 | |
2489 | atom2str (SCHEME_A_ l, f, &p, &len); |
2511 | atom2str (SCHEME_A_ l, f, &p, &len); |
2490 | putchars (SCHEME_A_ p, len); |
2512 | putchars (SCHEME_A_ p, len); |
2491 | } |
2513 | } |
2492 | |
|
|
2493 | |
2514 | |
2494 | /* Uses internal buffer unless string pointer is already available */ |
2515 | /* Uses internal buffer unless string pointer is already available */ |
2495 | static void |
2516 | static void |
2496 | atom2str (SCHEME_P_ pointer l, int f, char **pp, int *plen) |
2517 | atom2str (SCHEME_P_ pointer l, int f, char **pp, int *plen) |
2497 | { |
2518 | { |
… | |
… | |
2658 | #endif |
2679 | #endif |
2659 | } |
2680 | } |
2660 | else if (is_continuation (l)) |
2681 | else if (is_continuation (l)) |
2661 | p = "#<CONTINUATION>"; |
2682 | p = "#<CONTINUATION>"; |
2662 | else |
2683 | else |
|
|
2684 | { |
|
|
2685 | #if USE_PRINTF |
|
|
2686 | p = SCHEME_V->strbuff; |
|
|
2687 | snprintf (p, STRBUFFSIZE, "#<ERROR %x>", (int)typeflag (l)); |
|
|
2688 | #else |
2663 | p = "#<ERROR>"; |
2689 | p = "#<ERROR>"; |
|
|
2690 | #endif |
|
|
2691 | } |
2664 | |
2692 | |
2665 | *pp = p; |
2693 | *pp = p; |
2666 | *plen = strlen (p); |
2694 | *plen = strlen (p); |
2667 | } |
2695 | } |
2668 | |
2696 | |
… | |
… | |
2938 | #endif /* USE_ALIST_ENV else */ |
2966 | #endif /* USE_ALIST_ENV else */ |
2939 | |
2967 | |
2940 | ecb_inline void |
2968 | ecb_inline void |
2941 | new_slot_in_env (SCHEME_P_ pointer variable, pointer value) |
2969 | new_slot_in_env (SCHEME_P_ pointer variable, pointer value) |
2942 | { |
2970 | { |
|
|
2971 | assert (is_symbol (variable));//TODO: bug in current-ws/OP_LET2 |
2943 | new_slot_spec_in_env (SCHEME_A_ SCHEME_V->envir, variable, value); |
2972 | new_slot_spec_in_env (SCHEME_A_ SCHEME_V->envir, variable, value); |
2944 | } |
2973 | } |
2945 | |
2974 | |
2946 | ecb_inline void |
2975 | ecb_inline void |
2947 | set_slot_in_env (SCHEME_P_ pointer slot, pointer value) |
2976 | set_slot_in_env (SCHEME_P_ pointer slot, pointer value) |
… | |
… | |
3048 | { |
3077 | { |
3049 | int nframes = (uintptr_t)SCHEME_V->dump; |
3078 | int nframes = (uintptr_t)SCHEME_V->dump; |
3050 | struct dump_stack_frame *next_frame; |
3079 | struct dump_stack_frame *next_frame; |
3051 | |
3080 | |
3052 | /* enough room for the next frame? */ |
3081 | /* enough room for the next frame? */ |
3053 | if (nframes >= SCHEME_V->dump_size) |
3082 | if (ecb_expect_false (nframes >= SCHEME_V->dump_size)) |
3054 | { |
3083 | { |
3055 | SCHEME_V->dump_size += STACK_GROWTH; |
3084 | SCHEME_V->dump_size += STACK_GROWTH; |
3056 | SCHEME_V->dump_base = realloc (SCHEME_V->dump_base, sizeof (struct dump_stack_frame) * SCHEME_V->dump_size); |
3085 | SCHEME_V->dump_base = realloc (SCHEME_V->dump_base, sizeof (struct dump_stack_frame) * SCHEME_V->dump_size); |
3057 | } |
3086 | } |
3058 | |
3087 | |
… | |
… | |
3239 | |
3268 | |
3240 | #endif |
3269 | #endif |
3241 | |
3270 | |
3242 | #define s_retbool(tf) s_return ((tf) ? S_T : S_F) |
3271 | #define s_retbool(tf) s_return ((tf) ? S_T : S_F) |
3243 | |
3272 | |
|
|
3273 | #if EXPERIMENT |
|
|
3274 | static int |
|
|
3275 | debug (SCHEME_P_ int indent, pointer x) |
|
|
3276 | { |
|
|
3277 | int c; |
|
|
3278 | |
|
|
3279 | if (is_syntax (x)) |
|
|
3280 | { |
|
|
3281 | printf ("%*ssyntax<%s,%d>\n", indent, "", syntaxname(x),syntaxnum(x)); |
|
|
3282 | return 8 + 8; |
|
|
3283 | } |
|
|
3284 | |
|
|
3285 | if (x == NIL) |
|
|
3286 | { |
|
|
3287 | printf ("%*sNIL\n", indent, ""); |
|
|
3288 | return 3; |
|
|
3289 | } |
|
|
3290 | |
|
|
3291 | switch (type (x)) |
|
|
3292 | { |
|
|
3293 | case T_INTEGER: |
|
|
3294 | printf ("%*sI<%d>%p\n", indent, "", (int)ivalue_unchecked (x), x); |
|
|
3295 | return 32+8; |
|
|
3296 | |
|
|
3297 | case T_SYMBOL: |
|
|
3298 | printf ("%*sS<%s>\n", indent, "", symname (x)); |
|
|
3299 | return 24+8; |
|
|
3300 | |
|
|
3301 | case T_CLOSURE: |
|
|
3302 | printf ("%*sS<%s>\n", indent, "", "closure"); |
|
|
3303 | debug (SCHEME_A_ indent + 3, cdr(x)); |
|
|
3304 | return 32 + debug (SCHEME_A_ indent + 3, car (x)); |
|
|
3305 | |
|
|
3306 | case T_PAIR: |
|
|
3307 | printf ("%*spair %p %p\n", indent, "", car(x),cdr(x)); |
|
|
3308 | c = debug (SCHEME_A_ indent + 3, car (x)); |
|
|
3309 | c += debug (SCHEME_A_ indent + 3, cdr (x)); |
|
|
3310 | return c + 1; |
|
|
3311 | |
|
|
3312 | case T_PORT: |
|
|
3313 | printf ("%*sS<%s>\n", indent, "", "port"); |
|
|
3314 | return 24+8; |
|
|
3315 | |
|
|
3316 | case T_VECTOR: |
|
|
3317 | printf ("%*sS<%s>\n", indent, "", "vector"); |
|
|
3318 | return 24+8; |
|
|
3319 | |
|
|
3320 | case T_ENVIRONMENT: |
|
|
3321 | printf ("%*sS<%s>\n", indent, "", "environment"); |
|
|
3322 | return 0 + debug (SCHEME_A_ indent + 3, car (x)); |
|
|
3323 | |
|
|
3324 | default: |
|
|
3325 | printf ("unhandled type %d\n", type (x)); |
|
|
3326 | break; |
|
|
3327 | } |
|
|
3328 | } |
|
|
3329 | #endif |
|
|
3330 | |
3244 | static int |
3331 | static int |
3245 | opexe_0 (SCHEME_P_ enum scheme_opcodes op) |
3332 | opexe_0 (SCHEME_P_ enum scheme_opcodes op) |
3246 | { |
3333 | { |
3247 | pointer args = SCHEME_V->args; |
3334 | pointer args = SCHEME_V->args; |
3248 | pointer x, y; |
3335 | pointer x, y; |
3249 | |
3336 | |
3250 | switch (op) |
3337 | switch (op) |
3251 | { |
3338 | { |
|
|
3339 | #if EXPERIMENT //D |
|
|
3340 | case OP_DEBUG: |
|
|
3341 | printf ("len = %d\n", debug (SCHEME_A_ 0, args) / 8); |
|
|
3342 | printf ("\n"); |
|
|
3343 | s_return (S_T); |
|
|
3344 | #endif |
3252 | case OP_LOAD: /* load */ |
3345 | case OP_LOAD: /* load */ |
3253 | if (file_interactive (SCHEME_A)) |
3346 | if (file_interactive (SCHEME_A)) |
3254 | { |
3347 | { |
3255 | xwrstr ("Loading "); xwrstr (strvalue (car (args))); xwrstr ("\n"); |
3348 | xwrstr ("Loading "); xwrstr (strvalue (car (args))); xwrstr ("\n"); |
3256 | //D fprintf (SCHEME_V->outport->object.port->rep.stdio.file, "Loading %s\n", strvalue (car (args))); |
3349 | //D fprintf (port (SCHEME_V->outport)->rep.stdio.file, "Loading %s\n", strvalue (car (args))); |
3257 | } |
3350 | } |
3258 | |
3351 | |
3259 | if (!file_push (SCHEME_A_ strvalue (car (args)))) |
3352 | if (!file_push (SCHEME_A_ strvalue (car (args)))) |
3260 | Error_1 ("unable to open", car (args)); |
3353 | Error_1 ("unable to open", car (args)); |
3261 | else |
3354 | else |
… | |
… | |
3265 | } |
3358 | } |
3266 | |
3359 | |
3267 | case OP_T0LVL: /* top level */ |
3360 | case OP_T0LVL: /* top level */ |
3268 | |
3361 | |
3269 | /* If we reached the end of file, this loop is done. */ |
3362 | /* If we reached the end of file, this loop is done. */ |
3270 | if (SCHEME_V->loadport->object.port->kind & port_saw_EOF) |
3363 | if (port (SCHEME_V->loadport)->kind & port_saw_EOF) |
3271 | { |
3364 | { |
3272 | if (SCHEME_V->file_i == 0) |
3365 | if (SCHEME_V->file_i == 0) |
3273 | { |
3366 | { |
3274 | SCHEME_V->args = NIL; |
3367 | SCHEME_V->args = NIL; |
3275 | s_goto (OP_QUIT); |
3368 | s_goto (OP_QUIT); |
… | |
… | |
3353 | #endif |
3446 | #endif |
3354 | if (is_symbol (SCHEME_V->code)) /* symbol */ |
3447 | if (is_symbol (SCHEME_V->code)) /* symbol */ |
3355 | { |
3448 | { |
3356 | x = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->code, 1); |
3449 | x = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->code, 1); |
3357 | |
3450 | |
3358 | if (x != NIL) |
3451 | if (x == NIL) |
3359 | s_return (slot_value_in_env (x)); |
|
|
3360 | else |
|
|
3361 | Error_1 ("eval: unbound variable:", SCHEME_V->code); |
3452 | Error_1 ("eval: unbound variable:", SCHEME_V->code); |
|
|
3453 | |
|
|
3454 | s_return (slot_value_in_env (x)); |
3362 | } |
3455 | } |
3363 | else if (is_pair (SCHEME_V->code)) |
3456 | else if (is_pair (SCHEME_V->code)) |
3364 | { |
3457 | { |
3365 | x = car (SCHEME_V->code); |
3458 | x = car (SCHEME_V->code); |
3366 | |
3459 | |
… | |
… | |
3379 | } |
3472 | } |
3380 | else |
3473 | else |
3381 | s_return (SCHEME_V->code); |
3474 | s_return (SCHEME_V->code); |
3382 | |
3475 | |
3383 | case OP_E0ARGS: /* eval arguments */ |
3476 | case OP_E0ARGS: /* eval arguments */ |
3384 | if (is_macro (SCHEME_V->value)) /* macro expansion */ |
3477 | if (ecb_expect_false (is_macro (SCHEME_V->value))) /* macro expansion */ |
3385 | { |
3478 | { |
3386 | s_save (SCHEME_A_ OP_DOMACRO, NIL, NIL); |
3479 | s_save (SCHEME_A_ OP_DOMACRO, NIL, NIL); |
3387 | SCHEME_V->args = cons (SCHEME_V->code, NIL); |
3480 | SCHEME_V->args = cons (SCHEME_V->code, NIL); |
3388 | SCHEME_V->code = SCHEME_V->value; |
3481 | SCHEME_V->code = SCHEME_V->value; |
3389 | s_goto (OP_APPLY); |
3482 | s_goto (OP_APPLY); |
… | |
… | |
3443 | s_goto (procnum (SCHEME_V->code)); /* PROCEDURE */ |
3536 | s_goto (procnum (SCHEME_V->code)); /* PROCEDURE */ |
3444 | else if (is_foreign (SCHEME_V->code)) |
3537 | else if (is_foreign (SCHEME_V->code)) |
3445 | { |
3538 | { |
3446 | /* Keep nested calls from GC'ing the arglist */ |
3539 | /* Keep nested calls from GC'ing the arglist */ |
3447 | push_recent_alloc (SCHEME_A_ args, NIL); |
3540 | push_recent_alloc (SCHEME_A_ args, NIL); |
3448 | x = SCHEME_V->code->object.ff (SCHEME_A_ args); |
3541 | x = CELL(SCHEME_V->code)->object.ff (SCHEME_A_ args); |
3449 | |
3542 | |
3450 | s_return (x); |
3543 | s_return (x); |
3451 | } |
3544 | } |
3452 | else if (is_closure (SCHEME_V->code) || is_macro (SCHEME_V->code) || is_promise (SCHEME_V->code)) /* CLOSURE */ |
3545 | else if (is_closure (SCHEME_V->code) || is_macro (SCHEME_V->code) || is_promise (SCHEME_V->code)) /* CLOSURE */ |
3453 | { |
3546 | { |
… | |
… | |
3490 | |
3583 | |
3491 | case OP_DOMACRO: /* do macro */ |
3584 | case OP_DOMACRO: /* do macro */ |
3492 | SCHEME_V->code = SCHEME_V->value; |
3585 | SCHEME_V->code = SCHEME_V->value; |
3493 | s_goto (OP_EVAL); |
3586 | s_goto (OP_EVAL); |
3494 | |
3587 | |
3495 | #if 1 |
|
|
3496 | |
|
|
3497 | case OP_LAMBDA: /* lambda */ |
3588 | case OP_LAMBDA: /* lambda */ |
3498 | /* If the hook is defined, apply it to SCHEME_V->code, otherwise |
3589 | /* If the hook is defined, apply it to SCHEME_V->code, otherwise |
3499 | set SCHEME_V->value fall thru */ |
3590 | set SCHEME_V->value fall thru */ |
3500 | { |
3591 | { |
3501 | pointer f = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->COMPILE_HOOK, 1); |
3592 | pointer f = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->COMPILE_HOOK, 1); |
… | |
… | |
3507 | SCHEME_V->code = slot_value_in_env (f); |
3598 | SCHEME_V->code = slot_value_in_env (f); |
3508 | s_goto (OP_APPLY); |
3599 | s_goto (OP_APPLY); |
3509 | } |
3600 | } |
3510 | |
3601 | |
3511 | SCHEME_V->value = SCHEME_V->code; |
3602 | SCHEME_V->value = SCHEME_V->code; |
3512 | /* Fallthru */ |
|
|
3513 | } |
3603 | } |
|
|
3604 | /* Fallthru */ |
3514 | |
3605 | |
3515 | case OP_LAMBDA1: |
3606 | case OP_LAMBDA1: |
3516 | s_return (mk_closure (SCHEME_A_ SCHEME_V->value, SCHEME_V->envir)); |
3607 | s_return (mk_closure (SCHEME_A_ SCHEME_V->value, SCHEME_V->envir)); |
3517 | |
|
|
3518 | #else |
|
|
3519 | |
|
|
3520 | case OP_LAMBDA: /* lambda */ |
|
|
3521 | s_return (mk_closure (SCHEME_A_ SCHEME_V->code, SCHEME_V->envir)); |
|
|
3522 | |
|
|
3523 | #endif |
|
|
3524 | |
3608 | |
3525 | case OP_MKCLOSURE: /* make-closure */ |
3609 | case OP_MKCLOSURE: /* make-closure */ |
3526 | x = car (args); |
3610 | x = car (args); |
3527 | |
3611 | |
3528 | if (car (x) == SCHEME_V->LAMBDA) |
3612 | if (car (x) == SCHEME_V->LAMBDA) |
… | |
… | |
4124 | else |
4208 | else |
4125 | Error_0 ("modulo: division by zero"); |
4209 | Error_0 ("modulo: division by zero"); |
4126 | |
4210 | |
4127 | s_return (mk_number (SCHEME_A_ v)); |
4211 | s_return (mk_number (SCHEME_A_ v)); |
4128 | |
4212 | |
4129 | case OP_CAR: /* car */ |
4213 | /* the compiler will optimize this mess... */ |
4130 | s_return (caar (args)); |
4214 | case OP_CAR: op_car: s_return (car (x)); |
4131 | |
4215 | case OP_CDR: op_cdr: s_return (cdr (x)); |
4132 | case OP_CDR: /* cdr */ |
4216 | case OP_CAAR: op_caar: x = car (x); goto op_car; |
4133 | s_return (cdar (args)); |
4217 | case OP_CADR: op_cadr: x = cdr (x); goto op_car; |
|
|
4218 | case OP_CDAR: op_cdar: x = car (x); goto op_cdr; |
|
|
4219 | case OP_CDDR: op_cddr: x = cdr (x); goto op_cdr; |
|
|
4220 | case OP_CAAAR: op_caaar: x = car (x); goto op_caar; |
|
|
4221 | case OP_CAADR: op_caadr: x = cdr (x); goto op_caar; |
|
|
4222 | case OP_CADAR: op_cadar: x = car (x); goto op_cadr; |
|
|
4223 | case OP_CADDR: op_caddr: x = cdr (x); goto op_cadr; |
|
|
4224 | case OP_CDAAR: op_cdaar: x = car (x); goto op_cdar; |
|
|
4225 | case OP_CDADR: op_cdadr: x = cdr (x); goto op_cdar; |
|
|
4226 | case OP_CDDAR: op_cddar: x = car (x); goto op_cddr; |
|
|
4227 | case OP_CDDDR: op_cdddr: x = cdr (x); goto op_cddr; |
|
|
4228 | case OP_CAAAAR: x = car (x); goto op_caaar; |
|
|
4229 | case OP_CAAADR: x = cdr (x); goto op_caaar; |
|
|
4230 | case OP_CAADAR: x = car (x); goto op_caadr; |
|
|
4231 | case OP_CAADDR: x = cdr (x); goto op_caadr; |
|
|
4232 | case OP_CADAAR: x = car (x); goto op_cadar; |
|
|
4233 | case OP_CADADR: x = cdr (x); goto op_cadar; |
|
|
4234 | case OP_CADDAR: x = car (x); goto op_caddr; |
|
|
4235 | case OP_CADDDR: x = cdr (x); goto op_caddr; |
|
|
4236 | case OP_CDAAAR: x = car (x); goto op_cdaar; |
|
|
4237 | case OP_CDAADR: x = cdr (x); goto op_cdaar; |
|
|
4238 | case OP_CDADAR: x = car (x); goto op_cdadr; |
|
|
4239 | case OP_CDADDR: x = cdr (x); goto op_cdadr; |
|
|
4240 | case OP_CDDAAR: x = car (x); goto op_cddar; |
|
|
4241 | case OP_CDDADR: x = cdr (x); goto op_cddar; |
|
|
4242 | case OP_CDDDAR: x = car (x); goto op_cdddr; |
|
|
4243 | case OP_CDDDDR: x = cdr (x); goto op_cdddr; |
4134 | |
4244 | |
4135 | case OP_CONS: /* cons */ |
4245 | case OP_CONS: /* cons */ |
4136 | set_cdr (args, cadr (args)); |
4246 | set_cdr (args, cadr (args)); |
4137 | s_return (args); |
4247 | s_return (args); |
4138 | |
4248 | |
… | |
… | |
4387 | } |
4497 | } |
4388 | |
4498 | |
4389 | case OP_VECLEN: /* vector-length */ |
4499 | case OP_VECLEN: /* vector-length */ |
4390 | s_return (mk_integer (SCHEME_A_ veclength (x))); |
4500 | s_return (mk_integer (SCHEME_A_ veclength (x))); |
4391 | |
4501 | |
|
|
4502 | case OP_VECRESIZE: |
|
|
4503 | vector_resize (x, ivalue_unchecked (cadr (args)), caddr (args)); |
|
|
4504 | s_return (x); |
|
|
4505 | |
4392 | case OP_VECREF: /* vector-ref */ |
4506 | case OP_VECREF: /* vector-ref */ |
4393 | { |
4507 | { |
4394 | int index = ivalue_unchecked (cadr (args)); |
4508 | int index = ivalue_unchecked (cadr (args)); |
4395 | |
4509 | |
4396 | if (index >= veclength (car (args)) && USE_ERROR_CHECKING) |
4510 | if (index >= veclength (car (args)) && USE_ERROR_CHECKING) |
… | |
… | |
4456 | pointer d = cdr (args); |
4570 | pointer d = cdr (args); |
4457 | int r; |
4571 | int r; |
4458 | |
4572 | |
4459 | switch (op) |
4573 | switch (op) |
4460 | { |
4574 | { |
4461 | case OP_NOT: /* not */ r = is_false (a) ; break; |
4575 | case OP_NOT: /* not */ r = is_false (a) ; break; |
4462 | case OP_BOOLP: /* boolean? */ r = a == S_F || a == S_T; break; |
4576 | case OP_BOOLP: /* boolean? */ r = a == S_F || a == S_T ; break; |
4463 | case OP_EOFOBJP: /* eof-object? */ r = a == S_EOF ; break; |
4577 | case OP_EOFOBJP: /* eof-object? */ r = a == S_EOF ; break; |
4464 | case OP_NULLP: /* null? */ r = a == NIL ; break; |
4578 | case OP_NULLP: /* null? */ r = a == NIL ; break; |
4465 | case OP_SYMBOLP: /* symbol? */ r = is_symbol (a) ; break; |
4579 | case OP_SYMBOLP: /* symbol? */ r = is_symbol (a) ; break; |
|
|
4580 | case OP_GENSYMP: /* gensym? */ r = is_gensym (SCHEME_A_ a); break; |
4466 | case OP_NUMBERP: /* number? */ r = is_number (a) ; break; |
4581 | case OP_NUMBERP: /* number? */ r = is_number (a) ; break; |
4467 | case OP_STRINGP: /* string? */ r = is_string (a) ; break; |
4582 | case OP_STRINGP: /* string? */ r = is_string (a) ; break; |
4468 | case OP_INTEGERP: /* integer? */ r = is_integer (a) ; break; |
4583 | case OP_INTEGERP: /* integer? */ r = is_integer (a) ; break; |
4469 | case OP_REALP: /* real? */ r = is_number (a) ; break; /* all numbers are real */ |
4584 | case OP_REALP: /* real? */ r = is_number (a) ; break; /* all numbers are real */ |
4470 | case OP_CHARP: /* char? */ r = is_character (a) ; break; |
4585 | case OP_CHARP: /* char? */ r = is_character (a) ; break; |
4471 | |
4586 | |
4472 | #if USE_CHAR_CLASSIFIERS |
4587 | #if USE_CHAR_CLASSIFIERS |
4473 | case OP_CHARAP: /* char-alphabetic? */ r = Cisalpha (ivalue_unchecked (a)); break; |
4588 | case OP_CHARAP: /* char-alphabetic? */ r = Cisalpha (ivalue_unchecked (a)); break; |
4474 | case OP_CHARNP: /* char-numeric? */ r = Cisdigit (ivalue_unchecked (a)); break; |
4589 | case OP_CHARNP: /* char-numeric? */ r = Cisdigit (ivalue_unchecked (a)); break; |
4475 | case OP_CHARWP: /* char-whitespace? */ r = Cisspace (ivalue_unchecked (a)); break; |
4590 | case OP_CHARWP: /* char-whitespace? */ r = Cisspace (ivalue_unchecked (a)); break; |
… | |
… | |
4525 | } |
4640 | } |
4526 | else |
4641 | else |
4527 | s_return (SCHEME_V->code); |
4642 | s_return (SCHEME_V->code); |
4528 | |
4643 | |
4529 | case OP_SAVE_FORCED: /* Save forced value replacing promise */ |
4644 | case OP_SAVE_FORCED: /* Save forced value replacing promise */ |
4530 | memcpy (SCHEME_V->code, SCHEME_V->value, sizeof (struct cell)); |
4645 | *CELL (SCHEME_V->code) = *CELL (SCHEME_V->value); |
4531 | s_return (SCHEME_V->value); |
4646 | s_return (SCHEME_V->value); |
4532 | |
4647 | |
4533 | #if USE_PORTS |
4648 | #if USE_PORTS |
4534 | |
4649 | |
4535 | case OP_WRITE: /* write */ |
4650 | case OP_WRITE: /* write */ |
… | |
… | |
4680 | SCHEME_V->gc_verbose = (a != S_F); |
4795 | SCHEME_V->gc_verbose = (a != S_F); |
4681 | s_retbool (was); |
4796 | s_retbool (was); |
4682 | } |
4797 | } |
4683 | |
4798 | |
4684 | case OP_NEWSEGMENT: /* new-segment */ |
4799 | case OP_NEWSEGMENT: /* new-segment */ |
|
|
4800 | #if 0 |
4685 | if (!is_pair (args) || !is_number (a)) |
4801 | if (!is_pair (args) || !is_number (a)) |
4686 | Error_0 ("new-segment: argument must be a number"); |
4802 | Error_0 ("new-segment: argument must be a number"); |
4687 | |
4803 | #endif |
4688 | alloc_cellseg (SCHEME_A_ ivalue (a)); |
4804 | s_retbool (alloc_cellseg (SCHEME_A)); |
4689 | |
|
|
4690 | s_return (S_T); |
|
|
4691 | |
4805 | |
4692 | case OP_OBLIST: /* oblist */ |
4806 | case OP_OBLIST: /* oblist */ |
4693 | s_return (oblist_all_symbols (SCHEME_A)); |
4807 | s_return (oblist_all_symbols (SCHEME_A)); |
4694 | |
4808 | |
4695 | #if USE_PORTS |
4809 | #if USE_PORTS |
… | |
… | |
4765 | s_return (p == NIL ? S_F : p); |
4879 | s_return (p == NIL ? S_F : p); |
4766 | } |
4880 | } |
4767 | |
4881 | |
4768 | case OP_GET_OUTSTRING: /* get-output-string */ |
4882 | case OP_GET_OUTSTRING: /* get-output-string */ |
4769 | { |
4883 | { |
4770 | port *p; |
4884 | port *p = port (a); |
4771 | |
4885 | |
4772 | if ((p = a->object.port)->kind & port_string) |
4886 | if (p->kind & port_string) |
4773 | { |
4887 | { |
4774 | off_t size; |
4888 | off_t size; |
4775 | char *str; |
4889 | char *str; |
4776 | |
4890 | |
4777 | size = p->rep.string.curr - p->rep.string.start + 1; |
4891 | size = p->rep.string.curr - p->rep.string.start + 1; |
… | |
… | |
4882 | int res; |
4996 | int res; |
4883 | |
4997 | |
4884 | if (is_pair (args)) |
4998 | if (is_pair (args)) |
4885 | p = car (args); |
4999 | p = car (args); |
4886 | |
5000 | |
4887 | res = p->object.port->kind & port_string; |
5001 | res = port (p)->kind & port_string; |
4888 | |
5002 | |
4889 | s_retbool (res); |
5003 | s_retbool (res); |
4890 | } |
5004 | } |
4891 | |
5005 | |
4892 | case OP_SET_INPORT: /* set-input-port */ |
5006 | case OP_SET_INPORT: /* set-input-port */ |
… | |
… | |
4951 | s_save (SCHEME_A_ OP_RDUQTSP, NIL, NIL); |
5065 | s_save (SCHEME_A_ OP_RDUQTSP, NIL, NIL); |
4952 | SCHEME_V->tok = token (SCHEME_A); |
5066 | SCHEME_V->tok = token (SCHEME_A); |
4953 | s_goto (OP_RDSEXPR); |
5067 | s_goto (OP_RDSEXPR); |
4954 | |
5068 | |
4955 | case TOK_ATOM: |
5069 | case TOK_ATOM: |
4956 | s_return (mk_atom (SCHEME_A_ readstr_upto (SCHEME_A_ DELIMITERS))); |
5070 | s_return (mk_atom (SCHEME_A_ readstr_upto (SCHEME_A_ 0, DELIMITERS))); |
|
|
5071 | |
|
|
5072 | case TOK_DOTATOM: |
|
|
5073 | SCHEME_V->strbuff[0] = '.'; |
|
|
5074 | s_return (mk_atom (SCHEME_A_ readstr_upto (SCHEME_A_ 1, DELIMITERS))); |
|
|
5075 | |
|
|
5076 | case TOK_STRATOM: |
|
|
5077 | x = readstrexp (SCHEME_A_ '|'); |
|
|
5078 | //TODO: haven't checked whether the garbage collector could interfere |
|
|
5079 | s_return (mk_atom (SCHEME_A_ strvalue (x))); |
4957 | |
5080 | |
4958 | case TOK_DQUOTE: |
5081 | case TOK_DQUOTE: |
4959 | x = readstrexp (SCHEME_A); |
5082 | x = readstrexp (SCHEME_A_ '"'); |
4960 | |
5083 | |
4961 | if (x == S_F) |
5084 | if (x == S_F) |
4962 | Error_0 ("Error reading string"); |
5085 | Error_0 ("Error reading string"); |
4963 | |
5086 | |
4964 | setimmutable (x); |
5087 | setimmutable (x); |
… | |
… | |
4976 | s_goto (OP_EVAL); |
5099 | s_goto (OP_EVAL); |
4977 | } |
5100 | } |
4978 | } |
5101 | } |
4979 | |
5102 | |
4980 | case TOK_SHARP_CONST: |
5103 | case TOK_SHARP_CONST: |
4981 | if ((x = mk_sharp_const (SCHEME_A_ readstr_upto (SCHEME_A_ DELIMITERS))) == NIL) |
5104 | if ((x = mk_sharp_const (SCHEME_A_ readstr_upto (SCHEME_A_ 0, DELIMITERS))) == NIL) |
4982 | Error_0 ("undefined sharp expression"); |
5105 | Error_0 ("undefined sharp expression"); |
4983 | else |
5106 | else |
4984 | s_return (x); |
5107 | s_return (x); |
4985 | |
5108 | |
4986 | default: |
5109 | default: |
… | |
… | |
5208 | |
5331 | |
5209 | case OP_CLOSUREP: /* closure? */ |
5332 | case OP_CLOSUREP: /* closure? */ |
5210 | /* |
5333 | /* |
5211 | * Note, macro object is also a closure. |
5334 | * Note, macro object is also a closure. |
5212 | * Therefore, (closure? <#MACRO>) ==> #t |
5335 | * Therefore, (closure? <#MACRO>) ==> #t |
|
|
5336 | * (schmorp) well, obviously not, fix? TODO |
5213 | */ |
5337 | */ |
5214 | s_retbool (is_closure (a)); |
5338 | s_retbool (is_closure (a)); |
5215 | |
5339 | |
5216 | case OP_MACROP: /* macro? */ |
5340 | case OP_MACROP: /* macro? */ |
5217 | s_retbool (is_macro (a)); |
5341 | s_retbool (is_macro (a)); |
… | |
… | |
5458 | |
5582 | |
5459 | /* Hard-coded for the given keywords. Remember to rewrite if more are added! */ |
5583 | /* Hard-coded for the given keywords. Remember to rewrite if more are added! */ |
5460 | static int |
5584 | static int |
5461 | syntaxnum (pointer p) |
5585 | syntaxnum (pointer p) |
5462 | { |
5586 | { |
5463 | const char *s = strvalue (car (p)); |
5587 | const char *s = strvalue (p); |
5464 | |
5588 | |
5465 | switch (strlength (car (p))) |
5589 | switch (strlength (p)) |
5466 | { |
5590 | { |
5467 | case 2: |
5591 | case 2: |
5468 | if (s[0] == 'i') |
5592 | if (s[0] == 'i') |
5469 | return OP_IF0; /* if */ |
5593 | return OP_IF0; /* if */ |
5470 | else |
5594 | else |
… | |
… | |
5545 | ecb_cold int |
5669 | ecb_cold int |
5546 | scheme_init (SCHEME_P) |
5670 | scheme_init (SCHEME_P) |
5547 | { |
5671 | { |
5548 | int i, n = sizeof (dispatch_table) / sizeof (dispatch_table[0]); |
5672 | int i, n = sizeof (dispatch_table) / sizeof (dispatch_table[0]); |
5549 | pointer x; |
5673 | pointer x; |
|
|
5674 | |
|
|
5675 | /* this memset is not strictly correct, as we assume (intcache) |
|
|
5676 | * that memset 0 will also set pointers to 0, but memset does |
|
|
5677 | * of course not guarantee that. screw such systems. |
|
|
5678 | */ |
|
|
5679 | memset (SCHEME_V, 0, sizeof (*SCHEME_V)); |
5550 | |
5680 | |
5551 | num_set_fixnum (num_zero, 1); |
5681 | num_set_fixnum (num_zero, 1); |
5552 | num_set_ivalue (num_zero, 0); |
5682 | num_set_ivalue (num_zero, 0); |
5553 | num_set_fixnum (num_one, 1); |
5683 | num_set_fixnum (num_one, 1); |
5554 | num_set_ivalue (num_one, 1); |
5684 | num_set_ivalue (num_one, 1); |
… | |
… | |
5566 | SCHEME_V->save_inport = NIL; |
5696 | SCHEME_V->save_inport = NIL; |
5567 | SCHEME_V->loadport = NIL; |
5697 | SCHEME_V->loadport = NIL; |
5568 | SCHEME_V->nesting = 0; |
5698 | SCHEME_V->nesting = 0; |
5569 | SCHEME_V->interactive_repl = 0; |
5699 | SCHEME_V->interactive_repl = 0; |
5570 | |
5700 | |
5571 | if (alloc_cellseg (SCHEME_A_ FIRST_CELLSEGS) != FIRST_CELLSEGS) |
5701 | if (!alloc_cellseg (SCHEME_A)) |
5572 | { |
5702 | { |
5573 | #if USE_ERROR_CHECKING |
5703 | #if USE_ERROR_CHECKING |
5574 | SCHEME_V->no_memory = 1; |
5704 | SCHEME_V->no_memory = 1; |
5575 | return 0; |
5705 | return 0; |
5576 | #endif |
5706 | #endif |
… | |
… | |
5906 | # endif |
6036 | # endif |
5907 | int fin; |
6037 | int fin; |
5908 | char *file_name = InitFile; |
6038 | char *file_name = InitFile; |
5909 | int retcode; |
6039 | int retcode; |
5910 | int isfile = 1; |
6040 | int isfile = 1; |
|
|
6041 | system ("ps v $PPID");//D |
5911 | |
6042 | |
5912 | if (argc == 2 && strcmp (argv[1], "-?") == 0) |
6043 | if (argc == 2 && strcmp (argv[1], "-?") == 0) |
5913 | { |
6044 | { |
5914 | xwrstr ("Usage: tinyscheme -?\n"); |
6045 | xwrstr ("Usage: tinyscheme -?\n"); |
5915 | xwrstr ("or: tinyscheme [<file1> <file2> ...]\n"); |
6046 | xwrstr ("or: tinyscheme [<file1> <file2> ...]\n"); |