Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6812ca1c
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,发现更多精彩内容 >>
提交
6812ca1c
编写于
6月 02, 2015
作者:
P
Peter Elmers
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move EnumData to the API.
上级
48e9ef64
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
72 addition
and
55 deletion
+72
-55
src/librustc_trans/save/dump_csv.rs
src/librustc_trans/save/dump_csv.rs
+49
-54
src/librustc_trans/save/mod.rs
src/librustc_trans/save/mod.rs
+23
-1
未找到文件。
src/librustc_trans/save/dump_csv.rs
浏览文件 @
6812ca1c
...
@@ -604,65 +604,60 @@ fn process_enum(&mut self,
...
@@ -604,65 +604,60 @@ fn process_enum(&mut self,
item
:
&
ast
::
Item
,
item
:
&
ast
::
Item
,
enum_definition
:
&
ast
::
EnumDef
,
enum_definition
:
&
ast
::
EnumDef
,
ty_params
:
&
ast
::
Generics
)
{
ty_params
:
&
ast
::
Generics
)
{
let
enum_name
=
format!
(
"::{}"
,
self
.analysis.ty_cx.map
.path_to_string
(
item
.id
));
let
enum_data
=
self
.save_ctxt
.get_item_data
(
item
);
let
val
=
self
.span
.snippet
(
item
.span
);
if
let
super
::
Data
::
EnumData
(
enum_data
)
=
enum_data
{
match
self
.span
.sub_span_after_keyword
(
item
.span
,
keywords
::
Enum
)
{
self
.fmt
.enum_str
(
item
.span
,
Some
(
sub_span
)
=>
self
.fmt
.enum_str
(
item
.span
,
Some
(
enum_data
.span
),
Some
(
sub_span
),
enum_data
.id
,
item
.id
,
&
enum_data
.qualname
,
&
enum_name
[
..
],
self
.cur_scope
,
self
.cur_scope
,
&
enum_data
.value
);
&
val
[
..
]),
for
variant
in
&
enum_definition
.variants
{
None
=>
self
.sess
.span_bug
(
item
.span
,
let
name
=
&
get_ident
(
variant
.node.name
);
&
format!
(
"Could not find subspan for enum {}"
,
let
mut
qualname
=
enum_data
.qualname
.clone
();
enum_name
)),
qualname
.push_str
(
"::"
);
}
qualname
.push_str
(
name
);
for
variant
in
&
enum_definition
.variants
{
let
val
=
self
.span
.snippet
(
variant
.span
);
let
name
=
get_ident
(
variant
.node.name
);
match
variant
.node.kind
{
let
name
=
&
name
;
ast
::
TupleVariantKind
(
ref
args
)
=>
{
let
mut
qualname
=
enum_name
.clone
();
// first ident in span is the variant's name
qualname
.push_str
(
"::"
);
self
.fmt
.tuple_variant_str
(
variant
.span
,
qualname
.push_str
(
name
);
self
.span
.span_for_first_ident
(
variant
.span
),
let
val
=
self
.span
.snippet
(
variant
.span
);
variant
.node.id
,
match
variant
.node.kind
{
name
,
ast
::
TupleVariantKind
(
ref
args
)
=>
{
&
qualname
,
// first ident in span is the variant's name
&
enum_data
.qualname
,
self
.fmt
.tuple_variant_str
(
variant
.span
,
&
val
,
self
.span
.span_for_first_ident
(
variant
.span
),
item
.id
);
variant
.node.id
,
for
arg
in
args
{
name
,
self
.visit_ty
(
&*
arg
.ty
);
&
qualname
[
..
],
}
&
enum_name
[
..
],
&
val
[
..
],
item
.id
);
for
arg
in
args
{
self
.visit_ty
(
&*
arg
.ty
);
}
}
}
ast
::
StructVariantKind
(
ref
struct_def
)
=>
{
ast
::
StructVariantKind
(
ref
struct_def
)
=>
{
let
ctor_id
=
match
struct_def
.ctor_id
{
let
ctor_id
=
match
struct_def
.ctor_id
{
Some
(
node_id
)
=>
node_id
,
Some
(
node_id
)
=>
node_id
,
None
=>
-
1
,
None
=>
-
1
,
};
};
self
.fmt
.struct_variant_str
(
variant
.span
,
self
.fmt
.struct_variant_str
(
self
.span
.span_for_first_ident
(
variant
.span
),
variant
.span
,
variant
.node.id
,
self
.span
.span_for_first_ident
(
variant
.span
),
ctor_id
,
variant
.node.id
,
&
qualname
,
ctor_id
,
&
enum_data
.qualname
,
&
qualname
[
..
],
&
val
,
&
enum_name
[
..
],
item
.id
);
&
val
[
..
],
item
.id
);
for
field
in
&
struct_def
.fields
{
self
.process_struct_field_def
(
field
,
&
qualname
,
variant
.node.id
);
for
field
in
&
struct_def
.fields
{
self
.visit_ty
(
&*
field
.node.ty
);
self
.process_struct_field_def
(
field
,
&
qualname
,
variant
.node.id
);
}
self
.visit_ty
(
&*
field
.node.ty
);
}
}
}
}
}
}
self
.process_generic_params
(
ty_params
,
item
.span
,
&
enum_data
.qualname
,
item
.id
);
}
else
{
self
.sess
.span_bug
(
item
.span
,
"expected EnumData"
);
}
}
self
.process_generic_params
(
ty_params
,
item
.span
,
&
enum_name
[
..
],
item
.id
);
}
}
fn
process_impl
(
&
mut
self
,
fn
process_impl
(
&
mut
self
,
...
...
src/librustc_trans/save/mod.rs
浏览文件 @
6812ca1c
...
@@ -51,6 +51,8 @@ pub enum Data {
...
@@ -51,6 +51,8 @@ pub enum Data {
VariableData
(
VariableData
),
VariableData
(
VariableData
),
/// Data for modules.
/// Data for modules.
ModData
(
ModData
),
ModData
(
ModData
),
/// Data for Enums.
EnumData
(
EnumData
),
/// Data for the use of some variable (e.g., the use of a local variable, which
/// Data for the use of some variable (e.g., the use of a local variable, which
/// will refere to that variables declaration).
/// will refere to that variables declaration).
...
@@ -88,6 +90,14 @@ pub struct ModData {
...
@@ -88,6 +90,14 @@ pub struct ModData {
pub
filename
:
String
,
pub
filename
:
String
,
}
}
/// Data for enum declarations.
pub
struct
EnumData
{
pub
id
:
NodeId
,
pub
value
:
String
,
pub
qualname
:
String
,
pub
span
:
Span
,
}
/// Data for the use of some item (e.g., the use of a local variable, which
/// Data for the use of some item (e.g., the use of a local variable, which
/// will refere to that variables declaration (by ref_id)).
/// will refere to that variables declaration (by ref_id)).
pub
struct
VariableRefData
{
pub
struct
VariableRefData
{
...
@@ -188,7 +198,19 @@ pub fn get_item_data(&self, item: &ast::Item) -> Data {
...
@@ -188,7 +198,19 @@ pub fn get_item_data(&self, item: &ast::Item) -> Data {
scope
:
self
.analysis.ty_cx.map
.get_parent
(
item
.id
),
scope
:
self
.analysis.ty_cx.map
.get_parent
(
item
.id
),
filename
:
filename
,
filename
:
filename
,
})
})
}
},
ast
::
ItemEnum
(
..
)
=>
{
let
enum_name
=
format!
(
"::{}"
,
self
.analysis.ty_cx.map
.path_to_string
(
item
.id
));
let
val
=
self
.span_utils
.snippet
(
item
.span
);
let
sub_span
=
self
.span_utils
.sub_span_after_keyword
(
item
.span
,
keywords
::
Enum
);
Data
::
EnumData
(
EnumData
{
id
:
item
.id
,
value
:
val
,
span
:
sub_span
.unwrap
(),
qualname
:
enum_name
,
})
},
_
=>
{
_
=>
{
// FIXME
// FIXME
unimplemented!
();
unimplemented!
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录