57 lines
1.0 KiB
C
57 lines
1.0 KiB
C
#ifndef NCTREF_VARTABLE_H
|
|
#define NCTREF_VARTABLE_H
|
|
|
|
#include"types.h"
|
|
|
|
typedef enum {
|
|
VARTABLEENTRY_SYMBOL, VARTABLEENTRY_TYPE, VARTABLEENTRY_VAR
|
|
} VarTableEntryKind;
|
|
|
|
typedef struct UseDef {
|
|
union AST *use; //expr
|
|
union AST *def; //assign stmt
|
|
size_t t;
|
|
struct UseDef *next;
|
|
} UseDef;
|
|
|
|
typedef struct VarTableEntry {
|
|
Type *type;
|
|
|
|
VarTableEntryKind kind;
|
|
struct {
|
|
union {
|
|
struct {
|
|
char isLocal;
|
|
char isExternal;
|
|
const char *name;
|
|
} symbol;
|
|
struct {
|
|
uint16_t color, degree;
|
|
size_t start, end;
|
|
uint8_t priority;
|
|
|
|
UseDef *usedefFirst;
|
|
UseDef *usedefLast;
|
|
} var;
|
|
};
|
|
struct VarTableEntry *offset;
|
|
} data;
|
|
|
|
void *userdata;
|
|
} VarTableEntry;
|
|
|
|
typedef struct VarTable {
|
|
struct VarTable *parent;
|
|
|
|
size_t count;
|
|
const char **names;
|
|
VarTableEntry **data;
|
|
} VarTable;
|
|
|
|
VarTable *vartable_new(VarTable*);
|
|
VarTableEntry *vartable_get(VarTable*, const char*);
|
|
VarTableEntry *vartable_find(VarTable*, const char*);
|
|
VarTableEntry *vartable_set(VarTable*, const char*, VarTableEntry*);
|
|
|
|
#endif
|