Skip to content

Commit 6443327

Browse files
committed
util function for directives
1 parent 2d753bb commit 6443327

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/lang/program.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ int64_t Program::getDirective(const std::string& name) const {
187187
return d->second;
188188
}
189189

190+
int64_t Program::getDirective(const std::string& name,
191+
int64_t defaultValue) const {
192+
auto d = directives.find(name);
193+
return d != directives.end() ? d->second : defaultValue;
194+
}
195+
190196
bool Program::operator==(const Program& p) const { return (ops == p.ops); }
191197

192198
bool Program::operator!=(const Program& p) const { return !(*this == p); }

src/lang/program.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ class Program {
127127

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

130+
int64_t getDirective(const std::string &name, int64_t defaultValue) const;
131+
130132
bool operator==(const Program &p) const;
131133

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

0 commit comments

Comments
 (0)