Skip to content

Commit

Permalink
Implementation of SymbolTable::removeSymbol(std::string) function.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Dec 26, 2024
1 parent 1b3ca00 commit efb2a3f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/n8/core/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ void SymbolTable::setSymbol(
else this->table[name] = std::move(value);
}

void SymbolTable::removeSymbol(std::string name) {
if(this->parent && this->parent->hasSymbol(name)) {
this->parent->removeSymbol(name);
return;
}

if(this->hasSymbol(name) && !this->table[name].hasLock())
this->table.erase(name);
}

void SymbolTable::removeSymbol(std::shared_ptr<Token> name) {
std::string symbol = name->getImage();
if(this->parent && this->parent->hasSymbol(symbol)) {
Expand Down

0 comments on commit efb2a3f

Please sign in to comment.