37 lines
740 B
C
37 lines
740 B
C
#ifndef SYMBOLSTABLE_H
|
|
#define SYMBOLSTABLE_H
|
|
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "opcodes.h"
|
|
|
|
#define SYMBOLSTABLE_DEFAULT_CAPACITY 128
|
|
|
|
typedef struct {
|
|
char* Name;
|
|
int Length;
|
|
int Resolved;
|
|
int InstructionPointer;
|
|
|
|
union {
|
|
char* Text;
|
|
int Number;
|
|
Instruction* Instruction;
|
|
} Value;
|
|
} Symbol;
|
|
|
|
typedef struct {
|
|
Symbol** Symbols;
|
|
int Size;
|
|
int Capacity;
|
|
} SymbolTable;
|
|
|
|
SymbolTable* CreateSymbolTable(void);
|
|
Symbol* TryGetSymbol(char* name, SymbolTable* table);
|
|
Symbol* AddSymbolToTable(char* name, void* value, int length, SymbolTable* table);
|
|
void FreeSymbolTable(SymbolTable* table);
|
|
void FreeSymbol(Symbol* symbol);
|
|
|
|
#endif |