Make all non-extern globals static

This commit is contained in:
Rangi42
2025-07-21 20:14:09 -04:00
parent 8d268e8a8a
commit c83b87e0a0
9 changed files with 26 additions and 21 deletions

View File

@@ -32,9 +32,9 @@ struct FreeSpace {
};
// 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
static void initFreeSpace() {

View File

@@ -27,8 +27,6 @@
Options options;
FILE *linkerScript;
std::string const &FileStackNode::dump(uint32_t curLineNo) const {
if (std::holds_alternative<std::vector<uint32_t>>(data)) {
assume(parent); // REPT nodes use their parent's name

View File

@@ -25,10 +25,10 @@
static constexpr size_t BANK_SIZE = 0x4000;
FILE *outputFile;
FILE *overlayFile;
FILE *symFile;
FILE *mapFile;
static FILE *outputFile;
static FILE *overlayFile;
static FILE *symFile;
static FILE *mapFile;
struct SortedSymbol {
Symbol const *sym;

View File

@@ -16,14 +16,14 @@
#include "link/symbol.hpp"
#include "link/warning.hpp"
std::deque<Assertion> assertions;
static std::deque<Assertion> assertions;
struct RPNStackEntry {
int32_t value;
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) {
rpnStack.push_front({.value = value, .errorFlag = comesFromError});

View File

@@ -12,8 +12,8 @@
#include "link/warning.hpp"
std::vector<std::unique_ptr<Section>> sectionList;
std::unordered_map<std::string, size_t> sectionMap; // Indexes into `sectionList`
static std::vector<std::unique_ptr<Section>> sectionList;
static std::unordered_map<std::string, size_t> sectionMap; // Indexes into `sectionList`
void sect_ForEach(void (*callback)(Section &)) {
for (std::unique_ptr<Section> &ptr : sectionList) {

View File

@@ -13,8 +13,8 @@
#include "link/section.hpp"
#include "link/warning.hpp"
std::unordered_map<std::string, Symbol *> symbols;
std::unordered_map<std::string, std::vector<Symbol *>> localSymbols;
static std::unordered_map<std::string, Symbol *> symbols;
static std::unordered_map<std::string, std::vector<Symbol *>> localSymbols;
void sym_ForEach(void (*callback)(Symbol &)) {
for (auto &it : symbols) {