diff --git a/include/link/patch.hpp b/include/link/patch.hpp index 8f9ac48e..557e5281 100644 --- a/include/link/patch.hpp +++ b/include/link/patch.hpp @@ -3,6 +3,23 @@ #ifndef RGBDS_LINK_PATCH_HPP #define RGBDS_LINK_PATCH_HPP +#include +#include + +#include "link/section.hpp" + +struct Symbol; + +struct Assertion { + Patch patch; // Also used for its `.type` + std::string message; + // This would be redundant with `patch.pcSection->fileSymbols`, but `section` is sometimes + // `nullptr`! + std::vector *fileSymbols; +}; + +Assertion &patch_AddAssertion(); + // Checks all assertions void patch_CheckAssertions(); diff --git a/include/link/section.hpp b/include/link/section.hpp index 1872d986..4330a95e 100644 --- a/include/link/section.hpp +++ b/include/link/section.hpp @@ -56,15 +56,6 @@ struct Section { std::unique_ptr
nextu; // The next "component" of this unionized sect }; -struct Assertion { - Patch patch; // Also used for its `.type` - std::string message; - // This would be redundant with `.section->fileSymbols`, but `section` is sometimes `nullptr`! - std::vector *fileSymbols; -}; - -extern std::deque assertions; - // Execute a callback for each section currently registered. // This is to avoid exposing the data structure in which sections are stored. void sect_ForEach(void (*callback)(Section &)); diff --git a/src/link/object.cpp b/src/link/object.cpp index 233da1f7..4c76edc1 100644 --- a/src/link/object.cpp +++ b/src/link/object.cpp @@ -21,6 +21,7 @@ #include "link/assign.hpp" #include "link/main.hpp" +#include "link/patch.hpp" #include "link/sdas_obj.hpp" #include "link/section.hpp" #include "link/symbol.hpp" @@ -544,7 +545,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) { tryReadLong(nbAsserts, file, "%s: Cannot read number of assertions: %s", fileName); verbosePrint("Reading %" PRIu32 " assertions...\n", nbAsserts); for (uint32_t i = 0; i < nbAsserts; i++) { - Assertion &assertion = assertions.emplace_front(); + Assertion &assertion = patch_AddAssertion(); readAssertion(file, assertion, fileName, i, nodes[fileID]); linkPatchToPCSect(assertion.patch, fileSections); diff --git a/src/link/patch.cpp b/src/link/patch.cpp index 6d13ec31..c7d60c84 100644 --- a/src/link/patch.cpp +++ b/src/link/patch.cpp @@ -459,6 +459,10 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil return popRPN(patch); } +Assertion &patch_AddAssertion() { + return assertions.emplace_front(); +} + void patch_CheckAssertions() { verbosePrint("Checking assertions...\n");