Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ecbdfb49
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ecbdfb49
编写于
8月 25, 2018
作者:
V
varkor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert EntryKind to a struct, Entry
上级
11665ca4
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
118 addition
and
243 deletion
+118
-243
src/librustc/hir/map/collector.rs
src/librustc/hir/map/collector.rs
+19
-36
src/librustc/hir/map/mod.rs
src/librustc/hir/map/mod.rs
+99
-207
未找到文件。
src/librustc/hir/map/collector.rs
浏览文件 @
ecbdfb49
...
...
@@ -29,7 +29,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
/// The crate
krate
:
&
'hir
Crate
,
/// The node map
map
:
Vec
<
EntryKind
<
'hir
>>
,
map
:
Vec
<
Option
<
Entry
<
'hir
>
>>
,
/// The parent of this node
parent_node
:
NodeId
,
...
...
@@ -114,7 +114,11 @@ pub(super) fn root(krate: &'hir Crate,
hcx
,
hir_body_nodes
,
};
collector
.insert_entry
(
CRATE_NODE_ID
,
EntryKind
::
RootCrate
(
root_mod_sig_dep_index
));
collector
.insert_entry
(
CRATE_NODE_ID
,
Entry
{
parent
:
ast
::
DUMMY_NODE_ID
,
dep_node
:
root_mod_sig_dep_index
,
node
:
NodeKind
::
Crate
,
});
collector
}
...
...
@@ -124,9 +128,8 @@ pub(super) fn finalize_and_compute_crate_hash(mut self,
cstore
:
&
dyn
CrateStore
,
source_map
:
&
SourceMap
,
commandline_args_hash
:
u64
)
->
(
Vec
<
EntryKind
<
'hir
>>
,
Svh
)
{
self
.hir_body_nodes
->
(
Vec
<
Option
<
Entry
<
'hir
>>>
,
Svh
)
{
self
.hir_body_nodes
.sort_unstable_by
(|
&
(
ref
d1
,
_
),
&
(
ref
d2
,
_
)|
d1
.cmp
(
d2
));
let
node_hashes
=
self
...
...
@@ -178,44 +181,24 @@ pub(super) fn finalize_and_compute_crate_hash(mut self,
(
self
.map
,
svh
)
}
fn
insert_entry
(
&
mut
self
,
id
:
NodeId
,
entry
:
Entry
Kind
<
'hir
>
)
{
fn
insert_entry
(
&
mut
self
,
id
:
NodeId
,
entry
:
Entry
<
'hir
>
)
{
debug!
(
"hir_map: {:?} => {:?}"
,
id
,
entry
);
let
len
=
self
.map
.len
();
if
id
.as_usize
()
>=
len
{
self
.map
.extend
(
repeat
(
EntryKind
::
NotPresent
)
.take
(
id
.as_usize
()
-
len
+
1
));
self
.map
.extend
(
repeat
(
None
)
.take
(
id
.as_usize
()
-
len
+
1
));
}
self
.map
[
id
.as_usize
()]
=
entry
;
self
.map
[
id
.as_usize
()]
=
Some
(
entry
)
;
}
fn
insert
(
&
mut
self
,
id
:
NodeId
,
node
:
NodeKind
<
'hir
>
)
{
let
parent
=
self
.parent_node
;
let
dep_node_index
=
if
self
.currently_in_body
{
self
.current_full_dep_index
}
else
{
self
.current_signature_dep_index
};
let
entry
=
match
node
{
NodeKind
::
Item
(
n
)
=>
EntryKind
::
Item
(
parent
,
dep_node_index
,
n
),
NodeKind
::
ForeignItem
(
n
)
=>
EntryKind
::
ForeignItem
(
parent
,
dep_node_index
,
n
),
NodeKind
::
TraitItem
(
n
)
=>
EntryKind
::
TraitItem
(
parent
,
dep_node_index
,
n
),
NodeKind
::
ImplItem
(
n
)
=>
EntryKind
::
ImplItem
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Variant
(
n
)
=>
EntryKind
::
Variant
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Field
(
n
)
=>
EntryKind
::
Field
(
parent
,
dep_node_index
,
n
),
NodeKind
::
AnonConst
(
n
)
=>
EntryKind
::
AnonConst
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Expr
(
n
)
=>
EntryKind
::
Expr
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Stmt
(
n
)
=>
EntryKind
::
Stmt
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Ty
(
n
)
=>
EntryKind
::
Ty
(
parent
,
dep_node_index
,
n
),
NodeKind
::
TraitRef
(
n
)
=>
EntryKind
::
TraitRef
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Binding
(
n
)
=>
EntryKind
::
Binding
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Pat
(
n
)
=>
EntryKind
::
Pat
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Block
(
n
)
=>
EntryKind
::
Block
(
parent
,
dep_node_index
,
n
),
NodeKind
::
StructCtor
(
n
)
=>
EntryKind
::
StructCtor
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Lifetime
(
n
)
=>
EntryKind
::
Lifetime
(
parent
,
dep_node_index
,
n
),
NodeKind
::
GenericParam
(
n
)
=>
EntryKind
::
GenericParam
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Visibility
(
n
)
=>
EntryKind
::
Visibility
(
parent
,
dep_node_index
,
n
),
NodeKind
::
Local
(
n
)
=>
EntryKind
::
Local
(
parent
,
dep_node_index
,
n
),
NodeKind
::
MacroDef
(
n
)
=>
EntryKind
::
MacroDef
(
dep_node_index
,
n
),
let
entry
=
Entry
{
parent
:
self
.parent_node
,
dep_node
:
if
self
.currently_in_body
{
self
.current_full_dep_index
}
else
{
self
.current_signature_dep_index
},
node
,
};
// Make sure that the DepNode of some node coincides with the HirId
...
...
src/librustc/hir/map/mod.rs
浏览文件 @
ecbdfb49
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录