提交 5e8d8e07 编写于 作者: Q qiaolongfei

refine GetOrCreateVariable

上级 2f47562d
......@@ -34,15 +34,17 @@ Variable* Scope::GetVariable(const std::string &name) const {
}
Variable* Scope::GetOrCreateVariable(const std::string &name) {
Variable* var;
var = GetVariable(name);
if (var == nullptr) {
auto err = CreateVariable(name);
Variable* var = GetVariable(name);
if (var != nullptr) {
return var;
}
Error err = CreateVariable(name);
if (!err.isOK()) {
return nullptr;
}
}
} else {
return GetVariable(name);
}
}
bool Scope::HaveVariable(const std::string &name) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册