ref: 8dc7c659e34ad5d244477e01b1ebf4def63be24d
dir: /dat.h/
enum DataTag { DataAux, DataSession, DataSessionList, DataModule, DataModuleList, DataSymtab, DataSymbol, DataEnumeration, DataTokenList, DataArray, DataAst, DataByteCode, DataValueStack, DataMax, }; typedef struct DataSpec DataSpec; struct DataSpec { usize size; }; extern DataSpec dataspecs[DataMax]; /* memory.c */ typedef struct Symbol Symbol; typedef struct Symtab Symtab; struct Symbol { char *name; void *value; Qid qsymbol; Symtab *table; uvlong id; }; struct Symtab { RWLock lock; uvlong count; Symbol **symbols; }; typedef struct Module Module; struct Module { uvlong id; char *name; Symtab *symtab; Qid qsession; Qid qmodule; }; typedef struct ModuleList ModuleList; struct ModuleList { RWLock lock; uvlong count; Module **modules; }; typedef struct Session Session; struct Session { uvlong id; char *name; int active; /* is the session alive? */ ModuleList *modules; /* file server stuff */ Qid qsession; Qid qctl; Qid qcons; Qid qlog; Qid qmodules; Qid qthreads; QLock loglock; Rendez logwait; uvlong logsize; char *log; Channel *input; }; typedef struct Enumeration Enumeration; struct Enumeration { uvlong count; void **items; }; enum Primitive { PrimPlus, PrimMinus, }; enum TokenTag { TokNumber, TokName, TokLparen, TokRparen, TokLbrack, TokRbrack, TokLbrace, TokRbrace, TokNewline, TokDiamond, TokPrimitive, TokDel, TokLarrow, TokSemi, TokEnd, }; typedef struct Token Token; struct Token { int tag; int nameclass; union { vlong num; /* TokNumber */ char *name; /* TokName: UTF-8 encoded name */ int prim; /* TokPrimitive */ }; }; typedef struct TokenList TokenList; struct TokenList { uvlong count; Token *tokens; uvlong offset; jmp_buf errbuf; char *err; }; enum ArrayType { TypeNumber, TypeChar, TypeArray, }; typedef struct Array Array; #pragma incomplete Array enum AstTag { AstProg, AstFunc, AstName, AstLocals, AstAssign, AstMonadic, AstDyadic, AstConst, AstPrim, AstStrand, AstLater, /* parse at runtime */ }; typedef struct Ast Ast; struct Ast { int tag; char *name; int nameclass; int prim; Ast *funcname; Ast *funcresult; Ast *funcleftarg; Ast *funcrightarg; Ast *funclocals; Ast *func; Ast *left; Ast *right; Array *val; TokenList *tokens; /* for AstLater */ uvlong childcount; Ast **children; }; enum Nameclass { NameclassUndef, /* Unknown name */ NameclassLocal, /* Local variable, but no value yet */ NameclassArray, /* Array value */ NameclassFunc, /* Function value */ }; typedef struct ByteCode ByteCode; struct ByteCode { uvlong count; u8int *instrs; }; enum Instr { IPushConst, IPushPrim, ILookup, IStrand, IMonadic, IDyadic, IClear, IParse, IDone, IJump, }; typedef struct ValueStack ValueStack; struct ValueStack { uvlong count; void **values; };