#include "as_analyzer.h" #include #include struct symTableEntry { 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; char * buf = allocate(alct, sz + 1); memcpy(buf, section, sectionLen); memcpy(buf + sectionLen, name, nameLen); buf[sz] = '\0'; return buf; } void processSectionLabel(Allocator alct, Prog prog) { const char * section = ""; Stmt* 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); } else { section = name; continue; } } } size_t instrSize(Instr instr) { // TODO return 0; } SymTableEntry* analyzeProg(Allocator alct, Prog prog) { processSectionLabel(alct, prog); // TODO return NULL; }