diff options
Diffstat (limited to 'src/as_analyzer.c')
| -rw-r--r-- | src/as_analyzer.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/as_analyzer.c b/src/as_analyzer.c index 39616da..dbc1bd2 100644 --- a/src/as_analyzer.c +++ b/src/as_analyzer.c @@ -3,31 +3,31 @@ #include <stddef.h> #include <string.h> -struct symTableEntry { +struct sym_table_entry { const char * name; size_t offset; }; -const char * composeSectionLabel(Allocator alct, const char * section, const char * name) { - size_t sectionLen = strlen(section); - size_t nameLen = strlen(name); - size_t sz = sectionLen + nameLen; +const char * compose_section_label(allocator_t alct, const char * section, const char * name) { + size_t section_len = strlen(section); + size_t name_len = strlen(name); + size_t sz = section_len + name_len; char * buf = allocate(alct, sz + 1); - memcpy(buf, section, sectionLen); - memcpy(buf + sectionLen, name, nameLen); + memcpy(buf, section, section_len); + memcpy(buf + section_len, name, name_len); buf[sz] = '\0'; return buf; } -void processSectionLabel(Allocator alct, Prog prog) { +void process_section_label(allocator_t alct, prog_t prog) { const char * section = ""; - Stmt* stmts = prog->stmts->stmts; + stmt_t* stmts = prog->stmts->stmts; for (size_t i = 0; ; i++) { if (stmts[i] == NULL) break; if (stmts[i]->label == NULL) continue; const char* name = stmts[i]->label->name; if (name[0] == '.') { - stmts[i]->label->name = composeSectionLabel(alct, section, name); + stmts[i]->label->name = compose_section_label(alct, section, name); } else { section = name; continue; @@ -35,14 +35,19 @@ void processSectionLabel(Allocator alct, Prog prog) { } } -size_t instrSize(Instr instr) { +size_t instr_size(instr_t instr) { // TODO return 0; } -SymTableEntry* analyzeProg(Allocator alct, Prog prog) { - processSectionLabel(alct, prog); +struct sym_table analyze_prog(allocator_t alct, prog_t prog) { + process_section_label(alct, prog); + stmt_t * stmts = prog->stmts->stmts; + for (int i = 0; ; i++) { + if (stmts[i] == NULL) break; + } + struct sym_table tbl; // TODO - return NULL; + return tbl; } |
