Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d328c7e0
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,发现更多精彩内容 >>
提交
d328c7e0
编写于
6月 27, 2011
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
List crate attributes when running rustc with '--ls'
上级
9561def2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
22 deletion
+64
-22
src/comp/metadata/creader.rs
src/comp/metadata/creader.rs
+2
-20
src/comp/metadata/decoder.rs
src/comp/metadata/decoder.rs
+58
-2
src/comp/pretty/pprust.rs
src/comp/pretty/pprust.rs
+4
-0
未找到文件。
src/comp/metadata/creader.rs
浏览文件 @
d328c7e0
...
...
@@ -24,25 +24,6 @@
export
read_crates
;
export
list_file_metadata
;
fn
get_exported_metadata
(
&
session
::
session
sess
,
&
str
path
,
&
vec
[
u8
]
data
)
->
hashmap
[
str
,
str
]
{
auto
meta_items
=
ebml
::
get_doc
(
ebml
::
new_doc
(
data
),
tag_meta_export
);
auto
mm
=
common
::
new_str_hash
[
str
]();
for
each
(
ebml
::
doc
m
in
ebml
::
tagged_docs
(
meta_items
,
tag_meta_item
))
{
auto
kd
=
ebml
::
get_doc
(
m
,
tag_meta_item_key
);
auto
vd
=
ebml
::
get_doc
(
m
,
tag_meta_item_value
);
auto
k
=
str
::
unsafe_from_bytes
(
ebml
::
doc_data
(
kd
));
auto
v
=
str
::
unsafe_from_bytes
(
ebml
::
doc_data
(
vd
));
log
#
fmt
(
"metadata in %s: %s = %s"
,
path
,
k
,
v
);
if
(
!
mm
.insert
(
k
,
v
))
{
sess
.warn
(
#
fmt
(
"Duplicate metadata item in %s: %s"
,
path
,
k
));
}
}
ret
mm
;
}
fn
metadata_matches
(
hashmap
[
str
,
str
]
mm
,
&
vec
[
@
ast
::
meta_item
]
metas
)
->
bool
{
log
#
fmt
(
"matching %u metadata requirements against %u metadata items"
,
...
...
@@ -126,7 +107,8 @@ fn find_library_crate(&session::session sess, &ast::ident ident,
}
alt
(
get_metadata_section
(
path
))
{
case
(
option
::
some
(
?
cvec
))
{
auto
mm
=
get_exported_metadata
(
sess
,
path
,
cvec
);
auto
mm
=
decoder
::
get_exported_metadata
(
sess
,
path
,
cvec
);
if
(
!
metadata_matches
(
mm
,
metas
))
{
log
#
fmt
(
"skipping %s, metadata doesn't match"
,
path
);
cont
;
...
...
src/comp/metadata/decoder.rs
浏览文件 @
d328c7e0
...
...
@@ -5,12 +5,15 @@
import
std
::
vec
;
import
std
::
str
;
import
std
::
io
;
import
std
::
map
::
hashmap
;
import
front
::
ast
;
import
middle
::
ty
;
import
tags
::
*
;
import
tydecode
::
parse_def_id
;
import
tydecode
::
parse_ty_data
;
import
driver
::
session
;
import
util
::
common
;
import
pretty
::
pprust
;
export
get_symbol
;
export
get_tag_variants
;
...
...
@@ -18,6 +21,7 @@
export
lookup_defs
;
export
get_type
;
export
list_crate_metadata
;
export
get_exported_metadata
;
fn
lookup_hash
(
&
ebml
::
doc
d
,
fn
(
vec
[
u8
])
->
bool
eq_fn
,
uint
hash
)
->
vec
[
ebml
::
doc
]
{
...
...
@@ -252,8 +256,35 @@ fn item_kind_to_str(u8 kind) -> str {
}
}
fn
list_crate_metadata
(
vec
[
u8
]
bytes
,
io
::
writer
out
)
{
auto
md
=
ebml
::
new_doc
(
bytes
);
fn
get_meta_items
(
&
ebml
::
doc
md
)
->
vec
[
ast
::
meta_item
]
{
let
vec
[
ast
::
meta_item
]
items
=
[];
for
each
(
ebml
::
doc
meta_item_doc
in
ebml
::
tagged_docs
(
md
,
tag_meta_item
))
{
auto
kd
=
ebml
::
get_doc
(
meta_item_doc
,
tag_meta_item_key
);
auto
vd
=
ebml
::
get_doc
(
meta_item_doc
,
tag_meta_item_value
);
auto
k
=
str
::
unsafe_from_bytes
(
ebml
::
doc_data
(
kd
));
auto
v
=
str
::
unsafe_from_bytes
(
ebml
::
doc_data
(
vd
));
items
+=
[
rec
(
node
=
ast
::
meta_key_value
(
k
,
v
),
span
=
rec
(
lo
=
0u
,
hi
=
0u
))];
}
ret
items
;
}
fn
list_meta_items
(
&
ebml
::
doc
meta_items
,
io
::
writer
out
)
{
for
(
ast
::
meta_item
mi
in
get_meta_items
(
meta_items
))
{
out
.write_str
(
#
fmt
(
"%s
\n
"
,
pprust
::
meta_item_to_str
(
mi
)));
}
}
fn
list_crate_attributes
(
&
ebml
::
doc
md
,
io
::
writer
out
)
{
out
.write_str
(
"=Crate=
\n
"
);
auto
meta_items
=
ebml
::
get_doc
(
md
,
tag_meta_export
);
list_meta_items
(
meta_items
,
out
);
out
.write_str
(
"
\n
"
);
}
fn
list_crate_items
(
vec
[
u8
]
bytes
,
&
ebml
::
doc
md
,
io
::
writer
out
)
{
out
.write_str
(
"=Items=
\n
"
);
auto
paths
=
ebml
::
get_doc
(
md
,
tag_paths
);
auto
items
=
ebml
::
get_doc
(
md
,
tag_items
);
auto
index
=
ebml
::
get_doc
(
paths
,
tag_index
);
...
...
@@ -270,8 +301,33 @@ fn list_crate_metadata(vec[u8] bytes, io::writer out) {
describe_def
(
items
,
did
)));
}
}
out
.write_str
(
"
\n
"
);
}
fn
list_crate_metadata
(
vec
[
u8
]
bytes
,
io
::
writer
out
)
{
auto
md
=
ebml
::
new_doc
(
bytes
);
list_crate_attributes
(
md
,
out
);
list_crate_items
(
bytes
,
md
,
out
);
}
fn
get_exported_metadata
(
&
session
::
session
sess
,
&
str
path
,
&
vec
[
u8
]
data
)
->
hashmap
[
str
,
str
]
{
auto
meta_items
=
ebml
::
get_doc
(
ebml
::
new_doc
(
data
),
tag_meta_export
);
auto
mm
=
common
::
new_str_hash
[
str
]();
for
each
(
ebml
::
doc
m
in
ebml
::
tagged_docs
(
meta_items
,
tag_meta_item
))
{
auto
kd
=
ebml
::
get_doc
(
m
,
tag_meta_item_key
);
auto
vd
=
ebml
::
get_doc
(
m
,
tag_meta_item_value
);
auto
k
=
str
::
unsafe_from_bytes
(
ebml
::
doc_data
(
kd
));
auto
v
=
str
::
unsafe_from_bytes
(
ebml
::
doc_data
(
vd
));
log
#
fmt
(
"metadata in %s: %s = %s"
,
path
,
k
,
v
);
if
(
!
mm
.insert
(
k
,
v
))
{
sess
.warn
(
#
fmt
(
"Duplicate metadata item in %s: %s"
,
path
,
k
));
}
}
ret
mm
;
}
// Local Variables:
// mode: rust
...
...
src/comp/pretty/pprust.rs
浏览文件 @
d328c7e0
...
...
@@ -80,6 +80,10 @@ fn block_to_str(&ast::block blk) -> str {
ret
writer
.get_str
();
}
fn
meta_item_to_str
(
&
ast
::
meta_item
mi
)
->
str
{
ret
to_str
(
@
mi
,
print_meta_item
);
}
fn
cbox
(
&
ps
s
,
uint
u
)
{
vec
::
push
(
s
.boxes
,
pp
::
consistent
);
pp
::
cbox
(
s
.s
,
u
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录