mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Make all non-extern globals static
This commit is contained in:
@@ -58,7 +58,7 @@ static std::deque<Charmap> charmapList;
|
|||||||
static std::unordered_map<std::string, size_t> charmapMap; // Indexes into `charmapList`
|
static std::unordered_map<std::string, size_t> charmapMap; // Indexes into `charmapList`
|
||||||
|
|
||||||
static Charmap *currentCharmap;
|
static Charmap *currentCharmap;
|
||||||
std::stack<Charmap *> charmapStack;
|
static std::stack<Charmap *> charmapStack;
|
||||||
|
|
||||||
bool charmap_ForEach(
|
bool charmap_ForEach(
|
||||||
void (*mapFunc)(std::string const &),
|
void (*mapFunc)(std::string const &),
|
||||||
|
|||||||
@@ -38,15 +38,19 @@ struct SectionStackEntry {
|
|||||||
std::stack<UnionStackEntry> unionStack;
|
std::stack<UnionStackEntry> unionStack;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::stack<UnionStackEntry> currentUnionStack;
|
|
||||||
std::deque<SectionStackEntry> sectionStack;
|
|
||||||
std::deque<Section> sectionList;
|
std::deque<Section> sectionList;
|
||||||
std::unordered_map<std::string, size_t> sectionMap; // Indexes into `sectionList`
|
std::unordered_map<std::string, size_t> sectionMap; // Indexes into `sectionList`
|
||||||
uint32_t curOffset; // Offset into the current section (see sect_GetSymbolOffset)
|
|
||||||
Section *currentSection = nullptr;
|
Section *currentSection = nullptr;
|
||||||
|
|
||||||
|
static uint32_t curOffset; // Offset into the current section (see `sect_GetSymbolOffset`)
|
||||||
|
|
||||||
|
static std::deque<SectionStackEntry> sectionStack;
|
||||||
|
|
||||||
static Section *currentLoadSection = nullptr;
|
static Section *currentLoadSection = nullptr;
|
||||||
static std::pair<Symbol const *, Symbol const *> currentLoadLabelScopes = {nullptr, nullptr};
|
static std::pair<Symbol const *, Symbol const *> currentLoadLabelScopes = {nullptr, nullptr};
|
||||||
int32_t loadOffset; // Offset into the LOAD section's parent (see sect_GetOutputOffset)
|
static int32_t loadOffset; // Offset into the LOAD section's parent (see sect_GetOutputOffset)
|
||||||
|
|
||||||
|
static std::stack<UnionStackEntry> currentUnionStack;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static bool requireSection() {
|
static bool requireSection() {
|
||||||
|
|||||||
@@ -22,20 +22,23 @@
|
|||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
std::unordered_map<std::string, Symbol> symbols;
|
static std::unordered_map<std::string, Symbol> symbols;
|
||||||
std::unordered_set<std::string> purgedSymbols;
|
static std::unordered_set<std::string> purgedSymbols;
|
||||||
|
|
||||||
static Symbol const *globalScope = nullptr; // Current section's global label scope
|
static Symbol const *globalScope = nullptr; // Current section's global label scope
|
||||||
static Symbol const *localScope = nullptr; // Current section's local label scope
|
static Symbol const *localScope = nullptr; // Current section's local label scope
|
||||||
|
|
||||||
static Symbol *PCSymbol;
|
static Symbol *PCSymbol;
|
||||||
static Symbol *NARGSymbol;
|
static Symbol *NARGSymbol;
|
||||||
static Symbol *globalScopeSymbol;
|
static Symbol *globalScopeSymbol;
|
||||||
static Symbol *localScopeSymbol;
|
static Symbol *localScopeSymbol;
|
||||||
static Symbol *RSSymbol;
|
static Symbol *RSSymbol;
|
||||||
|
|
||||||
static char savedTIME[256];
|
static char savedTIME[256];
|
||||||
static char savedDATE[256];
|
static char savedDATE[256];
|
||||||
static char savedTIMESTAMP_ISO8601_LOCAL[256];
|
static char savedTIMESTAMP_ISO8601_LOCAL[256];
|
||||||
static char savedTIMESTAMP_ISO8601_UTC[256];
|
static char savedTIMESTAMP_ISO8601_UTC[256];
|
||||||
|
|
||||||
static bool exportAll = false; // -E
|
static bool exportAll = false; // -E
|
||||||
|
|
||||||
bool sym_IsPC(Symbol const *sym) {
|
bool sym_IsPC(Symbol const *sym) {
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ struct FreeSpace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Table of free space for each bank
|
// Table of free space for each bank
|
||||||
std::vector<std::deque<FreeSpace>> memory[SECTTYPE_INVALID];
|
static std::vector<std::deque<FreeSpace>> memory[SECTTYPE_INVALID];
|
||||||
|
|
||||||
uint64_t nbSectionsToAssign;
|
static uint64_t nbSectionsToAssign;
|
||||||
|
|
||||||
// Init the free space-modelling structs
|
// Init the free space-modelling structs
|
||||||
static void initFreeSpace() {
|
static void initFreeSpace() {
|
||||||
|
|||||||
@@ -27,8 +27,6 @@
|
|||||||
|
|
||||||
Options options;
|
Options options;
|
||||||
|
|
||||||
FILE *linkerScript;
|
|
||||||
|
|
||||||
std::string const &FileStackNode::dump(uint32_t curLineNo) const {
|
std::string const &FileStackNode::dump(uint32_t curLineNo) const {
|
||||||
if (std::holds_alternative<std::vector<uint32_t>>(data)) {
|
if (std::holds_alternative<std::vector<uint32_t>>(data)) {
|
||||||
assume(parent); // REPT nodes use their parent's name
|
assume(parent); // REPT nodes use their parent's name
|
||||||
|
|||||||
@@ -25,10 +25,10 @@
|
|||||||
|
|
||||||
static constexpr size_t BANK_SIZE = 0x4000;
|
static constexpr size_t BANK_SIZE = 0x4000;
|
||||||
|
|
||||||
FILE *outputFile;
|
static FILE *outputFile;
|
||||||
FILE *overlayFile;
|
static FILE *overlayFile;
|
||||||
FILE *symFile;
|
static FILE *symFile;
|
||||||
FILE *mapFile;
|
static FILE *mapFile;
|
||||||
|
|
||||||
struct SortedSymbol {
|
struct SortedSymbol {
|
||||||
Symbol const *sym;
|
Symbol const *sym;
|
||||||
|
|||||||
@@ -16,14 +16,14 @@
|
|||||||
#include "link/symbol.hpp"
|
#include "link/symbol.hpp"
|
||||||
#include "link/warning.hpp"
|
#include "link/warning.hpp"
|
||||||
|
|
||||||
std::deque<Assertion> assertions;
|
static std::deque<Assertion> assertions;
|
||||||
|
|
||||||
struct RPNStackEntry {
|
struct RPNStackEntry {
|
||||||
int32_t value;
|
int32_t value;
|
||||||
bool errorFlag; // Whether the value is a placeholder inserted for error recovery
|
bool errorFlag; // Whether the value is a placeholder inserted for error recovery
|
||||||
};
|
};
|
||||||
|
|
||||||
std::deque<RPNStackEntry> rpnStack;
|
static std::deque<RPNStackEntry> rpnStack;
|
||||||
|
|
||||||
static void pushRPN(int32_t value, bool comesFromError) {
|
static void pushRPN(int32_t value, bool comesFromError) {
|
||||||
rpnStack.push_front({.value = value, .errorFlag = comesFromError});
|
rpnStack.push_front({.value = value, .errorFlag = comesFromError});
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
#include "link/warning.hpp"
|
#include "link/warning.hpp"
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Section>> sectionList;
|
static std::vector<std::unique_ptr<Section>> sectionList;
|
||||||
std::unordered_map<std::string, size_t> sectionMap; // Indexes into `sectionList`
|
static std::unordered_map<std::string, size_t> sectionMap; // Indexes into `sectionList`
|
||||||
|
|
||||||
void sect_ForEach(void (*callback)(Section &)) {
|
void sect_ForEach(void (*callback)(Section &)) {
|
||||||
for (std::unique_ptr<Section> &ptr : sectionList) {
|
for (std::unique_ptr<Section> &ptr : sectionList) {
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
#include "link/section.hpp"
|
#include "link/section.hpp"
|
||||||
#include "link/warning.hpp"
|
#include "link/warning.hpp"
|
||||||
|
|
||||||
std::unordered_map<std::string, Symbol *> symbols;
|
static std::unordered_map<std::string, Symbol *> symbols;
|
||||||
std::unordered_map<std::string, std::vector<Symbol *>> localSymbols;
|
static std::unordered_map<std::string, std::vector<Symbol *>> localSymbols;
|
||||||
|
|
||||||
void sym_ForEach(void (*callback)(Symbol &)) {
|
void sym_ForEach(void (*callback)(Symbol &)) {
|
||||||
for (auto &it : symbols) {
|
for (auto &it : symbols) {
|
||||||
|
|||||||
Reference in New Issue
Block a user