-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8793f5
commit c805be6
Showing
7 changed files
with
55 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,2 @@ | ||
module; | ||
#include <stdexcept> | ||
module IR.Context; | ||
|
||
namespace Riddle { | ||
Variable &VarManager::getVariable(const std::string &name) { | ||
if(!Vars.contains(name) || Vars.find(name)->second.empty()) { | ||
throw std::logic_error("Variable not found"); | ||
} | ||
return *Vars[name].top(); | ||
} | ||
|
||
void VarManager::addVariable(Variable &var) { | ||
if(Defined.top().contains(var.name)) { | ||
throw std::logic_error("Variable already exists"); | ||
} | ||
Defined.top().insert(var.name); | ||
Vars[var.name].push(&var); | ||
} | ||
|
||
void VarManager::push() { | ||
Defined.emplace(); | ||
} | ||
|
||
void VarManager::pop() { | ||
for(const auto &i: Defined.top()) { | ||
Vars[i].pop(); | ||
if(Vars[i].empty()) { | ||
Vars.erase(i); | ||
} | ||
} | ||
Defined.pop(); | ||
} | ||
|
||
}// namespace Riddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters