Skip to content

Commit

Permalink
assembler: fix conditionals implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
catharanthus committed Oct 17, 2021
1 parent 02c565a commit 7d45285
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/src/lxp32asm/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ void Assembler::elaborate(TokenList &list) {

if(list.empty()) return;

// If the section is disabled, we look only for #else or #endif
if(!isSectionEnabled()&&list[0]!="#else"&&list[0]!="#endif") return;
// If the section is disabled, we look only for #ifdef, #ifndef, #else or #endif
if(!isSectionEnabled()&&list[0]!="#ifdef"&&list[0]!="#ifndef"&&
list[0]!="#else"&&list[0]!="#endif") return;

// Process statement itself
if(list[0][0]=='#') elaborateDirective(list);
Expand Down Expand Up @@ -438,7 +439,9 @@ LinkableObject::Word Assembler::elaborateInstruction(TokenList &list) {

bool Assembler::isSectionEnabled() const {
if(_sectionEnabled.empty()) return true;
else return _sectionEnabled.back();
bool enabled=true;
for(auto b: _sectionEnabled) enabled=enabled&&b;
return enabled;
}

bool Assembler::validateIdentifier(const std::string &str) {
Expand Down

0 comments on commit 7d45285

Please sign in to comment.