mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 18:52:07 +00:00
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:
@@ -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), [§](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`
|
||||
|
||||
Reference in New Issue
Block a user