Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
b603c182
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b603c182
编写于
6月 29, 2017
作者:
T
Travis CI
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deploy to GitHub Pages:
590795d7
上级
09aeb825
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
26 addition
and
26 deletion
+26
-26
develop/doc/_sources/design/scope.md.txt
develop/doc/_sources/design/scope.md.txt
+6
-6
develop/doc/design/scope.html
develop/doc/design/scope.html
+6
-6
develop/doc/searchindex.js
develop/doc/searchindex.js
+1
-1
develop/doc_cn/_sources/design/scope.md.txt
develop/doc_cn/_sources/design/scope.md.txt
+6
-6
develop/doc_cn/design/scope.html
develop/doc_cn/design/scope.html
+6
-6
develop/doc_cn/searchindex.js
develop/doc_cn/searchindex.js
+1
-1
未找到文件。
develop/doc/_sources/design/scope.md.txt
浏览文件 @
b603c182
...
...
@@ -41,7 +41,7 @@ class Scope {
const Variable* GetVariable(const std::string& name) const;
private:
std::unordered_map<std::string, std::unique_ptr<Va
ir
able>> vars_;
std::unordered_map<std::string, std::unique_ptr<Va
ri
able>> vars_;
};
```
...
...
@@ -59,9 +59,9 @@ class Scope {
Scope(const std::shared_ptr<Scope>& scope): parent_(scope) {}
Variable* GetVariable(const std::string& name) const {
Variable* var = GetVarLocally
(name);
if (
var != nullptr
) {
return
var
;
auto it = vars_.find
(name);
if (
it != vars_.end()
) {
return
it->second.get()
;
} else if (parent_ != nullptr) {
return parent_->GetVariable(name);
} else {
...
...
@@ -97,8 +97,8 @@ class Scope {
// return nullptr if not found.
Variable* GetVariable(const std::string& name) const;
// return
Error
if already contains same name variable.
Error
CreateVariable(const std::string& name);
// return if already contains same name variable.
Variable*
CreateVariable(const std::string& name);
private:
std::shared_ptr<Scope> parent_;
...
...
develop/doc/design/scope.html
浏览文件 @
b603c182
...
...
@@ -219,7 +219,7 @@
<span
class=
"k"
>
const
</span>
<span
class=
"n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"nf"
>
GetVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
const
</span><span
class=
"p"
>
;
</span>
<span
class=
"k"
>
private
</span><span
class=
"o"
>
:
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
unordered_map
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
unique_ptr
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
Va
ir
able
</span><span
class=
"o"
>
>>
</span>
<span
class=
"n"
>
vars_
</span><span
class=
"p"
>
;
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
unordered_map
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
unique_ptr
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
Va
ri
able
</span><span
class=
"o"
>
>>
</span>
<span
class=
"n"
>
vars_
</span><span
class=
"p"
>
;
</span>
<span
class=
"p"
>
};
</span>
</pre></div>
</div>
...
...
@@ -236,9 +236,9 @@
<span
class=
"n"
>
Scope
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
shared_ptr
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
Scope
</span><span
class=
"o"
>
>&
</span>
<span
class=
"n"
>
scope
</span><span
class=
"p"
>
)
</span><span
class=
"o"
>
:
</span>
<span
class=
"n"
>
parent_
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
scope
</span><span
class=
"p"
>
)
</span>
<span
class=
"p"
>
{}
</span>
<span
class=
"n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"n"
>
GetVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
const
</span>
<span
class=
"p"
>
{
</span>
<span
class=
"
n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"n"
>
var
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
GetVarLocally
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
var
</span>
<span
class=
"o"
>
!=
</span>
<span
class=
"k"
>
nullptr
</span><span
class=
"p"
>
)
</span>
<span
class=
"p"
>
{
</span>
<span
class=
"k"
>
return
</span>
<span
class=
"n"
>
var
</span><span
class=
"p"
>
;
</span>
<span
class=
"
k"
>
auto
</span>
<span
class=
"n"
>
it
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
vars_
</span><span
class=
"p"
>
.
</span><span
class=
"n"
>
find
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
it
</span>
<span
class=
"o"
>
!=
</span>
<span
class=
"n"
>
vars_
</span><span
class=
"p"
>
.
</span><span
class=
"n"
>
end
</span><span
class=
"p"
>
()
)
</span>
<span
class=
"p"
>
{
</span>
<span
class=
"k"
>
return
</span>
<span
class=
"n"
>
it
</span><span
class=
"o"
>
-
>
</span><span
class=
"n"
>
second
</span><span
class=
"p"
>
.
</span><span
class=
"n"
>
get
</span><span
class=
"p"
>
()
;
</span>
<span
class=
"p"
>
}
</span>
<span
class=
"k"
>
else
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
parent_
</span>
<span
class=
"o"
>
!=
</span>
<span
class=
"k"
>
nullptr
</span><span
class=
"p"
>
)
</span>
<span
class=
"p"
>
{
</span>
<span
class=
"k"
>
return
</span>
<span
class=
"n"
>
parent_
</span><span
class=
"o"
>
-
>
</span><span
class=
"n"
>
GetVariable
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"p"
>
}
</span>
<span
class=
"k"
>
else
</span>
<span
class=
"p"
>
{
</span>
...
...
@@ -273,8 +273,8 @@
<span
class=
"c1"
>
// return nullptr if not found.
</span>
<span
class=
"n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"nf"
>
GetVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
const
</span><span
class=
"p"
>
;
</span>
<span
class=
"c1"
>
// return
Error
if already contains same name variable.
</span>
<span
class=
"n"
>
Error
</span>
<span
class=
"nf"
>
CreateVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"c1"
>
// return if already contains same name variable.
</span>
<span
class=
"n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"nf"
>
CreateVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"k"
>
private
</span><span
class=
"o"
>
:
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
shared_ptr
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
Scope
</span><span
class=
"o"
>
>
</span>
<span
class=
"n"
>
parent_
</span><span
class=
"p"
>
;
</span>
...
...
develop/doc/searchindex.js
浏览文件 @
b603c182
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
develop/doc_cn/_sources/design/scope.md.txt
浏览文件 @
b603c182
...
...
@@ -41,7 +41,7 @@ class Scope {
const Variable* GetVariable(const std::string& name) const;
private:
std::unordered_map<std::string, std::unique_ptr<Va
ir
able>> vars_;
std::unordered_map<std::string, std::unique_ptr<Va
ri
able>> vars_;
};
```
...
...
@@ -59,9 +59,9 @@ class Scope {
Scope(const std::shared_ptr<Scope>& scope): parent_(scope) {}
Variable* GetVariable(const std::string& name) const {
Variable* var = GetVarLocally
(name);
if (
var != nullptr
) {
return
var
;
auto it = vars_.find
(name);
if (
it != vars_.end()
) {
return
it->second.get()
;
} else if (parent_ != nullptr) {
return parent_->GetVariable(name);
} else {
...
...
@@ -97,8 +97,8 @@ class Scope {
// return nullptr if not found.
Variable* GetVariable(const std::string& name) const;
// return
Error
if already contains same name variable.
Error
CreateVariable(const std::string& name);
// return if already contains same name variable.
Variable*
CreateVariable(const std::string& name);
private:
std::shared_ptr<Scope> parent_;
...
...
develop/doc_cn/design/scope.html
浏览文件 @
b603c182
...
...
@@ -224,7 +224,7 @@
<span
class=
"k"
>
const
</span>
<span
class=
"n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"nf"
>
GetVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
const
</span><span
class=
"p"
>
;
</span>
<span
class=
"k"
>
private
</span><span
class=
"o"
>
:
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
unordered_map
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
unique_ptr
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
Va
ir
able
</span><span
class=
"o"
>
>>
</span>
<span
class=
"n"
>
vars_
</span><span
class=
"p"
>
;
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
unordered_map
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
unique_ptr
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
Va
ri
able
</span><span
class=
"o"
>
>>
</span>
<span
class=
"n"
>
vars_
</span><span
class=
"p"
>
;
</span>
<span
class=
"p"
>
};
</span>
</pre></div>
</div>
...
...
@@ -241,9 +241,9 @@
<span
class=
"n"
>
Scope
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
shared_ptr
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
Scope
</span><span
class=
"o"
>
>&
</span>
<span
class=
"n"
>
scope
</span><span
class=
"p"
>
)
</span><span
class=
"o"
>
:
</span>
<span
class=
"n"
>
parent_
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
scope
</span><span
class=
"p"
>
)
</span>
<span
class=
"p"
>
{}
</span>
<span
class=
"n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"n"
>
GetVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
const
</span>
<span
class=
"p"
>
{
</span>
<span
class=
"
n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"n"
>
var
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
GetVarLocally
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
var
</span>
<span
class=
"o"
>
!=
</span>
<span
class=
"k"
>
nullptr
</span><span
class=
"p"
>
)
</span>
<span
class=
"p"
>
{
</span>
<span
class=
"k"
>
return
</span>
<span
class=
"n"
>
var
</span><span
class=
"p"
>
;
</span>
<span
class=
"
k"
>
auto
</span>
<span
class=
"n"
>
it
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
vars_
</span><span
class=
"p"
>
.
</span><span
class=
"n"
>
find
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
it
</span>
<span
class=
"o"
>
!=
</span>
<span
class=
"n"
>
vars_
</span><span
class=
"p"
>
.
</span><span
class=
"n"
>
end
</span><span
class=
"p"
>
()
)
</span>
<span
class=
"p"
>
{
</span>
<span
class=
"k"
>
return
</span>
<span
class=
"n"
>
it
</span><span
class=
"o"
>
-
>
</span><span
class=
"n"
>
second
</span><span
class=
"p"
>
.
</span><span
class=
"n"
>
get
</span><span
class=
"p"
>
()
;
</span>
<span
class=
"p"
>
}
</span>
<span
class=
"k"
>
else
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
parent_
</span>
<span
class=
"o"
>
!=
</span>
<span
class=
"k"
>
nullptr
</span><span
class=
"p"
>
)
</span>
<span
class=
"p"
>
{
</span>
<span
class=
"k"
>
return
</span>
<span
class=
"n"
>
parent_
</span><span
class=
"o"
>
-
>
</span><span
class=
"n"
>
GetVariable
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"p"
>
}
</span>
<span
class=
"k"
>
else
</span>
<span
class=
"p"
>
{
</span>
...
...
@@ -278,8 +278,8 @@
<span
class=
"c1"
>
// return nullptr if not found.
</span>
<span
class=
"n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"nf"
>
GetVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
const
</span><span
class=
"p"
>
;
</span>
<span
class=
"c1"
>
// return
Error
if already contains same name variable.
</span>
<span
class=
"n"
>
Error
</span>
<span
class=
"nf"
>
CreateVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"c1"
>
// return if already contains same name variable.
</span>
<span
class=
"n"
>
Variable
</span><span
class=
"o"
>
*
</span>
<span
class=
"nf"
>
CreateVariable
</span><span
class=
"p"
>
(
</span><span
class=
"k"
>
const
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
string
</span><span
class=
"o"
>
&
</span>
<span
class=
"n"
>
name
</span><span
class=
"p"
>
);
</span>
<span
class=
"k"
>
private
</span><span
class=
"o"
>
:
</span>
<span
class=
"n"
>
std
</span><span
class=
"o"
>
::
</span><span
class=
"n"
>
shared_ptr
</span><span
class=
"o"
>
<
</span><span
class=
"n"
>
Scope
</span><span
class=
"o"
>
>
</span>
<span
class=
"n"
>
parent_
</span><span
class=
"p"
>
;
</span>
...
...
develop/doc_cn/searchindex.js
浏览文件 @
b603c182
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录