mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Use std::variant for symbol values (#1330)
This commit is contained in:
@@ -8,12 +8,20 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
#include "linkdefs.hpp"
|
||||
|
||||
struct FileStackNode;
|
||||
struct Section;
|
||||
|
||||
struct Label {
|
||||
int32_t sectionID;
|
||||
int32_t offset;
|
||||
// Extra info computed during linking
|
||||
Section *section;
|
||||
};
|
||||
|
||||
struct Symbol {
|
||||
// Info contained in the object files
|
||||
std::string name;
|
||||
@@ -21,14 +29,10 @@ struct Symbol {
|
||||
char const *objFileName;
|
||||
FileStackNode const *src;
|
||||
int32_t lineNo;
|
||||
int32_t sectionID;
|
||||
union {
|
||||
// Both types must be identical
|
||||
int32_t offset;
|
||||
int32_t value;
|
||||
};
|
||||
// Extra info computed during linking
|
||||
Section *section;
|
||||
std::variant<
|
||||
int32_t, // Constants just have a numeric value
|
||||
Label // Label values refer to an offset within a specific section
|
||||
> data;
|
||||
};
|
||||
|
||||
void sym_AddSymbol(Symbol &symbol);
|
||||
|
||||
Reference in New Issue
Block a user