mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Use std::vector for symbols
This commit is contained in:
@@ -50,7 +50,6 @@ struct Symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
uint32_t ID; // ID of the symbol in the object file (-1 if none)
|
uint32_t ID; // ID of the symbol in the object file (-1 if none)
|
||||||
struct Symbol *next; // Next object to output in the object file
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool sym_IsPC(struct Symbol const *sym);
|
bool sym_IsPC(struct Symbol const *sym);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "asm/charmap.hpp"
|
#include "asm/charmap.hpp"
|
||||||
#include "asm/fstack.hpp"
|
#include "asm/fstack.hpp"
|
||||||
@@ -48,10 +49,8 @@ const char *objectName;
|
|||||||
|
|
||||||
std::deque<struct Section *> sectionList;
|
std::deque<struct Section *> sectionList;
|
||||||
|
|
||||||
// Linked list of symbols to put in the object file
|
// List of symbols to put in the object file
|
||||||
static struct Symbol *objectSymbols = NULL;
|
static std::vector<struct Symbol *> objectSymbols;
|
||||||
static struct Symbol **objectSymbolsTail = &objectSymbols;
|
|
||||||
static uint32_t nbSymbols = 0; // Length of the above list
|
|
||||||
|
|
||||||
static struct Assertion *assertions = NULL;
|
static struct Assertion *assertions = NULL;
|
||||||
|
|
||||||
@@ -233,13 +232,9 @@ static void writesymbol(struct Symbol const *sym, FILE *f)
|
|||||||
|
|
||||||
static void registerSymbol(struct Symbol *sym)
|
static void registerSymbol(struct Symbol *sym)
|
||||||
{
|
{
|
||||||
*objectSymbolsTail = sym;
|
sym->ID = objectSymbols.size();
|
||||||
objectSymbolsTail = &sym->next;
|
objectSymbols.push_back(sym);
|
||||||
out_RegisterNode(sym->src);
|
out_RegisterNode(sym->src);
|
||||||
if (nbSymbols == (uint32_t)-1)
|
|
||||||
fatalerror("Registered too many symbols (%" PRIu32
|
|
||||||
"); try splitting up your files\n", (uint32_t)-1);
|
|
||||||
sym->ID = nbSymbols++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a symbol's ID within the object file
|
// Returns a symbol's ID within the object file
|
||||||
@@ -482,7 +477,7 @@ void out_WriteObject(void)
|
|||||||
fprintf(f, RGBDS_OBJECT_VERSION_STRING);
|
fprintf(f, RGBDS_OBJECT_VERSION_STRING);
|
||||||
putlong(RGBDS_OBJECT_REV, f);
|
putlong(RGBDS_OBJECT_REV, f);
|
||||||
|
|
||||||
putlong(nbSymbols, f);
|
putlong(objectSymbols.size(), f);
|
||||||
putlong(sectionList.size(), f);
|
putlong(sectionList.size(), f);
|
||||||
|
|
||||||
putlong(getNbFileStackNodes(), f);
|
putlong(getNbFileStackNodes(), f);
|
||||||
@@ -494,7 +489,7 @@ void out_WriteObject(void)
|
|||||||
node->next->ID, node->ID);
|
node->next->ID, node->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (struct Symbol const *sym = objectSymbols; sym; sym = sym->next)
|
for (struct Symbol const *sym : objectSymbols)
|
||||||
writesymbol(sym, f);
|
writesymbol(sym, f);
|
||||||
|
|
||||||
for (struct Section *sect : sectionList) {
|
for (struct Section *sect : sectionList) {
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ static struct Symbol *createsymbol(char const *symName)
|
|||||||
sym->section = NULL;
|
sym->section = NULL;
|
||||||
setSymbolFilename(sym);
|
setSymbolFilename(sym);
|
||||||
sym->ID = -1;
|
sym->ID = -1;
|
||||||
sym->next = NULL;
|
|
||||||
|
|
||||||
hash_AddElement(symbols, sym->name, sym);
|
hash_AddElement(symbols, sym->name, sym);
|
||||||
return sym;
|
return sym;
|
||||||
|
|||||||
Reference in New Issue
Block a user