Skip to content

Commit

Permalink
util function for directives
Browse files Browse the repository at this point in the history
  • Loading branch information
ckrause committed Nov 3, 2024
1 parent 2d753bb commit 6443327
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lang/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ int64_t Program::getDirective(const std::string& name) const {
return d->second;
}

int64_t Program::getDirective(const std::string& name,
int64_t defaultValue) const {
auto d = directives.find(name);
return d != directives.end() ? d->second : defaultValue;
}

bool Program::operator==(const Program& p) const { return (ops == p.ops); }

bool Program::operator!=(const Program& p) const { return !(*this == p); }
Expand Down
2 changes: 2 additions & 0 deletions src/lang/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class Program {

int64_t getDirective(const std::string &name) const;

int64_t getDirective(const std::string &name, int64_t defaultValue) const;

bool operator==(const Program &p) const;

bool operator!=(const Program &p) const;
Expand Down

0 comments on commit 6443327

Please sign in to comment.