Allow STARTOF(SECTTYPE) and SIZEOF(SECTTYPE) to be constant when possible (#2131)

This commit is contained in:
Rangi authored and GitHub committed 2026-09-26 19:08:28 +02:00
1 parent 548a11c3ef
commit e0ee6c9013
6 files changed
+45 -6

No files matched your search

+10 -4
View File
@@ -142,14 +142,20 @@ void Expression::makeStartOfSection(std::string const &sectName) {
void Expression::makeSizeOfSectionType(SectionType type) {
assume(rpn.empty());
data = "Section type's size is not known";
rpn.emplace_back(RPN_SIZEOF_SECTTYPE, static_cast<uint8_t>(type));
if (type == SECTTYPE_WRAM0) {
data = "Section type WRAM0's size is not known (can be affected by RGBLINK '-w/--wramx')";
rpn.emplace_back(RPN_SIZEOF_SECTTYPE, static_cast<uint8_t>(type));
} else if (type == SECTTYPE_ROM0) {
data = "Section type ROM0's size is not known (can be affected by RGBLINK '-t/--tiny')";
rpn.emplace_back(RPN_SIZEOF_SECTTYPE, static_cast<uint8_t>(type));
} else {
data = static_cast<int32_t>(sectionTypeInfo[type].size);
}
}
void Expression::makeStartOfSectionType(SectionType type) {
assume(rpn.empty());
data = "Section type's start is not known";
rpn.emplace_back(RPN_STARTOF_SECTTYPE, static_cast<uint8_t>(type));
data = static_cast<int32_t>(sectionTypeInfo[type].startAddr);
}
static bool tryConstZero(Expression const &lhs, Expression const &rhs) {