ref: e5cbdb2d92963fccf56980ea7a60ecc2b03204cf
dir: /lisp.h/
#ifdef PLAN9 #include <u.h> #include <libc.h> #include <stdio.h> #include <ctype.h> typedef uintptr uintptr_t; typedef u32int uint32_t; typedef s32int int32_t; typedef u64int uint64_t; typedef s64int int64_t; #else #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <stdarg.h> #include <string.h> #include <ctype.h> #include <math.h> #include <setjmp.h> #include <assert.h> #define nil NULL #endif #define FIXMIN (-FIXMAX-1) /* basic data types */ typedef uintptr_t P; #ifdef LISP32 /* assume we're running on 32 bits!!! */ typedef uint32_t word; typedef int32_t fixnum; typedef float flonum; #define FIXMAX ((fixnum)0x7FFFFFFF) #define FLOMAX 3.40282347E+38f enum { B2W = 32, /* bits per word */ C2W = B2W/8, /* character per word */ }; #else /* assume we're running on 64 bits!!! */ typedef uint64_t word; typedef int64_t fixnum; typedef double flonum; #define FIXMAX ((fixnum)0x7FFFFFFFFFFFFFFF) #define FLOMAX 1.7976931348623157E+308 enum { B2W = 64, /* bits per word */ C2W = B2W/8, /* character per word */ }; #endif extern FILE *sysin, *sysout, *syserr; /* static storage sizes */ enum { NUMCONS = 32*1024, NUMFW = 32*1024, PDLSZ = 1024, }; typedef struct C C; typedef union F F; /* A cons cell */ struct C { union { C *a; F *af; P ap; }; union { C *d; F *df; P dp; fixnum fix; flonum flo; char *str; }; }; /* CAR bits */ enum { CAR_MARK = 1, CAR_ATOM = 2, CAR_FIX = 4, CAR_FLO = 8, CAR_NUM = CAR_FIX | CAR_FLO, CAR_STR = 16 }; /* A full word */ union F { word fw; char c[C2W]; F *p; fixnum n; C *(*subr)(void); }; /* free storage */ extern C *fclist; extern F *fflist; /* push down list */ extern C *pdl[PDLSZ]; extern int pdp; /* Temporary variables automatically saved */ typedef struct Temlis Temlis; struct Temlis { /* temp */ void *a, *b, *c; /* arguments to cons */ void *ca; void *cd; /* pname */ void *pn; }; extern Temlis temlis; extern C **alist; extern int nargs; extern C *oblist; typedef struct Arglist Arglist; struct Arglist { int nargs; C **alist; int pdp; }; extern Arglist largs; /* LEXPR/LSUBR args */ typedef struct Prog Prog; struct Prog { C *prog; C *pc; C *ret; }; extern Prog prog; extern C *noval; extern C *t; extern C *value; extern C *expr; extern C *subr; extern C *lsubr; extern C *fexpr; extern C *fsubr; extern C *macro; extern C *funarg; extern C *cond; extern C *set; extern C *setq; extern C *go; extern C *retrn; void err(char *fmt, ...); void panic(char *fmt, ...); C **push(C *c); C *pop(void); C *cons(void *a, C *d); F *consw(word fw); C *mkfix(fixnum fix); C *mkflo(flonum flo); C *mksubr(C *(*subr)(void), int n); int atom(C *c); int fixnump(C *c); int flonump(C *c); int numberp(C *c); int listp(C *c); int stringp(C *c); fixnum length(C *c); C *get(C *l, C *p); C *assq(C *x, C *y); C *putprop(C *l, C *p, C *ind); C *intern(char *name); C *readsxp(void); void lprint(C *c); void princ(C *c); void printatom(C *c, int x); C *eval(C *form, C *a); C *evlis(C *m, C *a); C *apply(C *fn, C *args, C *a); void gc(void); void initsubr(void);