浏览代码

Refactor out symbol table init; stop unused arg warnings for stubs.

master
Ben Kurtovic 9 年前
父节点
当前提交
eba603659a
共有 3 个文件被更改,包括 21 次插入4 次删除
  1. +4
    -4
      src/assembler.c
  2. +16
    -0
      src/assembler/state.c
  3. +1
    -0
      src/assembler/state.h

+ 4
- 4
src/assembler.c 查看文件

@@ -24,6 +24,7 @@ static ErrorInfo* tokenize(AssemblerState *state)
// verify no instructions clash with header offset
// if rom size is set, verify nothing overflows

(void) state;
return NULL;
}

@@ -45,6 +46,7 @@ static ErrorInfo* resolve_defaults(AssemblerState *state)
// if (!state.header.rom_size)
// set to actual rom size

(void) state;
return NULL;
}

@@ -58,6 +60,7 @@ static ErrorInfo* resolve_symbols(AssemblerState *state)
{
// TODO

(void) state;
return NULL;
}

@@ -98,10 +101,7 @@ size_t assemble(const LineBuffer *source, uint8_t **binary_ptr, ErrorInfo **ei_p
if ((error_info = preprocess(&state, source)))
goto error;

if (!(state.symtable = malloc(sizeof(ASMSymbolTable))))
OUT_OF_MEMORY()
for (size_t bucket = 0; bucket < SYMBOL_TABLE_BUCKETS; bucket++)
state.symtable->buckets[bucket] = NULL;
asm_symtable_init(&state.symtable);

if ((error_info = tokenize(&state)))
goto error;


+ 16
- 0
src/assembler/state.c 查看文件

@@ -5,6 +5,7 @@

#include "state.h"
#include "io.h"
#include "../logging.h"
#include "../util.h"

#define DEFAULT_HEADER_OFFSET 0x7FF0
@@ -31,6 +32,21 @@ void state_init(AssemblerState *state)
}

/*
Initialize an ASMSymbolTable and place it in *symtable_ptr.
*/
void asm_symtable_init(ASMSymbolTable **symtable_ptr)
{
ASMSymbolTable *symtable;
if (!(symtable = malloc(sizeof(ASMSymbolTable))))
OUT_OF_MEMORY()

for (size_t bucket = 0; bucket < SYMBOL_TABLE_BUCKETS; bucket++)
symtable->buckets[bucket] = NULL;

*symtable_ptr = symtable;
}

/*
Deallocate an ASMLine list.
*/
void asm_lines_free(ASMLine *line)


+ 1
- 0
src/assembler/state.h 查看文件

@@ -71,6 +71,7 @@ typedef struct {
/* Functions */

void state_init(AssemblerState*);
void asm_symtable_init(ASMSymbolTable**);
void asm_lines_free(ASMLine*);
void asm_includes_free(ASMInclude*);
void asm_instructions_free(ASMInstruction*);


正在加载...
取消
保存