… | |
… | |
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> |
… | |
… | |
77 | |
81 | |
78 | #define BACKQUOTE '`' |
82 | #define BACKQUOTE '`' |
79 | #define WHITESPACE " \t\r\n\v\f" |
83 | #define WHITESPACE " \t\r\n\v\f" |
80 | #define DELIMITERS "()\";" WHITESPACE |
84 | #define DELIMITERS "()\";" WHITESPACE |
81 | |
85 | |
82 | #define NIL (&SCHEME_V->xNIL) //TODO: make this 0? |
86 | #define NIL POINTER (&SCHEME_V->xNIL) |
83 | #define S_T (&SCHEME_V->xT) //TODO: magic ptr value? |
87 | #define S_T POINTER (&SCHEME_V->xT) |
84 | #define S_F (&SCHEME_V->xF) //TODO: magic ptr value? |
88 | #define S_F POINTER (&SCHEME_V->xF) |
85 | #define S_SINK (&SCHEME_V->xsink) |
89 | #define S_SINK POINTER (&SCHEME_V->xsink) |
86 | #define S_EOF (&SCHEME_V->xEOF_OBJ) |
90 | #define S_EOF POINTER (&SCHEME_V->xEOF_OBJ) |
87 | |
91 | |
88 | #if !USE_MULTIPLICITY |
92 | #if !USE_MULTIPLICITY |
89 | static scheme sc; |
93 | static scheme sc; |
90 | #endif |
94 | #endif |
91 | |
95 | |
… | |
… | |
99 | } |
103 | } |
100 | |
104 | |
101 | char *p = s; |
105 | char *p = s; |
102 | |
106 | |
103 | do { |
107 | do { |
104 | *p++ = '0' + n % base; |
108 | *p++ = "0123456789abcdef"[n % base]; |
105 | n /= base; |
109 | n /= base; |
106 | } while (n); |
110 | } while (n); |
107 | |
111 | |
108 | *p-- = 0; |
112 | *p-- = 0; |
109 | |
113 | |
… | |
… | |
119 | { |
123 | { |
120 | xbase (s, n, 10); |
124 | xbase (s, n, 10); |
121 | } |
125 | } |
122 | |
126 | |
123 | static void |
127 | static void |
124 | xwrstr (const char *s) |
128 | putnum (SCHEME_P_ long n) |
125 | { |
|
|
126 | write (1, s, strlen (s)); |
|
|
127 | } |
|
|
128 | |
|
|
129 | static void |
|
|
130 | xwrnum (long n) |
|
|
131 | { |
129 | { |
132 | char buf[64]; |
130 | char buf[64]; |
133 | |
131 | |
134 | xnum (buf, n); |
132 | xnum (buf, n); |
135 | xwrstr (buf); |
133 | putstr (SCHEME_A_ buf); |
136 | } |
134 | } |
137 | |
135 | |
138 | static char |
136 | static char |
139 | xtoupper (char c) |
137 | xtoupper (char c) |
140 | { |
138 | { |
… | |
… | |
190 | # define prompt "ts> " |
188 | # define prompt "ts> " |
191 | #endif |
189 | #endif |
192 | |
190 | |
193 | #ifndef InitFile |
191 | #ifndef InitFile |
194 | # define InitFile "init.scm" |
192 | # define InitFile "init.scm" |
195 | #endif |
|
|
196 | |
|
|
197 | #ifndef FIRST_CELLSEGS |
|
|
198 | # define FIRST_CELLSEGS 3 |
|
|
199 | #endif |
193 | #endif |
200 | |
194 | |
201 | enum scheme_types |
195 | enum scheme_types |
202 | { |
196 | { |
203 | T_INTEGER, |
197 | T_INTEGER, |
… | |
… | |
264 | static int is_zero_rvalue (RVALUE x); |
258 | static int is_zero_rvalue (RVALUE x); |
265 | |
259 | |
266 | static num num_zero; |
260 | static num num_zero; |
267 | static num num_one; |
261 | static num num_one; |
268 | |
262 | |
|
|
263 | /* convert "pointer" to cell* / cell* to pointer */ |
|
|
264 | #define CELL(p) ((struct cell *)(p) + 0) |
|
|
265 | #define POINTER(c) ((void *)((c) - 0)) |
|
|
266 | |
269 | /* macros for cell operations */ |
267 | /* macros for cell operations */ |
270 | #define typeflag(p) ((p)->flag + 0) |
268 | #define typeflag(p) (CELL(p)->flag + 0) |
271 | #define set_typeflag(p,v) ((p)->flag = (v)) |
269 | #define set_typeflag(p,v) (CELL(p)->flag = (v)) |
272 | #define type(p) (typeflag (p) & T_MASKTYPE) |
270 | #define type(p) (typeflag (p) & T_MASKTYPE) |
273 | |
271 | |
274 | INTERFACE int |
272 | INTERFACE int |
275 | is_string (pointer p) |
273 | is_string (pointer p) |
276 | { |
274 | { |
277 | return type (p) == T_STRING; |
275 | return type (p) == T_STRING; |
278 | } |
276 | } |
279 | |
277 | |
280 | #define strvalue(p) ((p)->object.string.svalue) |
278 | #define strvalue(p) (CELL(p)->object.string.svalue) |
281 | #define strlength(p) ((p)->object.string.length) |
279 | #define strlength(p) (CELL(p)->object.string.length) |
282 | |
280 | |
283 | INTERFACE int |
281 | INTERFACE int |
284 | is_vector (pointer p) |
282 | is_vector (pointer p) |
285 | { |
283 | { |
286 | return type (p) == T_VECTOR; |
284 | return type (p) == T_VECTOR; |
287 | } |
285 | } |
288 | |
286 | |
289 | #define vecvalue(p) ((p)->object.vector.vvalue) |
287 | #define vecvalue(p) (CELL(p)->object.vector.vvalue) |
290 | #define veclength(p) ((p)->object.vector.length) |
288 | #define veclength(p) (CELL(p)->object.vector.length) |
291 | INTERFACE void fill_vector (pointer vec, uint32_t start, pointer obj); |
289 | INTERFACE void fill_vector (pointer vec, uint32_t start, pointer obj); |
292 | INTERFACE pointer vector_get (pointer vec, uint32_t ielem); |
290 | INTERFACE pointer vector_get (pointer vec, uint32_t ielem); |
293 | INTERFACE void vector_set (pointer vec, uint32_t ielem, pointer a); |
291 | INTERFACE void vector_set (pointer vec, uint32_t ielem, pointer a); |
294 | |
292 | |
295 | INTERFACE int |
293 | INTERFACE int |
… | |
… | |
321 | string_value (pointer p) |
319 | string_value (pointer p) |
322 | { |
320 | { |
323 | return strvalue (p); |
321 | return strvalue (p); |
324 | } |
322 | } |
325 | |
323 | |
326 | #define ivalue_unchecked(p) (p)->object.ivalue |
324 | #define ivalue_unchecked(p) CELL(p)->object.ivalue |
327 | #define set_ivalue(p,v) (p)->object.ivalue = (v) |
325 | #define set_ivalue(p,v) CELL(p)->object.ivalue = (v) |
328 | |
326 | |
329 | #if USE_REAL |
327 | #if USE_REAL |
330 | #define rvalue_unchecked(p) (p)->object.rvalue |
328 | #define rvalue_unchecked(p) CELL(p)->object.rvalue |
331 | #define set_rvalue(p,v) (p)->object.rvalue = (v) |
329 | #define set_rvalue(p,v) CELL(p)->object.rvalue = (v) |
332 | #else |
330 | #else |
333 | #define rvalue_unchecked(p) (p)->object.ivalue |
331 | #define rvalue_unchecked(p) CELL(p)->object.ivalue |
334 | #define set_rvalue(p,v) (p)->object.ivalue = (v) |
332 | #define set_rvalue(p,v) CELL(p)->object.ivalue = (v) |
335 | #endif |
333 | #endif |
336 | |
334 | |
337 | INTERFACE long |
335 | INTERFACE long |
338 | charvalue (pointer p) |
336 | charvalue (pointer p) |
339 | { |
337 | { |
340 | return ivalue_unchecked (p); |
338 | return ivalue_unchecked (p); |
341 | } |
339 | } |
342 | |
340 | |
|
|
341 | #define port(p) CELL(p)->object.port |
|
|
342 | #define set_port(p,v) port(p) = (v) |
343 | INTERFACE int |
343 | INTERFACE int |
344 | is_port (pointer p) |
344 | is_port (pointer p) |
345 | { |
345 | { |
346 | return type (p) == T_PORT; |
346 | return type (p) == T_PORT; |
347 | } |
347 | } |
348 | |
348 | |
349 | INTERFACE int |
349 | INTERFACE int |
350 | is_inport (pointer p) |
350 | is_inport (pointer p) |
351 | { |
351 | { |
352 | return is_port (p) && p->object.port->kind & port_input; |
352 | return is_port (p) && port (p)->kind & port_input; |
353 | } |
353 | } |
354 | |
354 | |
355 | INTERFACE int |
355 | INTERFACE int |
356 | is_outport (pointer p) |
356 | is_outport (pointer p) |
357 | { |
357 | { |
358 | return is_port (p) && p->object.port->kind & port_output; |
358 | return is_port (p) && port (p)->kind & port_output; |
359 | } |
359 | } |
360 | |
360 | |
361 | INTERFACE int |
361 | INTERFACE int |
362 | is_pair (pointer p) |
362 | is_pair (pointer p) |
363 | { |
363 | { |
364 | return type (p) == T_PAIR; |
364 | return type (p) == T_PAIR; |
365 | } |
365 | } |
366 | |
366 | |
367 | #define car(p) ((p)->object.cons.car + 0) |
367 | #define car(p) (POINTER (CELL(p)->object.cons.car)) |
368 | #define cdr(p) ((p)->object.cons.cdr + 0) |
368 | #define cdr(p) (POINTER (CELL(p)->object.cons.cdr)) |
369 | |
369 | |
370 | static pointer caar (pointer p) { return car (car (p)); } |
370 | static pointer caar (pointer p) { return car (car (p)); } |
371 | static pointer cadr (pointer p) { return car (cdr (p)); } |
371 | static pointer cadr (pointer p) { return car (cdr (p)); } |
372 | static pointer cdar (pointer p) { return cdr (car (p)); } |
372 | static pointer cdar (pointer p) { return cdr (car (p)); } |
373 | static pointer cddr (pointer p) { return cdr (cdr (p)); } |
373 | static pointer cddr (pointer p) { return cdr (cdr (p)); } |
… | |
… | |
377 | static pointer cdaar (pointer p) { return cdr (car (car (p))); } |
377 | static pointer cdaar (pointer p) { return cdr (car (car (p))); } |
378 | |
378 | |
379 | INTERFACE void |
379 | INTERFACE void |
380 | set_car (pointer p, pointer q) |
380 | set_car (pointer p, pointer q) |
381 | { |
381 | { |
382 | p->object.cons.car = q; |
382 | CELL(p)->object.cons.car = CELL (q); |
383 | } |
383 | } |
384 | |
384 | |
385 | INTERFACE void |
385 | INTERFACE void |
386 | set_cdr (pointer p, pointer q) |
386 | set_cdr (pointer p, pointer q) |
387 | { |
387 | { |
388 | p->object.cons.cdr = q; |
388 | CELL(p)->object.cons.cdr = CELL (q); |
389 | } |
389 | } |
390 | |
390 | |
391 | INTERFACE pointer |
391 | INTERFACE pointer |
392 | pair_car (pointer p) |
392 | pair_car (pointer p) |
393 | { |
393 | { |
… | |
… | |
411 | { |
411 | { |
412 | return strvalue (p); |
412 | return strvalue (p); |
413 | } |
413 | } |
414 | |
414 | |
415 | #if USE_PLIST |
415 | #if USE_PLIST |
|
|
416 | #error plists are broken because symbols are no longer pairs |
|
|
417 | #define symprop(p) cdr(p) |
416 | SCHEME_EXPORT int |
418 | SCHEME_EXPORT int |
417 | hasprop (pointer p) |
419 | hasprop (pointer p) |
418 | { |
420 | { |
419 | return typeflag (p) & T_SYMBOL; |
421 | return typeflag (p) & T_SYMBOL; |
420 | } |
422 | } |
421 | |
|
|
422 | # define symprop(p) cdr(p) |
|
|
423 | #endif |
423 | #endif |
424 | |
424 | |
425 | INTERFACE int |
425 | INTERFACE int |
426 | is_syntax (pointer p) |
426 | is_syntax (pointer p) |
427 | { |
427 | { |
… | |
… | |
668 | |
668 | |
669 | static int file_push (SCHEME_P_ const char *fname); |
669 | static int file_push (SCHEME_P_ const char *fname); |
670 | static void file_pop (SCHEME_P); |
670 | static void file_pop (SCHEME_P); |
671 | static int file_interactive (SCHEME_P); |
671 | static int file_interactive (SCHEME_P); |
672 | ecb_inline int is_one_of (const char *s, int c); |
672 | ecb_inline int is_one_of (const char *s, int c); |
673 | static int alloc_cellseg (SCHEME_P_ int n); |
673 | static int alloc_cellseg (SCHEME_P); |
674 | ecb_inline pointer get_cell (SCHEME_P_ pointer a, pointer b); |
674 | ecb_inline pointer get_cell (SCHEME_P_ pointer a, pointer b); |
675 | static void finalize_cell (SCHEME_P_ pointer a); |
675 | static void finalize_cell (SCHEME_P_ pointer a); |
676 | static int count_consecutive_cells (pointer x, int needed); |
676 | static int count_consecutive_cells (pointer x, int needed); |
677 | static pointer find_slot_in_env (SCHEME_P_ pointer env, pointer sym, int all); |
677 | static pointer find_slot_in_env (SCHEME_P_ pointer env, pointer sym, int all); |
678 | static pointer mk_number (SCHEME_P_ const num n); |
678 | static pointer mk_number (SCHEME_P_ const num n); |
… | |
… | |
912 | #endif |
912 | #endif |
913 | } |
913 | } |
914 | |
914 | |
915 | /* allocate new cell segment */ |
915 | /* allocate new cell segment */ |
916 | static int |
916 | static int |
917 | alloc_cellseg (SCHEME_P_ int n) |
917 | alloc_cellseg (SCHEME_P) |
918 | { |
918 | { |
919 | pointer newp; |
919 | struct cell *newp; |
920 | pointer last; |
920 | struct cell *last; |
921 | pointer p; |
921 | struct cell *p; |
922 | char *cp; |
922 | char *cp; |
923 | long i; |
923 | long i; |
924 | int k; |
924 | int k; |
925 | |
925 | |
926 | static int segsize = CELL_SEGSIZE >> 1; |
926 | static int segsize = CELL_SEGSIZE >> 1; |
927 | segsize <<= 1; |
927 | segsize <<= 1; |
928 | |
928 | |
929 | for (k = 0; k < n; k++) |
|
|
930 | { |
|
|
931 | if (SCHEME_V->last_cell_seg >= CELL_NSEGMENT - 1) |
|
|
932 | return k; |
|
|
933 | |
|
|
934 | cp = malloc (segsize * sizeof (struct cell)); |
929 | cp = malloc (segsize * sizeof (struct cell)); |
935 | |
930 | |
936 | if (!cp && USE_ERROR_CHECKING) |
931 | if (!cp && USE_ERROR_CHECKING) |
937 | return k; |
932 | return k; |
938 | |
933 | |
939 | i = ++SCHEME_V->last_cell_seg; |
934 | i = ++SCHEME_V->last_cell_seg; |
940 | SCHEME_V->alloc_seg[i] = cp; |
935 | SCHEME_V->alloc_seg[i] = cp; |
941 | |
936 | |
942 | newp = (pointer)cp; |
937 | newp = (struct cell *)cp; |
943 | SCHEME_V->cell_seg[i] = newp; |
938 | SCHEME_V->cell_seg[i] = newp; |
944 | SCHEME_V->cell_segsize[i] = segsize; |
939 | SCHEME_V->cell_segsize[i] = segsize; |
945 | SCHEME_V->fcells += segsize; |
940 | SCHEME_V->fcells += segsize; |
946 | last = newp + segsize - 1; |
941 | last = newp + segsize - 1; |
947 | |
942 | |
948 | for (p = newp; p <= last; p++) |
943 | for (p = newp; p <= last; p++) |
949 | { |
944 | { |
|
|
945 | pointer cp = POINTER (p); |
950 | set_typeflag (p, T_PAIR); |
946 | set_typeflag (cp, T_PAIR); |
951 | set_car (p, NIL); |
947 | set_car (cp, NIL); |
952 | set_cdr (p, p + 1); |
948 | set_cdr (cp, POINTER (p + 1)); |
953 | } |
949 | } |
954 | |
950 | |
955 | set_cdr (last, SCHEME_V->free_cell); |
951 | set_cdr (POINTER (last), SCHEME_V->free_cell); |
956 | SCHEME_V->free_cell = newp; |
952 | SCHEME_V->free_cell = POINTER (newp); |
957 | } |
|
|
958 | |
953 | |
959 | return n; |
954 | return 1; |
960 | } |
955 | } |
961 | |
956 | |
962 | /* get new cell. parameter a, b is marked by gc. */ |
957 | /* get new cell. parameter a, b is marked by gc. */ |
963 | ecb_inline pointer |
958 | ecb_inline pointer |
964 | get_cell_x (SCHEME_P_ pointer a, pointer b) |
959 | get_cell_x (SCHEME_P_ pointer a, pointer b) |
… | |
… | |
968 | if (SCHEME_V->no_memory && USE_ERROR_CHECKING) |
963 | if (SCHEME_V->no_memory && USE_ERROR_CHECKING) |
969 | return S_SINK; |
964 | return S_SINK; |
970 | |
965 | |
971 | if (SCHEME_V->free_cell == NIL) |
966 | if (SCHEME_V->free_cell == NIL) |
972 | { |
967 | { |
973 | const int min_to_be_recovered = SCHEME_V->last_cell_seg < 128 ? 128 * 8 : SCHEME_V->last_cell_seg * 8; |
968 | const int min_to_be_recovered = SCHEME_V->cell_segsize [SCHEME_V->last_cell_seg] >> 1; |
974 | |
969 | |
975 | gc (SCHEME_A_ a, b); |
970 | gc (SCHEME_A_ a, b); |
976 | |
971 | |
977 | if (SCHEME_V->fcells < min_to_be_recovered || SCHEME_V->free_cell == NIL) |
972 | if (SCHEME_V->fcells < min_to_be_recovered || SCHEME_V->free_cell == NIL) |
978 | { |
973 | { |
979 | /* if only a few recovered, get more to avoid fruitless gc's */ |
974 | /* if only a few recovered, get more to avoid fruitless gc's */ |
980 | if (!alloc_cellseg (SCHEME_A_ 1) && SCHEME_V->free_cell == NIL) |
975 | if (!alloc_cellseg (SCHEME_A) && SCHEME_V->free_cell == NIL) |
981 | { |
976 | { |
982 | #if USE_ERROR_CHECKING |
977 | #if USE_ERROR_CHECKING |
983 | SCHEME_V->no_memory = 1; |
978 | SCHEME_V->no_memory = 1; |
984 | return S_SINK; |
979 | return S_SINK; |
985 | #endif |
980 | #endif |
… | |
… | |
997 | } |
992 | } |
998 | } |
993 | } |
999 | |
994 | |
1000 | /* To retain recent allocs before interpreter knows about them - |
995 | /* To retain recent allocs before interpreter knows about them - |
1001 | Tehom */ |
996 | Tehom */ |
1002 | |
|
|
1003 | static void |
997 | static void |
1004 | push_recent_alloc (SCHEME_P_ pointer recent, pointer extra) |
998 | push_recent_alloc (SCHEME_P_ pointer recent, pointer extra) |
1005 | { |
999 | { |
1006 | pointer holder = get_cell_x (SCHEME_A_ recent, extra); |
1000 | pointer holder = get_cell_x (SCHEME_A_ recent, extra); |
1007 | |
1001 | |
… | |
… | |
1029 | } |
1023 | } |
1030 | |
1024 | |
1031 | static pointer |
1025 | static pointer |
1032 | get_vector_object (SCHEME_P_ uint32_t len, pointer init) |
1026 | get_vector_object (SCHEME_P_ uint32_t len, pointer init) |
1033 | { |
1027 | { |
1034 | pointer v = get_cell_x (SCHEME_A_ 0, 0); |
1028 | pointer v = get_cell_x (SCHEME_A_ NIL, NIL); |
1035 | pointer *e = malloc (len * sizeof (pointer)); |
1029 | pointer *e = malloc (len * sizeof (pointer)); |
1036 | |
1030 | |
1037 | if (!e && USE_ERROR_CHECKING) |
1031 | if (!e && USE_ERROR_CHECKING) |
1038 | return S_SINK; |
1032 | return S_SINK; |
1039 | |
1033 | |
1040 | /* Record it as a vector so that gc understands it. */ |
1034 | /* Record it as a vector so that gc understands it. */ |
1041 | set_typeflag (v, T_VECTOR | T_ATOM); |
1035 | set_typeflag (v, T_VECTOR | T_ATOM); |
1042 | |
1036 | |
1043 | v->object.vector.vvalue = e; |
1037 | CELL(v)->object.vector.vvalue = e; |
1044 | v->object.vector.length = len; |
1038 | CELL(v)->object.vector.length = len; |
1045 | fill_vector (v, 0, init); |
1039 | fill_vector (v, 0, init); |
1046 | push_recent_alloc (SCHEME_A_ v, NIL); |
1040 | push_recent_alloc (SCHEME_A_ v, NIL); |
1047 | |
1041 | |
1048 | return v; |
1042 | return v; |
1049 | } |
1043 | } |
… | |
… | |
1058 | static void |
1052 | static void |
1059 | check_cell_alloced (pointer p, int expect_alloced) |
1053 | check_cell_alloced (pointer p, int expect_alloced) |
1060 | { |
1054 | { |
1061 | /* Can't use putstr(SCHEME_A_ str) because callers have no access to sc. */ |
1055 | /* Can't use putstr(SCHEME_A_ str) because callers have no access to sc. */ |
1062 | if (typeflag (p) & !expect_alloced) |
1056 | if (typeflag (p) & !expect_alloced) |
1063 | xwrstr ("Cell is already allocated!\n"); |
1057 | putstr (SCHEME_A_ "Cell is already allocated!\n"); |
1064 | |
1058 | |
1065 | if (!(typeflag (p)) & expect_alloced) |
1059 | if (!(typeflag (p)) & expect_alloced) |
1066 | xwrstr ("Cell is not allocated!\n"); |
1060 | putstr (SCHEME_A_ "Cell is not allocated!\n"); |
1067 | } |
1061 | } |
1068 | |
1062 | |
1069 | static void |
1063 | static void |
1070 | check_range_alloced (pointer p, int n, int expect_alloced) |
1064 | check_range_alloced (pointer p, int n, int expect_alloced) |
1071 | { |
1065 | { |
… | |
… | |
1092 | set_car (x, a); |
1086 | set_car (x, a); |
1093 | set_cdr (x, b); |
1087 | set_cdr (x, b); |
1094 | |
1088 | |
1095 | return x; |
1089 | return x; |
1096 | } |
1090 | } |
1097 | |
|
|
1098 | /* ========== oblist implementation ========== */ |
|
|
1099 | |
1091 | |
1100 | static pointer |
1092 | static pointer |
1101 | generate_symbol (SCHEME_P_ const char *name) |
1093 | generate_symbol (SCHEME_P_ const char *name) |
1102 | { |
1094 | { |
1103 | pointer x = mk_string (SCHEME_A_ name); |
1095 | pointer x = mk_string (SCHEME_A_ name); |
1104 | setimmutable (x); |
1096 | setimmutable (x); |
1105 | set_typeflag (x, T_SYMBOL | T_ATOM); |
1097 | set_typeflag (x, T_SYMBOL | T_ATOM); |
1106 | return x; |
1098 | return x; |
1107 | } |
1099 | } |
1108 | |
1100 | |
|
|
1101 | /* ========== oblist implementation ========== */ |
|
|
1102 | |
1109 | #ifndef USE_OBJECT_LIST |
1103 | #ifndef USE_OBJECT_LIST |
1110 | |
1104 | |
1111 | static int |
1105 | static int |
1112 | hash_fn (const char *key, int table_size) |
1106 | hash_fn (const char *key, int table_size) |
1113 | { |
1107 | { |
… | |
… | |
1199 | |
1193 | |
1200 | /* returns the new symbol */ |
1194 | /* returns the new symbol */ |
1201 | static pointer |
1195 | static pointer |
1202 | oblist_add_by_name (SCHEME_P_ const char *name) |
1196 | oblist_add_by_name (SCHEME_P_ const char *name) |
1203 | { |
1197 | { |
1204 | pointer x = mk_string (SCHEME_A_ name); |
1198 | pointer x = generate_symbol (SCHEME_A_ name); |
1205 | set_typeflag (x, T_SYMBOL); |
|
|
1206 | setimmutable (x); |
|
|
1207 | SCHEME_V->oblist = immutable_cons (x, SCHEME_V->oblist); |
1199 | SCHEME_V->oblist = immutable_cons (x, SCHEME_V->oblist); |
1208 | return x; |
1200 | return x; |
1209 | } |
1201 | } |
1210 | |
1202 | |
1211 | static pointer |
1203 | static pointer |
… | |
… | |
1221 | mk_port (SCHEME_P_ port *p) |
1213 | mk_port (SCHEME_P_ port *p) |
1222 | { |
1214 | { |
1223 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1215 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1224 | |
1216 | |
1225 | set_typeflag (x, T_PORT | T_ATOM); |
1217 | set_typeflag (x, T_PORT | T_ATOM); |
1226 | x->object.port = p; |
1218 | set_port (x, p); |
1227 | |
1219 | |
1228 | return x; |
1220 | return x; |
1229 | } |
1221 | } |
1230 | #endif |
1222 | #endif |
1231 | |
1223 | |
1232 | pointer |
1224 | pointer |
1233 | mk_foreign_func (SCHEME_P_ foreign_func f) |
1225 | mk_foreign_func (SCHEME_P_ foreign_func f) |
1234 | { |
1226 | { |
1235 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1227 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1236 | |
1228 | |
1237 | set_typeflag (x, (T_FOREIGN | T_ATOM)); |
1229 | set_typeflag (x, T_FOREIGN | T_ATOM); |
1238 | x->object.ff = f; |
1230 | CELL(x)->object.ff = f; |
1239 | |
1231 | |
1240 | return x; |
1232 | return x; |
1241 | } |
1233 | } |
1242 | |
1234 | |
1243 | INTERFACE pointer |
1235 | INTERFACE pointer |
1244 | mk_character (SCHEME_P_ int c) |
1236 | mk_character (SCHEME_P_ int c) |
1245 | { |
1237 | { |
1246 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1238 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1247 | |
1239 | |
1248 | set_typeflag (x, (T_CHARACTER | T_ATOM)); |
1240 | set_typeflag (x, T_CHARACTER | T_ATOM); |
1249 | set_ivalue (x, c & 0xff); |
1241 | set_ivalue (x, c & 0xff); |
1250 | |
1242 | |
1251 | return x; |
1243 | return x; |
1252 | } |
1244 | } |
1253 | |
1245 | |
1254 | /* get number atom (integer) */ |
1246 | /* get number atom (integer) */ |
1255 | INTERFACE pointer |
1247 | INTERFACE pointer |
1256 | mk_integer (SCHEME_P_ long n) |
1248 | mk_integer (SCHEME_P_ long n) |
1257 | { |
1249 | { |
|
|
1250 | pointer p = 0; |
|
|
1251 | pointer *pp = &p; |
|
|
1252 | |
|
|
1253 | #if USE_INTCACHE |
|
|
1254 | if (n >= INTCACHE_MIN && n <= INTCACHE_MAX) |
|
|
1255 | pp = &SCHEME_V->intcache[n - INTCACHE_MIN]; |
|
|
1256 | #endif |
|
|
1257 | |
|
|
1258 | if (!*pp) |
|
|
1259 | { |
1258 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1260 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1259 | |
1261 | |
1260 | set_typeflag (x, (T_INTEGER | T_ATOM)); |
1262 | set_typeflag (x, T_INTEGER | T_ATOM); |
|
|
1263 | setimmutable (x); /* shouldn't do anythi9ng, doesn't cost anything */ |
1261 | set_ivalue (x, n); |
1264 | set_ivalue (x, n); |
1262 | |
1265 | |
|
|
1266 | *pp = x; |
|
|
1267 | } |
|
|
1268 | |
1263 | return x; |
1269 | return *pp; |
1264 | } |
1270 | } |
1265 | |
1271 | |
1266 | INTERFACE pointer |
1272 | INTERFACE pointer |
1267 | mk_real (SCHEME_P_ RVALUE n) |
1273 | mk_real (SCHEME_P_ RVALUE n) |
1268 | { |
1274 | { |
1269 | #if USE_REAL |
1275 | #if USE_REAL |
1270 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1276 | pointer x = get_cell (SCHEME_A_ NIL, NIL); |
1271 | |
1277 | |
1272 | set_typeflag (x, (T_REAL | T_ATOM)); |
1278 | set_typeflag (x, T_REAL | T_ATOM); |
1273 | set_rvalue (x, n); |
1279 | set_rvalue (x, n); |
1274 | |
1280 | |
1275 | return x; |
1281 | return x; |
1276 | #else |
1282 | #else |
1277 | return mk_integer (SCHEME_A_ n); |
1283 | return mk_integer (SCHEME_A_ n); |
… | |
… | |
1396 | pointer x; |
1402 | pointer x; |
1397 | char name[40] = "gensym-"; |
1403 | char name[40] = "gensym-"; |
1398 | xnum (name + 7, ++SCHEME_V->gensym_cnt); |
1404 | xnum (name + 7, ++SCHEME_V->gensym_cnt); |
1399 | |
1405 | |
1400 | return generate_symbol (SCHEME_A_ name); |
1406 | return generate_symbol (SCHEME_A_ name); |
|
|
1407 | } |
|
|
1408 | |
|
|
1409 | static int |
|
|
1410 | is_gensym (SCHEME_P_ pointer x) |
|
|
1411 | { |
|
|
1412 | return is_symbol (x) && oblist_find_by_name (SCHEME_A_ strvalue (x)) != x; |
1401 | } |
1413 | } |
1402 | |
1414 | |
1403 | /* make symbol or number atom from string */ |
1415 | /* make symbol or number atom from string */ |
1404 | static pointer |
1416 | static pointer |
1405 | mk_atom (SCHEME_P_ char *q) |
1417 | mk_atom (SCHEME_P_ char *q) |
… | |
… | |
1614 | |
1626 | |
1615 | /* garbage collection. parameter a, b is marked. */ |
1627 | /* garbage collection. parameter a, b is marked. */ |
1616 | static void |
1628 | static void |
1617 | gc (SCHEME_P_ pointer a, pointer b) |
1629 | gc (SCHEME_P_ pointer a, pointer b) |
1618 | { |
1630 | { |
1619 | pointer p; |
|
|
1620 | int i; |
1631 | int i; |
1621 | |
1632 | |
1622 | if (SCHEME_V->gc_verbose) |
1633 | if (SCHEME_V->gc_verbose) |
1623 | putstr (SCHEME_A_ "gc..."); |
1634 | putstr (SCHEME_A_ "gc..."); |
1624 | |
1635 | |
… | |
… | |
1640 | /* Mark recent objects the interpreter doesn't know about yet. */ |
1651 | /* Mark recent objects the interpreter doesn't know about yet. */ |
1641 | mark (car (S_SINK)); |
1652 | mark (car (S_SINK)); |
1642 | /* Mark any older stuff above nested C calls */ |
1653 | /* Mark any older stuff above nested C calls */ |
1643 | mark (SCHEME_V->c_nest); |
1654 | mark (SCHEME_V->c_nest); |
1644 | |
1655 | |
|
|
1656 | #if USE_INTCACHE |
|
|
1657 | /* mark intcache */ |
|
|
1658 | for (i = INTCACHE_MIN; i <= INTCACHE_MAX; ++i) |
|
|
1659 | if (SCHEME_V->intcache[i - INTCACHE_MIN]) |
|
|
1660 | mark (SCHEME_V->intcache[i - INTCACHE_MIN]); |
|
|
1661 | #endif |
|
|
1662 | |
1645 | /* mark variables a, b */ |
1663 | /* mark variables a, b */ |
1646 | mark (a); |
1664 | mark (a); |
1647 | mark (b); |
1665 | mark (b); |
1648 | |
1666 | |
1649 | /* garbage collect */ |
1667 | /* garbage collect */ |
1650 | clrmark (NIL); |
1668 | clrmark (NIL); |
1651 | SCHEME_V->fcells = 0; |
1669 | SCHEME_V->fcells = 0; |
1652 | SCHEME_V->free_cell = NIL; |
1670 | SCHEME_V->free_cell = NIL; |
1653 | |
1671 | |
1654 | /* free-list is kept sorted by address so as to maintain consecutive |
1672 | if (SCHEME_V->gc_verbose) |
1655 | ranges, if possible, for use with vectors. Here we scan the cells |
1673 | putstr (SCHEME_A_ "freeing..."); |
1656 | (which are also kept sorted by address) downwards to build the |
1674 | |
1657 | free-list in sorted order. |
1675 | uint32_t total = 0; |
1658 | */ |
1676 | |
|
|
1677 | /* Here we scan the cells to build the free-list. */ |
1659 | for (i = SCHEME_V->last_cell_seg; i >= 0; i--) |
1678 | for (i = SCHEME_V->last_cell_seg; i >= 0; i--) |
1660 | { |
1679 | { |
1661 | p = SCHEME_V->cell_seg[i] + SCHEME_V->cell_segsize [i]; |
1680 | struct cell *end = SCHEME_V->cell_seg[i] + SCHEME_V->cell_segsize [i]; |
|
|
1681 | struct cell *p; |
|
|
1682 | total += SCHEME_V->cell_segsize [i]; |
1662 | |
1683 | |
1663 | while (--p >= SCHEME_V->cell_seg[i]) |
1684 | for (p = SCHEME_V->cell_seg[i]; p < end; ++p) |
1664 | { |
1685 | { |
|
|
1686 | pointer c = POINTER (p); |
|
|
1687 | |
1665 | if (is_mark (p)) |
1688 | if (is_mark (c)) |
1666 | clrmark (p); |
1689 | clrmark (c); |
1667 | else |
1690 | else |
1668 | { |
1691 | { |
1669 | /* reclaim cell */ |
1692 | /* reclaim cell */ |
1670 | if (typeflag (p) != T_PAIR) |
1693 | if (typeflag (c) != T_PAIR) |
1671 | { |
1694 | { |
1672 | finalize_cell (SCHEME_A_ p); |
1695 | finalize_cell (SCHEME_A_ c); |
1673 | set_typeflag (p, T_PAIR); |
1696 | set_typeflag (c, T_PAIR); |
1674 | set_car (p, NIL); |
1697 | set_car (c, NIL); |
1675 | } |
1698 | } |
1676 | |
1699 | |
1677 | ++SCHEME_V->fcells; |
1700 | ++SCHEME_V->fcells; |
1678 | set_cdr (p, SCHEME_V->free_cell); |
1701 | set_cdr (c, SCHEME_V->free_cell); |
1679 | SCHEME_V->free_cell = p; |
1702 | SCHEME_V->free_cell = c; |
1680 | } |
1703 | } |
1681 | } |
1704 | } |
1682 | } |
1705 | } |
1683 | |
1706 | |
1684 | if (SCHEME_V->gc_verbose) |
1707 | if (SCHEME_V->gc_verbose) |
1685 | { |
1708 | { |
1686 | xwrstr ("done: "); xwrnum (SCHEME_V->fcells); xwrstr (" cells were recovered.\n"); |
1709 | putstr (SCHEME_A_ "done: "); putnum (SCHEME_A_ SCHEME_V->fcells); putstr (SCHEME_A_ " out of "); putnum (SCHEME_A_ total); putstr (SCHEME_A_ " cells were recovered.\n"); |
1687 | } |
1710 | } |
1688 | } |
1711 | } |
1689 | |
1712 | |
1690 | static void |
1713 | static void |
1691 | finalize_cell (SCHEME_P_ pointer a) |
1714 | finalize_cell (SCHEME_P_ pointer a) |
… | |
… | |
1696 | else if (is_vector (a)) |
1719 | else if (is_vector (a)) |
1697 | free (vecvalue (a)); |
1720 | free (vecvalue (a)); |
1698 | #if USE_PORTS |
1721 | #if USE_PORTS |
1699 | else if (is_port (a)) |
1722 | else if (is_port (a)) |
1700 | { |
1723 | { |
1701 | if (a->object.port->kind & port_file && a->object.port->rep.stdio.closeit) |
1724 | if (port(a)->kind & port_file && port (a)->rep.stdio.closeit) |
1702 | port_close (SCHEME_A_ a, port_input | port_output); |
1725 | port_close (SCHEME_A_ a, port_input | port_output); |
1703 | |
1726 | |
1704 | free (a->object.port); |
1727 | free (port (a)); |
1705 | } |
1728 | } |
1706 | #endif |
1729 | #endif |
1707 | } |
1730 | } |
1708 | |
1731 | |
1709 | /* ========== Routines for Reading ========== */ |
1732 | /* ========== Routines for Reading ========== */ |
… | |
… | |
1725 | SCHEME_V->load_stack[SCHEME_V->file_i].unget = -1; |
1748 | SCHEME_V->load_stack[SCHEME_V->file_i].unget = -1; |
1726 | SCHEME_V->load_stack[SCHEME_V->file_i].kind = port_file | port_input; |
1749 | SCHEME_V->load_stack[SCHEME_V->file_i].kind = port_file | port_input; |
1727 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.file = fin; |
1750 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.file = fin; |
1728 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.closeit = 1; |
1751 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.closeit = 1; |
1729 | SCHEME_V->nesting_stack[SCHEME_V->file_i] = 0; |
1752 | SCHEME_V->nesting_stack[SCHEME_V->file_i] = 0; |
1730 | SCHEME_V->loadport->object.port = SCHEME_V->load_stack + SCHEME_V->file_i; |
1753 | set_port (SCHEME_V->loadport, SCHEME_V->load_stack + SCHEME_V->file_i); |
1731 | |
1754 | |
1732 | #if SHOW_ERROR_LINE |
1755 | #if SHOW_ERROR_LINE |
1733 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.curr_line = 0; |
1756 | SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.curr_line = 0; |
1734 | |
1757 | |
1735 | if (fname) |
1758 | if (fname) |
… | |
… | |
1752 | SCHEME_V->nesting = SCHEME_V->nesting_stack[SCHEME_V->file_i]; |
1775 | SCHEME_V->nesting = SCHEME_V->nesting_stack[SCHEME_V->file_i]; |
1753 | #if USE_PORTS |
1776 | #if USE_PORTS |
1754 | port_close (SCHEME_A_ SCHEME_V->loadport, port_input); |
1777 | port_close (SCHEME_A_ SCHEME_V->loadport, port_input); |
1755 | #endif |
1778 | #endif |
1756 | SCHEME_V->file_i--; |
1779 | SCHEME_V->file_i--; |
1757 | SCHEME_V->loadport->object.port = SCHEME_V->load_stack + SCHEME_V->file_i; |
1780 | set_port (SCHEME_V->loadport, SCHEME_V->load_stack + SCHEME_V->file_i); |
1758 | } |
1781 | } |
1759 | } |
1782 | } |
1760 | |
1783 | |
1761 | static int |
1784 | static int |
1762 | file_interactive (SCHEME_P) |
1785 | file_interactive (SCHEME_P) |
1763 | { |
1786 | { |
1764 | #if USE_PORTS |
1787 | #if USE_PORTS |
1765 | return SCHEME_V->file_i == 0 |
1788 | return SCHEME_V->file_i == 0 |
1766 | && SCHEME_V->load_stack[0].rep.stdio.file == STDIN_FILENO |
1789 | && SCHEME_V->load_stack[0].rep.stdio.file == STDIN_FILENO |
1767 | && (SCHEME_V->inport->object.port->kind & port_file); |
1790 | && (port (SCHEME_V->inport)->kind & port_file); |
1768 | #else |
1791 | #else |
1769 | return 0; |
1792 | return 0; |
1770 | #endif |
1793 | #endif |
1771 | } |
1794 | } |
1772 | |
1795 | |
… | |
… | |
1906 | } |
1929 | } |
1907 | |
1930 | |
1908 | static void |
1931 | static void |
1909 | port_close (SCHEME_P_ pointer p, int flag) |
1932 | port_close (SCHEME_P_ pointer p, int flag) |
1910 | { |
1933 | { |
1911 | port *pt = p->object.port; |
1934 | port *pt = port (p); |
1912 | |
1935 | |
1913 | pt->kind &= ~flag; |
1936 | pt->kind &= ~flag; |
1914 | |
1937 | |
1915 | if ((pt->kind & (port_input | port_output)) == 0) |
1938 | if ((pt->kind & (port_input | port_output)) == 0) |
1916 | { |
1939 | { |
… | |
… | |
1937 | /* get new character from input file */ |
1960 | /* get new character from input file */ |
1938 | static int |
1961 | static int |
1939 | inchar (SCHEME_P) |
1962 | inchar (SCHEME_P) |
1940 | { |
1963 | { |
1941 | int c; |
1964 | int c; |
1942 | port *pt; |
1965 | port *pt = port (SCHEME_V->inport); |
1943 | |
|
|
1944 | pt = SCHEME_V->inport->object.port; |
|
|
1945 | |
1966 | |
1946 | if (pt->kind & port_saw_EOF) |
1967 | if (pt->kind & port_saw_EOF) |
1947 | return EOF; |
1968 | return EOF; |
1948 | |
1969 | |
1949 | c = basic_inchar (pt); |
1970 | c = basic_inchar (pt); |
… | |
… | |
2016 | port *pt; |
2037 | port *pt; |
2017 | |
2038 | |
2018 | if (c == EOF) |
2039 | if (c == EOF) |
2019 | return; |
2040 | return; |
2020 | |
2041 | |
2021 | pt = SCHEME_V->inport->object.port; |
2042 | pt = port (SCHEME_V->inport); |
2022 | pt->unget = c; |
2043 | pt->unget = c; |
2023 | #else |
2044 | #else |
2024 | if (c == EOF) |
2045 | if (c == EOF) |
2025 | return; |
2046 | return; |
2026 | |
2047 | |
… | |
… | |
2054 | |
2075 | |
2055 | INTERFACE void |
2076 | INTERFACE void |
2056 | putstr (SCHEME_P_ const char *s) |
2077 | putstr (SCHEME_P_ const char *s) |
2057 | { |
2078 | { |
2058 | #if USE_PORTS |
2079 | #if USE_PORTS |
2059 | port *pt = SCHEME_V->outport->object.port; |
2080 | port *pt = port (SCHEME_V->outport); |
2060 | |
2081 | |
2061 | if (pt->kind & port_file) |
2082 | if (pt->kind & port_file) |
2062 | write (pt->rep.stdio.file, s, strlen (s)); |
2083 | write (pt->rep.stdio.file, s, strlen (s)); |
2063 | else |
2084 | else |
2064 | for (; *s; s++) |
2085 | for (; *s; s++) |
… | |
… | |
2066 | *pt->rep.string.curr++ = *s; |
2087 | *pt->rep.string.curr++ = *s; |
2067 | else if (pt->kind & port_srfi6 && realloc_port_string (SCHEME_A_ pt)) |
2088 | else if (pt->kind & port_srfi6 && realloc_port_string (SCHEME_A_ pt)) |
2068 | *pt->rep.string.curr++ = *s; |
2089 | *pt->rep.string.curr++ = *s; |
2069 | |
2090 | |
2070 | #else |
2091 | #else |
2071 | xwrstr (s); |
2092 | write (pt->rep.stdio.file, s, strlen (s)); |
2072 | #endif |
2093 | #endif |
2073 | } |
2094 | } |
2074 | |
2095 | |
2075 | static void |
2096 | static void |
2076 | putchars (SCHEME_P_ const char *s, int len) |
2097 | putchars (SCHEME_P_ const char *s, int len) |
2077 | { |
2098 | { |
2078 | #if USE_PORTS |
2099 | #if USE_PORTS |
2079 | port *pt = SCHEME_V->outport->object.port; |
2100 | port *pt = port (SCHEME_V->outport); |
2080 | |
2101 | |
2081 | if (pt->kind & port_file) |
2102 | if (pt->kind & port_file) |
2082 | write (pt->rep.stdio.file, s, len); |
2103 | write (pt->rep.stdio.file, s, len); |
2083 | else |
2104 | else |
2084 | { |
2105 | { |
… | |
… | |
2098 | |
2119 | |
2099 | INTERFACE void |
2120 | INTERFACE void |
2100 | putcharacter (SCHEME_P_ int c) |
2121 | putcharacter (SCHEME_P_ int c) |
2101 | { |
2122 | { |
2102 | #if USE_PORTS |
2123 | #if USE_PORTS |
2103 | port *pt = SCHEME_V->outport->object.port; |
2124 | port *pt = port (SCHEME_V->outport); |
2104 | |
2125 | |
2105 | if (pt->kind & port_file) |
2126 | if (pt->kind & port_file) |
2106 | { |
2127 | { |
2107 | char cc = c; |
2128 | char cc = c; |
2108 | write (pt->rep.stdio.file, &cc, 1); |
2129 | write (pt->rep.stdio.file, &cc, 1); |
… | |
… | |
3050 | { |
3071 | { |
3051 | int nframes = (uintptr_t)SCHEME_V->dump; |
3072 | int nframes = (uintptr_t)SCHEME_V->dump; |
3052 | struct dump_stack_frame *next_frame; |
3073 | struct dump_stack_frame *next_frame; |
3053 | |
3074 | |
3054 | /* enough room for the next frame? */ |
3075 | /* enough room for the next frame? */ |
3055 | if (nframes >= SCHEME_V->dump_size) |
3076 | if (ecb_expect_false (nframes >= SCHEME_V->dump_size)) |
3056 | { |
3077 | { |
3057 | SCHEME_V->dump_size += STACK_GROWTH; |
3078 | SCHEME_V->dump_size += STACK_GROWTH; |
3058 | SCHEME_V->dump_base = realloc (SCHEME_V->dump_base, sizeof (struct dump_stack_frame) * SCHEME_V->dump_size); |
3079 | SCHEME_V->dump_base = realloc (SCHEME_V->dump_base, sizeof (struct dump_stack_frame) * SCHEME_V->dump_size); |
3059 | } |
3080 | } |
3060 | |
3081 | |
… | |
… | |
3241 | |
3262 | |
3242 | #endif |
3263 | #endif |
3243 | |
3264 | |
3244 | #define s_retbool(tf) s_return ((tf) ? S_T : S_F) |
3265 | #define s_retbool(tf) s_return ((tf) ? S_T : S_F) |
3245 | |
3266 | |
3246 | #if 1 |
3267 | #if EXPERIMENT |
3247 | static int |
3268 | static int |
3248 | debug (SCHEME_P_ int indent, pointer x) |
3269 | debug (SCHEME_P_ int indent, pointer x) |
3249 | { |
3270 | { |
3250 | int c; |
3271 | int c; |
3251 | |
3272 | |
… | |
… | |
3307 | pointer args = SCHEME_V->args; |
3328 | pointer args = SCHEME_V->args; |
3308 | pointer x, y; |
3329 | pointer x, y; |
3309 | |
3330 | |
3310 | switch (op) |
3331 | switch (op) |
3311 | { |
3332 | { |
3312 | #if 1 //D |
3333 | #if EXPERIMENT //D |
3313 | case OP_DEBUG: |
3334 | case OP_DEBUG: |
3314 | printf ("len = %d\n", debug (SCHEME_A_ 0, args) / 8); |
3335 | printf ("len = %d\n", debug (SCHEME_A_ 0, args) / 8); |
3315 | printf ("\n"); |
3336 | printf ("\n"); |
3316 | s_return (S_T); |
3337 | s_return (S_T); |
3317 | #endif |
3338 | #endif |
3318 | case OP_LOAD: /* load */ |
3339 | case OP_LOAD: /* load */ |
3319 | if (file_interactive (SCHEME_A)) |
3340 | if (file_interactive (SCHEME_A)) |
3320 | { |
3341 | { |
3321 | xwrstr ("Loading "); xwrstr (strvalue (car (args))); xwrstr ("\n"); |
3342 | putstr (SCHEME_A_ "Loading "); putstr (SCHEME_A_ strvalue (car (args))); putstr (SCHEME_A_ "\n"); |
3322 | //D fprintf (SCHEME_V->outport->object.port->rep.stdio.file, "Loading %s\n", strvalue (car (args))); |
3343 | //D fprintf (port (SCHEME_V->outport)->rep.stdio.file, "Loading %s\n", strvalue (car (args))); |
3323 | } |
3344 | } |
3324 | |
3345 | |
3325 | if (!file_push (SCHEME_A_ strvalue (car (args)))) |
3346 | if (!file_push (SCHEME_A_ strvalue (car (args)))) |
3326 | Error_1 ("unable to open", car (args)); |
3347 | Error_1 ("unable to open", car (args)); |
3327 | else |
3348 | else |
… | |
… | |
3331 | } |
3352 | } |
3332 | |
3353 | |
3333 | case OP_T0LVL: /* top level */ |
3354 | case OP_T0LVL: /* top level */ |
3334 | |
3355 | |
3335 | /* If we reached the end of file, this loop is done. */ |
3356 | /* If we reached the end of file, this loop is done. */ |
3336 | if (SCHEME_V->loadport->object.port->kind & port_saw_EOF) |
3357 | if (port (SCHEME_V->loadport)->kind & port_saw_EOF) |
3337 | { |
3358 | { |
3338 | if (SCHEME_V->file_i == 0) |
3359 | if (SCHEME_V->file_i == 0) |
3339 | { |
3360 | { |
3340 | SCHEME_V->args = NIL; |
3361 | SCHEME_V->args = NIL; |
3341 | s_goto (OP_QUIT); |
3362 | s_goto (OP_QUIT); |
… | |
… | |
3419 | #endif |
3440 | #endif |
3420 | if (is_symbol (SCHEME_V->code)) /* symbol */ |
3441 | if (is_symbol (SCHEME_V->code)) /* symbol */ |
3421 | { |
3442 | { |
3422 | x = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->code, 1); |
3443 | x = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->code, 1); |
3423 | |
3444 | |
3424 | if (x != NIL) |
3445 | if (x == NIL) |
3425 | s_return (slot_value_in_env (x)); |
|
|
3426 | else |
|
|
3427 | Error_1 ("eval: unbound variable:", SCHEME_V->code); |
3446 | Error_1 ("eval: unbound variable:", SCHEME_V->code); |
|
|
3447 | |
|
|
3448 | s_return (slot_value_in_env (x)); |
3428 | } |
3449 | } |
3429 | else if (is_pair (SCHEME_V->code)) |
3450 | else if (is_pair (SCHEME_V->code)) |
3430 | { |
3451 | { |
3431 | x = car (SCHEME_V->code); |
3452 | x = car (SCHEME_V->code); |
3432 | |
3453 | |
… | |
… | |
3509 | s_goto (procnum (SCHEME_V->code)); /* PROCEDURE */ |
3530 | s_goto (procnum (SCHEME_V->code)); /* PROCEDURE */ |
3510 | else if (is_foreign (SCHEME_V->code)) |
3531 | else if (is_foreign (SCHEME_V->code)) |
3511 | { |
3532 | { |
3512 | /* Keep nested calls from GC'ing the arglist */ |
3533 | /* Keep nested calls from GC'ing the arglist */ |
3513 | push_recent_alloc (SCHEME_A_ args, NIL); |
3534 | push_recent_alloc (SCHEME_A_ args, NIL); |
3514 | x = SCHEME_V->code->object.ff (SCHEME_A_ args); |
3535 | x = CELL(SCHEME_V->code)->object.ff (SCHEME_A_ args); |
3515 | |
3536 | |
3516 | s_return (x); |
3537 | s_return (x); |
3517 | } |
3538 | } |
3518 | else if (is_closure (SCHEME_V->code) || is_macro (SCHEME_V->code) || is_promise (SCHEME_V->code)) /* CLOSURE */ |
3539 | else if (is_closure (SCHEME_V->code) || is_macro (SCHEME_V->code) || is_promise (SCHEME_V->code)) /* CLOSURE */ |
3519 | { |
3540 | { |
… | |
… | |
3556 | |
3577 | |
3557 | case OP_DOMACRO: /* do macro */ |
3578 | case OP_DOMACRO: /* do macro */ |
3558 | SCHEME_V->code = SCHEME_V->value; |
3579 | SCHEME_V->code = SCHEME_V->value; |
3559 | s_goto (OP_EVAL); |
3580 | s_goto (OP_EVAL); |
3560 | |
3581 | |
3561 | #if 1 |
|
|
3562 | |
|
|
3563 | case OP_LAMBDA: /* lambda */ |
3582 | case OP_LAMBDA: /* lambda */ |
3564 | /* If the hook is defined, apply it to SCHEME_V->code, otherwise |
3583 | /* If the hook is defined, apply it to SCHEME_V->code, otherwise |
3565 | set SCHEME_V->value fall thru */ |
3584 | set SCHEME_V->value fall thru */ |
3566 | { |
3585 | { |
3567 | pointer f = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->COMPILE_HOOK, 1); |
3586 | pointer f = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->COMPILE_HOOK, 1); |
… | |
… | |
3573 | SCHEME_V->code = slot_value_in_env (f); |
3592 | SCHEME_V->code = slot_value_in_env (f); |
3574 | s_goto (OP_APPLY); |
3593 | s_goto (OP_APPLY); |
3575 | } |
3594 | } |
3576 | |
3595 | |
3577 | SCHEME_V->value = SCHEME_V->code; |
3596 | SCHEME_V->value = SCHEME_V->code; |
3578 | /* Fallthru */ |
|
|
3579 | } |
3597 | } |
|
|
3598 | /* Fallthru */ |
3580 | |
3599 | |
3581 | case OP_LAMBDA1: |
3600 | case OP_LAMBDA1: |
3582 | s_return (mk_closure (SCHEME_A_ SCHEME_V->value, SCHEME_V->envir)); |
3601 | s_return (mk_closure (SCHEME_A_ SCHEME_V->value, SCHEME_V->envir)); |
3583 | |
|
|
3584 | #else |
|
|
3585 | |
|
|
3586 | case OP_LAMBDA: /* lambda */ |
|
|
3587 | s_return (mk_closure (SCHEME_A_ SCHEME_V->code, SCHEME_V->envir)); |
|
|
3588 | |
|
|
3589 | #endif |
|
|
3590 | |
3602 | |
3591 | case OP_MKCLOSURE: /* make-closure */ |
3603 | case OP_MKCLOSURE: /* make-closure */ |
3592 | x = car (args); |
3604 | x = car (args); |
3593 | |
3605 | |
3594 | if (car (x) == SCHEME_V->LAMBDA) |
3606 | if (car (x) == SCHEME_V->LAMBDA) |
… | |
… | |
4190 | else |
4202 | else |
4191 | Error_0 ("modulo: division by zero"); |
4203 | Error_0 ("modulo: division by zero"); |
4192 | |
4204 | |
4193 | s_return (mk_number (SCHEME_A_ v)); |
4205 | s_return (mk_number (SCHEME_A_ v)); |
4194 | |
4206 | |
4195 | case OP_CAR: /* car */ |
4207 | /* the compiler will optimize this mess... */ |
4196 | s_return (caar (args)); |
4208 | case OP_CAR: op_car: s_return (car (x)); |
4197 | |
4209 | case OP_CDR: op_cdr: s_return (cdr (x)); |
4198 | case OP_CDR: /* cdr */ |
4210 | case OP_CAAR: op_caar: x = car (x); goto op_car; |
4199 | s_return (cdar (args)); |
4211 | case OP_CADR: op_cadr: x = cdr (x); goto op_car; |
|
|
4212 | case OP_CDAR: op_cdar: x = car (x); goto op_cdr; |
|
|
4213 | case OP_CDDR: op_cddr: x = cdr (x); goto op_cdr; |
|
|
4214 | case OP_CAAAR: op_caaar: x = car (x); goto op_caar; |
|
|
4215 | case OP_CAADR: op_caadr: x = cdr (x); goto op_caar; |
|
|
4216 | case OP_CADAR: op_cadar: x = car (x); goto op_cadr; |
|
|
4217 | case OP_CADDR: op_caddr: x = cdr (x); goto op_cadr; |
|
|
4218 | case OP_CDAAR: op_cdaar: x = car (x); goto op_cdar; |
|
|
4219 | case OP_CDADR: op_cdadr: x = cdr (x); goto op_cdar; |
|
|
4220 | case OP_CDDAR: op_cddar: x = car (x); goto op_cddr; |
|
|
4221 | case OP_CDDDR: op_cdddr: x = cdr (x); goto op_cddr; |
|
|
4222 | case OP_CAAAAR: x = car (x); goto op_caaar; |
|
|
4223 | case OP_CAAADR: x = cdr (x); goto op_caaar; |
|
|
4224 | case OP_CAADAR: x = car (x); goto op_caadr; |
|
|
4225 | case OP_CAADDR: x = cdr (x); goto op_caadr; |
|
|
4226 | case OP_CADAAR: x = car (x); goto op_cadar; |
|
|
4227 | case OP_CADADR: x = cdr (x); goto op_cadar; |
|
|
4228 | case OP_CADDAR: x = car (x); goto op_caddr; |
|
|
4229 | case OP_CADDDR: x = cdr (x); goto op_caddr; |
|
|
4230 | case OP_CDAAAR: x = car (x); goto op_cdaar; |
|
|
4231 | case OP_CDAADR: x = cdr (x); goto op_cdaar; |
|
|
4232 | case OP_CDADAR: x = car (x); goto op_cdadr; |
|
|
4233 | case OP_CDADDR: x = cdr (x); goto op_cdadr; |
|
|
4234 | case OP_CDDAAR: x = car (x); goto op_cddar; |
|
|
4235 | case OP_CDDADR: x = cdr (x); goto op_cddar; |
|
|
4236 | case OP_CDDDAR: x = car (x); goto op_cdddr; |
|
|
4237 | case OP_CDDDDR: x = cdr (x); goto op_cdddr; |
4200 | |
4238 | |
4201 | case OP_CONS: /* cons */ |
4239 | case OP_CONS: /* cons */ |
4202 | set_cdr (args, cadr (args)); |
4240 | set_cdr (args, cadr (args)); |
4203 | s_return (args); |
4241 | s_return (args); |
4204 | |
4242 | |
… | |
… | |
4526 | pointer d = cdr (args); |
4564 | pointer d = cdr (args); |
4527 | int r; |
4565 | int r; |
4528 | |
4566 | |
4529 | switch (op) |
4567 | switch (op) |
4530 | { |
4568 | { |
4531 | case OP_NOT: /* not */ r = is_false (a) ; break; |
4569 | case OP_NOT: /* not */ r = is_false (a) ; break; |
4532 | case OP_BOOLP: /* boolean? */ r = a == S_F || a == S_T; break; |
4570 | case OP_BOOLP: /* boolean? */ r = a == S_F || a == S_T ; break; |
4533 | case OP_EOFOBJP: /* eof-object? */ r = a == S_EOF ; break; |
4571 | case OP_EOFOBJP: /* eof-object? */ r = a == S_EOF ; break; |
4534 | case OP_NULLP: /* null? */ r = a == NIL ; break; |
4572 | case OP_NULLP: /* null? */ r = a == NIL ; break; |
4535 | case OP_SYMBOLP: /* symbol? */ r = is_symbol (a) ; break; |
4573 | case OP_SYMBOLP: /* symbol? */ r = is_symbol (a) ; break; |
|
|
4574 | case OP_GENSYMP: /* gensym? */ r = is_gensym (SCHEME_A_ a); break; |
4536 | case OP_NUMBERP: /* number? */ r = is_number (a) ; break; |
4575 | case OP_NUMBERP: /* number? */ r = is_number (a) ; break; |
4537 | case OP_STRINGP: /* string? */ r = is_string (a) ; break; |
4576 | case OP_STRINGP: /* string? */ r = is_string (a) ; break; |
4538 | case OP_INTEGERP: /* integer? */ r = is_integer (a) ; break; |
4577 | case OP_INTEGERP: /* integer? */ r = is_integer (a) ; break; |
4539 | case OP_REALP: /* real? */ r = is_number (a) ; break; /* all numbers are real */ |
4578 | case OP_REALP: /* real? */ r = is_number (a) ; break; /* all numbers are real */ |
4540 | case OP_CHARP: /* char? */ r = is_character (a) ; break; |
4579 | case OP_CHARP: /* char? */ r = is_character (a) ; break; |
4541 | |
4580 | |
4542 | #if USE_CHAR_CLASSIFIERS |
4581 | #if USE_CHAR_CLASSIFIERS |
4543 | case OP_CHARAP: /* char-alphabetic? */ r = Cisalpha (ivalue_unchecked (a)); break; |
4582 | case OP_CHARAP: /* char-alphabetic? */ r = Cisalpha (ivalue_unchecked (a)); break; |
4544 | case OP_CHARNP: /* char-numeric? */ r = Cisdigit (ivalue_unchecked (a)); break; |
4583 | case OP_CHARNP: /* char-numeric? */ r = Cisdigit (ivalue_unchecked (a)); break; |
4545 | case OP_CHARWP: /* char-whitespace? */ r = Cisspace (ivalue_unchecked (a)); break; |
4584 | case OP_CHARWP: /* char-whitespace? */ r = Cisspace (ivalue_unchecked (a)); break; |
… | |
… | |
4595 | } |
4634 | } |
4596 | else |
4635 | else |
4597 | s_return (SCHEME_V->code); |
4636 | s_return (SCHEME_V->code); |
4598 | |
4637 | |
4599 | case OP_SAVE_FORCED: /* Save forced value replacing promise */ |
4638 | case OP_SAVE_FORCED: /* Save forced value replacing promise */ |
4600 | memcpy (SCHEME_V->code, SCHEME_V->value, sizeof (struct cell)); |
4639 | *CELL (SCHEME_V->code) = *CELL (SCHEME_V->value); |
4601 | s_return (SCHEME_V->value); |
4640 | s_return (SCHEME_V->value); |
4602 | |
4641 | |
4603 | #if USE_PORTS |
4642 | #if USE_PORTS |
4604 | |
4643 | |
4605 | case OP_WRITE: /* write */ |
4644 | case OP_WRITE: /* write */ |
… | |
… | |
4750 | SCHEME_V->gc_verbose = (a != S_F); |
4789 | SCHEME_V->gc_verbose = (a != S_F); |
4751 | s_retbool (was); |
4790 | s_retbool (was); |
4752 | } |
4791 | } |
4753 | |
4792 | |
4754 | case OP_NEWSEGMENT: /* new-segment */ |
4793 | case OP_NEWSEGMENT: /* new-segment */ |
|
|
4794 | #if 0 |
4755 | if (!is_pair (args) || !is_number (a)) |
4795 | if (!is_pair (args) || !is_number (a)) |
4756 | Error_0 ("new-segment: argument must be a number"); |
4796 | Error_0 ("new-segment: argument must be a number"); |
4757 | |
4797 | #endif |
4758 | alloc_cellseg (SCHEME_A_ ivalue (a)); |
4798 | s_retbool (alloc_cellseg (SCHEME_A)); |
4759 | |
|
|
4760 | s_return (S_T); |
|
|
4761 | |
4799 | |
4762 | case OP_OBLIST: /* oblist */ |
4800 | case OP_OBLIST: /* oblist */ |
4763 | s_return (oblist_all_symbols (SCHEME_A)); |
4801 | s_return (oblist_all_symbols (SCHEME_A)); |
4764 | |
4802 | |
4765 | #if USE_PORTS |
4803 | #if USE_PORTS |
… | |
… | |
4835 | s_return (p == NIL ? S_F : p); |
4873 | s_return (p == NIL ? S_F : p); |
4836 | } |
4874 | } |
4837 | |
4875 | |
4838 | case OP_GET_OUTSTRING: /* get-output-string */ |
4876 | case OP_GET_OUTSTRING: /* get-output-string */ |
4839 | { |
4877 | { |
4840 | port *p; |
4878 | port *p = port (a); |
4841 | |
4879 | |
4842 | if ((p = a->object.port)->kind & port_string) |
4880 | if (p->kind & port_string) |
4843 | { |
4881 | { |
4844 | off_t size; |
4882 | off_t size; |
4845 | char *str; |
4883 | char *str; |
4846 | |
4884 | |
4847 | size = p->rep.string.curr - p->rep.string.start + 1; |
4885 | size = p->rep.string.curr - p->rep.string.start + 1; |
… | |
… | |
4952 | int res; |
4990 | int res; |
4953 | |
4991 | |
4954 | if (is_pair (args)) |
4992 | if (is_pair (args)) |
4955 | p = car (args); |
4993 | p = car (args); |
4956 | |
4994 | |
4957 | res = p->object.port->kind & port_string; |
4995 | res = port (p)->kind & port_string; |
4958 | |
4996 | |
4959 | s_retbool (res); |
4997 | s_retbool (res); |
4960 | } |
4998 | } |
4961 | |
4999 | |
4962 | case OP_SET_INPORT: /* set-input-port */ |
5000 | case OP_SET_INPORT: /* set-input-port */ |
… | |
… | |
5502 | if (ecb_expect_false (dispatch_funcs [pcd->func] (SCHEME_A_ SCHEME_V->op) != 0)) |
5540 | if (ecb_expect_false (dispatch_funcs [pcd->func] (SCHEME_A_ SCHEME_V->op) != 0)) |
5503 | return; |
5541 | return; |
5504 | |
5542 | |
5505 | if (SCHEME_V->no_memory && USE_ERROR_CHECKING) |
5543 | if (SCHEME_V->no_memory && USE_ERROR_CHECKING) |
5506 | { |
5544 | { |
5507 | xwrstr ("No memory!\n"); |
5545 | putstr (SCHEME_A_ "No memory!\n"); |
5508 | return; |
5546 | return; |
5509 | } |
5547 | } |
5510 | } |
5548 | } |
5511 | } |
5549 | } |
5512 | |
5550 | |
… | |
… | |
5625 | ecb_cold int |
5663 | ecb_cold int |
5626 | scheme_init (SCHEME_P) |
5664 | scheme_init (SCHEME_P) |
5627 | { |
5665 | { |
5628 | int i, n = sizeof (dispatch_table) / sizeof (dispatch_table[0]); |
5666 | int i, n = sizeof (dispatch_table) / sizeof (dispatch_table[0]); |
5629 | pointer x; |
5667 | pointer x; |
|
|
5668 | |
|
|
5669 | /* this memset is not strictly correct, as we assume (intcache) |
|
|
5670 | * that memset 0 will also set pointers to 0, but memset does |
|
|
5671 | * of course not guarantee that. screw such systems. |
|
|
5672 | */ |
|
|
5673 | memset (SCHEME_V, 0, sizeof (*SCHEME_V)); |
5630 | |
5674 | |
5631 | num_set_fixnum (num_zero, 1); |
5675 | num_set_fixnum (num_zero, 1); |
5632 | num_set_ivalue (num_zero, 0); |
5676 | num_set_ivalue (num_zero, 0); |
5633 | num_set_fixnum (num_one, 1); |
5677 | num_set_fixnum (num_one, 1); |
5634 | num_set_ivalue (num_one, 1); |
5678 | num_set_ivalue (num_one, 1); |
… | |
… | |
5646 | SCHEME_V->save_inport = NIL; |
5690 | SCHEME_V->save_inport = NIL; |
5647 | SCHEME_V->loadport = NIL; |
5691 | SCHEME_V->loadport = NIL; |
5648 | SCHEME_V->nesting = 0; |
5692 | SCHEME_V->nesting = 0; |
5649 | SCHEME_V->interactive_repl = 0; |
5693 | SCHEME_V->interactive_repl = 0; |
5650 | |
5694 | |
5651 | if (alloc_cellseg (SCHEME_A_ FIRST_CELLSEGS) != FIRST_CELLSEGS) |
5695 | if (!alloc_cellseg (SCHEME_A)) |
5652 | { |
5696 | { |
5653 | #if USE_ERROR_CHECKING |
5697 | #if USE_ERROR_CHECKING |
5654 | SCHEME_V->no_memory = 1; |
5698 | SCHEME_V->no_memory = 1; |
5655 | return 0; |
5699 | return 0; |
5656 | #endif |
5700 | #endif |
… | |
… | |
5990 | int isfile = 1; |
6034 | int isfile = 1; |
5991 | system ("ps v $PPID");//D |
6035 | system ("ps v $PPID");//D |
5992 | |
6036 | |
5993 | if (argc == 2 && strcmp (argv[1], "-?") == 0) |
6037 | if (argc == 2 && strcmp (argv[1], "-?") == 0) |
5994 | { |
6038 | { |
5995 | xwrstr ("Usage: tinyscheme -?\n"); |
6039 | putstr (SCHEME_A_ "Usage: tinyscheme -?\n"); |
5996 | xwrstr ("or: tinyscheme [<file1> <file2> ...]\n"); |
6040 | putstr (SCHEME_A_ "or: tinyscheme [<file1> <file2> ...]\n"); |
5997 | xwrstr ("followed by\n"); |
6041 | putstr (SCHEME_A_ "followed by\n"); |
5998 | xwrstr (" -1 <file> [<arg1> <arg2> ...]\n"); |
6042 | putstr (SCHEME_A_ " -1 <file> [<arg1> <arg2> ...]\n"); |
5999 | xwrstr (" -c <Scheme commands> [<arg1> <arg2> ...]\n"); |
6043 | putstr (SCHEME_A_ " -c <Scheme commands> [<arg1> <arg2> ...]\n"); |
6000 | xwrstr ("assuming that the executable is named tinyscheme.\n"); |
6044 | putstr (SCHEME_A_ "assuming that the executable is named tinyscheme.\n"); |
6001 | xwrstr ("Use - as filename for stdin.\n"); |
6045 | putstr (SCHEME_A_ "Use - as filename for stdin.\n"); |
6002 | return 1; |
6046 | return 1; |
6003 | } |
6047 | } |
6004 | |
6048 | |
6005 | if (!scheme_init (SCHEME_A)) |
6049 | if (!scheme_init (SCHEME_A)) |
6006 | { |
6050 | { |
6007 | xwrstr ("Could not initialize!\n"); |
6051 | putstr (SCHEME_A_ "Could not initialize!\n"); |
6008 | return 2; |
6052 | return 2; |
6009 | } |
6053 | } |
6010 | |
6054 | |
6011 | # if USE_PORTS |
6055 | # if USE_PORTS |
6012 | scheme_set_input_port_file (SCHEME_A_ STDIN_FILENO); |
6056 | scheme_set_input_port_file (SCHEME_A_ STDIN_FILENO); |
… | |
… | |
6057 | fin = open (file_name, O_RDONLY); |
6101 | fin = open (file_name, O_RDONLY); |
6058 | #endif |
6102 | #endif |
6059 | |
6103 | |
6060 | if (isfile && fin < 0) |
6104 | if (isfile && fin < 0) |
6061 | { |
6105 | { |
6062 | xwrstr ("Could not open file "); xwrstr (file_name); xwrstr ("\n"); |
6106 | putstr (SCHEME_A_ "Could not open file "); putstr (SCHEME_A_ file_name); putstr (SCHEME_A_ "\n"); |
6063 | } |
6107 | } |
6064 | else |
6108 | else |
6065 | { |
6109 | { |
6066 | if (isfile) |
6110 | if (isfile) |
6067 | scheme_load_named_file (SCHEME_A_ fin, file_name); |
6111 | scheme_load_named_file (SCHEME_A_ fin, file_name); |
… | |
… | |
6071 | #if USE_PORTS |
6115 | #if USE_PORTS |
6072 | if (!isfile || fin != STDIN_FILENO) |
6116 | if (!isfile || fin != STDIN_FILENO) |
6073 | { |
6117 | { |
6074 | if (SCHEME_V->retcode != 0) |
6118 | if (SCHEME_V->retcode != 0) |
6075 | { |
6119 | { |
6076 | xwrstr ("Errors encountered reading "); xwrstr (file_name); xwrstr ("\n"); |
6120 | putstr (SCHEME_A_ "Errors encountered reading "); putstr (SCHEME_A_ file_name); putstr (SCHEME_A_ "\n"); |
6077 | } |
6121 | } |
6078 | |
6122 | |
6079 | if (isfile) |
6123 | if (isfile) |
6080 | close (fin); |
6124 | close (fin); |
6081 | } |
6125 | } |