Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f1acc69a
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,发现更多精彩内容 >>
提交
f1acc69a
编写于
6月 25, 2012
作者:
T
Tim Chevalier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add class fields to the global index
Closes #2192
上级
b837f37d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
6 deletion
+18
-6
src/rustc/metadata/decoder.rs
src/rustc/metadata/decoder.rs
+7
-1
src/rustc/metadata/encoder.rs
src/rustc/metadata/encoder.rs
+5
-5
src/test/run-pass/issue-2192.rs
src/test/run-pass/issue-2192.rs
+6
-0
未找到文件。
src/rustc/metadata/decoder.rs
浏览文件 @
f1acc69a
...
@@ -546,7 +546,11 @@ fn read_path(d: ebml::doc) -> {path: str, pos: uint} {
...
@@ -546,7 +546,11 @@ fn read_path(d: ebml::doc) -> {path: str, pos: uint} {
fn
describe_def
(
items
:
ebml
::
doc
,
id
:
ast
::
def_id
)
->
str
{
fn
describe_def
(
items
:
ebml
::
doc
,
id
:
ast
::
def_id
)
->
str
{
if
id
.crate
!=
ast
::
local_crate
{
ret
"external"
;
}
if
id
.crate
!=
ast
::
local_crate
{
ret
"external"
;
}
ret
item_family_to_str
(
item_family
(
find_item
(
id
.node
,
items
)));
let
it
=
alt
maybe_find_item
(
id
.node
,
items
)
{
some
(
it
)
{
it
}
none
{
fail
(
#
fmt
(
"describe_def: item not found %?"
,
id
));
}
};
ret
item_family_to_str
(
item_family
(
it
));
}
}
fn
item_family_to_str
(
fam
:
char
)
->
str
{
fn
item_family_to_str
(
fam
:
char
)
->
str
{
...
@@ -567,6 +571,8 @@ fn item_family_to_str(fam: char) -> str {
...
@@ -567,6 +571,8 @@ fn item_family_to_str(fam: char) -> str {
'i'
{
ret
"impl"
;
}
'i'
{
ret
"impl"
;
}
'I'
{
ret
"iface"
;
}
'I'
{
ret
"iface"
;
}
'C'
{
ret
"class"
;
}
'C'
{
ret
"class"
;
}
'g'
{
ret
"public field"
;
}
'j'
{
ret
"private field"
;
}
}
}
}
}
...
...
src/rustc/metadata/encoder.rs
浏览文件 @
f1acc69a
...
@@ -191,7 +191,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
...
@@ -191,7 +191,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
encode_name_and_def_id
(
ebml_w
,
it
.ident
,
it
.id
);
encode_name_and_def_id
(
ebml_w
,
it
.ident
,
it
.id
);
}
}
ebml_w
.wr_tag
(
tag_paths
)
{||
ebml_w
.wr_tag
(
tag_paths
)
{||
//
As in the res case, w
e add the same ident twice: for the
//
W
e add the same ident twice: for the
// class and for its ctor
// class and for its ctor
add_to_index
(
ebml_w
,
path
,
index
,
it
.ident
);
add_to_index
(
ebml_w
,
path
,
index
,
it
.ident
);
encode_named_def_id
(
ebml_w
,
it
.ident
,
encode_named_def_id
(
ebml_w
,
it
.ident
,
...
@@ -422,8 +422,9 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
...
@@ -422,8 +422,9 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
id
:
node_id
,
path
:
ast_map
::
path
,
id
:
node_id
,
path
:
ast_map
::
path
,
class_tps
:
[
ty_param
],
class_tps
:
[
ty_param
],
items
:
[
@
class_member
],
items
:
[
@
class_member
],
global_index
:
@
mut
[
entry
<
int
>
])
global_index
:
@
mut
[
entry
<
int
>
])
->
[
entry
<
int
>
]
{
->
[
entry
<
int
>
]
{
/* Each class has its own index, since different classes
may have fields with the same name */
let
index
=
@
mut
[];
let
index
=
@
mut
[];
let
tcx
=
ecx
.tcx
;
let
tcx
=
ecx
.tcx
;
for
items
.each
{|
ci
|
for
items
.each
{|
ci
|
...
@@ -432,6 +433,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
...
@@ -432,6 +433,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
alt
ci
.node
{
alt
ci
.node
{
instance_var
(
nm
,
_
,
mt
,
id
,
vis
)
{
instance_var
(
nm
,
_
,
mt
,
id
,
vis
)
{
*
index
+=
[{
val
:
id
,
pos
:
ebml_w
.writer
.tell
()}];
*
index
+=
[{
val
:
id
,
pos
:
ebml_w
.writer
.tell
()}];
*
global_index
+=
[{
val
:
id
,
pos
:
ebml_w
.writer
.tell
()}];
ebml_w
.start_tag
(
tag_items_data_item
);
ebml_w
.start_tag
(
tag_items_data_item
);
#
debug
(
"encode_info_for_class: doing %s %d"
,
*
nm
,
id
);
#
debug
(
"encode_info_for_class: doing %s %d"
,
*
nm
,
id
);
encode_visibility
(
ebml_w
,
vis
);
encode_visibility
(
ebml_w
,
vis
);
...
@@ -446,8 +448,6 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
...
@@ -446,8 +448,6 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
alt
m
.vis
{
alt
m
.vis
{
public
{
public
{
*
index
+=
[{
val
:
m
.id
,
pos
:
ebml_w
.writer
.tell
()}];
*
index
+=
[{
val
:
m
.id
,
pos
:
ebml_w
.writer
.tell
()}];
/* Not sure whether we really need to have two indices,
but it works for now -- tjc */
*
global_index
+=
[{
val
:
m
.id
,
pos
:
ebml_w
.writer
.tell
()}];
*
global_index
+=
[{
val
:
m
.id
,
pos
:
ebml_w
.writer
.tell
()}];
let
impl_path
=
path
+
[
ast_map
::
path_name
(
m
.ident
)];
let
impl_path
=
path
+
[
ast_map
::
path_name
(
m
.ident
)];
#
debug
(
"encode_info_for_class: doing %s %d"
,
*
m
.ident
,
m
.id
);
#
debug
(
"encode_info_for_class: doing %s %d"
,
*
m
.ident
,
m
.id
);
...
...
src/test/run-pass/issue-2192.rs
0 → 100644
浏览文件 @
f1acc69a
#[crate_type
=
"lib"
]
;
class
foo
{
let
mut
x
:
int
;
new
(
xx
:
int
)
{
self
.x
=
xx
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录