summaryrefslogtreecommitdiff
path: root/masm/symtbl.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--masm/symtbl.c57
1 files changed, 0 insertions, 57 deletions
diff --git a/masm/symtbl.c b/masm/symtbl.c
deleted file mode 100644
index 8aa7bcf..0000000
--- a/masm/symtbl.c
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <merror.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "asm.h"
-
-#define SYMTBL_INIT_LEN 24
-
-int symtbl_init(struct symbol_table *sym_tbl)
-{
- sym_tbl->len = SYMTBL_INIT_LEN;
- sym_tbl->count = 0;
- sym_tbl->symbols = malloc(sizeof(struct symbol) * SYMTBL_INIT_LEN);
-
- if (sym_tbl->symbols == NULL) {
- ERROR("cannot alloc");
- return M_ERROR;
- }
-
- return M_SUCCESS;
-}
-
-void symtbl_free(struct symbol_table *sym_tbl)
-{
- free(sym_tbl->symbols);
-}
-
-int symtbl_push(struct symbol_table *sym_tbl, struct symbol sym)
-{
- if (sym_tbl->count >= sym_tbl->len) {
- sym_tbl->len *= 2;
- sym_tbl->symbols = realloc(sym_tbl->symbols,
- sizeof(struct symbol) * sym_tbl->len);
- if (sym_tbl->symbols == NULL) {
- ERROR("cannot relloc");
- return M_ERROR;
- }
- }
-
- sym_tbl->symbols[sym_tbl->count++] = sym;
- return M_SUCCESS;
-}
-
-int symtbl_find(struct symbol_table *sym_tbl, struct symbol **ptr,
- const char name[MAX_LEX_LENGTH])
-{
- for (uint32_t i = 0; i < sym_tbl->count; i++) {
- struct symbol *sym = &sym_tbl->symbols[i];
- if (strcmp(sym->name, name) == 0) {
- if (ptr != NULL)
- *ptr = sym;
- return M_SUCCESS;
- }
- }
- return M_ERROR;
-}