Implement [[ fragment literals ]] (#1614)

This feature is referred to as "code/data literals" in ASMotor,
and simply as "literals" in some older assemblers like MIDAS
for the PDP-10. RGBASM already had the "section fragments"
feature for keeping disparate contents together when linked,
so these worked naturally as "fragment literals".
This commit is contained in:
Rangi
2025-07-09 12:13:01 -04:00
committed by GitHub
parent 5e43ece578
commit 41ab5dff5a
19 changed files with 343 additions and 13 deletions

View File

@@ -68,8 +68,12 @@ static uint32_t getSectIDIfAny(Section *sect) {
return UINT32_MAX;
}
if (auto search = sectionMap.find(sect->name); search != sectionMap.end()) {
return static_cast<uint32_t>(search->second);
// Search in `sectionList` instead of `sectionMap`, since section fragments share the
// same name but have different IDs
if (auto search =
std::find_if(RANGE(sectionList), [&sect](Section const &s) { return &s == sect; });
search != sectionList.end()) {
return static_cast<uint32_t>(std::distance(sectionList.begin(), search));
}
// Every section that exists should be in `sectionMap`