enum { /* size of argument arrays, uses Maxarg * sizeof(Node*) stack per call */ Maxarg = 16, }; typedef struct Gc Gc; typedef struct List List; typedef struct Lsym Lsym; typedef struct Metatable Metatable; typedef struct Node Node; typedef struct Pointer Pointer; typedef struct Rplace Rplace; typedef struct Store Store; typedef struct Strc Strc; typedef struct String String; typedef struct Value Value; #pragma incomplete List #pragma incomplete Value enum { /* Gc.mark */ GCMARK = 1, /* Gc.flag */ GCMETA = GCMARK<<1, GCPIN = GCMETA<<1, }; struct Gc { Gc* link; unsigned char mark; unsigned char flag; unsigned short type; }; struct String { Gc gc; char *string; int len; }; struct Lsym { char* name; int lexval; Lsym* hash; Value* v; Node* proc; void (*builtin)(Node*, Node**, int); }; struct Pointer { Gc gc; Metatable *meta; void *v; }; /* Store.type */ enum { TINT, TFLOAT, TSTRING, TLIST, TCODE, TPOINTER, TMAX, }; struct Store { uchar type; union { vlong ival; double fval; String* string; List* l; Node* cc; Pointer *pval; }; }; struct List { Gc gc; List* next; Store store; }; /* Node.op */ enum { OINVALID, ONAME, OCONST, OMUL, ODIV, OMOD, OADD, OSUB, ORSH, OLSH, OLT, OGT, OLEQ, OGEQ, OEQ, ONEQ, OLAND, OXOR, OLOR, OCAND, OCOR, OASGN, OINDM, OEDEC, OEINC, OPINC, OPDEC, ONOT, OIF, ODO, OFOR, OBREAK, OCONTINUE, OLIST, OCALL, OCTRUCT, OWHILE, OELSE, OHEAD, OTAIL, OAPPEND2, ORET, OINDEX, OINDC, ODOT, OLOCAL, ODELETE, OCAST, OEVAL, OWHAT, }; struct Node { Gc gc; uchar op; Node* left; Node* right; Lsym* sym; int builtin; Store store; }; #define ZN (Node*)0 /* possible future lua-isms index, newindex, mode, call, metatable, tostring, len, pairs, ipairs, gc unm, add, sub, mul, div, idiv, mod, pow, concat band, bor, bxor, bnot, shl, shr eq, lt, le */ struct Metatable { void (*index)(Node *v, char *nam, Node *res); void (*newindex)(Node *v, char *nam, Node *arg); void (*gc)(Pointer *v); }; void ppsetup(void); void ppdestroy(void); void pppin(Node*); void ppunpin(Node*); void ppinput(void); void ppbind(char*, void (*)(Node*, Node**, int)); int ppcall(char*, Node*, Node*); void ppcheckarg(Node **av, int na, int i, int type, Node *res); void ppexpr(Node*, Node*); void pperror(char*, ...); Node* ppsetpointer(Node*, void*, Metatable*); Node* pppointer(void *v, Metatable*); Pointer* pppointernode(void *v, Metatable*); Node* ppdup(Node*); Node* ppsetnil(Node*); Node* ppsetstring(Node*, char*); Node* ppsetstringlen(Node*, char*, int); Node* ppstring(char*); Node* ppsetconst(Node*, vlong); Node* ppconst(vlong); List* pplist(int);