shithub: lpa

ref: ad872eeb19b4fcc41a5d34750ca6cdcf88a39795
dir: /dat.h/

View raw version
enum DataTag
{
	DataAux,
	DataSession,
	DataSessionList,
	DataModule,
	DataModuleList,
	DataSymtab,
	DataSymbol,
	DataEnumeration,
	DataTokenList,
	DataArray,
	DataAst,

	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 TokenTag
{
	TokNumber,
	TokName,
	TokLparen,
	TokRparen,
	TokLbrack,
	TokRbrack,
	TokNewline,
	TokDiamond,
};

typedef struct Token Token;
struct Token
{
	int tag;
	union {
		vlong num; /* TokNumber */
		char *name; /* TokName: UTF-8 encoded name */
	};
};

typedef struct TokenList TokenList;
struct TokenList
{
	uvlong count;
	Token *tokens;
};

enum ArrayType
{
	TypeNumber,
	TypeChar,
};

typedef struct Array Array;
#pragma incomplete Array

typedef struct Ast Ast;
struct Ast
{
	int lol;
};