提交 3c925feb 编写于 作者: Q qiaolongfei

update design doc

上级 9af54c9e
...@@ -59,9 +59,9 @@ class Scope { ...@@ -59,9 +59,9 @@ class Scope {
Scope(const std::shared_ptr<Scope>& scope): parent_(scope) {} Scope(const std::shared_ptr<Scope>& scope): parent_(scope) {}
Variable* GetVariable(const std::string& name) const { Variable* GetVariable(const std::string& name) const {
Variable* var = GetVarLocally(name); auto it = vars_.find(name);
if (var != nullptr) { if (it != vars_.end()) {
return var; return it->second.get();
} else if (parent_ != nullptr) { } else if (parent_ != nullptr) {
return parent_->GetVariable(name); return parent_->GetVariable(name);
} else { } else {
...@@ -97,8 +97,8 @@ class Scope { ...@@ -97,8 +97,8 @@ class Scope {
// return nullptr if not found. // return nullptr if not found.
Variable* GetVariable(const std::string& name) const; Variable* GetVariable(const std::string& name) const;
// return Error if already contains same name variable. // return if already contains same name variable.
Error CreateVariable(const std::string& name); Variable* CreateVariable(const std::string& name);
private: private:
std::shared_ptr<Scope> parent_; std::shared_ptr<Scope> parent_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册