Files
assm-test/includes/symbols_table.h
T

47 lines
957 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 enum {
RefUnknown,
RefLiteral,
RefExpression,
RefPointer
} ReferenceType;
typedef struct _symbol {
char* Name;
int Address;
int Length;
union {
Token* Mnemonic;
struct _symbol* Symbol;
unsigned short Number;
} Value;
ReferenceType Type;
} 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, SymbolTable* table);
void FreeSymbolTable(SymbolTable* table);
void FreeSymbol(Symbol* symbol);
int SymbolResolved(Symbol* symbol);
#endif