Built-in symbols are "<builtin>", not "<command-line>" (#1362)

This commit is contained in:
Sylvie
2024-03-19 16:01:45 -04:00
committed by GitHub
parent fec2266dd8
commit 554778da5b
7 changed files with 103 additions and 84 deletions

View File

@@ -143,18 +143,13 @@ static void writesymbol(Symbol const &sym, FILE *file) {
}
}
static void registerSymbol(Symbol &sym) {
sym.ID = objectSymbols.size();
objectSymbols.push_back(&sym);
out_RegisterNode(sym.src);
}
// Returns a symbol's ID within the object file
// If the symbol does not have one, one is assigned by registering the symbol
static uint32_t getSymbolID(Symbol &sym) {
if (sym.ID == (uint32_t)-1 && !sym_IsPC(&sym))
registerSymbol(sym);
return sym.ID;
static void registerUnregisteredSymbol(Symbol &sym) {
// Check for `sym.src`, to skip any built-in symbol from rgbasm
if (sym.src && sym.ID == (uint32_t)-1 && !sym_IsPC(&sym)) {
sym.ID = objectSymbols.size(); // Set the symbol's ID within the object file
objectSymbols.push_back(&sym);
out_RegisterNode(sym.src);
}
}
static void writerpn(std::vector<uint8_t> &rpnexpr, std::vector<uint8_t> const &rpn) {
@@ -193,7 +188,8 @@ static void writerpn(std::vector<uint8_t> &rpnexpr, std::vector<uint8_t> const &
value = sym_GetConstantValue(symName);
} else {
rpnexpr[rpnptr++] = RPN_SYM;
value = getSymbolID(*sym);
registerUnregisteredSymbol(*sym); // Ensure that `sym->ID` is set
value = sym->ID;
}
rpnexpr[rpnptr++] = value & 0xFF;
@@ -213,7 +209,8 @@ static void writerpn(std::vector<uint8_t> &rpnexpr, std::vector<uint8_t> const &
// The symbol name is always written expanded
sym = sym_FindExactSymbol(symName);
value = getSymbolID(*sym);
registerUnregisteredSymbol(*sym); // Ensure that `sym->ID` is set
value = sym->ID;
rpnexpr[rpnptr++] = RPN_BANK_SYM;
rpnexpr[rpnptr++] = value & 0xFF;
@@ -323,13 +320,6 @@ static void writeFileStackNode(FileStackNode const &node, FILE *file) {
}
}
static void registerUnregisteredSymbol(Symbol &sym) {
// Check for symbol->src, to skip any built-in symbol from rgbasm
if (sym.src && sym.ID == (uint32_t)-1) {
registerSymbol(sym);
}
}
// Write an objectfile
void out_WriteObject() {
FILE *file;