1 /*
2 * Easy-ISLisp (ISLisp) written by kenichi sasagawa 2016/4
3 */
4 /*
5 * memory map M&S GC mode address 0 - 19999999 Heap area
6 *
7 * Copying GC mode 0 - 5999999 Heap area 6000000 - 12999999 Work1 area
8 * 12999999 - 19999999 Wrok2 area
9 */
10
11 #ifndef EISL_H
12 #define EISL_H
13
14 #include <setjmp.h>
15 #include <stdbool.h>
16 #include <string.h>
17 #include <signal.h>
18 #include "compat/cdefs.h"
19 #include "ffi.h"
20 #include "term.h"
21 #include "except.h"
22 #include "eiffel.h"
23
24 #define DYNSIZE 1000
25 #define STACKSIZE 400000
26 #define BUFSIZE 256
27 #define STRSIZE 100000
28 #define SHORT_STRSIZE 32
29 #define HASHTBSIZE 107
30 #define CTRLSTK 200
31 #define BACKSIZE 30
32 #define EISL_PATH_MAX 256
33 #define COL_SIZE 255
34 #define NUM_HISTORY 10
35 #define NESTED_BLOCKS_MAX 50
36
37 static const float VERSION = 2.35;
38 static const int WORK1 = ((int)((CELLSIZE) / 20 * 6));
39 static const int WORK2 = ((int)((CELLSIZE) / 20 * 13));
40 static const int FREESIZE = 900;
41 static const int SYMSIZE = 256;
42 static const int CHARSIZE = 2; // ascii char. add \0 to tail
43 static const int MATSIZE = 256;
44 static const int UNDEF = 4;
45 static const int FEND = 6;
46
47 static const int BIGNUM_BASE = 1000000000;
48 static const int FAILSE = -1000000000;
49
50 typedef enum __packed { EMP, INTN, FLTN, LONGN, BIGX, VEC, ARR, CHR, STR, SYM,
51 LIS, DUMMY,
52 SUBR, FSUBR, FUNC, MACRO, CLASS, INSTANCE, GENERIC, METHOD,
53 STREAM
54 } tag_t;
55 typedef enum __packed { FRE, USE } flag;
56
57 typedef int (*subr_t)(int args);
58 typedef struct __packed {
59 union __packed {
60 double fltnum;
61 long long int lngnum;
62 struct __packed {
63 union {
64 int intnum;
65 subr_t subr;
66 FILE *port;
67 int *dyna_vec;
68 float *dyna_fvec;
69 } car;
70 union {
71 int intnum;
72 } cdr;
73 };
74 } val;
75 int aux;
76 int prop;
77 char *name;
78 tag_t tag;
79 flag flag;
80 signed char option;
81 char trace;
82 } cell;
83
84
85 typedef enum { LPAREN, RPAREN, QUOTE, DOT, BACKQUOTE, COMMA, ATMARK,
86 STRING, SYMBOL,
87 FUNCTION, INTEGER, FLOAT_N, BIGNUM, VECTOR, ARRAY, CHARACTER,
88 BINARY, OCTAL, DECNUM, HEXNUM, EXPTNUM, EXPTOVERF, EXPTUNDERF, FILEEND, OTHER
89 } toktype;
90 typedef enum { GO, BACK } backtrack;
91
92 typedef struct {
93 char ch;
94 backtrack flag;
95 toktype type;
96 char buf[BUFSIZE];
97 } token;
98
99 typedef struct {
100 char sepch;
101 char before[BUFSIZE];
102 char after[BUFSIZE];
103 } septoken;
104
105
106 // ------pointer----
107 extern int ep; // environment pointer
108 extern int dp; // dynamic pointer
109 extern int hp; // heap pointer
110 extern int sp; // stack pointer
111 extern int fc; // free counter
112 extern int ap; // arglist pointer
113 extern int lp; // shelter pointer
114 extern int wp; // working pointer
115 extern int ac; // allocate counter
116
117 // ------class-----
118 extern int cobject;
119 extern int cbasic_array;
120 extern int cbasic_array_star;
121 extern int cgeneral_array_star;
122 extern int cbasic_vector;
123 extern int cgeneral_vector;
124 extern int cstring;
125 extern int cbuilt_in_class;
126 extern int ccharacter;
127 extern int cfunction;
128 extern int cgeneric_function;
129 extern int cstandard_generic_function;
130 extern int clist;
131 extern int ccons;
132 extern int cnull;
133 extern int csymbol;
134 extern int cnumber;
135 extern int cfloat;
136 extern int cinteger;
137 extern int cserious_condition;
138 extern int cerror;
139 extern int carithmetic_error;
140 extern int cdivision_by_zero;
141 extern int cfloating_point_overflow;
142 extern int cfloating_point_underflow;
143 extern int ccontrol_error;
144 extern int cparse_error;
145 extern int cprogram_error;
146 extern int cdomain_error;
147 extern int cclass_error;
148 extern int cundefined_entity;
149 extern int cunbound_variable;
150 extern int cundefined_function;
151 extern int csimple_error;
152 extern int cstream_error;
153 extern int cend_of_stream;
154 extern int cstorage_exhausted;
155 extern int cstandard_class;
156 extern int cstandard_object;
157 extern int cstream;
158 extern int cinvalid;
159 extern int cfixnum;
160 extern int clongnum;
161 extern int cbignum;
162
163 static const int CLASS_NULL = 28;
164 static const int CLASS_SYMBOL = 29;
165
166
167 // stream
168 extern int standard_input;
169 extern int standard_output;
170 extern int standard_error;
171 extern int input_stream;
172 extern int output_stream;
173 extern int error_stream;
174 extern char stream_str[STRSIZE];
175 extern int charcnt;
176
177
178 // read scanner
179 extern token stok;
180 extern int line;
181 extern int column;
182 extern int buffer[COL_SIZE + 1][NUM_HISTORY];
183 extern int buffer1[COL_SIZE + 1];
184
185
186 // heap and stack
187 extern cell heap[CELLSIZE];
188 extern int stack[STACKSIZE];
189 extern int argstk[STACKSIZE];
190 extern int cell_hash_table[HASHTBSIZE];
191 extern int shelter[STACKSIZE];
192 extern int dynamic[DYNSIZE][2];
193
194 #define DEF_GETTER(RETURN_TYPE, NAME, MEMBER, DEFAULT) \
195 static inline RETURN_TYPE GET_ ## NAME (int addr) \
196 { \
197 if (CELLRANGE(addr)) { \
198 return heap[addr].MEMBER; \
199 } else { \
200 return DEFAULT; \
201 } \
202 }
203 DEF_GETTER(int, CAR, val.car.intnum, NIL)
204 DEF_GETTER(int, CDR, val.cdr.intnum, NIL)
DEF_GETTER(int,AUX,aux,cfixnum)205 DEF_GETTER(int, AUX, aux, cfixnum)
206 DEF_GETTER(int, PROP, prop, NIL)
207 DEF_GETTER(subr_t, SUBR, val.car.subr, NULL)
208 DEF_GETTER(tag_t, TAG, tag, INTN)
209
210 static inline FILE *GET_PORT(int addr)
211 {
212 REQUIRE(CELLRANGE(addr) &&
213 GET_TAG(addr) == STREAM);
214 FILE *res = heap[addr].val.car.port;
215 ENSURE(res != NULL);
216 return res;
217 }
218
219 static inline int
GET_INT(int addr)220 GET_INT(int addr)
221 {
222 return ((addr > 0) ? (INT_MASK & addr) : addr);
223 }
224
225 DEF_GETTER(double, FLT, val.fltnum, NIL)
226 DEF_GETTER(long long int, LONG, val.lngnum, NIL)
227
228 static inline void
SET_NAME(int addr,const char * x)229 SET_NAME(int addr, const char *x)
230 {
231 REQUIRE(CELLRANGE(addr));
232 heap[addr].name = (char *)x;
233 }
GET_NAME(int addr)234 static inline char *GET_NAME(int addr)
235 {
236 REQUIRE(CELLRANGE(addr));
237 char *res = heap[addr].name;
238 ENSURE(res != NULL);
239 return res;
240 }
241
242 static inline char
GET_CHAR(int addr)243 GET_CHAR(int addr)
244 {
245 REQUIRE(CELLRANGE(addr) &&
246 GET_TAG(addr) == CHR &&
247 heap[addr].name != NULL);
248 return heap[addr].name[0];
249 }
250
251 DEF_GETTER(signed char, OPT, option, 0)
252
SET_TAG(int addr,tag_t x)253 static inline void SET_TAG(int addr, tag_t x)
254 {
255 REQUIRE(CELLRANGE(addr));
256 heap[addr].tag = x;
257 }
258
259 static inline void
SET_CAR(int addr,int x)260 SET_CAR(int addr, int x)
261 {
262 REQUIRE(CELLRANGE(addr));
263 heap[addr].val.car.intnum = x;
264 }
265
266 static inline void
SET_CDR(int addr,int x)267 SET_CDR(int addr, int x)
268 {
269 REQUIRE(CELLRANGE(addr));
270 heap[addr].val.cdr.intnum = x;
271 }
272
273 static inline void
SET_AUX(int addr,int x)274 SET_AUX(int addr, int x)
275 {
276 REQUIRE(CELLRANGE(addr));
277 heap[addr].aux = x;
278 }
279
280 static inline int
SET_PROP(int addr,int x)281 SET_PROP(int addr, int x)
282 {
283 if (CELLRANGE(addr)) {
284 return (heap[addr].prop = x);
285 } else {
286 return NIL;
287 }
288 }
289
290 static inline void
SET_FLT(int addr,double x)291 SET_FLT(int addr, double x)
292 {
293 REQUIRE(CELLRANGE(addr) &&
294 GET_TAG(addr) == FLTN);
295 heap[addr].val.fltnum = x;
296 }
297
298 static inline void
SET_LONG(int addr,long long int x)299 SET_LONG(int addr, long long int x)
300 {
301 REQUIRE(CELLRANGE(addr) &&
302 GET_TAG(addr) == LONGN);
303 heap[addr].val.lngnum = x;
304 }
305
306 static inline void
SET_PORT(int addr,FILE * x)307 SET_PORT(int addr, FILE * x)
308 {
309 REQUIRE(CELLRANGE(addr) &&
310 GET_TAG(addr) == STREAM);
311 heap[addr].val.car.port = x;
312 }
313
314 static inline void
SET_OPT(int addr,signed char x)315 SET_OPT(int addr, signed char x)
316 {
317 REQUIRE(CELLRANGE(addr));
318 heap[addr].option = x;
319 }
320
321 static inline void
SET_TR(int addr,char x)322 SET_TR(int addr, char x)
323 {
324 REQUIRE(CELLRANGE(addr));
325 heap[addr].trace = x;
326 }
327
328 static inline void
SET(int addr,int x)329 SET(int addr, int x)
330 {
331 REQUIRE(CELLRANGE(addr) && CELLRANGE(x));
332 heap[addr] = heap[x];
333 }
334
335 #define DEF_PREDICATE(NAME, TAG) \
336 static inline bool IS_ ## NAME (int addr) \
337 { \
338 if (CELLRANGE(addr)) { \
339 return (heap[addr].tag == TAG); \
340 } else { \
341 return NIL; \
342 } \
343 }
344 static inline bool
IS_INTEGER(int addr)345 IS_INTEGER(int addr)
346 {
347 return !CELLRANGE(addr);
348 }
349
DEF_PREDICATE(BIGXNUM,BIGX)350 DEF_PREDICATE(BIGXNUM, BIGX)
351 DEF_PREDICATE(LONGNUM, LONGN)
352 DEF_PREDICATE(FLOAT, FLTN)
353 DEF_PREDICATE(LIST, LIS)
354 DEF_PREDICATE(STRING, STR)
355
356 static inline bool IS_NIL(int addr)
357 {
358 return (addr == NIL);
359 }
360
361 static inline bool
IS_T(int addr)362 IS_T(int addr)
363 {
364 return (addr == T);
365 }
366
DEF_PREDICATE(VECTOR,VEC)367 DEF_PREDICATE(VECTOR, VEC)
368 DEF_PREDICATE(ARRAY, ARR)
369 DEF_PREDICATE(SUBR, SUBR)
370 DEF_PREDICATE(FSUBR, FSUBR)
371 DEF_PREDICATE(FUNC, FUNC)
372 DEF_PREDICATE(MACRO, MACRO)
373 DEF_PREDICATE(CLASS, CLASS)
374 DEF_PREDICATE(GENERIC, GENERIC)
375
376 static inline bool HAS_NAME(int addr, const char *x)
377 {
378 REQUIRE(CELLRANGE(addr) &&
379 heap[addr].name != NULL);
380 return (strcmp(heap[addr].name, x) == 0);
381 }
382
383 static inline bool
SAME_NAME(int addr1,int addr2)384 SAME_NAME(int addr1, int addr2)
385 {
386 REQUIRE(CELLRANGE(addr1) && CELLRANGE(addr2) &&
387 heap[addr1].name != NULL && heap[addr2].name != NULL);
388 return (strcmp(heap[addr1].name, heap[addr2].name) == 0);
389 }
390
391 static inline char
STRING_REF(int addr,int k)392 STRING_REF(int addr, int k)
393 {
394 REQUIRE(CELLRANGE(addr) &&
395 (GET_TAG(addr) == STR || GET_TAG(addr) == SYM ||
396 (GET_TAG(addr) == CHR && k == 0)) &&
397 heap[addr].name != NULL);
398 return heap[addr].name[k];
399 }
400
401 static inline void
STRING_SET(int addr,int k,char c)402 STRING_SET(int addr, int k, char c)
403 {
404 REQUIRE(CELLRANGE(addr) &&
405 GET_TAG(addr) == STR &&
406 heap[addr].name != NULL);
407 heap[addr].name[k] = c;
408 }
409
410 static inline int
GET_VEC_ELT(int addr,int i)411 GET_VEC_ELT(int addr, int i)
412 {
413 REQUIRE(CELLRANGE(addr) &&
414 (GET_TAG(addr) == VEC || GET_TAG(addr) == ARR) &&
415 heap[addr].val.car.dyna_vec != NULL);
416 return heap[addr].val.car.dyna_vec[i];
417 }
418
419 static inline void
SET_VEC_ELT(int addr,int i,int x)420 SET_VEC_ELT(int addr, int i, int x)
421 {
422 REQUIRE(CELLRANGE(addr) &&
423 (GET_TAG(addr) == VEC || GET_TAG(addr) == ARR) &&
424 heap[addr].val.car.dyna_vec != NULL);
425 heap[addr].val.car.dyna_vec[i] = x;
426 }
427
428 static inline void
SET_VEC(int addr,int * x)429 SET_VEC(int addr, int *x)
430 {
431 REQUIRE(CELLRANGE(addr) &&
432 (GET_TAG(addr) == VEC || GET_TAG(addr) == ARR));
433 heap[addr].val.car.dyna_vec = x;
434 }
435
436 static inline int
IDX2C(int i,int j,int ld)437 IDX2C(int i, int j, int ld)
438 {
439 return (j * ld + i);
440 }
441
442 static inline int
IDX2R(int i,int j,int ld)443 IDX2R(int i, int j, int ld)
444 {
445 return (i * ld + j);
446 }
447
448 static inline void
append_str(int output_stream,const char * from)449 append_str(int output_stream, const char *from)
450 {
451 char *to = GET_NAME(output_stream);
452 strncat(to, from, STRSIZE - strlen(to) - 1);
453 to[STRSIZE - 1] = '\0';
454 SET_PROP(output_stream,GET_PROP(output_stream)+strlen(from));
455 }
456
457 static inline void
output_str(int output_stream,const char * from)458 output_str(int output_stream, const char *from)
459 {
460 if (GET_OPT(output_stream) != EISL_OUTSTR) {
461 fputs(from, GET_PORT(output_stream));
462 } else {
463 append_str(output_stream, from);
464 }
465 }
466
467 static inline void
output_char(int output_stream,char c)468 output_char(int output_stream, char c)
469 {
470 if (GET_OPT(output_stream) != EISL_OUTSTR) {
471 fputc(c, GET_PORT(output_stream));
472 } else {
473 stream_str[0] = c;
474 stream_str[1] = '\0';
475 append_str(output_stream, stream_str);
476 }
477 }
478
479 // object oriented
480 extern int generic_func;
481 extern int generic_vars;
482 extern int next_method;
483 extern int generic_list;
484
485
486 // flag
487 extern int gArgC;
488 extern char **gArgV;
489 extern bool gbc_flag;
490 extern int genint;
491 extern bool simp_flag;
492 extern bool ignore_flag;
493 extern bool open_flag;
494 extern bool top_flag;
495 extern bool redef_flag;
496 extern bool start_flag;
497 extern bool back_flag;
498 extern bool ignore_topchk;
499 extern bool repl_flag;
500 extern volatile sig_atomic_t exit_flag;
501 extern bool greeting_flag;
502 extern bool script_flag;
503 extern bool handling_resource_err;
504 extern bool looking_for_shebang;
505 extern bool multiple_call_next_method;
506
507 // switch
508 extern int gc_sw;
509 extern int area_sw;
510
511 // longjmp control and etc
512 extern Except_T Restart_Repl,
513 Exit_Interp;
514 extern jmp_buf block_buf[NESTED_BLOCKS_MAX];
515 extern int block_tag_check[NESTED_BLOCKS_MAX];
516 extern int block_env[NESTED_BLOCKS_MAX][2];
517 extern jmp_buf catch_buf[10][50];
518 extern int catch_env[10][50];
519 extern Except_T Ignored_Error; // for ignore-errors
520 extern int block_tag[CTRLSTK]; // array to sotre tag address
521 extern int catch_tag[CTRLSTK];
522 extern int unwind_buf[CTRLSTK];
523 extern int catch_symbols;
524 extern int block_pt; // pointer for block
525 extern int catch_pt; // catch counter
526 extern int unwind_pt; // lambda address for unwind-protect
527 extern int block_arg; // argument that block will recieve
528 extern int catch_arg; // argument that catch will recieve
529 extern int tagbody_tag; // tag symbol address in tagbody
530 extern int error_handler;
531 extern int trace_list;
532 extern int backtrace[BACKSIZE];
533
534 __dead static inline void
DEBUG(void)535 DEBUG(void)
536 {
537 puts("debug");
538 RAISE(Exit_Interp);
539 }
540
541 extern int ed_lparen_col;
542 extern int ed_rparen_col;
543 extern const char *ed_candidate[COMPLETION_CANDIDATES_MAX];
544 extern int ed_candidate_pt;
545 extern const short ed_syntax_color;
546 extern const short ed_builtin_color;
547 extern const short ed_extended_color;
548 extern const short ed_string_color;
549 extern const short ed_comment_color;
550 extern int ed_incomment;
551
552 // -------error code---
553 enum {
554 UNDEF_VAR = 101,
555 UNDEF_FUN,
556 NOT_COMPUTABLE,
557 OUT_OF_RANGE,
558 MALLOC_OVERF,
559 UNDEF_CLASS,
560 WRONG_ARGS,
561 NOT_NUM,
562 NOT_STR,
563 NOT_LIST,
564 NOT_SYM,
565 ILLEGAL_INPUT,
566 NOT_FUNC,
567 UNDEF_TAG,
568 CANT_OPEN,
569 ILLEGAL_ARGS,
570 NOT_VEC,
571 NOT_ARR,
572 NOT_CLASS,
573 NOT_METHOD,
574 NOT_CONS,
575 CANT_MODIFY,
576 NOT_INT,
577 NOT_STREAM,
578 NOT_OUT_STREAM,
579 NOT_IN_STREAM,
580 NOT_CHAR,
581 NOT_FLT,
582 NOT_INSTANCE,
583 CTRL_OVERF,
584 ILLEGAL_RPAREN,
585 END_STREAM,
586 ILLEGAL_FORM,
587 IMPROPER_FORM,
588 DIV_ZERO,
589 NOT_VECARR,
590 CANT_CREATE,
591 CANT_PARSE,
592 CANT_ASSURE,
593 NOT_EXIST_METHOD,
594 HAS_COMMON_CLASS,
595 ILLEGAL_CLASS,
596 NOT_TOP_LEVEL,
597 NOT_POSITIVE,
598 FLT_OVERF,
599 FLT_UNDERF,
600 CANT_REDEFINE,
601 STACK_OVERF,
602 SHELTER_OVERF,
603 STACK_UNDERF,
604 SHELTER_UNDERF,
605 SYSTEM_ERR,
606 RESOURCE_ERR,
607 NOT_EXIST_ARG,
608 IMPROPER_ARGS,
609 OUT_OF_DOMAIN,
610 FLT_OUT_OF_DOMAIN,
611 OUT_OF_REAL,
612 NOT_BASIC_ARRAY,
613 SERIOUS_ERR,
614 ARITHMETIC_ERR,
615 DOMAIN_ERR,
616 UNDEF_DYN,
617 UNDEF_ENTITY,
618 SIMPLE_ERR,
619 EXHAUSTED_ERR,
620 DYNAMIC_OVERF,
621 };
622
623 double getETime(void);
624 int readc(void);
625 int absolute(int x);
626 int adddynenv(int sym, int val);
627 int addsym(const char *name, int index);
628 int adaptp(int varlist, int arglist);
629 int angle(int y, int x);
630 int append(int x, int y);
631 int apply(int func, int arg);
632 int argpush(int addr);
633 int argpop(void);
634 int array(int n, int ls);
635 int array_dim(int n, int ls);
636 int array_length(int obj);
637 int array_ref(int obj, int ls);
638 int array_set(int obj, int ls, int val);
639 int arrayp(int addr);
640 int assoc(int sym, int lis);
641 int assoclistp(int ls);
642 int assq(int x, int y);
643 int atomp(int addr);
644 int bignump(int x);
645 int bignumtoken(char buf[]);
646 int bigx_abs(int x);
647 int bigx_big_to_flt(int x);
648 int bigx_eqp(int x, int y);
649 int bigx_flt_to_big(int x);
650 int bigx_int_to_big(int x);
651 int bigx_length(int x);
652 int bigx_long_to_big(int x);
653 int bigx_minus(int arg1, int arg2);
654 int bigx_minus1(int arg1, int arg2);
655 int bigx_mult(int arg1, int arg2);
656 int bigx_mult_i(int x, int y);
657 int bigx_mult1(int arg1, int arg2);
658 int bigx_negativep(int x);
659 int bigx_plus(int arg1, int arg2);
660 int bigx_plus1(int arg1, int arg2);
661 int bigx_positivep(int x);
662 int bigx_div(int arg1, int arg2);
663 int bigx_div_i(int x, int y);
664 int bigx_div1(int arg1, int arg2);
665 int bigx_remainder_i(int x, int y);
666 int bigx_shift(int x, int n);
667 int bigx_simplify(int x);
668 int bigx_smallerp(int arg1, int arg2);
669 int bind_args(int x);
670 int bintoken(char buf[]);
671 int caar(int addr);
672 int cadar(int addr);
673 int caddar(int addr);
674 int caddr(int addr);
675 int cadr(int addr);
676 int car(int addr);
677 int cdar(int addr);
678 int cdddr(int addr);
679 int cddr(int addr);
680 int cdr(int addr);
681 int charp(int x);
682 int check_dimension(int ls);
683 int classp(int x);
684 int class_symbol_p(int x);
685 int cons(int car, int cdr);
686 int cons_next(int x, int y);
687 int cons_prev(int x, int y);
688 int copy(int x);
689 int copy_work(int x);
690 int copy_heap(int x);
691 int copy_symbol(int x);
692 int copy_int(int x);
693 int copy_long(int x);
694 int copy_flt(int x);
695 int copy_vec(int x);
696 int copy_array(int x);
697 int copy_str(int x);
698 int copy_char(int x);
699 int copy_func(int x);
700 int copy_generic(int x);
701 int copy_macro(int x);
702 int copy_stream(int x);
703 int copy_class(int x);
704 int copy_bignum(int x);
705 int copy_cons_next(int x, int y);
706 int copy_gen_big(void);
707 int count_args(int ls);
708 int create_array(int x);
709 int create_list(int x, int y);
710 int dectoken(char buf[]);
711 int divide(int arg1, int arg2);
712 int duplicate_list_p(int ls);
713 int each_car(int x);
714 int each_cdr(int x);
715 int eqgreaterp(int x, int y);
716 int eqlp(int addr1, int addr2);
717 int eqp(int addr1, int addr2);
718 int eqsmallerp(int x, int y);
719 int equalp(int addr1, int addr2);
720 int eval(int addr);
721 int evlis(int addr);
722 int exact_to_inexact(int x);
723 int expt(int x, int y);
724 int expttoken(char buf[]);
725 int f_abs(int x);
726 int f_address(int arglist);
727 int f_and(int addr);
728 int f_append(int addr);
729 int f_apply(int addr);
730 int f_aref(int x);
731 int f_arithmetic_error_operands(int arglist);
732 int f_arithmetic_error_operation(int arglist);
733 int f_array_dimensions(int x);
734 int f_assoc(int addr);
735 int f_assure(int arglist);
736 int f_atan(int x);
737 int f_atan2(int x);
738 int f_atanh(int x);
739 int f_atomp(int addr);
740 int f_basic_array_p(int x);
741 int f_basic_array_star_p(int arglist);
742 int f_basic_vector_p(int arglist);
743 int f_debug(int arglist);
744 int f_block(int x);
745 int f_break(int arglist);
746 int f_call_next_method(int arglist);
747 int f_car(int addr);
748 int f_case(int x);
749 int f_case_using(int x);
750 int f_catch(int x);
751 int f_cdr(int addr);
752 int f_ceiling(int x);
753 int f_cerror(int x);
754 int f_char_eqgreaterp(int x);
755 int f_char_eqp(int x);
756 int f_char_eqsmallerp(int x);
757 int f_char_greaterp(int x);
758 int f_char_index(int arglist);
759 int f_char_noteqp(int x);
760 int f_char_smallerp(int x);
761 int f_characterp(int addr);
762 int f_class(int x);
763 int f_class_of(int arglist);
764 int f_close(int x);
765 int f_cond(int addr);
766 int f_condition_continuable(int arglist);
767 int f_cons(int addr);
768 int f_consp(int addr);
769 int f_continue_condition(int arglist);
770 int f_convert(int arglist);
771 int f_cos(int addr);
772 int f_cosh(int x);
773 int f_create_array(int x);
774 int f_create_list(int addr);
775 int f_create_star(int x);
776 int f_create_string(int arglist);
777 int f_create_string_input_stream(int x);
778 int f_create_string_output_stream(int x);
779 int f_create_vector(int x);
780 int f_defclass(int x);
781 int f_defconstant(int addr);
782 int f_defdynamic(int addr);
783 int f_defgeneric(int x);
784 int f_defgeneric_star(int arglist);
785 int f_defglobal(int addr);
786 int f_defmacro(int addr);
787 int f_defmethod(int x);
788 int f_defmodule(int addr);
789 int f_defun(int addr);
790 int f_div(int x);
791 int f_domain_error_expected_class(int arglist);
792 int f_domain_error_object(int arglist);
793 int f_dummyp(int arglist);
794 int f_dynamic(int addr);
795 int f_dynamic_let(int x);
796 int f_elt(int arglist);
797 int f_eq(int addr);
798 int f_eqgreater(int addr);
799 int f_eql(int addr);
800 int f_eqsmaller(int addr);
801 int f_equal(int addr);
802 int f_error(int x);
803 int f_error_output(int x);
804 int f_eval(int addr);
805 int f_exp(int x);
806 int f_expt(int x);
807 int f_file_length(int arglist);
808 int f_file_position(int arglist);
809 int f_finish_output(int x);
810 int f_flet(int arglist);
811 int f_float(int x);
812 int f_floatp(int addr);
813 int f_floor(int x);
814 int f_for(int x);
815 int f_format(int x);
816 int f_format_char(int x);
817 int f_format_float(int x);
818 int f_format_fresh_line(int arglist);
819 int f_format_integer(int x);
820 int f_format_object(int arglist);
821 int f_format_tab(int arglist);
822 int f_funcall(int addr);
823 int f_function(int addr);
824 int f_function_star(int addr);
825 int f_functionp(int addr);
826 int f_garef(int arglist);
827 int f_gbc(int addr);
828 int f_gcd(int x);
829 int f_general_array_star_p(int arglist);
830 int f_general_vector_p(int arglist);
831 int f_generic_function_p(int arglist);
832 int f_gensym(int addr);
833 int f_get_internal_real_time(int arglist);
834 int f_get_internal_run_time(int arglist);
835 int f_get_output_stream_string(int x);
836 int f_get_universal_time(int arglist);
837 int f_go(int x);
838 int f_getenv(int arglist);
839 int f_greater(int addr);
840 int f_heapdump(int addr);
841 int f_identity(int arglist);
842 int f_if(int addr);
843 int f_ignore_errors(int arglist);
844 int f_import(int arglist);
845 int f_initialize_object_star(int arglist);
846 int f_input_stream_p(int x);
847 int f_instance(int x);
848 int f_instancep(int x);
849 int f_integerp(int x);
850 int f_internal_time_units_per_second(int arglist);
851 int f_isqrt(int arglist);
852 int f_labels(int addr);
853 int f_lambda(int addr);
854 int f_lcm(int x);
855 int f_length(int addr);
856 int f_let(int addr);
857 int f_letstar(int addr);
858 int f_list(int addr);
859 int f_listp(int addr);
860 int f_load(int arglist);
861 int f_log(int x);
862 int f_macroexpand_1(int arglist);
863 int f_macroexpand_all(int arglist);
864 int f_map_into(int arglist);
865 int f_mapc(int addr);
866 int f_mapcan(int arglist);
867 int f_mapcar(int addr);
868 int f_mapcon(int x);
869 int f_mapl(int x);
870 int f_maplist(int addr);
871 int f_max(int x);
872 int f_member(int addr);
873 int f_min(int x);
874 int f_minus(int addr);
875 int f_mod(int x);
876 int f_mult(int addr);
877 int f_nconc(int arglist);
878 int f_next_method_p(int arglist);
879 int f_not(int addr);
880 int f_notnumeqp(int x);
881 int f_nreverse(int addr);
882 int f_nullp(int addr);
883 int f_numberp(int addr);
884 int f_numeqp(int addr);
885 int f_open_input_file(int x);
886 int f_open_io_file(int x);
887 int f_open_output_file(int x);
888 int f_open_stream_p(int x);
889 int f_or(int addr);
890 int f_output_stream_p(int x);
891 int f_parse_error_expected_class(int arglist);
892 int f_parse_error_string(int arglist);
893 int f_parse_number(int arglist);
894 int f_plus(int addr);
895 int f_preview_char(int x);
896 int f_prin1(int addr);
897 int f_print(int addr);
898 int f_probe_file(int arglist);
899 int f_progn(int x);
900 int f_property(int addr);
901 __dead int f_quit(int addr);
902 int f_quotient(int addr);
903 int f_random_real(int arglist);
904 int f_random(int arglist);
905 int f_read(int addr);
906 int f_read_byte(int arglist);
907 int f_read_char(int x);
908 int f_read_line(int x);
909 int f_reciprocal(int x);
910 int f_remove_property(int arglist);
911 int f_return_from(int x);
912 int f_reverse(int addr);
913 int f_round(int arglist);
914 int f_set_aref(int arglist);
915 int f_set_car(int x);
916 int f_set_cdr(int x);
917 int f_set_dynamic(int arglist);
918 int f_set_elt(int arglist);
919 int f_set_file_position(int arglist);
920 int f_set_garef(int arglist);
921 int f_set_property(int addr);
922 int f_set_slot_value(int arglist);
923 int f_setf(int addr);
924 int f_setq(int addr);
925 int f_signal_condition(int arglist);
926 int f_simple_error_format_arguments(int arglist);
927 int f_simple_error_format_string(int arglist);
928 int f_sin(int addr);
929 int f_sinh(int x);
930 int f_slot_value(int x);
931 int f_smaller(int addr);
932 int f_sqrt(int x);
933 int f_standard_input(int x);
934 int f_standard_output(int x);
935 int f_stream_error_stream(int arglist);
936 int f_stream_ready_p(int arglist);
937 int f_streamp(int x);
938 int f_string_append(int arglist);
939 int f_string_eqgreaterp(int arglist);
940 int f_string_eqp(int x);
941 int f_string_eqsmallerp(int arglist);
942 int f_string_greaterp(int arglist);
943 int f_string_index(int arglist);
944 int f_string_noteqp(int x);
945 int f_string_smallerp(int arglist);
946 int f_stringp(int addr);
947 int f_subclassp(int x);
948 int f_subseq(int arglist);
949 int f_modulesubst(int arglist);
950 int f_symbolp(int addr);
951 int f_tagbody(int x);
952 int f_tan(int addr);
953 int f_tanh(int x);
954 int f_the(int arglist);
955 int f_throw(int x);
956 int f_time(int arglist);
957 int f_trace(int arglist);
958 int f_truncate(int x);
959 int f_undefined_entity_name(int arglist);
960 int f_undefined_entity_namespace(int arglist);
961 int f_untrace(int arglist);
962 int f_unwind_protect(int x);
963 int f_vector(int x);
964 int f_while(int x);
965 int f_with_error_output(int x);
966 int f_with_handler(int arglist);
967 int f_with_open_input_file(int x);
968 int f_with_open_io_file(int x);
969 int f_with_open_output_file(int x);
970 int f_with_standard_input(int x);
971 int f_with_standard_output(int x);
972 int f_write_byte(int arglist);
973 int f_line_argument(int arglist);
974 int find_return_from_p(int x);
975 int finddyn(int sym);
976 int findenv(int sym);
977 int flatten(int n, int ls);
978 int floatp(int x);
979 int flttoken(char buf[]);
980 int fprintr(FILE * p, int r, int n);
981 int freshcell(void);
982 int fsubrp(int addr);
983 int functionp(int addr);
984 int gbcsw(void);
985 int gcd(int x, int y);
986 int getwp(void);
987 int gen_big(void);
988 int gen_n(int n);
989 int genericp(int addr);
990 int genlamlis_to_lamlis(int varlist);
991 int get_msb(int x);
992 int get_nth(int x, int n);
993 int get_sign(int x);
994 int getsym(const char *name, int index);
995 int greaterp(int x, int y);
996 int has_common_p(int ls);
997 int has_common_p1(int x, int y);
998 int hash(const char *name);
999 int has_multiple_call_next_method_p(int x);
1000 int has_multiple_call_next_method_p1(int x);
1001 int has_multiple_call_next_method_p2(int x);
1002 int has_same_p(int ls);
1003 int has_sys_class_p(int ls);
1004 int hcons(int x, int y);
1005 int happend(int x, int y);
1006 int hreverse(int x);
1007 int hlist1(int x);
1008 int hextoken(char buf[]);
1009 int hfreshcell(void);
1010 int high_priority_p(int x, int y);
1011 int illegal_lambda_p(int ls);
1012 int improper_list_p(int ls);
1013 int includep(int x, int y);
1014 int initinst(int x, int initls);
1015 int initinst1(int ls, int sc, int initls);
1016 int initinst2(int inst_vars, int class_vars, int initls);
1017 int input_stream_p(int x);
1018 int indomainp(int ls);
1019 int inrangep(int x, int y);
1020 int int_gcd(int x, int y);
1021 int integerp(int x);
1022 int intlcm(int x, int y);
1023 int inttoken(char buf[]);
1024 int inttoken_nsgn(char buf[]);
1025 int isqrt(int x);
1026 int isqrt1(int s, int s2, int x);
1027 int issymch(char c);
1028 int ILOSerror(int fun, int arg);
1029 int last(int x);
1030 int laststr(char buf[]);
1031 int lcm(int x, int y);
1032 int length(int addr);
1033 char *library_file(const char *basename);
1034 int list(int addr);
1035 int list_drop(int ls, int n);
1036 int list_take(int ls, int n);
1037 int list1(int x);
1038 int list10(int x1, int x2, int x3, int x4, int x5, int x6,
1039 int x7, int x8, int x9, int x10);
1040 int list11(int x1, int x2, int x3, int x4, int x5, int x6,
1041 int x7, int x8, int x9, int x10, int x11);
1042 int list2(int x, int y);
1043 int list3(int x, int y, int z);
1044 int list4(int x1, int x2, int x3, int x4);
1045 int list6(int x1, int x2, int x3, int x4, int x5, int x6);
1046 int list8(int x1, int x2, int x3, int x4, int x5, int x6,
1047 int x7, int x8);
1048 int listcopy(int x);
1049 int listp(int addr);
1050 int listref(int lis, int n);
1051 int listref1(int lis, int n);
1052 int long_int_div(int x, int y);
1053 int long_int_remainder(int x, int y);
1054 int long_long_div(int x, int y);
1055 int long_long_remainder(int x, int y);
1056 int longnump(int x);
1057 int macroexpand_1(int macsym, int args);
1058 int macroexpand_all(int sexp);
1059 int macrop(int addr);
1060 int makearray(int lis, int obj);
1061 int makebigx(char *bignum);
1062 int makechar(const char *pname);
1063 int makeclass(const char *pname, int superclass);
1064 int makedummy(void);
1065 int makedoubleflt(double x);
1066 int makeflt(double floatn);
1067 int makefunc(const char *pname, int addr);
1068 int makegeneric(char *pname, int lamlist, int body);
1069 int makegeneric_star(int lamlist, int body);
1070 int makeinstance(int cl, int ls);
1071 int makeint(int intn);
1072 int makelong(long long int x);
1073 int makemethod(int x);
1074 int makenum(int num);
1075 int makestr(const char *string);
1076 int makestream(FILE * port, int type, const char *name);
1077 int makesym(const char *pname);
1078 int makesym1(const char *pname);
1079 int makeusercond(int cl, int str, int arg);
1080 int makevec(int n, int obj);
1081 int mapc(int x, int y);
1082 int mapcan(int x, int y);
1083 int mapcar(int x, int y);
1084 int mapcon(int x, int y);
1085 int mapl(int x, int y);
1086 int maplist(int x, int y);
1087 int maplist1(int y);
1088 int map_into_thunk(int x, int y);
1089 int map_into_to_list(int x);
1090 int matchp(int varlist, int arglist);
1091 int math_integerp(int x);
1092 int member(int x, int y);
1093 int member1(int x, int y, int z);
1094 int method_qualifier_p(int x);
1095 int minus(int arg1, int arg2);
1096 int modulesubst(int x, int module, int fname);
1097 int modulesubst1(int x, int module);
1098 int modulesubst_case(int addr, int module, int fname);
1099 int mult(int arg1, int arg2);
1100 int nconc(int x, int y);
1101 int negative_zerop(int x);
1102 int negativep(int x);
1103 int next(int x);
1104 int not_exist_class_p(int ls);
1105 int nreverse(int x);
1106 int nullp(int addr);
1107 int numberp(int addr);
1108 int numeqp(int x, int y);
1109 int octtoken(char buf[]);
1110 int output_stream_p(int x);
1111 int plus(int arg1, int arg2);
1112 int pop(void);
1113 int positive_zerop(int x);
1114 int positivep(int x);
1115 int prev(int x);
1116 int push(int x);
1117 int quasi_transfer(int x, int n);
1118 int quotient(int x, int y);
1119 int signal_condition(int x, int y);
1120 int sread(void);
1121 int readlist(void);
1122 int readbin(char *buf);
1123 int readoct(char *buf);
1124 int readhex(char *buf);
1125 int remove_list(int x, int y);
1126 int remove_prop(int x, int lis);
1127 int reverse(int x);
1128 int setdynenv(int sym, int val);
1129 int shelterpop(void);
1130 int s_remainder(int x, int y);
1131 int slotvars(int cl);
1132 int smallerp(int x, int y);
1133 int sprintr(char *str, int r, int n);
1134 int streamp(int x);
1135 int string_length(int x);
1136 int string_ref(int x, int y);
1137 int string_set(int x, int y, int z);
1138 int string_to_list(int x);
1139 int string_to_vector(int x);
1140 int stringp(int x);
1141 int structured(int ls, int st);
1142 int structured1(int ls, int st);
1143 int structured2(int ls, int n);
1144 int subclassp(int x, int y);
1145 int subclassp1(int x, int y);
1146 int sublis(int x, int s, int e);
1147 int subrp(int addr);
1148 int substr(int x, int s, int e);
1149 int subvec(int x, int s, int e);
1150 int symbol_list_p(int ls);
1151 int symbolp(int addr);
1152 int symboltoken(char buf[]);
1153 int symnamep(int addr, char *name);
1154 int superp(int x, int y);
1155 int undef_parameter_p(int ls);
1156 int unified_parameter_p(int lamlis, int ls);
1157 int vec_minus(int x, int y);
1158 int vec_plus(int x, int y);
1159 int vector(int lis);
1160 int vector_length(int x);
1161 int vector_ref(int v, int n);
1162 int vector_to_list(int x);
1163 int vectorp(int x);
1164 int zerop(int addr);
1165 septoken separater(char buf[], char sep);
1166 void addlexenv(int sym, int val);
1167 void bigx_gbc(int x);
1168 void bigx_minus2(int arg, int c, int msb);
1169 void bigx_plus2(int arg, int c, int msb);
1170 void bindarg(int lambda, int arglist);
1171 void bindclass(const char *name, int cl);
1172 void bindconst(const char *name, int obj);
1173 void bindfunc(const char *name, tag_t tag, int (*func)(int));
1174 void bindmacro(char *name, int addr);
1175 void cellprint(int addr);
1176 int checkgbc(void);
1177 void clrcell(int addr);
1178 void copygbc(void);
1179 void copy_hash(int x);
1180 void cut_zero(int x);
1181 void deffsubr(const char *symname, int (*func)(int));
1182 void defsubr(const char *symname, int (*func)(int));
1183 void dropchar(char buf[]);
1184 void error(int errnum, const char *fun, int arg);
1185 int gbc(void);
1186 void gbcmark(void);
1187 void gbcsweep(void);
1188 void gettoken(void);
1189 void heapdump(int start, int end);
1190 void initcell(void);
1191 void initclass(void);
1192 void initerrargs(int cl);
1193 void initexsubr(void);
1194 void initgeneric(void);
1195 void initpt(void);
1196 void initstream(void);
1197 void initsubr(void);
1198 void initsyntax(void);
1199 void insert_method(int x, int func);
1200 void insertstr(char ch, char buf[]);
1201 void markcell(int addr);
1202 void print(int addr);
1203 void print_bigx(int x);
1204 void printarray(int x);
1205 void printchar(int addr);
1206 void printclass(int x);
1207 void printflt(double x);
1208 void printint(int x);
1209 void printlist(int addr);
1210 void printlong(int x);
1211 void printobj(const char *str);
1212 void printstr(int addr);
1213 void printstream(int x);
1214 void printsym(int x);
1215 void printvec(int addr);
1216 void redef_generic(void);
1217 void resort_method(int func);
1218 void set_sign(int x, int y);
1219 void setlexenv(int sym, int val);
1220 void setval(int sym, int val, int ls);
1221 void signal_handler_c(int signo);
1222 void unbind(void);
1223 void unreadc(char c);
1224 void vector_set(int v, int n, int obj);
1225 void store_backtrace(int x);
1226
1227 int f_backtrace(int arglist);
1228 int f_symbol_function(int arglist);
1229 int f_symbol_class(int arglist);
1230
1231 void setcolor(short n);
1232 int eisl_getch(void);
1233 int f_edit(int arglist);
1234 #ifdef __arm__
1235 int f_wiringpi_setup_gpio(int arglist);
1236 int f_wiringpi_spi_setup_ch_speed(int arglist);
1237 int f_pwm_set_mode(int arglist);
1238 int f_pwm_set_range(int arglist);
1239 int f_pwm_set_clock(int arglist);
1240 int f_pin_mode(int arglist);
1241 int f_digital_write(int arglist);
1242 int f_digital_write_byte(int arglist);
1243 int f_pwm_write(int arglist);
1244 int f_pull_up_dn_control(int arglist);
1245 int f_digital_read(int arglist);
1246 int f_delay(int arglist);
1247 int f_delay_microseconds(int arglist);
1248 #endif
1249
1250 void debugger(void);
1251
1252 // Fast project
1253 int a_adaptp(int x, int y);
1254 int a_matchp(int x, int y);
1255 int shelterpush(int addr);
1256 int shelterpop(void);
1257 int freecell(void);
1258 int get_int(int addr);
1259 long long int get_long(int addr);
1260 int nth(int n, int addr);
1261 int f_freedll(int arglist);
1262 int f_system(int arglist);
1263 int set_car(int x, int y);
1264 int set_cdr(int x, int y);
1265 int set_aux(int x, int y);
1266 int set_opt(int x, int y);
1267 int callsubr(int func, int arglist);
1268 int f_subrp(int arglist);
1269 int makeintlong(int n);
1270 int makestrflt(const char *str);
1271 int makedoubleflt(double x);
1272 int makestrlong(const char *str);
1273 int makefaststrlong(const char *str);
1274 int nth_cdr(int n, int x);
1275 int f_macrop(int arglist);
1276 int f_fixnump(int arglist);
1277 int f_longnump(int arglist);
1278 int f_bignump(int arglist);
1279 int convert(int arg1, int arg2);
1280 int get_aux(int x);
1281 int f_readed_array_list(int arglist);
1282 int f_get_method(int arglist);
1283 int f_get_method_body(int arglist);
1284 int f_get_method_priority(int arglist);
1285 int f_ignore_toplevel_check(int arglist);
1286 int fast_length(int x);
1287 int fast_car(int x);
1288 int fast_cdr(int x);
1289 int f_self_introduction(int arglist);
1290 int set_dynamic(int x, int y);
1291 int set_prop(int x, int y);
1292 int get_prop(int x);
1293 int get_opt(int x);
1294 int get_dynpt();
1295 int set_dynpt(int x);
1296 int set_catch_symbols(int x);
1297 int f_ignore(int arglist);
1298 int f_classp(int arglist);
1299 int f_superp_for_compiler(int arglist);
1300 char *get_name(int x);
1301 double get_flt(int x);
1302
1303
1304 void display_buffer(void);
1305 enum HighlightToken check_token_buffer(int col);
1306 int findlparen_buffer(int col);
1307 int findrparen_buffer(int col);
1308 void emphasis_lparen_buffer(int col);
1309 void emphasis_rparen_buffer(int col);
1310 void reset_paren_buffer();
1311 void restore_paren_buffer(int col);
1312 char *get_fragment_buffer(int col);
1313 void find_candidate_buffer(int col);
1314 int replace_fragment_buffer(const char *newstr, int col);
1315 void insertcol_buffer(int col);
1316 void backspace_buffer(int col);
1317 int read_line(int flag);
1318
1319
1320 #endif
1321