#define GCSTACKSIZE 256 typedef union Trie Trie;#pragma incomplete Trie typedef struct aaContext aaContext;typedef struct aaHandlers aaHandlers;typedef struct aaNumber aaNumber;typedef struct aaObject aaObject; typedef union aaValue aaValue; typedef aaObject *(*aaCFunc)(aaContext *ctx, aaObject *args);typedef void (*aaErrorFn)(aaContext *ctx, const char *err, aaObject *cl);typedef char (*aaReadFn)(aaContext *ctx, void *udata); struct aaNumber { double r; //double i;};//#define aNumber(r,i) (aaNumber){r, i}#define aNumber(r,i) (aaNumber){r} union aaValue { Biobuf *port; aaObject *o; aaCFunc f; aaNumber n; char c;}; struct aaObject { aaValue car; aaValue cdr;}; struct aaHandlers { aaErrorFn error; aaCFunc mark; aaCFunc gc;}; struct aaContext { aaHandlers handlers; aaObject *gcstack[GCSTACKSIZE]; int gcstack_idx; aaObject *objects; int object_count; aaObject *calllist; aaObject *freelist; aaObject *symlist; Trie *symtrie; aaObject *t; Rune nextrune; Biobuf *fd[3];}; enum { AA_TPAIR, AA_TFREE, AA_TNUMBER, AA_TSYMBOL, AA_TSTRING, AA_TFUNC, AA_TMACRO, AA_TPRIM, AA_TCFUNC, AA_TPTR, AA_TBOOL, AA_TPORT, AA_TMAX, AA_NOSTDIO = 1<<0,}; extern aaObject Null;extern aaObject False;extern aaObject True; #pragma varargck argpos aa_error 2#pragma varargck type "ß" aaObject*#pragma varargck type "§" aaObject* aaContext *aa_open(void *ptr, int size, int flags);void aa_close(aaContext *ctx);aaHandlers *aa_handlers(aaContext *ctx);void aa_error(aaContext *ctx, const char *fmt, ...);aaObject *aa_nextarg(aaContext *ctx, aaObject **arg, int optional);int aa_type(aaContext *ctx, aaObject *obj);void aa_pushgc(aaContext *ctx, aaObject *obj);void aa_restoregc(aaContext *ctx, int idx);int aa_savegc(aaContext *ctx);void aa_mark(aaContext *ctx, aaObject *obj);aaObject *aa_cons(aaContext *ctx, aaObject *car, aaObject *cdr);aaObject *aa_bool(aaContext *ctx, int b);aaObject *aa_number(aaContext *ctx, aaNumber n);aaObject *aa_string(aaContext *ctx, const char *str);aaObject *aa_symbol_find(aaContext *ctx, const char *name);aaObject *aa_symbol(aaContext *ctx, const char *name);aaObject *aa_cfunc(aaContext *ctx, aaCFunc fn);aaObject *aa_ptr(aaContext *ctx, void *ptr);aaObject *aa_list(aaContext *ctx, aaObject **objs, int n);aaObject *aa_car(aaContext *ctx, aaObject *obj);aaObject *aa_cdr(aaContext *ctx, aaObject *obj);aaNumber aa_tonumber(aaContext *ctx, aaObject *obj);void *aa_toptr(aaContext *ctx, aaObject *obj);void aa_set(aaContext *ctx, aaObject *sym, aaObject *v);aaObject *aa_read(aaContext *ctx, Biobuf *fp);aaObject *aa_eval(aaContext *ctx, aaObject *obj);
#define GCSTACKSIZE 256
typedef union Trie Trie;
#pragma incomplete Trie
typedef struct aaContext aaContext;
typedef struct aaHandlers aaHandlers;
typedef struct aaNumber aaNumber;
typedef struct aaObject aaObject;
typedef union aaValue aaValue;
typedef aaObject *(*aaCFunc)(aaContext *ctx, aaObject *args);
typedef void (*aaErrorFn)(aaContext *ctx, const char *err, aaObject *cl);
typedef char (*aaReadFn)(aaContext *ctx, void *udata);
struct aaNumber {
double r;
//double i;
};
//#define aNumber(r,i) (aaNumber){r, i}
#define aNumber(r,i) (aaNumber){r}
union aaValue {
Biobuf *port;
aaObject *o;
aaCFunc f;
aaNumber n;
char c;
};
struct aaObject {
aaValue car;
aaValue cdr;
};
struct aaHandlers {
aaErrorFn error;
aaCFunc mark;
aaCFunc gc;
};
struct aaContext {
aaHandlers handlers;
aaObject *gcstack[GCSTACKSIZE];
int gcstack_idx;
aaObject *objects;
int object_count;
aaObject *calllist;
aaObject *freelist;
aaObject *symlist;
Trie *symtrie;
aaObject *t;
Rune nextrune;
Biobuf *fd[3];
};
enum {
AA_TPAIR,
AA_TFREE,
AA_TNUMBER,
AA_TSYMBOL,
AA_TSTRING,
AA_TFUNC,
AA_TMACRO,
AA_TPRIM,
AA_TCFUNC,
AA_TPTR,
AA_TBOOL,
AA_TPORT,
AA_TMAX,
AA_NOSTDIO = 1<<0,
};
extern aaObject Null;
extern aaObject False;
extern aaObject True;
#pragma varargck argpos aa_error 2
#pragma varargck type "ß" aaObject*
#pragma varargck type "§" aaObject*
aaContext *aa_open(void *ptr, int size, int flags);
void aa_close(aaContext *ctx);
aaHandlers *aa_handlers(aaContext *ctx);
void aa_error(aaContext *ctx, const char *fmt, ...);
aaObject *aa_nextarg(aaContext *ctx, aaObject **arg, int optional);
int aa_type(aaContext *ctx, aaObject *obj);
void aa_pushgc(aaContext *ctx, aaObject *obj);
void aa_restoregc(aaContext *ctx, int idx);
int aa_savegc(aaContext *ctx);
void aa_mark(aaContext *ctx, aaObject *obj);
aaObject *aa_cons(aaContext *ctx, aaObject *car, aaObject *cdr);
aaObject *aa_bool(aaContext *ctx, int b);
aaObject *aa_number(aaContext *ctx, aaNumber n);
aaObject *aa_string(aaContext *ctx, const char *str);
aaObject *aa_symbol_find(aaContext *ctx, const char *name);
aaObject *aa_symbol(aaContext *ctx, const char *name);
aaObject *aa_cfunc(aaContext *ctx, aaCFunc fn);
aaObject *aa_ptr(aaContext *ctx, void *ptr);
aaObject *aa_list(aaContext *ctx, aaObject **objs, int n);
aaObject *aa_car(aaContext *ctx, aaObject *obj);
aaObject *aa_cdr(aaContext *ctx, aaObject *obj);
aaNumber aa_tonumber(aaContext *ctx, aaObject *obj);
void *aa_toptr(aaContext *ctx, aaObject *obj);
void aa_set(aaContext *ctx, aaObject *sym, aaObject *v);
aaObject *aa_read(aaContext *ctx, Biobuf *fp);
aaObject *aa_eval(aaContext *ctx, aaObject *obj);