mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
More refactoring around extern variables
This commit is contained in:
@@ -17,7 +17,6 @@ struct FileStackNode;
|
||||
enum StateFeature { STATE_EQU, STATE_VAR, STATE_EQUS, STATE_CHAR, STATE_MACRO, NB_STATE_FEATURES };
|
||||
|
||||
void out_RegisterNode(std::shared_ptr<FileStackNode> node);
|
||||
void out_SetFileName(std::string const &name);
|
||||
void out_CreatePatch(uint32_t type, Expression const &expr, uint32_t ofs, uint32_t pcShift);
|
||||
void out_CreateAssert(
|
||||
AssertionType type, Expression const &expr, std::string const &message, uint32_t ofs
|
||||
|
||||
@@ -44,9 +44,8 @@ struct Context {
|
||||
static std::stack<Context> contextStack;
|
||||
|
||||
// The first include path for `fstk_FindFile` to try is none at all
|
||||
static std::vector<std::string> includePaths = {""};
|
||||
|
||||
static std::deque<std::string> preIncludeNames;
|
||||
static std::vector<std::string> includePaths = {""}; // -I
|
||||
static std::deque<std::string> preIncludeNames; // -P
|
||||
|
||||
std::string FileStackNode::reptChain() const {
|
||||
std::string chain;
|
||||
|
||||
@@ -501,8 +501,7 @@ LexerState::~LexerState() {
|
||||
|
||||
bool Expansion::advance() {
|
||||
assume(offset <= size());
|
||||
++offset;
|
||||
return offset > size();
|
||||
return ++offset > size();
|
||||
}
|
||||
|
||||
BufferedContent::~BufferedContent() {
|
||||
|
||||
@@ -182,7 +182,6 @@ int main(int argc, char *argv[]) {
|
||||
uint32_t maxDepth = 64;
|
||||
char const *dependFileName = nullptr;
|
||||
std::unordered_map<std::string, std::vector<StateFeature>> stateFileSpecs;
|
||||
std::string newTarget;
|
||||
// Maximum of 100 errors only applies if rgbasm is printing errors to a terminal.
|
||||
if (isatty(STDERR_FILENO)) {
|
||||
options.maxErrors = 100;
|
||||
@@ -252,7 +251,11 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
out_SetFileName(musl_optarg);
|
||||
if (!options.objectFileName.empty()) {
|
||||
warnx("Overriding output filename %s", options.objectFileName.c_str());
|
||||
}
|
||||
options.objectFileName = musl_optarg;
|
||||
verbosePrint("Output filename %s\n", options.objectFileName.c_str()); // LCOV_EXCL_LINE
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
@@ -274,14 +277,12 @@ int main(int argc, char *argv[]) {
|
||||
opt_P(padByte);
|
||||
break;
|
||||
|
||||
unsigned long precision;
|
||||
char const *precisionArg;
|
||||
case 'Q':
|
||||
precisionArg = musl_optarg;
|
||||
case 'Q': {
|
||||
char const *precisionArg = musl_optarg;
|
||||
if (precisionArg[0] == '.') {
|
||||
++precisionArg;
|
||||
}
|
||||
precision = strtoul(precisionArg, &endptr, 0);
|
||||
unsigned long precision = strtoul(precisionArg, &endptr, 0);
|
||||
|
||||
if (musl_optarg[0] == '\0' || *endptr != '\0') {
|
||||
fatal("Invalid argument for option 'Q'");
|
||||
@@ -293,6 +294,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
opt_Q(precision);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'r':
|
||||
maxDepth = strtoul(musl_optarg, &endptr, 0);
|
||||
@@ -338,9 +340,8 @@ int main(int argc, char *argv[]) {
|
||||
warnings.state.warningsEnabled = false;
|
||||
break;
|
||||
|
||||
unsigned long maxErrors;
|
||||
case 'X':
|
||||
maxErrors = strtoul(musl_optarg, &endptr, 0);
|
||||
case 'X': {
|
||||
unsigned long maxErrors = strtoul(musl_optarg, &endptr, 0);
|
||||
|
||||
if (musl_optarg[0] == '\0' || *endptr != '\0') {
|
||||
fatal("Invalid argument for option 'X'");
|
||||
@@ -352,6 +353,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
options.maxErrors = maxErrors;
|
||||
break;
|
||||
}
|
||||
|
||||
// Long-only options
|
||||
case 0:
|
||||
@@ -369,8 +371,8 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
case 'T':
|
||||
newTarget = musl_optarg;
|
||||
case 'T': {
|
||||
std::string newTarget = musl_optarg;
|
||||
if (depType == 'Q') {
|
||||
newTarget = make_escape(newTarget);
|
||||
}
|
||||
@@ -380,6 +382,7 @@ int main(int argc, char *argv[]) {
|
||||
options.targetFileName += newTarget;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Unrecognized options
|
||||
|
||||
@@ -369,14 +369,6 @@ void out_WriteObject() {
|
||||
}
|
||||
}
|
||||
|
||||
void out_SetFileName(std::string const &name) {
|
||||
if (!options.objectFileName.empty()) {
|
||||
warnx("Overriding output filename %s", options.objectFileName.c_str());
|
||||
}
|
||||
options.objectFileName = name;
|
||||
verbosePrint("Output filename %s\n", options.objectFileName.c_str()); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
static void dumpString(std::string const &escape, FILE *file) {
|
||||
for (char c : escape) {
|
||||
// Escape characters that need escaping
|
||||
|
||||
@@ -36,7 +36,7 @@ static char savedTIME[256];
|
||||
static char savedDATE[256];
|
||||
static char savedTIMESTAMP_ISO8601_LOCAL[256];
|
||||
static char savedTIMESTAMP_ISO8601_UTC[256];
|
||||
static bool exportAll;
|
||||
static bool exportAll; // -E
|
||||
|
||||
bool sym_IsPC(Symbol const *sym) {
|
||||
return sym == PCSymbol;
|
||||
|
||||
@@ -330,9 +330,8 @@ static void decant(
|
||||
members.push_back(iter - processed.begin());
|
||||
*iter = true; // Mark that proto-pal as processed
|
||||
}
|
||||
++iter;
|
||||
++attrs;
|
||||
} while (iter != processed.end());
|
||||
} while (++iter != processed.end());
|
||||
|
||||
if (to.combinedVolume(RANGE(colors)) <= options.maxOpaqueColors()) {
|
||||
// Iterate through the component's proto-palettes, and transfer them
|
||||
|
||||
@@ -149,12 +149,9 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
||||
location.address &= ~section.alignMask;
|
||||
// Go to next align boundary and add offset
|
||||
location.address += section.alignMask + 1 + section.alignOfs;
|
||||
} else {
|
||||
} else if (++spaceIdx < bankMem.size()) {
|
||||
// Any location is fine, so, next free block
|
||||
++spaceIdx;
|
||||
if (spaceIdx < bankMem.size()) {
|
||||
location.address = bankMem[spaceIdx].address;
|
||||
}
|
||||
location.address = bankMem[spaceIdx].address;
|
||||
}
|
||||
|
||||
// If that location is past the current block's end,
|
||||
|
||||
Reference in New Issue
Block a user