Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
075ab306
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,发现更多精彩内容 >>
提交
075ab306
编写于
4月 17, 2014
作者:
E
Eduard Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: de-@ metadata::cstore.
上级
fa33012b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
83 addition
and
73 deletion
+83
-73
src/librustc/metadata/creader.rs
src/librustc/metadata/creader.rs
+6
-6
src/librustc/metadata/csearch.rs
src/librustc/metadata/csearch.rs
+32
-32
src/librustc/metadata/cstore.rs
src/librustc/metadata/cstore.rs
+7
-7
src/librustc/metadata/decoder.rs
src/librustc/metadata/decoder.rs
+22
-12
src/librustc/middle/astencode.rs
src/librustc/middle/astencode.rs
+16
-16
未找到文件。
src/librustc/metadata/creader.rs
浏览文件 @
075ab306
...
...
@@ -279,7 +279,7 @@ fn resolve_crate<'a>(e: &mut Env,
hash
:
Option
<&
Svh
>
,
should_link
:
bool
,
span
:
Span
)
->
(
ast
::
CrateNum
,
@
cstore
::
crate_metadata
,
->
(
ast
::
CrateNum
,
Rc
<
cstore
::
crate_metadata
>
,
cstore
::
CrateSource
)
{
match
existing_match
(
e
,
crate_id
,
hash
)
{
None
=>
{
...
...
@@ -330,13 +330,13 @@ fn resolve_crate<'a>(e: &mut Env,
-
1
};
let
cmeta
=
@
cstore
::
crate_metadata
{
let
cmeta
=
Rc
::
new
(
cstore
::
crate_metadata
{
name
:
load_ctxt
.crate_id.name
.to_owned
(),
data
:
metadata
,
cnum_map
:
cnum_map
,
cnum
:
cnum
,
span
:
span
,
};
}
)
;
let
source
=
cstore
::
CrateSource
{
dylib
:
dylib
,
...
...
@@ -345,7 +345,7 @@ fn resolve_crate<'a>(e: &mut Env,
};
if
should_link
{
e
.sess.cstore
.set_crate_data
(
cnum
,
cmeta
);
e
.sess.cstore
.set_crate_data
(
cnum
,
cmeta
.clone
()
);
e
.sess.cstore
.add_used_crate_source
(
source
.clone
());
}
(
cnum
,
cmeta
,
source
)
...
...
@@ -402,8 +402,8 @@ fn load_crate(&mut self, krate: &ast::ViewItem) -> MacroCrate {
info
.ident
,
&
info
.crate_id
,
None
,
info
.should_link
,
krate
.span
);
let
macros
=
decoder
::
get_exported_macros
(
data
);
let
registrar
=
decoder
::
get_macro_registrar_fn
(
data
)
.map
(|
id
|
{
let
macros
=
decoder
::
get_exported_macros
(
&*
data
);
let
registrar
=
decoder
::
get_macro_registrar_fn
(
&*
data
)
.map
(|
id
|
{
decoder
::
get_symbol
(
data
.data
.as_slice
(),
id
)
});
MacroCrate
{
...
...
src/librustc/metadata/csearch.rs
浏览文件 @
075ab306
...
...
@@ -33,8 +33,8 @@ pub struct StaticMethodInfo {
}
pub
fn
get_symbol
(
cstore
:
&
cstore
::
CStore
,
def
:
ast
::
DefId
)
->
~
str
{
let
cdata
=
cstore
.get_crate_data
(
def
.krate
)
.data
()
;
return
decoder
::
get_symbol
(
cdata
,
def
.node
);
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_symbol
(
cdata
.data
(),
def
.node
)
}
/// Iterates over all the language items in the given crate.
...
...
@@ -43,7 +43,7 @@ pub fn each_lang_item(cstore: &cstore::CStore,
f
:
|
ast
::
NodeId
,
uint
|
->
bool
)
->
bool
{
let
crate_data
=
cstore
.get_crate_data
(
cnum
);
decoder
::
each_lang_item
(
crate_data
,
f
)
decoder
::
each_lang_item
(
&*
crate_data
,
f
)
}
/// Iterates over each child of the given item.
...
...
@@ -57,7 +57,7 @@ pub fn each_child_of_item(cstore: &cstore::CStore,
cstore
.get_crate_data
(
cnum
)
};
decoder
::
each_child_of_item
(
cstore
.intr
.clone
(),
crate_data
,
&*
crate_data
,
def_id
.node
,
get_crate_data
,
callback
)
...
...
@@ -74,7 +74,7 @@ pub fn each_top_level_item_of_crate(cstore: &cstore::CStore,
cstore
.get_crate_data
(
cnum
)
};
decoder
::
each_top_level_item_of_crate
(
cstore
.intr
.clone
(),
crate_data
,
&*
crate_data
,
get_crate_data
,
callback
)
}
...
...
@@ -82,7 +82,7 @@ pub fn each_top_level_item_of_crate(cstore: &cstore::CStore,
pub
fn
get_item_path
(
tcx
:
&
ty
::
ctxt
,
def
:
ast
::
DefId
)
->
Vec
<
ast_map
::
PathElem
>
{
let
cstore
=
&
tcx
.sess.cstore
;
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
let
path
=
decoder
::
get_item_path
(
cdata
,
def
.node
);
let
path
=
decoder
::
get_item_path
(
&*
cdata
,
def
.node
);
// FIXME #1920: This path is not always correct if the crate is not linked
// into the root namespace.
...
...
@@ -103,26 +103,26 @@ pub fn maybe_get_item_ast(tcx: &ty::ctxt, def: ast::DefId,
->
found_ast
{
let
cstore
=
&
tcx
.sess.cstore
;
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
maybe_get_item_ast
(
cdata
,
tcx
,
def
.node
,
decode_inlined_item
)
decoder
::
maybe_get_item_ast
(
&*
cdata
,
tcx
,
def
.node
,
decode_inlined_item
)
}
pub
fn
get_enum_variants
(
tcx
:
&
ty
::
ctxt
,
def
:
ast
::
DefId
)
->
Vec
<@
ty
::
VariantInfo
>
{
let
cstore
=
&
tcx
.sess.cstore
;
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
return
decoder
::
get_enum_variants
(
cstore
.intr
.clone
(),
cdata
,
def
.node
,
tcx
)
return
decoder
::
get_enum_variants
(
cstore
.intr
.clone
(),
&*
cdata
,
def
.node
,
tcx
)
}
/// Returns information about the given implementation.
pub
fn
get_impl
(
tcx
:
&
ty
::
ctxt
,
impl_def_id
:
ast
::
DefId
)
->
ty
::
Impl
{
let
cdata
=
tcx
.sess.cstore
.get_crate_data
(
impl_def_id
.krate
);
decoder
::
get_impl
(
tcx
.sess.cstore.intr
.clone
(),
cdata
,
impl_def_id
.node
,
tcx
)
decoder
::
get_impl
(
tcx
.sess.cstore.intr
.clone
(),
&*
cdata
,
impl_def_id
.node
,
tcx
)
}
pub
fn
get_method
(
tcx
:
&
ty
::
ctxt
,
def
:
ast
::
DefId
)
->
ty
::
Method
{
let
cdata
=
tcx
.sess.cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_method
(
tcx
.sess.cstore.intr
.clone
(),
cdata
,
def
.node
,
tcx
)
decoder
::
get_method
(
tcx
.sess.cstore.intr
.clone
(),
&*
cdata
,
def
.node
,
tcx
)
}
pub
fn
get_method_name_and_explicit_self
(
cstore
:
&
cstore
::
CStore
,
...
...
@@ -130,19 +130,19 @@ pub fn get_method_name_and_explicit_self(cstore: &cstore::CStore,
->
(
ast
::
Ident
,
ast
::
ExplicitSelf_
)
{
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_method_name_and_explicit_self
(
cstore
.intr
.clone
(),
cdata
,
def
.node
)
decoder
::
get_method_name_and_explicit_self
(
cstore
.intr
.clone
(),
&*
cdata
,
def
.node
)
}
pub
fn
get_trait_method_def_ids
(
cstore
:
&
cstore
::
CStore
,
def
:
ast
::
DefId
)
->
Vec
<
ast
::
DefId
>
{
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_trait_method_def_ids
(
cdata
,
def
.node
)
decoder
::
get_trait_method_def_ids
(
&*
cdata
,
def
.node
)
}
pub
fn
get_item_variances
(
cstore
:
&
cstore
::
CStore
,
def
:
ast
::
DefId
)
->
ty
::
ItemVariances
{
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_item_variances
(
cdata
,
def
.node
)
decoder
::
get_item_variances
(
&*
cdata
,
def
.node
)
}
pub
fn
get_provided_trait_methods
(
tcx
:
&
ty
::
ctxt
,
...
...
@@ -150,40 +150,40 @@ pub fn get_provided_trait_methods(tcx: &ty::ctxt,
->
Vec
<@
ty
::
Method
>
{
let
cstore
=
&
tcx
.sess.cstore
;
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_provided_trait_methods
(
cstore
.intr
.clone
(),
cdata
,
def
.node
,
tcx
)
decoder
::
get_provided_trait_methods
(
cstore
.intr
.clone
(),
&*
cdata
,
def
.node
,
tcx
)
}
pub
fn
get_supertraits
(
tcx
:
&
ty
::
ctxt
,
def
:
ast
::
DefId
)
->
Vec
<@
ty
::
TraitRef
>
{
let
cstore
=
&
tcx
.sess.cstore
;
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_supertraits
(
cdata
,
def
.node
,
tcx
)
decoder
::
get_supertraits
(
&*
cdata
,
def
.node
,
tcx
)
}
pub
fn
get_type_name_if_impl
(
cstore
:
&
cstore
::
CStore
,
def
:
ast
::
DefId
)
->
Option
<
ast
::
Ident
>
{
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_type_name_if_impl
(
cdata
,
def
.node
)
decoder
::
get_type_name_if_impl
(
&*
cdata
,
def
.node
)
}
pub
fn
get_static_methods_if_impl
(
cstore
:
&
cstore
::
CStore
,
def
:
ast
::
DefId
)
->
Option
<
Vec
<
StaticMethodInfo
>
>
{
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_static_methods_if_impl
(
cstore
.intr
.clone
(),
cdata
,
def
.node
)
decoder
::
get_static_methods_if_impl
(
cstore
.intr
.clone
(),
&*
cdata
,
def
.node
)
}
pub
fn
get_item_attrs
(
cstore
:
&
cstore
::
CStore
,
def_id
:
ast
::
DefId
,
f
:
|
Vec
<@
ast
::
MetaItem
>
|)
{
let
cdata
=
cstore
.get_crate_data
(
def_id
.krate
);
decoder
::
get_item_attrs
(
cdata
,
def_id
.node
,
f
)
decoder
::
get_item_attrs
(
&*
cdata
,
def_id
.node
,
f
)
}
pub
fn
get_struct_fields
(
cstore
:
&
cstore
::
CStore
,
def
:
ast
::
DefId
)
->
Vec
<
ty
::
field_ty
>
{
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_struct_fields
(
cstore
.intr
.clone
(),
cdata
,
def
.node
)
decoder
::
get_struct_fields
(
cstore
.intr
.clone
(),
&*
cdata
,
def
.node
)
}
pub
fn
get_type
(
tcx
:
&
ty
::
ctxt
,
...
...
@@ -191,13 +191,13 @@ pub fn get_type(tcx: &ty::ctxt,
->
ty
::
ty_param_bounds_and_ty
{
let
cstore
=
&
tcx
.sess.cstore
;
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_type
(
cdata
,
def
.node
,
tcx
)
decoder
::
get_type
(
&*
cdata
,
def
.node
,
tcx
)
}
pub
fn
get_trait_def
(
tcx
:
&
ty
::
ctxt
,
def
:
ast
::
DefId
)
->
ty
::
TraitDef
{
let
cstore
=
&
tcx
.sess.cstore
;
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_trait_def
(
cdata
,
def
.node
,
tcx
)
decoder
::
get_trait_def
(
&*
cdata
,
def
.node
,
tcx
)
}
pub
fn
get_field_type
(
tcx
:
&
ty
::
ctxt
,
class_id
:
ast
::
DefId
,
...
...
@@ -213,7 +213,7 @@ pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
decoder
::
maybe_find_item
(
def
.node
,
class_doc
),
||
format!
(
"get_field_type: in class {:?}, field ID {:?} not found"
,
class_id
,
def
)
);
let
ty
=
decoder
::
item_type
(
def
,
the_field
,
tcx
,
cdata
);
let
ty
=
decoder
::
item_type
(
def
,
the_field
,
tcx
,
&*
cdata
);
ty
::
ty_param_bounds_and_ty
{
generics
:
ty
::
Generics
{
type_param_defs
:
Rc
::
new
(
Vec
::
new
()),
region_param_defs
:
Rc
::
new
(
Vec
::
new
())},
...
...
@@ -227,7 +227,7 @@ pub fn get_impl_trait(tcx: &ty::ctxt,
def
:
ast
::
DefId
)
->
Option
<@
ty
::
TraitRef
>
{
let
cstore
=
&
tcx
.sess.cstore
;
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_impl_trait
(
cdata
,
def
.node
,
tcx
)
decoder
::
get_impl_trait
(
&*
cdata
,
def
.node
,
tcx
)
}
// Given a def_id for an impl, return information about its vtables
...
...
@@ -235,35 +235,35 @@ pub fn get_impl_vtables(tcx: &ty::ctxt,
def
:
ast
::
DefId
)
->
typeck
::
impl_res
{
let
cstore
=
&
tcx
.sess.cstore
;
let
cdata
=
cstore
.get_crate_data
(
def
.krate
);
decoder
::
get_impl_vtables
(
cdata
,
def
.node
,
tcx
)
decoder
::
get_impl_vtables
(
&*
cdata
,
def
.node
,
tcx
)
}
pub
fn
get_native_libraries
(
cstore
:
&
cstore
::
CStore
,
crate_num
:
ast
::
CrateNum
)
->
Vec
<
(
cstore
::
NativeLibaryKind
,
~
str
)
>
{
let
cdata
=
cstore
.get_crate_data
(
crate_num
);
decoder
::
get_native_libraries
(
cdata
)
decoder
::
get_native_libraries
(
&*
cdata
)
}
pub
fn
each_impl
(
cstore
:
&
cstore
::
CStore
,
crate_num
:
ast
::
CrateNum
,
callback
:
|
ast
::
DefId
|)
{
let
cdata
=
cstore
.get_crate_data
(
crate_num
);
decoder
::
each_impl
(
cdata
,
callback
)
decoder
::
each_impl
(
&*
cdata
,
callback
)
}
pub
fn
each_implementation_for_type
(
cstore
:
&
cstore
::
CStore
,
def_id
:
ast
::
DefId
,
callback
:
|
ast
::
DefId
|)
{
let
cdata
=
cstore
.get_crate_data
(
def_id
.krate
);
decoder
::
each_implementation_for_type
(
cdata
,
def_id
.node
,
callback
)
decoder
::
each_implementation_for_type
(
&*
cdata
,
def_id
.node
,
callback
)
}
pub
fn
each_implementation_for_trait
(
cstore
:
&
cstore
::
CStore
,
def_id
:
ast
::
DefId
,
callback
:
|
ast
::
DefId
|)
{
let
cdata
=
cstore
.get_crate_data
(
def_id
.krate
);
decoder
::
each_implementation_for_trait
(
cdata
,
def_id
.node
,
callback
)
decoder
::
each_implementation_for_trait
(
&*
cdata
,
def_id
.node
,
callback
)
}
/// If the given def ID describes a method belonging to a trait (either a
...
...
@@ -274,21 +274,21 @@ pub fn get_trait_of_method(cstore: &cstore::CStore,
tcx
:
&
ty
::
ctxt
)
->
Option
<
ast
::
DefId
>
{
let
cdata
=
cstore
.get_crate_data
(
def_id
.krate
);
decoder
::
get_trait_of_method
(
cdata
,
def_id
.node
,
tcx
)
decoder
::
get_trait_of_method
(
&*
cdata
,
def_id
.node
,
tcx
)
}
pub
fn
get_macro_registrar_fn
(
cstore
:
&
cstore
::
CStore
,
crate_num
:
ast
::
CrateNum
)
->
Option
<
ast
::
NodeId
>
{
let
cdata
=
cstore
.get_crate_data
(
crate_num
);
decoder
::
get_macro_registrar_fn
(
cdata
)
decoder
::
get_macro_registrar_fn
(
&*
cdata
)
}
pub
fn
get_exported_macros
(
cstore
:
&
cstore
::
CStore
,
crate_num
:
ast
::
CrateNum
)
->
Vec
<~
str
>
{
let
cdata
=
cstore
.get_crate_data
(
crate_num
);
decoder
::
get_exported_macros
(
cdata
)
decoder
::
get_exported_macros
(
&*
cdata
)
}
pub
fn
get_tuple_struct_definition_if_ctor
(
cstore
:
&
cstore
::
CStore
,
...
...
@@ -296,5 +296,5 @@ pub fn get_tuple_struct_definition_if_ctor(cstore: &cstore::CStore,
->
Option
<
ast
::
DefId
>
{
let
cdata
=
cstore
.get_crate_data
(
def_id
.krate
);
decoder
::
get_tuple_struct_definition_if_ctor
(
cdata
,
def_id
.node
)
decoder
::
get_tuple_struct_definition_if_ctor
(
&*
cdata
,
def_id
.node
)
}
src/librustc/metadata/cstore.rs
浏览文件 @
075ab306
...
...
@@ -68,7 +68,7 @@ pub struct CrateSource {
}
pub
struct
CStore
{
metas
:
RefCell
<
HashMap
<
ast
::
CrateNum
,
@
crate_metadata
>>
,
metas
:
RefCell
<
HashMap
<
ast
::
CrateNum
,
Rc
<
crate_metadata
>
>>
,
extern_mod_crate_map
:
RefCell
<
extern_mod_crate_map
>
,
used_crate_sources
:
RefCell
<
Vec
<
CrateSource
>>
,
used_libraries
:
RefCell
<
Vec
<
(
~
str
,
NativeLibaryKind
)
>>
,
...
...
@@ -95,8 +95,8 @@ pub fn next_crate_num(&self) -> ast::CrateNum {
self
.metas
.borrow
()
.len
()
as
ast
::
CrateNum
+
1
}
pub
fn
get_crate_data
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
@
crate_metadata
{
*
self
.metas
.borrow
()
.get
(
&
cnum
)
pub
fn
get_crate_data
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Rc
<
crate_metadata
>
{
self
.metas
.borrow
()
.get
(
&
cnum
)
.clone
(
)
}
pub
fn
get_crate_hash
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Svh
{
...
...
@@ -104,13 +104,13 @@ pub fn get_crate_hash(&self, cnum: ast::CrateNum) -> Svh {
decoder
::
get_crate_hash
(
cdata
.data
())
}
pub
fn
set_crate_data
(
&
self
,
cnum
:
ast
::
CrateNum
,
data
:
@
crate_metadata
)
{
pub
fn
set_crate_data
(
&
self
,
cnum
:
ast
::
CrateNum
,
data
:
Rc
<
crate_metadata
>
)
{
self
.metas
.borrow_mut
()
.insert
(
cnum
,
data
);
}
pub
fn
iter_crate_data
(
&
self
,
i
:
|
ast
::
CrateNum
,
@
crate_metadata
|)
{
for
(
&
k
,
&
v
)
in
self
.metas
.borrow
()
.iter
()
{
i
(
k
,
v
);
pub
fn
iter_crate_data
(
&
self
,
i
:
|
ast
::
CrateNum
,
&
crate_metadata
|)
{
for
(
&
k
,
v
)
in
self
.metas
.borrow
()
.iter
()
{
i
(
k
,
&**
v
);
}
}
...
...
src/librustc/metadata/decoder.rs
浏览文件 @
075ab306
...
...
@@ -45,7 +45,7 @@
use
syntax
::
codemap
;
use
syntax
::
crateid
::
CrateId
;
pub
type
Cmd
=
@
crate_metadata
;
pub
type
Cmd
<
'a
>
=
&
'a
crate_metadata
;
// A function that takes a def_id relative to the crate being searched and
// returns a def_id relative to the compilation environment, i.e. if we hit a
...
...
@@ -76,8 +76,6 @@ fn lookup_hash<'a>(d: ebml::Doc<'a>, eq_fn: |&[u8]| -> bool,
ret
}
pub
type
GetCrateDataCb
<
'a
>
=
|
ast
::
CrateNum
|:
'a
->
Cmd
;
pub
fn
maybe_find_item
<
'a
>
(
item_id
:
ast
::
NodeId
,
items
:
ebml
::
Doc
<
'a
>
)
->
Option
<
ebml
::
Doc
<
'a
>>
{
fn
eq_item
(
bytes
:
&
[
u8
],
item_id
:
ast
::
NodeId
)
->
bool
{
...
...
@@ -462,6 +460,8 @@ pub fn each_lang_item(cdata: Cmd, f: |ast::NodeId, uint| -> bool) -> bool {
})
}
pub
type
GetCrateDataCb
<
'a
>
=
|
ast
::
CrateNum
|:
'a
->
Rc
<
crate_metadata
>
;
fn
each_child_of_item_or_crate
(
intr
:
Rc
<
IdentInterner
>
,
cdata
:
Cmd
,
item_doc
:
ebml
::
Doc
,
...
...
@@ -477,13 +477,18 @@ fn each_child_of_item_or_crate(intr: Rc<IdentInterner>,
// This item may be in yet another crate if it was the child of a
// reexport.
let
other_crates_items
=
if
child_def_id
.krate
==
cdata
.cnum
{
reader
::
get_doc
(
reader
::
Doc
(
cdata
.data
()),
tag_items
)
let
crate_data
=
if
child_def_id
.krate
==
cdata
.cnum
{
None
}
else
{
let
crate_data
=
get_crate_data
(
child_def_id
.krate
);
reader
::
get_doc
(
reader
::
Doc
(
crate_data
.data
()),
tag_items
)
Some
(
get_crate_data
(
child_def_id
.krate
))
};
let
crate_data
=
match
crate_data
{
Some
(
ref
cdata
)
=>
&**
cdata
,
None
=>
cdata
};
let
other_crates_items
=
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
=>
{}
...
...
@@ -565,13 +570,18 @@ fn each_child_of_item_or_crate(intr: Rc<IdentInterner>,
let
name
=
name_doc
.as_str_slice
();
// This reexport may be in yet another crate.
let
other_crates_items
=
if
child_def_id
.krate
==
cdata
.cnum
{
reader
::
get_doc
(
reader
::
Doc
(
cdata
.data
()),
tag_items
)
let
crate_data
=
if
child_def_id
.krate
==
cdata
.cnum
{
None
}
else
{
let
crate_data
=
get_crate_data
(
child_def_id
.krate
);
reader
::
get_doc
(
reader
::
Doc
(
crate_data
.data
()),
tag_items
)
Some
(
get_crate_data
(
child_def_id
.krate
))
};
let
crate_data
=
match
crate_data
{
Some
(
ref
cdata
)
=>
&**
cdata
,
None
=>
cdata
};
let
other_crates_items
=
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
=>
{}
...
...
@@ -634,7 +644,7 @@ pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> Vec<ast_map::PathElem> {
item_path
(
lookup_item
(
id
,
cdata
.data
()))
}
pub
type
DecodeInlinedItem
<
'a
>
=
|
cdata
:
@
cstore
::
crate_metadata
,
pub
type
DecodeInlinedItem
<
'a
>
=
|
cdata
:
Cmd
,
tcx
:
&
ty
::
ctxt
,
path
:
Vec
<
ast_map
::
PathElem
>
,
par_doc
:
ebml
::
Doc
|:
'a
...
...
src/librustc/middle/astencode.rs
浏览文件 @
075ab306
...
...
@@ -59,7 +59,7 @@ pub struct Maps {
}
struct
DecodeContext
<
'a
>
{
cdata
:
@
cstore
::
crate_metadata
,
cdata
:
&
'a
cstore
::
crate_metadata
,
tcx
:
&
'a
ty
::
ctxt
,
maps
:
&
'a
Maps
}
...
...
@@ -110,7 +110,7 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext,
ebml_w
.writer
.tell
());
}
pub
fn
decode_inlined_item
(
cdata
:
@
cstore
::
crate_metadata
,
pub
fn
decode_inlined_item
(
cdata
:
&
cstore
::
crate_metadata
,
tcx
:
&
ty
::
ctxt
,
maps
:
&
Maps
,
path
:
Vec
<
ast_map
::
PathElem
>
,
...
...
@@ -271,7 +271,7 @@ fn emit_def_id(&mut self, did: ast::DefId) {
trait
def_id_decoder_helpers
{
fn
read_def_id
(
&
mut
self
,
xcx
:
&
ExtendedDecodeContext
)
->
ast
::
DefId
;
fn
read_def_id_noxcx
(
&
mut
self
,
cdata
:
@
cstore
::
crate_metadata
)
->
ast
::
DefId
;
cdata
:
&
cstore
::
crate_metadata
)
->
ast
::
DefId
;
}
impl
<
D
:
serialize
::
Decoder
<
E
>
,
E
>
def_id_decoder_helpers
for
D
{
...
...
@@ -281,7 +281,7 @@ fn read_def_id(&mut self, xcx: &ExtendedDecodeContext) -> ast::DefId {
}
fn
read_def_id_noxcx
(
&
mut
self
,
cdata
:
@
cstore
::
crate_metadata
)
->
ast
::
DefId
{
cdata
:
&
cstore
::
crate_metadata
)
->
ast
::
DefId
{
let
did
:
ast
::
DefId
=
Decodable
::
decode
(
self
)
.ok
()
.unwrap
();
decoder
::
translate_def_id
(
cdata
,
did
)
}
...
...
@@ -725,23 +725,23 @@ pub fn encode_vtable_origin(ecx: &e::EncodeContext,
pub
trait
vtable_decoder_helpers
{
fn
read_vtable_res_with_key
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
cdata
:
&
cstore
::
crate_metadata
)
->
(
u32
,
typeck
::
vtable_res
);
fn
read_vtable_res
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
tcx
:
&
ty
::
ctxt
,
cdata
:
&
cstore
::
crate_metadata
)
->
typeck
::
vtable_res
;
fn
read_vtable_param_res
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
tcx
:
&
ty
::
ctxt
,
cdata
:
&
cstore
::
crate_metadata
)
->
typeck
::
vtable_param_res
;
fn
read_vtable_origin
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
tcx
:
&
ty
::
ctxt
,
cdata
:
&
cstore
::
crate_metadata
)
->
typeck
::
vtable_origin
;
}
impl
<
'a
>
vtable_decoder_helpers
for
reader
::
Decoder
<
'a
>
{
fn
read_vtable_res_with_key
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
cdata
:
&
cstore
::
crate_metadata
)
->
(
u32
,
typeck
::
vtable_res
)
{
self
.read_struct
(
"VtableWithKey"
,
2
,
|
this
|
{
let
autoderef
=
this
.read_struct_field
(
"autoderef"
,
0
,
|
this
|
{
...
...
@@ -754,21 +754,21 @@ fn read_vtable_res_with_key(&mut self,
}
fn
read_vtable_res
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
tcx
:
&
ty
::
ctxt
,
cdata
:
&
cstore
::
crate_metadata
)
->
typeck
::
vtable_res
{
self
.read_to_vec
(|
this
|
Ok
(
this
.read_vtable_param_res
(
tcx
,
cdata
)))
.unwrap
()
.move_iter
()
.collect
()
}
fn
read_vtable_param_res
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
tcx
:
&
ty
::
ctxt
,
cdata
:
&
cstore
::
crate_metadata
)
->
typeck
::
vtable_param_res
{
self
.read_to_vec
(|
this
|
Ok
(
this
.read_vtable_origin
(
tcx
,
cdata
)))
.unwrap
()
.move_iter
()
.collect
()
}
fn
read_vtable_origin
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
tcx
:
&
ty
::
ctxt
,
cdata
:
&
cstore
::
crate_metadata
)
->
typeck
::
vtable_origin
{
self
.read_enum
(
"vtable_origin"
,
|
this
|
{
this
.read_enum_variant
([
"vtable_static"
,
...
...
@@ -1140,15 +1140,15 @@ fn convert_def_id(&mut self,
// Versions of the type reading functions that don't need the full
// ExtendedDecodeContext.
fn
read_ty_noxcx
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
->
ty
::
t
;
tcx
:
&
ty
::
ctxt
,
cdata
:
&
cstore
::
crate_metadata
)
->
ty
::
t
;
fn
read_tys_noxcx
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
->
Vec
<
ty
::
t
>
;
cdata
:
&
cstore
::
crate_metadata
)
->
Vec
<
ty
::
t
>
;
}
impl
<
'a
>
ebml_decoder_decoder_helpers
for
reader
::
Decoder
<
'a
>
{
fn
read_ty_noxcx
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
->
ty
::
t
{
tcx
:
&
ty
::
ctxt
,
cdata
:
&
cstore
::
crate_metadata
)
->
ty
::
t
{
self
.read_opaque
(|
_
,
doc
|
{
Ok
(
tydecode
::
parse_ty_data
(
doc
.data
,
...
...
@@ -1161,7 +1161,7 @@ fn read_ty_noxcx(&mut self,
fn
read_tys_noxcx
(
&
mut
self
,
tcx
:
&
ty
::
ctxt
,
cdata
:
@
cstore
::
crate_metadata
)
->
Vec
<
ty
::
t
>
{
cdata
:
&
cstore
::
crate_metadata
)
->
Vec
<
ty
::
t
>
{
self
.read_to_vec
(|
this
|
Ok
(
this
.read_ty_noxcx
(
tcx
,
cdata
))
)
.unwrap
()
.move_iter
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录