Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1bbb1e06
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
1bbb1e06
编写于
8月 21, 2013
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
librustc: Remove `each_path`.
This does not implement lazy symbol resolution yet.
上级
1ad2239f
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
285 addition
and
257 deletion
+285
-257
src/librustc/metadata/csearch.rs
src/librustc/metadata/csearch.rs
+24
-6
src/librustc/metadata/decoder.rs
src/librustc/metadata/decoder.rs
+103
-37
src/librustc/middle/resolve.rs
src/librustc/middle/resolve.rs
+158
-214
未找到文件。
src/librustc/metadata/csearch.rs
浏览文件 @
1bbb1e06
...
...
@@ -49,16 +49,34 @@ pub fn each_lang_item(cstore: @mut cstore::CStore,
decoder
::
each_lang_item
(
crate_data
,
f
)
}
/// Iterates over all the paths in the given crate.
pub
fn
each_path
(
cstore
:
@
mut
cstore
::
CStore
,
cnum
:
ast
::
CrateNum
,
f
:
&
fn
(
&
str
,
decoder
::
def_like
,
ast
::
visibility
)
->
bool
)
->
bool
{
/// Iterates over each child of the given item.
pub
fn
each_child_of_item
(
cstore
:
@
mut
cstore
::
CStore
,
def_id
:
ast
::
def_id
,
callback
:
&
fn
(
decoder
::
def_like
,
ast
::
ident
))
{
let
crate_data
=
cstore
::
get_crate_data
(
cstore
,
def_id
.crate
);
let
get_crate_data
:
decoder
::
GetCrateDataCb
=
|
cnum
|
{
cstore
::
get_crate_data
(
cstore
,
cnum
)
};
decoder
::
each_child_of_item
(
cstore
.intr
,
crate_data
,
def_id
.node
,
get_crate_data
,
callback
)
}
/// Iterates over each top-level crate item.
pub
fn
each_top_level_item_of_crate
(
cstore
:
@
mut
cstore
::
CStore
,
cnum
:
ast
::
CrateNum
,
callback
:
&
fn
(
decoder
::
def_like
,
ast
::
ident
))
{
let
crate_data
=
cstore
::
get_crate_data
(
cstore
,
cnum
);
let
get_crate_data
:
decoder
::
GetCrateDataCb
=
|
cnum
|
{
cstore
::
get_crate_data
(
cstore
,
cnum
)
};
decoder
::
each_path
(
cstore
.intr
,
crate_data
,
get_crate_data
,
f
)
decoder
::
each_top_level_item_of_crate
(
cstore
.intr
,
crate_data
,
get_crate_data
,
callback
)
}
pub
fn
get_item_path
(
tcx
:
ty
::
ctxt
,
def
:
ast
::
def_id
)
->
ast_map
::
path
{
...
...
src/librustc/metadata/decoder.rs
浏览文件 @
1bbb1e06
...
...
@@ -39,7 +39,7 @@
use
syntax
::
attr
;
use
syntax
::
parse
::
token
::{
ident_interner
,
special_idents
};
use
syntax
::
print
::
pprust
;
use
syntax
::
{
ast
,
ast_util
}
;
use
syntax
::
ast
;
use
syntax
::
codemap
;
use
syntax
::
parse
::
token
;
...
...
@@ -702,33 +702,114 @@ fn each_child_of_module_or_crate(&mut self, item_doc: ebml::Doc) -> bool {
}
}
/// Iterates over all the paths in the given crate.
pub
fn
each_path
(
intr
:
@
ident_interner
,
cdata
:
cmd
,
get_crate_data
:
GetCrateDataCb
,
f
:
&
fn
(
&
str
,
def_like
,
ast
::
visibility
)
->
bool
)
->
bool
{
// FIXME #4572: This function needs to be nuked, as it's impossible to
// make fast. It's the source of most of the performance problems when
// compiling small crates.
fn
each_child_of_item_or_crate
(
intr
:
@
ident_interner
,
cdata
:
cmd
,
item_doc
:
ebml
::
Doc
,
get_crate_data
:
GetCrateDataCb
,
callback
:
&
fn
(
def_like
,
ast
::
ident
))
{
// Iterate over all children.
let
_
=
do
reader
::
tagged_docs
(
item_doc
,
tag_mod_child
)
|
child_info_doc
|
{
let
child_def_id
=
reader
::
with_doc_data
(
child_info_doc
,
parse_def_id
);
let
child_def_id
=
translate_def_id
(
cdata
,
child_def_id
);
// This item may be in yet another crate if it was the child of a
// reexport.
let
other_crates_items
=
if
child_def_id
.crate
==
cdata
.cnum
{
reader
::
get_doc
(
reader
::
Doc
(
cdata
.data
),
tag_items
)
}
else
{
let
crate_data
=
get_crate_data
(
child_def_id
.crate
);
reader
::
get_doc
(
reader
::
Doc
(
crate_data
.data
),
tag_items
)
};
// Get the item.
match
maybe_find_item
(
child_def_id
.node
,
other_crates_items
)
{
None
=>
{}
Some
(
child_item_doc
)
=>
{
// Hand off the item to the callback.
let
child_name
=
item_name
(
intr
,
child_item_doc
);
let
def_like
=
item_to_def_like
(
child_item_doc
,
child_def_id
,
cdata
.cnum
);
callback
(
def_like
,
child_name
);
}
}
true
};
// Iterate over all reexports.
let
_
=
do
each_reexport
(
item_doc
)
|
reexport_doc
|
{
let
def_id_doc
=
reader
::
get_doc
(
reexport_doc
,
tag_items_data_item_reexport_def_id
);
let
child_def_id
=
reader
::
with_doc_data
(
def_id_doc
,
parse_def_id
);
let
child_def_id
=
translate_def_id
(
cdata
,
child_def_id
);
let
name_doc
=
reader
::
get_doc
(
reexport_doc
,
tag_items_data_item_reexport_name
);
let
name
=
name_doc
.as_str_slice
();
// This reexport may be in yet another crate.
let
other_crates_items
=
if
child_def_id
.crate
==
cdata
.cnum
{
reader
::
get_doc
(
reader
::
Doc
(
cdata
.data
),
tag_items
)
}
else
{
let
crate_data
=
get_crate_data
(
child_def_id
.crate
);
reader
::
get_doc
(
reader
::
Doc
(
crate_data
.data
),
tag_items
)
};
// Get the item.
match
maybe_find_item
(
child_def_id
.node
,
other_crates_items
)
{
None
=>
{}
Some
(
child_item_doc
)
=>
{
// Hand off the item to the callback.
let
def_like
=
item_to_def_like
(
child_item_doc
,
child_def_id
,
cdata
.cnum
);
callback
(
def_like
,
token
::
str_to_ident
(
name
));
}
}
true
};
}
/// Iterates over each child of the given item.
pub
fn
each_child_of_item
(
intr
:
@
ident_interner
,
cdata
:
cmd
,
id
:
ast
::
NodeId
,
get_crate_data
:
GetCrateDataCb
,
callback
:
&
fn
(
def_like
,
ast
::
ident
))
{
// Find the item.
let
root_doc
=
reader
::
Doc
(
cdata
.data
);
let
items
=
reader
::
get_doc
(
root_doc
,
tag_items
);
let
item_doc
=
match
maybe_find_item
(
id
,
items
)
{
None
=>
return
,
Some
(
item_doc
)
=>
item_doc
,
};
each_child_of_item_or_crate
(
intr
,
cdata
,
item_doc
,
get_crate_data
,
callback
)
}
/// Iterates over all the top-level crate items.
pub
fn
each_top_level_item_of_crate
(
intr
:
@
ident_interner
,
cdata
:
cmd
,
get_crate_data
:
GetCrateDataCb
,
callback
:
&
fn
(
def_like
,
ast
::
ident
))
{
let
root_doc
=
reader
::
Doc
(
cdata
.data
);
let
misc_info_doc
=
reader
::
get_doc
(
root_doc
,
tag_misc_info
);
let
crate_items_doc
=
reader
::
get_doc
(
misc_info_doc
,
tag_misc_info_crate_items
);
let
mut
path_builder
=
~
""
;
let
mut
context
=
EachItemContext
{
intr
:
intr
,
cdata
:
cdata
,
get_crate_data
:
get_crate_data
,
path_builder
:
&
mut
path_builder
,
callback
:
f
,
};
// Iterate over all top-level crate items.
context
.each_child_of_module_or_crate
(
crate_items_doc
)
each_child_of_item_or_crate
(
intr
,
cdata
,
crate_items_doc
,
get_crate_data
,
callback
)
}
pub
fn
get_item_path
(
cdata
:
cmd
,
id
:
ast
::
NodeId
)
->
ast_map
::
path
{
...
...
@@ -1268,21 +1349,6 @@ pub fn get_crate_vers(data: @~[u8]) -> @str {
}
}
fn
iter_crate_items
(
intr
:
@
ident_interner
,
cdata
:
cmd
,
get_crate_data
:
GetCrateDataCb
,
proc
:
&
fn
(
path
:
&
str
,
ast
::
def_id
))
{
do
each_path
(
intr
,
cdata
,
get_crate_data
)
|
path_string
,
def_like
,
_
|
{
match
def_like
{
dl_impl
(
*
)
|
dl_field
=>
{}
dl_def
(
def
)
=>
{
proc
(
path_string
,
ast_util
::
def_id_of_def
(
def
))
}
}
true
};
}
pub
fn
list_crate_metadata
(
intr
:
@
ident_interner
,
bytes
:
@~
[
u8
],
out
:
@
io
::
Writer
)
{
let
hash
=
get_crate_hash
(
bytes
);
...
...
src/librustc/middle/resolve.rs
浏览文件 @
1bbb1e06
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录