35 lines
732 B
C
35 lines
732 B
C
#ifndef SYMBOLSTABLE_H
|
|
#define SYMBOLSTABLE_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include "opcodes.h"
|
|
#include "token.h"
|
|
|
|
#define SYMBOLSTABLE_DEFAULT_CAPACITY 128
|
|
|
|
typedef struct {
|
|
char* Name;
|
|
int Address;
|
|
int Resolved;
|
|
int Length;
|
|
Token* References;
|
|
} Symbol;
|
|
|
|
typedef struct {
|
|
Symbol** Symbols;
|
|
int Size;
|
|
int Capacity;
|
|
} SymbolTable;
|
|
|
|
SymbolTable* CreateSymbolTable(void);
|
|
int TryGetSymbol(char* name, SymbolTable* table, Symbol** outSymbol);
|
|
Symbol* AddSymbolToTable(char* name, int address, int resolved, SymbolTable* table);
|
|
void FreeSymbolTable(SymbolTable* table);
|
|
void FreeSymbol(Symbol* symbol);
|
|
|
|
#endif |