Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
29ea8754
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,发现更多精彩内容 >>
提交
29ea8754
编写于
8月 15, 2011
作者:
M
Marijn Haverbeke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tuple fields are immutable
上级
9538b003
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
93 addition
and
138 deletion
+93
-138
src/comp/metadata/tydecode.rs
src/comp/metadata/tydecode.rs
+1
-1
src/comp/metadata/tyencode.rs
src/comp/metadata/tyencode.rs
+2
-2
src/comp/middle/alias.rs
src/comp/middle/alias.rs
+3
-3
src/comp/middle/gc.rs
src/comp/middle/gc.rs
+1
-1
src/comp/middle/shape.rs
src/comp/middle/shape.rs
+2
-2
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+26
-27
src/comp/middle/trans_comm.rs
src/comp/middle/trans_comm.rs
+1
-1
src/comp/middle/trans_objects.rs
src/comp/middle/trans_objects.rs
+9
-9
src/comp/middle/tstate/pre_post_conditions.rs
src/comp/middle/tstate/pre_post_conditions.rs
+1
-2
src/comp/middle/tstate/states.rs
src/comp/middle/tstate/states.rs
+1
-2
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+30
-51
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+7
-7
src/comp/syntax/ast.rs
src/comp/syntax/ast.rs
+2
-4
src/comp/syntax/fold.rs
src/comp/syntax/fold.rs
+1
-5
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+2
-9
src/comp/syntax/visit.rs
src/comp/syntax/visit.rs
+3
-3
src/comp/util/common.rs
src/comp/util/common.rs
+0
-8
src/comp/util/ppaux.rs
src/comp/util/ppaux.rs
+1
-1
未找到文件。
src/comp/metadata/tydecode.rs
浏览文件 @
29ea8754
...
...
@@ -239,7 +239,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t {
'T'
{
assert
(
next
(
st
)
as
char
==
'['
);
let
params
=
~
[];
while
peek
(
st
)
as
char
!=
']'
{
params
+=
~
[
parse_
mt
(
st
,
sd
)];
}
while
peek
(
st
)
as
char
!=
']'
{
params
+=
~
[
parse_
ty
(
st
,
sd
)];
}
st
.pos
=
st
.pos
+
1u
;
ret
ty
::
mk_tup
(
st
.tcx
,
params
);
}
...
...
src/comp/metadata/tyencode.rs
浏览文件 @
29ea8754
...
...
@@ -120,9 +120,9 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
for
t
:
ty
::
t
in
tys
{
enc_ty
(
w
,
cx
,
t
);
}
w
.write_char
(
']'
);
}
ty
::
ty_tup
(
m
ts
)
{
ty
::
ty_tup
(
ts
)
{
w
.write_str
(
"T["
);
for
mt
in
mts
{
enc_mt
(
w
,
cx
,
m
t
);
}
for
t
in
ts
{
enc_ty
(
w
,
cx
,
t
);
}
w
.write_char
(
']'
);
}
ty
::
ty_box
(
mt
)
{
w
.write_char
(
'@'
);
enc_mt
(
w
,
cx
,
mt
);
}
...
...
src/comp/middle/alias.rs
浏览文件 @
29ea8754
...
...
@@ -678,9 +678,9 @@ fn helper(tcx: &ty::ctxt, needle: ty::t, haystack: ty::t, mut: bool) ->
}
ret
false
;
}
ty
::
ty_tup
(
m
ts
)
{
for
mt
in
m
ts
{
if
helper
(
tcx
,
needle
,
mt
.ty
,
get_mut
(
mut
,
mt
)
)
{
ty
::
ty_tup
(
ts
)
{
for
t
in
ts
{
if
helper
(
tcx
,
needle
,
t
,
mut
)
{
ret
true
;
}
}
...
...
src/comp/middle/gc.rs
浏览文件 @
29ea8754
...
...
@@ -48,7 +48,7 @@ fn type_is_gc_relevant(cx: &ty::ctxt, ty: &ty::t) -> bool {
}
ty
::
ty_tup
(
elts
)
{
for
elt
in
elts
{
if
type_is_gc_relevant
(
cx
,
elt
.ty
)
{
ret
true
;
}
if
type_is_gc_relevant
(
cx
,
elt
)
{
ret
true
;
}
}
ret
false
;
}
...
...
src/comp/middle/shape.rs
浏览文件 @
29ea8754
...
...
@@ -174,7 +174,7 @@ fn largest_variants(ccx : &@crate_ctxt, tag_id : &ast::def_id) -> [uint] {
ret
result
;
}
// Computes the static size of a tag, without using mk_
imm_
tup(), which is
// Computes the static size of a tag, without using mk_tup(), which is
// bad for performance.
//
// TODO: Migrate trans over to use this.
...
...
@@ -374,7 +374,7 @@ fn shape_of(ccx : &@crate_ctxt, t : ty::t) -> [u8] {
ty
::
ty_tup
(
elts
)
{
s
+=
~
[
shape_struct
];
let
sub
=
~
[];
for
elt
in
elts
{
sub
+=
shape_of
(
ccx
,
elt
.ty
);
}
for
elt
in
elts
{
sub
+=
shape_of
(
ccx
,
elt
);
}
add_substr
(
s
,
sub
);
}
...
...
src/comp/middle/trans.rs
浏览文件 @
29ea8754
...
...
@@ -256,7 +256,7 @@ fn type_of_inner(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> TypeRef {
ty
::
ty_tup
(
elts
)
{
let
tys
=
~
[];
for
elt
in
elts
{
tys
+=
~
[
type_of_inner
(
cx
,
sp
,
elt
.ty
)];
tys
+=
~
[
type_of_inner
(
cx
,
sp
,
elt
)];
}
llty
=
T_struct
(
tys
);
}
...
...
@@ -490,20 +490,20 @@ fn simplifier(ccx: @crate_ctxt, typ: ty::t) -> ty::t {
ty
::
ty_uniq
(
_
)
{
ret
ty
::
mk_uniq
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
));
}
ty
::
ty_vec
(
_
)
{
ret
ty
::
mk_imm_vec
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
));
}
ty
::
ty_fn
(
_
,
_
,
_
,
_
,
_
)
{
ret
ty
::
mk_
imm_
tup
(
ccx
.tcx
,
~
[
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
)),
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
))]);
ret
ty
::
mk_tup
(
ccx
.tcx
,
~
[
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
)),
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
))]);
}
ty
::
ty_obj
(
_
)
{
ret
ty
::
mk_
imm_
tup
(
ccx
.tcx
,
ret
ty
::
mk_tup
(
ccx
.tcx
,
~
[
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
)),
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
))]);
}
ty
::
ty_res
(
_
,
sub
,
tps
)
{
let
sub1
=
ty
::
substitute_type_params
(
ccx
.tcx
,
tps
,
sub
);
ret
ty
::
mk_
imm_
tup
(
ccx
.tcx
,
ret
ty
::
mk_tup
(
ccx
.tcx
,
~
[
ty
::
mk_int
(
ccx
.tcx
),
simplify_type
(
ccx
,
sub1
)]);
}
...
...
@@ -530,7 +530,7 @@ fn static_size_of_tag(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> uint {
let
variants
=
ty
::
tag_variants
(
cx
.tcx
,
tid
);
for
variant
:
ty
::
variant_info
in
variants
{
let
tup_ty
=
simplify_type
(
cx
,
ty
::
mk_
imm_
tup
(
cx
.tcx
,
variant
.args
));
simplify_type
(
cx
,
ty
::
mk_tup
(
cx
.tcx
,
variant
.args
));
// Perform any type parameter substitutions.
tup_ty
=
ty
::
substitute_type_params
(
cx
.tcx
,
subtys
,
tup_ty
);
...
...
@@ -586,7 +586,7 @@ fn align_elements(cx: &@block_ctxt, elts: &[ty::t]) -> result {
}
ty
::
ty_tup
(
elts
)
{
let
tys
=
~
[];
for
mt
in
elts
{
tys
+=
~
[
mt
.ty
];
}
for
tp
in
elts
{
tys
+=
~
[
tp
];
}
ret
align_elements
(
cx
,
tys
);
}
ty
::
ty_tag
(
tid
,
tps
)
{
...
...
@@ -661,7 +661,7 @@ fn dynamic_align_of(cx: &@block_ctxt, t: &ty::t) -> result {
let
a
=
C_int
(
1
);
let
bcx
=
cx
;
for
e
in
elts
{
let
align
=
align_of
(
bcx
,
e
.ty
);
let
align
=
align_of
(
bcx
,
e
);
bcx
=
align
.bcx
;
a
=
umax
(
bcx
,
a
,
align
.val
);
}
...
...
@@ -766,7 +766,7 @@ fn split_type(ccx: &@crate_ctxt, t: &ty::t, ixs: &[int], n: uint) ->
let
args
=
~
[];
for
typ
:
ty
::
t
in
s
.prefix
{
args
+=
~
[
typ
];
}
let
prefix_ty
=
ty
::
mk_
imm_
tup
(
bcx_tcx
(
cx
),
args
);
let
prefix_ty
=
ty
::
mk_tup
(
bcx_tcx
(
cx
),
args
);
let
bcx
=
cx
;
let
sz
=
size_of
(
bcx
,
prefix_ty
);
...
...
@@ -795,7 +795,7 @@ fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: &ast::def_id,
if
i
==
ix
{
elem_ty
=
arg_ty
;
}
i
+=
1
;
}
let
tup_ty
=
ty
::
mk_
imm_
tup
(
bcx_tcx
(
cx
),
true_arg_tys
);
let
tup_ty
=
ty
::
mk_tup
(
bcx_tcx
(
cx
),
true_arg_tys
);
// Cast the blob pointer to the appropriate type, if we need to (i.e. if
// the blob pointer isn't dynamically sized).
...
...
@@ -858,7 +858,7 @@ fn trans_malloc_boxed_raw(cx: &@block_ctxt, t: ty::t) -> result {
// The mk_int here is the space being
// reserved for the refcount.
let
boxed_body
=
ty
::
mk_
imm_
tup
(
bcx_tcx
(
cx
),
~
[
ty
::
mk_int
(
bcx_tcx
(
cx
)),
t
]);
ty
::
mk_tup
(
bcx_tcx
(
cx
),
~
[
ty
::
mk_int
(
bcx_tcx
(
cx
)),
t
]);
let
box_ptr
=
ty
::
mk_imm_box
(
bcx_tcx
(
cx
),
t
);
let
sz
=
size_of
(
cx
,
boxed_body
);
...
...
@@ -1497,7 +1497,7 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id,
inner_t
:
ty
::
t
,
tps
:
&
[
ty
::
t
])
->
result
{
let
ccx
=
bcx_ccx
(
cx
);
let
inner_t_s
=
ty
::
substitute_type_params
(
ccx
.tcx
,
tps
,
inner_t
);
let
tup_ty
=
ty
::
mk_
imm_
tup
(
ccx
.tcx
,
~
[
ty
::
mk_int
(
ccx
.tcx
),
inner_t_s
]);
let
tup_ty
=
ty
::
mk_tup
(
ccx
.tcx
,
~
[
ty
::
mk_int
(
ccx
.tcx
),
inner_t_s
]);
let
drop_cx
=
new_sub_block_ctxt
(
cx
,
"drop res"
);
let
next_cx
=
new_sub_block_ctxt
(
cx
,
"next"
);
...
...
@@ -1846,8 +1846,7 @@ fn iter_variant(cx: @block_ctxt, a_tup: ValueRef,
for
arg
in
args
{
r
=
GEP_tup_like
(
r
.bcx
,
t
,
av
,
~
[
0
,
i
]);
let
llfld_a
=
r
.val
;
r
=
f
(
r
.bcx
,
load_if_immediate
(
r
.bcx
,
llfld_a
,
arg
.ty
),
arg
.ty
);
r
=
f
(
r
.bcx
,
load_if_immediate
(
r
.bcx
,
llfld_a
,
arg
),
arg
);
i
+=
1
;
}
}
...
...
@@ -1855,7 +1854,7 @@ fn iter_variant(cx: @block_ctxt, a_tup: ValueRef,
let
tcx
=
bcx_tcx
(
cx
);
let
inner1
=
ty
::
substitute_type_params
(
tcx
,
tps
,
inner
);
let
inner_t_s
=
ty
::
substitute_type_params
(
tcx
,
tps
,
inner
);
let
tup_t
=
ty
::
mk_
imm_
tup
(
tcx
,
~
[
ty
::
mk_int
(
tcx
),
inner_t_s
]);
let
tup_t
=
ty
::
mk_tup
(
tcx
,
~
[
ty
::
mk_int
(
tcx
),
inner_t_s
]);
r
=
GEP_tup_like
(
r
.bcx
,
tup_t
,
av
,
~
[
0
,
1
]);
let
llfld_a
=
r
.val
;
r
=
f
(
r
.bcx
,
load_if_immediate
(
r
.bcx
,
llfld_a
,
inner1
),
inner1
);
...
...
@@ -3516,7 +3515,7 @@ fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
// First, synthesize a tuple type containing the types of all the
// bound expressions.
// bindings_ty = ~[bound_ty1, bound_ty2, ...]
let
bindings_ty
:
ty
::
t
=
ty
::
mk_
imm_
tup
(
bcx_tcx
(
bcx
),
bound_tys
);
let
bindings_ty
:
ty
::
t
=
ty
::
mk_tup
(
bcx_tcx
(
bcx
),
bound_tys
);
// NB: keep this in sync with T_closure_ptr; we're making
// a ty::t structure that has the same "shape" as the LLVM type
...
...
@@ -3536,17 +3535,17 @@ fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
// closure_tys = [tydesc_ty, [bound_ty1, bound_ty2, ...], [tydesc_ty,
// tydesc_ty, ...]]
let
closure_tys
:
[
ty
::
t
]
=
~
[
tydesc_ty
,
bindings_ty
,
ty
::
mk_
imm_
tup
(
bcx_tcx
(
bcx
),
captured_tys
)];
~
[
tydesc_ty
,
bindings_ty
,
ty
::
mk_tup
(
bcx_tcx
(
bcx
),
captured_tys
)];
// Finally, synthesize a type for that whole vector.
let
closure_ty
:
ty
::
t
=
ty
::
mk_
imm_
tup
(
bcx_tcx
(
bcx
),
closure_tys
);
let
closure_ty
:
ty
::
t
=
ty
::
mk_tup
(
bcx_tcx
(
bcx
),
closure_tys
);
// Allocate a box that can hold something closure-sized.
let
r
=
if
copying
{
trans_malloc_boxed
(
bcx
,
closure_ty
)
}
else
{
// We need to dummy up a box on the stack
let
ty
=
ty
::
mk_
imm_
tup
(
bcx_tcx
(
bcx
),
let
ty
=
ty
::
mk_tup
(
bcx_tcx
(
bcx
),
~
[
ty
::
mk_int
(
bcx_tcx
(
bcx
)),
closure_ty
]);
let
r
=
alloc_ty
(
bcx
,
ty
);
let
body
=
GEPi
(
bcx
,
r
.val
,
~
[
0
,
abi
::
box_rc_field_body
]);
...
...
@@ -4769,7 +4768,7 @@ fn trans_call(cx: &@block_ctxt, f: &@ast::expr,
ret
rslt
(
bcx
,
retval
);
}
fn
trans_tup
(
cx
:
&@
block_ctxt
,
elts
:
&
[
ast
::
elt
],
id
:
ast
::
node_id
)
fn
trans_tup
(
cx
:
&@
block_ctxt
,
elts
:
&
[
@
ast
::
expr
],
id
:
ast
::
node_id
)
->
result
{
let
bcx
=
cx
;
let
t
=
node_id_type
(
bcx
.fcx.lcx.ccx
,
id
);
...
...
@@ -4779,8 +4778,8 @@ fn trans_tup(cx: &@block_ctxt, elts: &[ast::elt], id: ast::node_id)
add_clean_temp
(
cx
,
tup_val
,
t
);
let
i
:
int
=
0
;
for
e
in
elts
{
let
e_ty
=
ty
::
expr_ty
(
cx
.fcx.lcx.ccx.tcx
,
e
.expr
);
let
src
=
trans_lval
(
bcx
,
e
.expr
);
let
e_ty
=
ty
::
expr_ty
(
cx
.fcx.lcx.ccx.tcx
,
e
);
let
src
=
trans_lval
(
bcx
,
e
);
bcx
=
src
.res.bcx
;
let
dst_res
=
GEP_tup_like
(
bcx
,
t
,
tup_val
,
~
[
0
,
i
]);
bcx
=
move_val_if_temp
(
dst_res
.bcx
,
INIT
,
dst_res
.val
,
src
,
e_ty
)
.bcx
;
...
...
@@ -4813,7 +4812,7 @@ fn trans_vec(cx: &@block_ctxt, args: &[@ast::expr], id: ast::node_id) ->
add_clean_temp
(
bcx
,
vec_val
,
t
);
let
body
=
bcx
.build
.GEP
(
vec_val
,
~
[
C_int
(
0
),
C_int
(
abi
::
vec_elt_data
)]);
let
pseudo_tup_ty
=
ty
::
mk_
imm_
tup
(
bcx_tcx
(
cx
),
ty
::
mk_tup
(
bcx_tcx
(
cx
),
std
::
ivec
::
init_elt
[
ty
::
t
](
unit_ty
,
std
::
ivec
::
len
(
args
)));
let
i
:
int
=
0
;
...
...
@@ -5958,7 +5957,7 @@ fn populate_fn_ctxt_from_llself(fcx: @fn_ctxt, llself: val_self_pair) {
// Synthesize a tuple type for the fields so that GEP_tup_like() can work
// its magic.
let
fields_tup_ty
=
ty
::
mk_
imm_
tup
(
fcx
.lcx.ccx.tcx
,
field_tys
);
let
fields_tup_ty
=
ty
::
mk_tup
(
fcx
.lcx.ccx.tcx
,
field_tys
);
let
n_typarams
=
std
::
ivec
::
len
[
ast
::
ty_param
](
bcx
.fcx.lcx.obj_typarams
);
let
llobj_box_ty
:
TypeRef
=
T_obj_ptr
(
*
bcx_ccx
(
bcx
),
n_typarams
);
let
box_cell
=
...
...
@@ -6128,7 +6127,7 @@ fn trans_res_ctor(cx: @local_ctxt, sp: &span, dtor: &ast::_fn,
let
bcx
=
new_top_block_ctxt
(
fcx
);
let
lltop
=
bcx
.llbb
;
let
arg_t
=
arg_tys_of_fn
(
cx
.ccx
,
ctor_id
)
.
(
0
)
.ty
;
let
tup_t
=
ty
::
mk_
imm_
tup
(
cx
.ccx.tcx
,
~
[
ty
::
mk_int
(
cx
.ccx.tcx
),
arg_t
]);
let
tup_t
=
ty
::
mk_tup
(
cx
.ccx.tcx
,
~
[
ty
::
mk_int
(
cx
.ccx.tcx
),
arg_t
]);
let
arg
;
alt
fcx
.llargs
.find
(
dtor
.decl.inputs
.
(
0
)
.id
)
{
some
(
x
)
{
arg
=
load_if_immediate
(
bcx
,
x
,
arg_t
);
}
...
...
src/comp/middle/trans_comm.rs
浏览文件 @
29ea8754
...
...
@@ -122,7 +122,7 @@ fn trans_spawn(cx: &@block_ctxt, dom: &ast::spawn_dom, name: &option::t[str],
}
// Make the tuple.
let
args_ty
=
ty
::
mk_
imm_
tup
(
cx
.fcx.lcx.ccx.tcx
,
arg_tys
);
let
args_ty
=
ty
::
mk_tup
(
cx
.fcx.lcx.ccx.tcx
,
arg_tys
);
// Allocate and fill the tuple.
let
llargs
=
alloc_ty
(
bcx
,
args_ty
);
...
...
src/comp/middle/trans_objects.rs
浏览文件 @
29ea8754
...
...
@@ -152,7 +152,7 @@ fn trans_obj(cx: @local_ctxt, sp: &span, ob: &ast::_obj,
~
[
0
,
abi
::
obj_body_elt_typarams
]);
bcx
=
body_typarams
.bcx
;
// TODO: can we just get typarams_ty out of body_ty instead?
let
typarams_ty
:
ty
::
t
=
ty
::
mk_
imm_
tup
(
ccx
.tcx
,
tps
);
let
typarams_ty
:
ty
::
t
=
ty
::
mk_tup
(
ccx
.tcx
,
tps
);
let
i
:
int
=
0
;
for
tp
:
ast
::
ty_param
in
ty_params
{
let
typaram
=
bcx
.fcx.lltydescs
.
(
i
);
...
...
@@ -174,7 +174,7 @@ fn trans_obj(cx: @local_ctxt, sp: &span, ob: &ast::_obj,
some
(
arg1
)
{
let
arg
=
load_if_immediate
(
bcx
,
arg1
,
arg_tys
.
(
i
)
.ty
);
// TODO: can we just get fields_ty out of body_ty instead?
let
fields_ty
:
ty
::
t
=
ty
::
mk_
imm_
tup
(
ccx
.tcx
,
obj_fields
);
let
fields_ty
:
ty
::
t
=
ty
::
mk_tup
(
ccx
.tcx
,
obj_fields
);
let
field
=
GEP_tup_like
(
bcx
,
fields_ty
,
body_fields
.val
,
~
[
0
,
i
]);
bcx
=
field
.bcx
;
...
...
@@ -347,7 +347,7 @@ fn trans_anon_obj(bcx: @block_ctxt, sp: &span, anon_obj: &ast::anon_obj,
// have additional field exprs in the AST.
load_if_immediate
(
bcx
,
additional_field_vals
.
(
i
)
.val
,
additional_field_tys
.
(
i
));
let
fields_ty
:
ty
::
t
=
ty
::
mk_
imm_
tup
(
ccx
.tcx
,
let
fields_ty
:
ty
::
t
=
ty
::
mk_tup
(
ccx
.tcx
,
additional_field_tys
);
let
field
=
GEP_tup_like
(
bcx
,
fields_ty
,
body_fields
.val
,
~
[
0
,
i
]);
...
...
@@ -895,18 +895,18 @@ fn create_object_body_type(tcx: &ty::ctxt, fields_ty: &[ty::t],
maybe_inner_obj_ty
:
option
::
t
[
ty
::
t
])
->
ty
::
t
{
let
tydesc_ty
:
ty
::
t
=
ty
::
mk_type
(
tcx
);
let
typarams_ty_tup
:
ty
::
t
=
ty
::
mk_
imm_
tup
(
tcx
,
typarams_ty
);
let
fields_ty_tup
:
ty
::
t
=
ty
::
mk_
imm_
tup
(
tcx
,
fields_ty
);
let
typarams_ty_tup
:
ty
::
t
=
ty
::
mk_tup
(
tcx
,
typarams_ty
);
let
fields_ty_tup
:
ty
::
t
=
ty
::
mk_tup
(
tcx
,
fields_ty
);
let
body_ty
:
ty
::
t
;
alt
maybe_inner_obj_ty
{
some
(
inner_obj_ty
)
{
body_ty
=
ty
::
mk_
imm_
tup
(
tcx
,
~
[
tydesc_ty
,
typarams_ty_tup
,
fields_ty_tup
,
inner_obj_ty
]);
body_ty
=
ty
::
mk_tup
(
tcx
,
~
[
tydesc_ty
,
typarams_ty_tup
,
fields_ty_tup
,
inner_obj_ty
]);
}
none
{
body_ty
=
ty
::
mk_
imm_
tup
(
tcx
,
~
[
tydesc_ty
,
typarams_ty_tup
,
fields_ty_tup
]);
body_ty
=
ty
::
mk_tup
(
tcx
,
~
[
tydesc_ty
,
typarams_ty_tup
,
fields_ty_tup
]);
}
}
...
...
src/comp/middle/tstate/pre_post_conditions.rs
浏览文件 @
29ea8754
...
...
@@ -35,7 +35,6 @@
import
util
::
common
::
new_def_hash
;
import
util
::
common
::
log_expr
;
import
util
::
common
::
log_fn
;
import
util
::
common
::
elt_exprs
;
import
util
::
common
::
field_exprs
;
import
util
::
common
::
has_nonlocal_exits
;
import
util
::
common
::
log_stmt
;
...
...
@@ -405,7 +404,7 @@ fn find_pre_post_expr(fcx: &fn_ctxt, e: @expr) {
find_pre_post_exprs
(
fcx
,
es
,
e
.id
);
}
expr_tup
(
elts
)
{
find_pre_post_exprs
(
fcx
,
elt
_exprs
(
elts
)
,
e
.id
);
find_pre_post_exprs
(
fcx
,
elt
s
,
e
.id
);
}
expr_move
(
lhs
,
rhs
)
{
handle_update
(
fcx
,
e
,
lhs
,
rhs
,
oper_move
);
}
expr_swap
(
lhs
,
rhs
)
{
handle_update
(
fcx
,
e
,
lhs
,
rhs
,
oper_swap
);
}
...
...
src/comp/middle/tstate/states.rs
浏览文件 @
29ea8754
...
...
@@ -23,7 +23,6 @@
import
util
::
common
::
log_block
;
import
util
::
common
::
log_block_err
;
import
util
::
common
::
log_fn
;
import
util
::
common
::
elt_exprs
;
import
util
::
common
::
field_exprs
;
import
util
::
common
::
has_nonlocal_exits
;
import
util
::
common
::
log_stmt
;
...
...
@@ -392,7 +391,7 @@ fn find_pre_post_state_expr(fcx: &fn_ctxt, pres: &prestate, e: @expr) ->
ret
find_pre_post_state_exprs
(
fcx
,
pres
,
e
.id
,
ivec
::
init_elt
(
init_assign
,
ivec
::
len
(
elts
)),
elt
_exprs
(
elts
)
,
return
);
elt
s
,
return
);
}
expr_move
(
lhs
,
rhs
)
{
ret
find_pre_post_state_two
(
fcx
,
pres
,
lhs
,
rhs
,
e
.id
,
oper_move
);
...
...
src/comp/middle/ty.rs
浏览文件 @
29ea8754
...
...
@@ -70,7 +70,6 @@
export
mk_fn
;
export
mk_imm_box
;
export
mk_mut_ptr
;
export
mk_imm_tup
;
export
mk_imm_vec
;
export
mk_int
;
export
mk_istr
;
...
...
@@ -282,7 +281,7 @@ fn method_ty_to_fn_ty(cx: &ctxt, m: method) -> t {
ty_native_fn
(
ast
::
native_abi
,
[
arg
],
t
);
ty_obj
([
method
]);
ty_res
(
def_id
,
t
,
[
t
]);
ty_tup
([
m
t
]);
ty_tup
([
t
]);
ty_var
(
int
);
// type variable
ty_param
(
uint
,
ast
::
kind
);
// fn/tag type param
...
...
@@ -306,7 +305,6 @@ fn method_ty_to_fn_ty(cx: &ctxt, m: method) -> t {
terr_box_mutability
;
terr_vec_mutability
;
terr_tuple_size
(
uint
,
uint
);
terr_tuple_mutability
;
terr_record_size
(
uint
,
uint
);
terr_record_mutability
;
terr_record_fields
(
ast
::
ident
,
ast
::
ident
);
...
...
@@ -491,9 +489,9 @@ fn derive_flags_sig(cx: &ctxt, has_params: &mutable bool,
derive_flags_mt
(
cx
,
has_params
,
has_vars
,
f
.mt
);
}
}
ty_tup
(
m
ts
)
{
for
m
in
m
ts
{
derive_flags_
mt
(
cx
,
has_params
,
has_vars
,
m
);
ty_tup
(
ts
)
{
for
tt
in
ts
{
derive_flags_
t
(
cx
,
has_params
,
has_vars
,
tt
);
}
}
ty_fn
(
_
,
args
,
tt
,
_
,
_
)
{
...
...
@@ -605,14 +603,7 @@ fn mk_constr(cx: &ctxt, t: &t, cs: &[@type_constr]) -> t {
ret
gen_ty
(
cx
,
ty_constr
(
t
,
cs
));
}
fn
mk_tup
(
cx
:
&
ctxt
,
tms
:
&
[
mt
])
->
t
{
ret
gen_ty
(
cx
,
ty_tup
(
tms
));
}
fn
mk_imm_tup
(
cx
:
&
ctxt
,
tys
:
&
[
t
])
->
t
{
// TODO: map
let
mts
=
~
[];
for
typ
in
tys
{
mts
+=
~
[{
ty
:
typ
,
mut
:
ast
::
imm
}];
}
ret
mk_tup
(
cx
,
mts
);
}
fn
mk_tup
(
cx
:
&
ctxt
,
ts
:
&
[
t
])
->
t
{
ret
gen_ty
(
cx
,
ty_tup
(
ts
));
}
fn
mk_fn
(
cx
:
&
ctxt
,
proto
:
&
ast
::
proto
,
args
:
&
[
arg
],
ty
:
&
t
,
cf
:
&
controlflow
,
constrs
:
&
[
@
constr
])
->
t
{
...
...
@@ -687,8 +678,8 @@ fn walk_ty(cx: &ctxt, walker: ty_walk, ty: t) {
ty_rec
(
fields
)
{
for
fl
:
field
in
fields
{
walk_ty
(
cx
,
walker
,
fl
.mt.ty
);
}
}
ty_tup
(
m
ts
)
{
for
t
m
in
mts
{
walk_ty
(
cx
,
walker
,
tm
.ty
);
}
ty_tup
(
ts
)
{
for
t
t
in
ts
{
walk_ty
(
cx
,
walker
,
tt
);
}
}
ty_fn
(
proto
,
args
,
ret_ty
,
_
,
_
)
{
for
a
:
arg
in
args
{
walk_ty
(
cx
,
walker
,
a
.ty
);
}
...
...
@@ -775,13 +766,12 @@ fn fold_ty(cx: &ctxt, fld: fold_mode, ty_0: t) -> t {
}
ty
=
copy_cname
(
cx
,
mk_rec
(
cx
,
new_fields
),
ty
);
}
ty_tup
(
mts
)
{
let
new_mts
=
~
[];
for
tm
in
mts
{
let
new_subty
=
fold_ty
(
cx
,
fld
,
tm
.ty
);
new_mts
+=
~
[{
ty
:
new_subty
,
mut
:
tm
.mut
}];
ty_tup
(
ts
)
{
let
new_ts
=
~
[];
for
tt
in
ts
{
new_ts
+=
~
[
fold_ty
(
cx
,
fld
,
tt
)];
}
ty
=
copy_cname
(
cx
,
mk_tup
(
cx
,
new_
m
ts
),
ty
);
ty
=
copy_cname
(
cx
,
mk_tup
(
cx
,
new_ts
),
ty
);
}
ty_fn
(
proto
,
args
,
ret_ty
,
cf
,
constrs
)
{
let
new_args
:
[
arg
]
=
~
[];
...
...
@@ -956,7 +946,7 @@ fn type_is_tup_like(cx: &ctxt, ty: &t) -> bool {
fn
get_element_type
(
cx
:
&
ctxt
,
ty
:
&
t
,
i
:
uint
)
->
t
{
alt
struct
(
cx
,
ty
)
{
ty_rec
(
flds
)
{
ret
flds
.
(
i
)
.mt.ty
;
}
ty_tup
(
mts
)
{
ret
mts
.
(
i
)
.ty
;
}
ty_tup
(
ts
)
{
ret
ts
.
(
i
)
;
}
_
{
cx
.sess
.bug
(
"get_element_type called on type "
+
ty_to_str
(
cx
,
ty
)
+
" - expected a
\
...
...
@@ -1032,7 +1022,7 @@ fn type_has_pointers(cx: &ctxt, ty: &t) -> bool {
}
ty_tup
(
elts
)
{
for
m
in
elts
{
if
type_has_pointers
(
cx
,
m
.ty
)
{
result
=
true
;
}
if
type_has_pointers
(
cx
,
m
)
{
result
=
true
;
}
}
}
ty_tag
(
did
,
tps
)
{
...
...
@@ -1225,11 +1215,9 @@ fn type_has_dynamic_size(cx: &ctxt, ty: &t) -> bool {
}
ret
false
;
}
ty_tup
(
mts
)
{
let
i
=
0u
;
while
i
<
ivec
::
len
(
mts
)
{
if
type_has_dynamic_size
(
cx
,
mts
.
(
i
)
.ty
)
{
ret
true
;
}
i
+=
1u
;
ty_tup
(
ts
)
{
for
tt
in
ts
{
if
type_has_dynamic_size
(
cx
,
tt
)
{
ret
true
;
}
}
ret
false
;
}
...
...
@@ -1356,7 +1344,7 @@ fn type_owns_heap_mem(cx: &ctxt, ty: &t) -> bool {
}
ty_tup
(
elts
)
{
for
m
in
elts
{
if
type_owns_heap_mem
(
cx
,
m
.ty
)
{
result
=
true
;
}
if
type_owns_heap_mem
(
cx
,
m
)
{
result
=
true
;
}
}
}
ty_res
(
_
,
inner
,
tps
)
{
...
...
@@ -1397,7 +1385,7 @@ fn type_is_pod(cx : &ctxt, ty : &t) -> bool {
ty_tag
(
did
,
tps
)
{
let
variants
=
tag_variants
(
cx
,
did
);
for
variant
:
variant_info
in
variants
{
let
tup_ty
=
mk_
imm_
tup
(
cx
,
variant
.args
);
let
tup_ty
=
mk_tup
(
cx
,
variant
.args
);
// Perform any type parameter substitutions.
tup_ty
=
substitute_type_params
(
cx
,
tps
,
tup_ty
);
...
...
@@ -1411,7 +1399,7 @@ fn type_is_pod(cx : &ctxt, ty : &t) -> bool {
}
ty_tup
(
elts
)
{
for
elt
in
elts
{
if
!
type_is_pod
(
cx
,
elt
.ty
)
{
result
=
false
;
}
if
!
type_is_pod
(
cx
,
elt
)
{
result
=
false
;
}
}
}
ty_res
(
_
,
inner
,
tps
)
{
...
...
@@ -1563,9 +1551,9 @@ fn hash_fn(id: uint, args: &[arg], rty: &t) -> uint {
for
f
:
field
in
fields
{
h
+=
h
<<
5u
+
hash_ty
(
f
.mt.ty
);
}
ret
h
;
}
ty_tup
(
m
ts
)
{
ty_tup
(
ts
)
{
let
h
=
25u
;
for
t
m
in
mts
{
h
+=
h
<<
5u
+
hash_ty
(
tm
.ty
);
}
for
t
t
in
ts
{
h
+=
h
<<
5u
+
hash_ty
(
tt
);
}
ret
h
;
}
...
...
@@ -1749,14 +1737,14 @@ fn equal_def(did_a: &ast::def_id, did_b: &ast::def_id) -> bool {
_
{
ret
false
;
}
}
}
ty_tup
(
m
ts_a
)
{
ty_tup
(
ts_a
)
{
alt
(
b
)
{
ty_tup
(
m
ts_b
)
{
let
len
=
ivec
::
len
(
m
ts_a
);
if
len
!=
ivec
::
len
(
m
ts_b
)
{
ret
false
;
}
ty_tup
(
ts_b
)
{
let
len
=
ivec
::
len
(
ts_a
);
if
len
!=
ivec
::
len
(
ts_b
)
{
ret
false
;
}
let
i
=
0u
;
while
i
<
len
{
if
!
eq
ual_mt
(
mts_a
.
(
i
),
m
ts_b
.
(
i
))
{
ret
false
;
}
if
!
eq
_ty
(
ts_a
.
(
i
),
ts_b
.
(
i
))
{
ret
false
;
}
i
+=
1u
;
}
ret
true
;
...
...
@@ -2743,17 +2731,11 @@ fn unify_step(cx: &@ctxt, expected: &t, actual: &t) -> result {
while
i
<
expected_len
{
let
expected_elem
=
expected_elems
.
(
i
);
let
actual_elem
=
actual_elems
.
(
i
);
let
mut
;
alt
unify_mut
(
expected_elem
.mut
,
actual_elem
.mut
)
{
none
.
{
ret
ures_err
(
terr_tuple_mutability
);
}
some
(
m
)
{
mut
=
m
;
}
}
let
result
=
unify_step
(
cx
,
expected_elem
.ty
,
actual_elem
.ty
);
let
result
=
unify_step
(
cx
,
expected_elem
,
actual_elem
);
alt
result
{
ures_ok
(
rty
)
{
let
mt
=
{
ty
:
rty
,
mut
:
mut
};
result_elems
+=
~
[
mt
];
result_elems
+=
~
[
rty
];
}
_
{
ret
result
;
}
}
...
...
@@ -2912,9 +2894,6 @@ fn type_err_to_str(err: &ty::type_err) -> str {
" elements but found one with "
+
uint
::
to_str
(
a_sz
,
10u
)
+
" elements"
;
}
terr_tuple_mutability
.
{
ret
"tuple elements differ in mutability"
;
}
terr_record_size
(
e_sz
,
a_sz
)
{
ret
"expected a record with "
+
uint
::
to_str
(
e_sz
,
10u
)
+
" fields but found one with "
+
uint
::
to_str
(
a_sz
,
10u
)
+
...
...
src/comp/middle/typeck.rs
浏览文件 @
29ea8754
...
...
@@ -340,7 +340,7 @@ fn instantiate(tcx: &ty::ctxt, sp: &span, getter: &ty_getter,
typ
=
ty
::
mk_chan
(
tcx
,
ast_ty_to_ty
(
tcx
,
getter
,
t
));
}
ast
::
ty_tup
(
fields
)
{
let
flds
=
ivec
::
map
(
bind
ast_
mt_to_mt
(
tcx
,
getter
,
_
),
fields
);
let
flds
=
ivec
::
map
(
bind
ast_
ty_to_ty
(
tcx
,
getter
,
_
),
fields
);
typ
=
ty
::
mk_tup
(
tcx
,
flds
);
}
ast
::
ty_rec
(
fields
)
{
...
...
@@ -2178,14 +2178,14 @@ fn check_binop_type_compat(fcx: &@fn_ctxt, span: span, ty: ty::t,
write
::
ty_only_fixup
(
fcx
,
id
,
typ
);
}
ast
::
expr_tup
(
elts
)
{
let
elt
s_mt
=
~
[];
ivec
::
reserve
(
elt
s_mt
,
ivec
::
len
(
elts
));
let
elt
_ts
=
~
[];
ivec
::
reserve
(
elt
_ts
,
ivec
::
len
(
elts
));
for
e
in
elts
{
check_expr
(
fcx
,
e
.expr
);
let
ety
=
expr_ty
(
fcx
.ccx.tcx
,
e
.expr
);
elt
s_mt
+=
~
[{
ty
:
ety
,
mut
:
e
.mut
}
];
check_expr
(
fcx
,
e
);
let
ety
=
expr_ty
(
fcx
.ccx.tcx
,
e
);
elt
_ts
+=
~
[
ety
];
}
let
typ
=
ty
::
mk_tup
(
fcx
.ccx.tcx
,
elt
s_mt
);
let
typ
=
ty
::
mk_tup
(
fcx
.ccx.tcx
,
elt
_ts
);
write
::
ty_only_fixup
(
fcx
,
id
,
typ
);
}
ast
::
expr_rec
(
fields
,
base
)
{
...
...
src/comp/syntax/ast.rs
浏览文件 @
29ea8754
...
...
@@ -273,8 +273,6 @@ fn unop_to_str(op: unop) -> str {
type
arm
=
{
pats
:
[
@
pat
],
block
:
blk
};
type
elt
=
{
mut
:
mutability
,
expr
:
@
expr
};
type
field_
=
{
mut
:
mutability
,
ident
:
ident
,
expr
:
@
expr
};
type
field
=
spanned
[
field_
];
...
...
@@ -292,7 +290,7 @@ fn unop_to_str(op: unop) -> str {
expr_vec
([
@
expr
],
mutability
,
seq_kind
);
expr_rec
([
field
],
option
::
t
[
@
expr
]);
expr_call
(
@
expr
,
[
@
expr
]);
expr_tup
([
elt
]);
expr_tup
([
@
expr
]);
expr_self_method
(
ident
);
expr_bind
(
@
expr
,
[
option
::
t
[
@
expr
]]);
expr_spawn
(
spawn_dom
,
option
::
t
[
str
],
@
expr
,
[
@
expr
]);
...
...
@@ -448,7 +446,7 @@ fn ty_mach_to_str(tm: ty_mach) -> str {
ty_rec
([
ty_field
]);
ty_fn
(
proto
,
[
ty_arg
],
@
ty
,
controlflow
,
[
@
constr
]);
ty_obj
([
ty_method
]);
ty_tup
([
mt
]);
ty_tup
([
@
ty
]);
ty_path
(
path
,
node_id
);
ty_type
;
ty_constr
(
@
ty
,
[
@
ty_constr
]);
...
...
src/comp/syntax/fold.rs
浏览文件 @
29ea8754
...
...
@@ -339,11 +339,7 @@ fn fold_anon_obj_field_(aof: &anon_obj_field, fld: ast_fold) ->
option
::
map
(
fld
.fold_expr
,
maybe_expr
))
}
expr_tup
(
elts
)
{
let
elts_
=
~
[];
for
elt
in
elts
{
elts_
+=
~
[{
mut
:
elt
.mut
,
expr
:
fld
.fold_expr
(
elt
.expr
)}];
}
expr_tup
(
elts_
)
expr_tup
(
ivec
::
map
(
fld
.fold_expr
,
elts
))
}
expr_call
(
f
,
args
)
{
expr_call
(
fld
.fold_expr
(
f
),
fld
.map_exprs
(
fld
.fold_expr
,
args
))
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
29ea8754
...
...
@@ -324,7 +324,7 @@ fn print_field(s: &ps, f: &ast::ty_field) {
}
ast
::
ty_tup
(
elts
)
{
popen
(
s
);
commasep
(
s
,
inconsistent
,
elts
,
print_
mt
);
commasep
(
s
,
inconsistent
,
elts
,
print_
boxed_type
);
pclose
(
s
);
}
ast
::
ty_fn
(
proto
,
inputs
,
output
,
cf
,
constrs
)
{
...
...
@@ -753,15 +753,8 @@ fn print_field(s: &ps, field: &ast::field) {
word
(
s
.s
,
"}"
);
}
ast
::
expr_tup
(
exprs
)
{
fn
printElt
(
s
:
&
ps
,
elt
:
&
ast
::
elt
)
{
ibox
(
s
,
indent_unit
);
if
elt
.mut
==
ast
::
mut
{
word_nbsp
(
s
,
"mutable"
);
}
print_expr
(
s
,
elt
.expr
);
end
(
s
);
}
fn
get_span
(
elt
:
&
ast
::
elt
)
->
codemap
::
span
{
ret
elt
.expr.span
;
}
popen
(
s
);
commasep_
cmnt
(
s
,
inconsistent
,
exprs
,
printElt
,
get_span
);
commasep_
exprs
(
s
,
inconsistent
,
exprs
);
pclose
(
s
);
}
ast
::
expr_call
(
func
,
args
)
{
...
...
src/comp/syntax/visit.rs
浏览文件 @
29ea8754
...
...
@@ -133,8 +133,8 @@ fn visit_ty[E](t: &@ty, e: &E, v: &vt[E]) {
ty_rec
(
flds
)
{
for
f
:
ty_field
in
flds
{
v
.visit_ty
(
f
.node.mt.ty
,
e
,
v
);
}
}
ty_tup
(
m
ts
)
{
for
mt
in
mts
{
v
.visit_ty
(
mt
.ty
,
e
,
v
);
}
ty_tup
(
ts
)
{
for
tt
in
ts
{
v
.visit_ty
(
tt
,
e
,
v
);
}
}
ty_fn
(
_
,
args
,
out
,
_
,
constrs
)
{
for
a
:
ty_arg
in
args
{
v
.visit_ty
(
a
.node.ty
,
e
,
v
);
}
...
...
@@ -248,7 +248,7 @@ fn visit_expr[E](ex: &@expr, e: &E, v: &vt[E]) {
visit_expr_opt
(
base
,
e
,
v
);
}
expr_tup
(
elts
)
{
for
el
in
elts
{
v
.visit_expr
(
el
.expr
,
e
,
v
);
}
for
el
in
elts
{
v
.visit_expr
(
el
,
e
,
v
);
}
}
expr_call
(
callee
,
args
)
{
v
.visit_expr
(
callee
,
e
,
v
);
...
...
src/comp/util/common.rs
浏览文件 @
29ea8754
...
...
@@ -47,14 +47,6 @@ fn new_def_hash[@V]() -> std::map::hashmap[ast::def_id, V] {
ret
std
::
map
::
mk_hashmap
[
ast
::
def_id
,
V
](
hasher
,
eqer
);
}
fn
elt_expr
(
e
:
&
ast
::
elt
)
->
@
ast
::
expr
{
ret
e
.expr
;
}
fn
elt_exprs
(
elts
:
&
[
ast
::
elt
])
->
[
@
ast
::
expr
]
{
let
es
=
~
[];
for
e
:
ast
::
elt
in
elts
{
es
+=
~
[
e
.expr
];
}
ret
es
;
}
fn
field_expr
(
f
:
&
ast
::
field
)
->
@
ast
::
expr
{
ret
f
.node.expr
;
}
fn
field_exprs
(
fields
:
&
[
ast
::
field
])
->
[
@
ast
::
expr
]
{
...
...
src/comp/util/ppaux.rs
浏览文件 @
29ea8754
...
...
@@ -105,7 +105,7 @@ fn mt_to_str(cx: &ctxt, m: &mt) -> str {
}
ty_tup
(
elems
)
{
let
strs
=
~
[];
for
tm
in
elems
{
strs
+=
~
[
mt_to_str
(
cx
,
t
m
)];
}
for
elem
in
elems
{
strs
+=
~
[
ty_to_str
(
cx
,
ele
m
)];
}
s
+=
"("
+
str
::
connect
(
strs
,
","
)
+
")"
;
}
ty_tag
(
id
,
tps
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录