mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Use camelCase instead of lowercase for static functions
This commit is contained in:
@@ -37,7 +37,7 @@ static std::deque<Assertion> assertions;
|
|||||||
|
|
||||||
static std::deque<std::shared_ptr<FileStackNode>> fileStackNodes;
|
static std::deque<std::shared_ptr<FileStackNode>> fileStackNodes;
|
||||||
|
|
||||||
static void putlong(uint32_t n, FILE *file) {
|
static void putLong(uint32_t n, FILE *file) {
|
||||||
uint8_t bytes[] = {
|
uint8_t bytes[] = {
|
||||||
(uint8_t)n,
|
(uint8_t)n,
|
||||||
(uint8_t)(n >> 8),
|
(uint8_t)(n >> 8),
|
||||||
@@ -47,7 +47,7 @@ static void putlong(uint32_t n, FILE *file) {
|
|||||||
fwrite(bytes, 1, sizeof(bytes), file);
|
fwrite(bytes, 1, sizeof(bytes), file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void putstring(std::string const &s, FILE *file) {
|
static void putString(std::string const &s, FILE *file) {
|
||||||
fputs(s.c_str(), file);
|
fputs(s.c_str(), file);
|
||||||
putc('\0', file);
|
putc('\0', file);
|
||||||
}
|
}
|
||||||
@@ -71,54 +71,55 @@ static uint32_t getSectIDIfAny(Section *sect) {
|
|||||||
fatalerror("Unknown section '%s'\n", sect->name.c_str());
|
fatalerror("Unknown section '%s'\n", sect->name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writepatch(Patch const &patch, FILE *file) {
|
static void writePatch(Patch const &patch, FILE *file) {
|
||||||
assume(patch.src->ID != (uint32_t)-1);
|
assume(patch.src->ID != (uint32_t)-1);
|
||||||
putlong(patch.src->ID, file);
|
|
||||||
putlong(patch.lineNo, file);
|
putLong(patch.src->ID, file);
|
||||||
putlong(patch.offset, file);
|
putLong(patch.lineNo, file);
|
||||||
putlong(getSectIDIfAny(patch.pcSection), file);
|
putLong(patch.offset, file);
|
||||||
putlong(patch.pcOffset, file);
|
putLong(getSectIDIfAny(patch.pcSection), file);
|
||||||
|
putLong(patch.pcOffset, file);
|
||||||
putc(patch.type, file);
|
putc(patch.type, file);
|
||||||
putlong(patch.rpn.size(), file);
|
putLong(patch.rpn.size(), file);
|
||||||
fwrite(patch.rpn.data(), 1, patch.rpn.size(), file);
|
fwrite(patch.rpn.data(), 1, patch.rpn.size(), file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writesection(Section const §, FILE *file) {
|
static void writeSection(Section const §, FILE *file) {
|
||||||
putstring(sect.name, file);
|
putString(sect.name, file);
|
||||||
|
|
||||||
putlong(sect.size, file);
|
putLong(sect.size, file);
|
||||||
|
|
||||||
bool isUnion = sect.modifier == SECTION_UNION;
|
bool isUnion = sect.modifier == SECTION_UNION;
|
||||||
bool isFragment = sect.modifier == SECTION_FRAGMENT;
|
bool isFragment = sect.modifier == SECTION_FRAGMENT;
|
||||||
|
|
||||||
putc(sect.type | isUnion << 7 | isFragment << 6, file);
|
putc(sect.type | isUnion << 7 | isFragment << 6, file);
|
||||||
|
|
||||||
putlong(sect.org, file);
|
putLong(sect.org, file);
|
||||||
putlong(sect.bank, file);
|
putLong(sect.bank, file);
|
||||||
putc(sect.align, file);
|
putc(sect.align, file);
|
||||||
putlong(sect.alignOfs, file);
|
putLong(sect.alignOfs, file);
|
||||||
|
|
||||||
if (sect_HasData(sect.type)) {
|
if (sect_HasData(sect.type)) {
|
||||||
fwrite(sect.data.data(), 1, sect.size, file);
|
fwrite(sect.data.data(), 1, sect.size, file);
|
||||||
putlong(sect.patches.size(), file);
|
putLong(sect.patches.size(), file);
|
||||||
|
|
||||||
for (Patch const &patch : sect.patches)
|
for (Patch const &patch : sect.patches)
|
||||||
writepatch(patch, file);
|
writePatch(patch, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writesymbol(Symbol const &sym, FILE *file) {
|
static void writeSymbol(Symbol const &sym, FILE *file) {
|
||||||
putstring(sym.name, file);
|
putString(sym.name, file);
|
||||||
if (!sym.isDefined()) {
|
if (!sym.isDefined()) {
|
||||||
putc(SYMTYPE_IMPORT, file);
|
putc(SYMTYPE_IMPORT, file);
|
||||||
} else {
|
} else {
|
||||||
assume(sym.src->ID != (uint32_t)-1);
|
assume(sym.src->ID != (uint32_t)-1);
|
||||||
|
|
||||||
putc(sym.isExported ? SYMTYPE_EXPORT : SYMTYPE_LOCAL, file);
|
putc(sym.isExported ? SYMTYPE_EXPORT : SYMTYPE_LOCAL, file);
|
||||||
putlong(sym.src->ID, file);
|
putLong(sym.src->ID, file);
|
||||||
putlong(sym.fileLine, file);
|
putLong(sym.fileLine, file);
|
||||||
putlong(getSectIDIfAny(sym.getSection()), file);
|
putLong(getSectIDIfAny(sym.getSection()), file);
|
||||||
putlong(sym.getOutputValue(), file);
|
putLong(sym.getOutputValue(), file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +132,7 @@ static void registerUnregisteredSymbol(Symbol &sym) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writerpn(std::vector<uint8_t> &rpnexpr, std::vector<uint8_t> const &rpn) {
|
static void writeRpn(std::vector<uint8_t> &rpnexpr, std::vector<uint8_t> const &rpn) {
|
||||||
std::string symName;
|
std::string symName;
|
||||||
size_t rpnptr = 0;
|
size_t rpnptr = 0;
|
||||||
|
|
||||||
@@ -229,7 +230,7 @@ static void writerpn(std::vector<uint8_t> &rpnexpr, std::vector<uint8_t> const &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initpatch(Patch &patch, uint32_t type, Expression const &expr, uint32_t ofs) {
|
static void initPatch(Patch &patch, uint32_t type, Expression const &expr, uint32_t ofs) {
|
||||||
patch.type = type;
|
patch.type = type;
|
||||||
patch.src = fstk_GetFileStack();
|
patch.src = fstk_GetFileStack();
|
||||||
// All patches are assumed to eventually be written, so the file stack node is registered
|
// All patches are assumed to eventually be written, so the file stack node is registered
|
||||||
@@ -250,7 +251,7 @@ static void initpatch(Patch &patch, uint32_t type, Expression const &expr, uint3
|
|||||||
patch.rpn[4] = val >> 24;
|
patch.rpn[4] = val >> 24;
|
||||||
} else {
|
} else {
|
||||||
patch.rpn.resize(expr.rpnPatchSize);
|
patch.rpn.resize(expr.rpnPatchSize);
|
||||||
writerpn(patch.rpn, expr.rpn);
|
writeRpn(patch.rpn, expr.rpn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +259,7 @@ void out_CreatePatch(uint32_t type, Expression const &expr, uint32_t ofs, uint32
|
|||||||
// Add the patch to the list
|
// Add the patch to the list
|
||||||
Patch &patch = currentSection->patches.emplace_front();
|
Patch &patch = currentSection->patches.emplace_front();
|
||||||
|
|
||||||
initpatch(patch, type, expr, ofs);
|
initPatch(patch, type, expr, ofs);
|
||||||
|
|
||||||
// If the patch had a quantity of bytes output before it,
|
// If the patch had a quantity of bytes output before it,
|
||||||
// PC is not at the patch's location, but at the location
|
// PC is not at the patch's location, but at the location
|
||||||
@@ -271,28 +272,28 @@ void out_CreateAssert(
|
|||||||
) {
|
) {
|
||||||
Assertion &assertion = assertions.emplace_front();
|
Assertion &assertion = assertions.emplace_front();
|
||||||
|
|
||||||
initpatch(assertion.patch, type, expr, ofs);
|
initPatch(assertion.patch, type, expr, ofs);
|
||||||
assertion.message = message;
|
assertion.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeassert(Assertion &assert, FILE *file) {
|
static void writeAssert(Assertion &assert, FILE *file) {
|
||||||
writepatch(assert.patch, file);
|
writePatch(assert.patch, file);
|
||||||
putstring(assert.message, file);
|
putString(assert.message, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeFileStackNode(FileStackNode const &node, FILE *file) {
|
static void writeFileStackNode(FileStackNode const &node, FILE *file) {
|
||||||
putlong(node.parent ? node.parent->ID : (uint32_t)-1, file);
|
putLong(node.parent ? node.parent->ID : (uint32_t)-1, file);
|
||||||
putlong(node.lineNo, file);
|
putLong(node.lineNo, file);
|
||||||
putc(node.type, file);
|
putc(node.type, file);
|
||||||
if (node.type != NODE_REPT) {
|
if (node.type != NODE_REPT) {
|
||||||
putstring(node.name(), file);
|
putString(node.name(), file);
|
||||||
} else {
|
} else {
|
||||||
std::vector<uint32_t> const &nodeIters = node.iters();
|
std::vector<uint32_t> const &nodeIters = node.iters();
|
||||||
|
|
||||||
putlong(nodeIters.size(), file);
|
putLong(nodeIters.size(), file);
|
||||||
// Iters are stored by decreasing depth, so reverse the order for output
|
// Iters are stored by decreasing depth, so reverse the order for output
|
||||||
for (uint32_t i = nodeIters.size(); i--;)
|
for (uint32_t i = nodeIters.size(); i--;)
|
||||||
putlong(nodeIters[i], file);
|
putLong(nodeIters[i], file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,12 +316,12 @@ void out_WriteObject() {
|
|||||||
sym_ForEach(registerUnregisteredSymbol);
|
sym_ForEach(registerUnregisteredSymbol);
|
||||||
|
|
||||||
fprintf(file, RGBDS_OBJECT_VERSION_STRING);
|
fprintf(file, RGBDS_OBJECT_VERSION_STRING);
|
||||||
putlong(RGBDS_OBJECT_REV, file);
|
putLong(RGBDS_OBJECT_REV, file);
|
||||||
|
|
||||||
putlong(objectSymbols.size(), file);
|
putLong(objectSymbols.size(), file);
|
||||||
putlong(sectionList.size(), file);
|
putLong(sectionList.size(), file);
|
||||||
|
|
||||||
putlong(fileStackNodes.size(), file);
|
putLong(fileStackNodes.size(), file);
|
||||||
for (auto it = fileStackNodes.begin(); it != fileStackNodes.end(); it++) {
|
for (auto it = fileStackNodes.begin(); it != fileStackNodes.end(); it++) {
|
||||||
FileStackNode const &node = **it;
|
FileStackNode const &node = **it;
|
||||||
|
|
||||||
@@ -337,15 +338,15 @@ void out_WriteObject() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Symbol const *sym : objectSymbols)
|
for (Symbol const *sym : objectSymbols)
|
||||||
writesymbol(*sym, file);
|
writeSymbol(*sym, file);
|
||||||
|
|
||||||
for (auto it = sectionList.rbegin(); it != sectionList.rend(); it++)
|
for (auto it = sectionList.rbegin(); it != sectionList.rend(); it++)
|
||||||
writesection(*it, file);
|
writeSection(*it, file);
|
||||||
|
|
||||||
putlong(assertions.size(), file);
|
putLong(assertions.size(), file);
|
||||||
|
|
||||||
for (Assertion &assert : assertions)
|
for (Assertion &assert : assertions)
|
||||||
writeassert(assert, file);
|
writeAssert(assert, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void out_SetFileName(std::string const &name) {
|
void out_SetFileName(std::string const &name) {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ static std::vector<std::vector<FileStackNode>> nodes;
|
|||||||
// Helper functions for reading object files
|
// Helper functions for reading object files
|
||||||
|
|
||||||
// Internal, DO NOT USE.
|
// Internal, DO NOT USE.
|
||||||
// For helper wrapper macros defined below, such as `tryReadlong`
|
// For helper wrapper macros defined below, such as `tryReadLong`
|
||||||
#define tryRead(func, type, errval, vartype, var, file, ...) \
|
#define tryRead(func, type, errval, vartype, var, file, ...) \
|
||||||
do { \
|
do { \
|
||||||
FILE *tmpFile = file; \
|
FILE *tmpFile = file; \
|
||||||
@@ -48,7 +48,7 @@ static std::vector<std::vector<FileStackNode>> nodes;
|
|||||||
* @param file The file to read from. This will read 4 bytes from the file.
|
* @param file The file to read from. This will read 4 bytes from the file.
|
||||||
* @return The value read, cast to a int64_t, or -1 on failure.
|
* @return The value read, cast to a int64_t, or -1 on failure.
|
||||||
*/
|
*/
|
||||||
static int64_t readlong(FILE *file) {
|
static int64_t readLong(FILE *file) {
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
|
|
||||||
// Read the little-endian value byte by byte
|
// Read the little-endian value byte by byte
|
||||||
@@ -76,8 +76,8 @@ static int64_t readlong(FILE *file) {
|
|||||||
* @param ... A format string and related arguments; note that an extra string
|
* @param ... A format string and related arguments; note that an extra string
|
||||||
* argument is provided, the reason for failure
|
* argument is provided, the reason for failure
|
||||||
*/
|
*/
|
||||||
#define tryReadlong(var, file, ...) \
|
#define tryReadLong(var, file, ...) \
|
||||||
tryRead(readlong, int64_t, INT64_MAX, long, var, file, __VA_ARGS__)
|
tryRead(readLong, int64_t, INT64_MAX, long, var, file, __VA_ARGS__)
|
||||||
|
|
||||||
// There is no `readbyte`, just use `fgetc` or `getc`.
|
// There is no `readbyte`, just use `fgetc` or `getc`.
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ static int64_t readlong(FILE *file) {
|
|||||||
* @param ... A format string and related arguments; note that an extra string
|
* @param ... A format string and related arguments; note that an extra string
|
||||||
* argument is provided, the reason for failure
|
* argument is provided, the reason for failure
|
||||||
*/
|
*/
|
||||||
#define tryReadstring(var, file, ...) \
|
#define tryReadString(var, file, ...) \
|
||||||
do { \
|
do { \
|
||||||
FILE *tmpFile = file; \
|
FILE *tmpFile = file; \
|
||||||
std::string &tmpVal = var; \
|
std::string &tmpVal = var; \
|
||||||
@@ -127,9 +127,9 @@ static void readFileStackNode(
|
|||||||
FileStackNode &node = fileNodes[i];
|
FileStackNode &node = fileNodes[i];
|
||||||
uint32_t parentID;
|
uint32_t parentID;
|
||||||
|
|
||||||
tryReadlong(parentID, file, "%s: Cannot read node #%" PRIu32 "'s parent ID: %s", fileName, i);
|
tryReadLong(parentID, file, "%s: Cannot read node #%" PRIu32 "'s parent ID: %s", fileName, i);
|
||||||
node.parent = parentID != (uint32_t)-1 ? &fileNodes[parentID] : nullptr;
|
node.parent = parentID != (uint32_t)-1 ? &fileNodes[parentID] : nullptr;
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
node.lineNo, file, "%s: Cannot read node #%" PRIu32 "'s line number: %s", fileName, i
|
node.lineNo, file, "%s: Cannot read node #%" PRIu32 "'s line number: %s", fileName, i
|
||||||
);
|
);
|
||||||
tryGetc(
|
tryGetc(
|
||||||
@@ -144,17 +144,17 @@ static void readFileStackNode(
|
|||||||
case NODE_FILE:
|
case NODE_FILE:
|
||||||
case NODE_MACRO:
|
case NODE_MACRO:
|
||||||
node.data = "";
|
node.data = "";
|
||||||
tryReadstring(
|
tryReadString(
|
||||||
node.name(), file, "%s: Cannot read node #%" PRIu32 "'s file name: %s", fileName, i
|
node.name(), file, "%s: Cannot read node #%" PRIu32 "'s file name: %s", fileName, i
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
uint32_t depth;
|
uint32_t depth;
|
||||||
case NODE_REPT:
|
case NODE_REPT:
|
||||||
tryReadlong(depth, file, "%s: Cannot read node #%" PRIu32 "'s rept depth: %s", fileName, i);
|
tryReadLong(depth, file, "%s: Cannot read node #%" PRIu32 "'s rept depth: %s", fileName, i);
|
||||||
node.data = std::vector<uint32_t>(depth);
|
node.data = std::vector<uint32_t>(depth);
|
||||||
for (uint32_t k = 0; k < depth; k++)
|
for (uint32_t k = 0; k < depth; k++)
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
node.iters()[k],
|
node.iters()[k],
|
||||||
file,
|
file,
|
||||||
"%s: Cannot read node #%" PRIu32 "'s iter #%" PRIu32 ": %s",
|
"%s: Cannot read node #%" PRIu32 "'s iter #%" PRIu32 ": %s",
|
||||||
@@ -182,7 +182,7 @@ static void readFileStackNode(
|
|||||||
static void readSymbol(
|
static void readSymbol(
|
||||||
FILE *file, Symbol &symbol, char const *fileName, std::vector<FileStackNode> const &fileNodes
|
FILE *file, Symbol &symbol, char const *fileName, std::vector<FileStackNode> const &fileNodes
|
||||||
) {
|
) {
|
||||||
tryReadstring(symbol.name, file, "%s: Cannot read symbol name: %s", fileName);
|
tryReadString(symbol.name, file, "%s: Cannot read symbol name: %s", fileName);
|
||||||
tryGetc(
|
tryGetc(
|
||||||
ExportLevel,
|
ExportLevel,
|
||||||
symbol.type,
|
symbol.type,
|
||||||
@@ -195,11 +195,11 @@ static void readSymbol(
|
|||||||
if (symbol.type != SYMTYPE_IMPORT) {
|
if (symbol.type != SYMTYPE_IMPORT) {
|
||||||
symbol.objFileName = fileName;
|
symbol.objFileName = fileName;
|
||||||
uint32_t nodeID;
|
uint32_t nodeID;
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
nodeID, file, "%s: Cannot read \"%s\"'s node ID: %s", fileName, symbol.name.c_str()
|
nodeID, file, "%s: Cannot read \"%s\"'s node ID: %s", fileName, symbol.name.c_str()
|
||||||
);
|
);
|
||||||
symbol.src = &fileNodes[nodeID];
|
symbol.src = &fileNodes[nodeID];
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
symbol.lineNo,
|
symbol.lineNo,
|
||||||
file,
|
file,
|
||||||
"%s: Cannot read \"%s\"'s line number: %s",
|
"%s: Cannot read \"%s\"'s line number: %s",
|
||||||
@@ -207,14 +207,14 @@ static void readSymbol(
|
|||||||
symbol.name.c_str()
|
symbol.name.c_str()
|
||||||
);
|
);
|
||||||
int32_t sectionID, value;
|
int32_t sectionID, value;
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
sectionID,
|
sectionID,
|
||||||
file,
|
file,
|
||||||
"%s: Cannot read \"%s\"'s section ID: %s",
|
"%s: Cannot read \"%s\"'s section ID: %s",
|
||||||
fileName,
|
fileName,
|
||||||
symbol.name.c_str()
|
symbol.name.c_str()
|
||||||
);
|
);
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
value, file, "%s: Cannot read \"%s\"'s value: %s", fileName, symbol.name.c_str()
|
value, file, "%s: Cannot read \"%s\"'s value: %s", fileName, symbol.name.c_str()
|
||||||
);
|
);
|
||||||
if (sectionID == -1) {
|
if (sectionID == -1) {
|
||||||
@@ -250,7 +250,7 @@ static void readPatch(
|
|||||||
uint32_t nodeID, rpnSize;
|
uint32_t nodeID, rpnSize;
|
||||||
PatchType type;
|
PatchType type;
|
||||||
|
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
nodeID,
|
nodeID,
|
||||||
file,
|
file,
|
||||||
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s node ID: %s",
|
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s node ID: %s",
|
||||||
@@ -259,7 +259,7 @@ static void readPatch(
|
|||||||
i
|
i
|
||||||
);
|
);
|
||||||
patch.src = &fileNodes[nodeID];
|
patch.src = &fileNodes[nodeID];
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
patch.lineNo,
|
patch.lineNo,
|
||||||
file,
|
file,
|
||||||
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s line number: %s",
|
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s line number: %s",
|
||||||
@@ -267,7 +267,7 @@ static void readPatch(
|
|||||||
sectName.c_str(),
|
sectName.c_str(),
|
||||||
i
|
i
|
||||||
);
|
);
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
patch.offset,
|
patch.offset,
|
||||||
file,
|
file,
|
||||||
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s offset: %s",
|
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s offset: %s",
|
||||||
@@ -275,7 +275,7 @@ static void readPatch(
|
|||||||
sectName.c_str(),
|
sectName.c_str(),
|
||||||
i
|
i
|
||||||
);
|
);
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
patch.pcSectionID,
|
patch.pcSectionID,
|
||||||
file,
|
file,
|
||||||
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s",
|
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s",
|
||||||
@@ -283,7 +283,7 @@ static void readPatch(
|
|||||||
sectName.c_str(),
|
sectName.c_str(),
|
||||||
i
|
i
|
||||||
);
|
);
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
patch.pcOffset,
|
patch.pcOffset,
|
||||||
file,
|
file,
|
||||||
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s",
|
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s",
|
||||||
@@ -301,7 +301,7 @@ static void readPatch(
|
|||||||
i
|
i
|
||||||
);
|
);
|
||||||
patch.type = type;
|
patch.type = type;
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
rpnSize,
|
rpnSize,
|
||||||
file,
|
file,
|
||||||
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s RPN size: %s",
|
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s RPN size: %s",
|
||||||
@@ -345,8 +345,8 @@ static void readSection(
|
|||||||
int32_t tmp;
|
int32_t tmp;
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
|
|
||||||
tryReadstring(section.name, file, "%s: Cannot read section name: %s", fileName);
|
tryReadString(section.name, file, "%s: Cannot read section name: %s", fileName);
|
||||||
tryReadlong(tmp, file, "%s: Cannot read \"%s\"'s' size: %s", fileName, section.name.c_str());
|
tryReadLong(tmp, file, "%s: Cannot read \"%s\"'s' size: %s", fileName, section.name.c_str());
|
||||||
if (tmp < 0 || tmp > UINT16_MAX)
|
if (tmp < 0 || tmp > UINT16_MAX)
|
||||||
errx("\"%s\"'s section size (%" PRId32 ") is invalid", section.name.c_str(), tmp);
|
errx("\"%s\"'s section size (%" PRId32 ") is invalid", section.name.c_str(), tmp);
|
||||||
section.size = tmp;
|
section.size = tmp;
|
||||||
@@ -365,14 +365,14 @@ static void readSection(
|
|||||||
section.modifier = SECTION_FRAGMENT;
|
section.modifier = SECTION_FRAGMENT;
|
||||||
else
|
else
|
||||||
section.modifier = SECTION_NORMAL;
|
section.modifier = SECTION_NORMAL;
|
||||||
tryReadlong(tmp, file, "%s: Cannot read \"%s\"'s org: %s", fileName, section.name.c_str());
|
tryReadLong(tmp, file, "%s: Cannot read \"%s\"'s org: %s", fileName, section.name.c_str());
|
||||||
section.isAddressFixed = tmp >= 0;
|
section.isAddressFixed = tmp >= 0;
|
||||||
if (tmp > UINT16_MAX) {
|
if (tmp > UINT16_MAX) {
|
||||||
error(nullptr, 0, "\"%s\"'s org is too large (%" PRId32 ")", section.name.c_str(), tmp);
|
error(nullptr, 0, "\"%s\"'s org is too large (%" PRId32 ")", section.name.c_str(), tmp);
|
||||||
tmp = UINT16_MAX;
|
tmp = UINT16_MAX;
|
||||||
}
|
}
|
||||||
section.org = tmp;
|
section.org = tmp;
|
||||||
tryReadlong(tmp, file, "%s: Cannot read \"%s\"'s bank: %s", fileName, section.name.c_str());
|
tryReadLong(tmp, file, "%s: Cannot read \"%s\"'s bank: %s", fileName, section.name.c_str());
|
||||||
section.isBankFixed = tmp >= 0;
|
section.isBankFixed = tmp >= 0;
|
||||||
section.bank = tmp;
|
section.bank = tmp;
|
||||||
tryGetc(
|
tryGetc(
|
||||||
@@ -387,7 +387,7 @@ static void readSection(
|
|||||||
byte = 16;
|
byte = 16;
|
||||||
section.isAlignFixed = byte != 0;
|
section.isAlignFixed = byte != 0;
|
||||||
section.alignMask = (1 << byte) - 1;
|
section.alignMask = (1 << byte) - 1;
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
tmp, file, "%s: Cannot read \"%s\"'s alignment offset: %s", fileName, section.name.c_str()
|
tmp, file, "%s: Cannot read \"%s\"'s alignment offset: %s", fileName, section.name.c_str()
|
||||||
);
|
);
|
||||||
if (tmp > UINT16_MAX) {
|
if (tmp > UINT16_MAX) {
|
||||||
@@ -417,7 +417,7 @@ static void readSection(
|
|||||||
|
|
||||||
uint32_t nbPatches;
|
uint32_t nbPatches;
|
||||||
|
|
||||||
tryReadlong(
|
tryReadLong(
|
||||||
nbPatches,
|
nbPatches,
|
||||||
file,
|
file,
|
||||||
"%s: Cannot read \"%s\"'s number of patches: %s",
|
"%s: Cannot read \"%s\"'s number of patches: %s",
|
||||||
@@ -470,7 +470,7 @@ static void readAssertion(
|
|||||||
|
|
||||||
assertName += std::to_string(i);
|
assertName += std::to_string(i);
|
||||||
readPatch(file, assert.patch, fileName, assertName, 0, fileNodes);
|
readPatch(file, assert.patch, fileName, assertName, 0, fileNodes);
|
||||||
tryReadstring(assert.message, file, "%s: Cannot read assertion's message: %s", fileName);
|
tryReadString(assert.message, file, "%s: Cannot read assertion's message: %s", fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void obj_ReadFile(char const *fileName, unsigned int fileID) {
|
void obj_ReadFile(char const *fileName, unsigned int fileID) {
|
||||||
@@ -525,7 +525,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) {
|
|||||||
|
|
||||||
uint32_t revNum;
|
uint32_t revNum;
|
||||||
|
|
||||||
tryReadlong(revNum, file, "%s: Cannot read revision number: %s", fileName);
|
tryReadLong(revNum, file, "%s: Cannot read revision number: %s", fileName);
|
||||||
if (revNum != RGBDS_OBJECT_REV)
|
if (revNum != RGBDS_OBJECT_REV)
|
||||||
errx(
|
errx(
|
||||||
"%s: Unsupported object file for rgblink %s; try rebuilding \"%s\"%s"
|
"%s: Unsupported object file for rgblink %s; try rebuilding \"%s\"%s"
|
||||||
@@ -542,12 +542,12 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) {
|
|||||||
uint32_t nbSymbols;
|
uint32_t nbSymbols;
|
||||||
uint32_t nbSections;
|
uint32_t nbSections;
|
||||||
|
|
||||||
tryReadlong(nbSymbols, file, "%s: Cannot read number of symbols: %s", fileName);
|
tryReadLong(nbSymbols, file, "%s: Cannot read number of symbols: %s", fileName);
|
||||||
tryReadlong(nbSections, file, "%s: Cannot read number of sections: %s", fileName);
|
tryReadLong(nbSections, file, "%s: Cannot read number of sections: %s", fileName);
|
||||||
|
|
||||||
nbSectionsToAssign += nbSections;
|
nbSectionsToAssign += nbSections;
|
||||||
|
|
||||||
tryReadlong(nbNodes, file, "%s: Cannot read number of nodes: %s", fileName);
|
tryReadLong(nbNodes, file, "%s: Cannot read number of nodes: %s", fileName);
|
||||||
nodes[fileID].resize(nbNodes);
|
nodes[fileID].resize(nbNodes);
|
||||||
verbosePrint("Reading %u nodes...\n", nbNodes);
|
verbosePrint("Reading %u nodes...\n", nbNodes);
|
||||||
for (uint32_t i = nbNodes; i--;)
|
for (uint32_t i = nbNodes; i--;)
|
||||||
@@ -584,7 +584,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) {
|
|||||||
|
|
||||||
uint32_t nbAsserts;
|
uint32_t nbAsserts;
|
||||||
|
|
||||||
tryReadlong(nbAsserts, file, "%s: Cannot read number of assertions: %s", fileName);
|
tryReadLong(nbAsserts, file, "%s: Cannot read number of assertions: %s", fileName);
|
||||||
verbosePrint("Reading %" PRIu32 " assertions...\n", nbAsserts);
|
verbosePrint("Reading %" PRIu32 " assertions...\n", nbAsserts);
|
||||||
for (uint32_t i = 0; i < nbAsserts; i++) {
|
for (uint32_t i = 0; i < nbAsserts; i++) {
|
||||||
Assertion &assertion = assertions.emplace_front();
|
Assertion &assertion = assertions.emplace_front();
|
||||||
|
|||||||
Reference in New Issue
Block a user