Bläddra i källkod

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

master
Ben Kurtovic 9 år sedan
förälder
incheckning
eba603659a
3 ändrade filer med 21 tillägg och 4 borttagningar
  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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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*);


Laddar…
Avbryt
Spara