Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2e119698
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,发现更多精彩内容 >>
提交
2e119698
编写于
12月 03, 2010
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Add def ids to variant arguments so we can turn them into function arguments later
上级
0c19c8e1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
18 deletion
+20
-18
src/comp/front/ast.rs
src/comp/front/ast.rs
+2
-1
src/comp/front/parser.rs
src/comp/front/parser.rs
+9
-9
src/comp/middle/fold.rs
src/comp/middle/fold.rs
+4
-3
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+2
-2
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+3
-3
未找到文件。
src/comp/front/ast.rs
浏览文件 @
2e119698
...
...
@@ -198,7 +198,8 @@
type
_
mod
=
rec
(
vec
[
@
item
]
items
,
hashmap
[
ident
,
mod_index_entry
]
index
);
type
variant
=
rec
(
str
name
,
vec
[
@
ty
]
args
,
def_id
id
,
ann
ann
);
type
variant_arg
=
rec
(
@
ty
ty
,
def_id
id
);
type
variant
=
rec
(
str
name
,
vec
[
variant_arg
]
args
,
def_id
id
,
ann
ann
);
type
item
=
spanned
[
item_
];
tag
item_
{
...
...
src/comp/front/parser.rs
浏览文件 @
2e119698
...
...
@@ -1271,19 +1271,19 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
case
(
token
.IDENT
(
?
name
))
{
p
.bump
();
auto
args
;
let
vec
[
ast
.variant_arg
]
args
=
vec
()
;
alt
(
p
.peek
())
{
case
(
token
.LPAREN
)
{
auto
f
=
parse_ty
;
auto
tys
=
parse_seq
[
@
ast
.ty
](
token
.LPAREN
,
token
.RPAREN
,
some
(
token
.COMMA
),
f
,
p
);
args
=
tys
.node
;
}
case
(
_
)
{
args
=
vec
();
auto
arg_tys
=
parse_seq
[
@
ast
.ty
](
token
.LPAREN
,
token
.RPAREN
,
some
(
token
.COMMA
),
f
,
p
);
for
(
@
ast
.ty
ty
in
arg_tys
.node
)
{
args
+=
vec
(
rec
(
ty
=
ty
,
id
=
p
.next_def_id
()));
}
}
case
(
_
)
{
/* empty */
}
}
expect
(
p
,
token
.SEMI
);
...
...
src/comp/middle/fold.rs
浏览文件 @
2e119698
...
...
@@ -602,9 +602,10 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item {
case
(
ast
.item_tag
(
?
ident
,
?
variants
,
?
ty_params
,
?
id
))
{
let
vec
[
ast
.variant
]
new_variants
=
vec
();
for
(
ast
.variant
v
in
variants
)
{
let
vec
[
@
ast
.ty
]
new_args
=
vec
();
for
(
@
ast
.ty
t
in
v
.args
)
{
new_args
+=
vec
(
fold_ty
[
ENV
](
env_
,
fld
,
t
));
let
vec
[
ast
.variant_arg
]
new_args
=
vec
();
for
(
ast
.variant_arg
va
in
v
.args
)
{
auto
new_ty
=
fold_ty
[
ENV
](
env_
,
fld
,
va
.ty
);
new_args
+=
vec
(
rec
(
ty
=
new_ty
,
id
=
va
.id
));
}
new_variants
+=
rec
(
name
=
v
.name
,
args
=
new_args
,
id
=
v
.id
,
ann
=
v
.ann
);
...
...
src/comp/middle/trans.rs
浏览文件 @
2e119698
...
...
@@ -1861,7 +1861,7 @@ fn is_terminated(@block_ctxt cx) -> bool {
fn
trans_tag_variant
(
@
crate_ctxt
cx
,
ast
.def_id
tag_id
,
&
ast
.variant
variant
)
{
if
(
_
vec
.len
[
@
ast
.ty
](
variant
.args
)
==
0u
)
{
if
(
_
vec
.len
[
ast
.variant_arg
](
variant
.args
)
==
0u
)
{
ret
;
// nullary constructors are just constants
}
...
...
@@ -1951,7 +1951,7 @@ fn resolve_tag_types_for_item(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
for
(
ast
.variant
variant
in
variants
)
{
auto
arity_info
;
if
(
_
vec
.len
[
@
ast
.ty
](
variant
.args
)
>
0u
)
{
if
(
_
vec
.len
[
ast
.variant_arg
](
variant
.args
)
>
0u
)
{
auto
llvariantty
=
type_of_variant
(
cx
,
variant
);
auto
align
=
llvm
.LLVMPreferredAlignmentOfType
(
cx
.td.lltd
,
llvariantty
);
...
...
src/comp/middle/typeck.rs
浏览文件 @
2e119698
...
...
@@ -418,7 +418,7 @@ fn get_tag_variant_types(@hashmap[ast.def_id,@ast.item] id_to_ty_item,
// Nullary tag constructors get turned into constants; n-ary tag
// constructors get turned into functions.
auto
result_ty
;
if
(
_
vec
.len
[
@
ast
.ty
](
variant
.args
)
==
0u
)
{
if
(
_
vec
.len
[
ast
.variant_arg
](
variant
.args
)
==
0u
)
{
result_ty
=
plain_ty
(
ty_tag
(
tag_id
));
}
else
{
// As above, tell ast_ty_to_ty() that trans_ty_item_to_ty()
...
...
@@ -427,8 +427,8 @@ fn get_tag_variant_types(@hashmap[ast.def_id,@ast.item] id_to_ty_item,
item_to_ty
,
_
);
let
vec
[
arg
]
args
=
vec
();
for
(
@
ast
.ty
arg_ast_ty
in
variant
.args
)
{
auto
arg_ty
=
ast_ty_to_ty
(
f
,
arg_ast_
ty
);
for
(
ast
.variant_arg
va
in
variant
.args
)
{
auto
arg_ty
=
ast_ty_to_ty
(
f
,
va
.
ty
);
args
+=
vec
(
rec
(
mode
=
ast
.alias
,
ty
=
arg_ty
));
}
result_ty
=
plain_ty
(
ty_fn
(
args
,
plain_ty
(
ty_tag
(
tag_id
))));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录