Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fd0d1cb7
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,发现更多精彩内容 >>
提交
fd0d1cb7
编写于
6月 30, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Make mk_imm_tup() take an interior vector
上级
b841152a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
48 deletion
+65
-48
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+53
-45
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+12
-3
未找到文件。
src/comp/middle/trans.rs
浏览文件 @
fd0d1cb7
...
@@ -1209,22 +1209,22 @@ fn simplifier(@crate_ctxt ccx, ty::t typ) -> ty::t {
...
@@ -1209,22 +1209,22 @@ fn simplifier(@crate_ctxt ccx, ty::t typ) -> ty::t {
}
}
case
(
ty
::
ty_fn
(
_
,
_
,
_
,
_
,
_
))
{
case
(
ty
::
ty_fn
(
_
,
_
,
_
,
_
,
_
))
{
ret
ty
::
mk_imm_tup
(
ccx
.tcx
,
ret
ty
::
mk_imm_tup
(
ccx
.tcx
,
[
ty
::
mk_imm_box
(
ccx
.tcx
,
~
[
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
)),
ty
::
mk_nil
(
ccx
.tcx
)),
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
))]);
ty
::
mk_nil
(
ccx
.tcx
))]);
}
}
case
(
ty
::
ty_obj
(
_
))
{
case
(
ty
::
ty_obj
(
_
))
{
ret
ty
::
mk_imm_tup
(
ccx
.tcx
,
ret
ty
::
mk_imm_tup
(
ccx
.tcx
,
[
ty
::
mk_imm_box
(
ccx
.tcx
,
~
[
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
)),
ty
::
mk_nil
(
ccx
.tcx
)),
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_imm_box
(
ccx
.tcx
,
ty
::
mk_nil
(
ccx
.tcx
))]);
ty
::
mk_nil
(
ccx
.tcx
))]);
}
}
case
(
ty
::
ty_res
(
_
,
?
sub
,
?
tps
))
{
case
(
ty
::
ty_res
(
_
,
?
sub
,
?
tps
))
{
auto
sub1
=
ty
::
substitute_type_params
(
ccx
.tcx
,
tps
,
sub
);
auto
sub1
=
ty
::
substitute_type_params
(
ccx
.tcx
,
tps
,
sub
);
ret
ty
::
mk_imm_tup
(
ccx
.tcx
,
[
ty
::
mk_int
(
ccx
.tcx
),
ret
ty
::
mk_imm_tup
(
ccx
.tcx
,
~
[
ty
::
mk_int
(
ccx
.tcx
),
simplify_type
(
ccx
,
sub1
)]);
simplify_type
(
ccx
,
sub1
)]);
}
}
case
(
_
)
{
ret
typ
;
}
case
(
_
)
{
ret
typ
;
}
}
}
...
@@ -1256,7 +1256,11 @@ fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint {
...
@@ -1256,7 +1256,11 @@ fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint {
auto
max_size
=
0u
;
auto
max_size
=
0u
;
auto
variants
=
ty
::
tag_variants
(
cx
.tcx
,
tid
);
auto
variants
=
ty
::
tag_variants
(
cx
.tcx
,
tid
);
for
(
ty
::
variant_info
variant
in
variants
)
{
for
(
ty
::
variant_info
variant
in
variants
)
{
auto
tup_ty
=
simplify_type
(
cx
,
ty
::
mk_imm_tup
(
cx
.tcx
,
variant
.args
));
// TODO: Remove this vec->ivec conversion.
auto
args
=
~
[];
for
(
ty
::
t
typ
in
variant
.args
)
{
args
+=
~
[
typ
];
}
auto
tup_ty
=
simplify_type
(
cx
,
ty
::
mk_imm_tup
(
cx
.tcx
,
args
));
// Perform any type parameter substitutions.
// Perform any type parameter substitutions.
tup_ty
=
ty
::
substitute_type_params
(
cx
.tcx
,
subtys
,
tup_ty
);
tup_ty
=
ty
::
substitute_type_params
(
cx
.tcx
,
subtys
,
tup_ty
);
...
@@ -1469,7 +1473,11 @@ fn split_type(&@crate_ctxt ccx, &ty::t t, &vec[int] ixs, uint n) ->
...
@@ -1469,7 +1473,11 @@ fn split_type(&@crate_ctxt ccx, &ty::t t, &vec[int] ixs, uint n) ->
// flattened the incoming structure.
// flattened the incoming structure.
auto
s
=
split_type
(
cx
.fcx.lcx.ccx
,
t
,
ixs
,
0u
);
auto
s
=
split_type
(
cx
.fcx.lcx.ccx
,
t
,
ixs
,
0u
);
auto
prefix_ty
=
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
s
.prefix
);
auto
args
=
~
[];
for
(
ty
::
t
typ
in
s
.prefix
)
{
args
+=
~
[
typ
];
}
auto
prefix_ty
=
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
args
);
auto
bcx
=
cx
;
auto
bcx
=
cx
;
auto
sz
=
size_of
(
bcx
,
prefix_ty
);
auto
sz
=
size_of
(
bcx
,
prefix_ty
);
bcx
=
sz
.bcx
;
bcx
=
sz
.bcx
;
...
@@ -1498,11 +1506,11 @@ fn GEP_tag(@block_ctxt cx, ValueRef llblobptr, &ast::def_id tag_id,
...
@@ -1498,11 +1506,11 @@ fn GEP_tag(@block_ctxt cx, ValueRef llblobptr, &ast::def_id tag_id,
auto
elem_ty
=
ty
::
mk_nil
(
cx
.fcx.lcx.ccx.tcx
);
// typestate infelicity
auto
elem_ty
=
ty
::
mk_nil
(
cx
.fcx.lcx.ccx.tcx
);
// typestate infelicity
auto
i
=
0
;
auto
i
=
0
;
let
vec
[
ty
::
t
]
true_arg_tys
=
[];
let
ty
::
t
[]
true_arg_tys
=
~
[];
for
(
ty
::
t
aty
in
arg_tys
)
{
for
(
ty
::
t
aty
in
arg_tys
)
{
auto
arg_ty
=
auto
arg_ty
=
ty
::
substitute_type_params
(
cx
.fcx.lcx.ccx.tcx
,
ty_substs
,
aty
);
ty
::
substitute_type_params
(
cx
.fcx.lcx.ccx.tcx
,
ty_substs
,
aty
);
true_arg_tys
+=
[
arg_ty
];
true_arg_tys
+=
~
[
arg_ty
];
if
(
i
==
ix
)
{
elem_ty
=
arg_ty
;
}
if
(
i
==
ix
)
{
elem_ty
=
arg_ty
;
}
i
+=
1
;
i
+=
1
;
}
}
...
@@ -1559,7 +1567,7 @@ fn trans_malloc_boxed(&@block_ctxt cx, ty::t t) -> result {
...
@@ -1559,7 +1567,7 @@ fn trans_malloc_boxed(&@block_ctxt cx, ty::t t) -> result {
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
// The mk_int here is the space being
// The mk_int here is the space being
// reserved for the refcount.
// reserved for the refcount.
[
ty
::
mk_int
(
cx
.fcx.lcx.ccx.tcx
),
t
]);
~
[
ty
::
mk_int
(
cx
.fcx.lcx.ccx.tcx
),
t
]);
auto
box_ptr
=
ty
::
mk_imm_box
(
cx
.fcx.lcx.ccx.tcx
,
t
);
auto
box_ptr
=
ty
::
mk_imm_box
(
cx
.fcx.lcx.ccx.tcx
,
t
);
auto
sz
=
size_of
(
cx
,
boxed_body
);
auto
sz
=
size_of
(
cx
,
boxed_body
);
// Grab the TypeRef type of box_ptr, because that's what trans_raw_malloc
// Grab the TypeRef type of box_ptr, because that's what trans_raw_malloc
...
@@ -2111,9 +2119,8 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
...
@@ -2111,9 +2119,8 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
fn
trans_res_drop
(
@
block_ctxt
cx
,
ValueRef
rs
,
&
ast
::
def_id
did
,
fn
trans_res_drop
(
@
block_ctxt
cx
,
ValueRef
rs
,
&
ast
::
def_id
did
,
ty
::
t
inner_t
,
&
vec
[
ty
::
t
]
tps
)
->
result
{
ty
::
t
inner_t
,
&
vec
[
ty
::
t
]
tps
)
->
result
{
auto
ccx
=
cx
.fcx.lcx.ccx
;
auto
ccx
=
cx
.fcx.lcx.ccx
;
auto
inner_t_s
=
ty
::
substitute_type_params
(
ccx
.tcx
,
tps
,
inner_t
);
auto
inner_t_s
=
ty
::
substitute_type_params
(
ccx
.tcx
,
tps
,
inner_t
);
auto
tup_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
[
ty
::
mk_int
(
ccx
.tcx
),
inner_t_s
]);
auto
tup_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
~
[
ty
::
mk_int
(
ccx
.tcx
),
inner_t_s
]);
auto
drop_cx
=
new_sub_block_ctxt
(
cx
,
"drop res"
);
auto
drop_cx
=
new_sub_block_ctxt
(
cx
,
"drop res"
);
auto
next_cx
=
new_sub_block_ctxt
(
cx
,
"next"
);
auto
next_cx
=
new_sub_block_ctxt
(
cx
,
"next"
);
...
@@ -5343,8 +5350,7 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
...
@@ -5343,8 +5350,7 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
auto
arg
=
trans_expr
(
bcx
,
e
);
auto
arg
=
trans_expr
(
bcx
,
e
);
bcx
=
arg
.bcx
;
bcx
=
arg
.bcx
;
vec
::
push
[
ValueRef
](
bound_vals
,
arg
.val
);
vec
::
push
[
ValueRef
](
bound_vals
,
arg
.val
);
vec
::
push
[
ty
::
t
](
bound_tys
,
bound_tys
+=
[
ty
::
expr_ty
(
cx
.fcx.lcx.ccx.tcx
,
e
)];
ty
::
expr_ty
(
cx
.fcx.lcx.ccx.tcx
,
e
));
}
}
// Synthesize a closure type.
// Synthesize a closure type.
...
@@ -5352,8 +5358,13 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
...
@@ -5352,8 +5358,13 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
// First, synthesize a tuple type containing the types of all the
// First, synthesize a tuple type containing the types of all the
// bound expressions.
// bound expressions.
// bindings_ty = [bound_ty1, bound_ty2, ...]
// bindings_ty = [bound_ty1, bound_ty2, ...]
// TODO: Remove this vec->ivec conversion.
auto
bound_tys_ivec
=
~
[];
for
(
ty
::
t
typ
in
bound_tys
)
{
bound_tys_ivec
+=
~
[
typ
];
}
let
ty
::
t
bindings_ty
=
let
ty
::
t
bindings_ty
=
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
bound_tys
);
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
bound_tys
_ivec
);
// NB: keep this in sync with T_closure_ptr; we're making
// 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
// a ty::t structure that has the same "shape" as the LLVM type
...
@@ -5362,8 +5373,8 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
...
@@ -5362,8 +5373,8 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
// Make a vector that contains ty_param_count copies of tydesc_ty.
// Make a vector that contains ty_param_count copies of tydesc_ty.
// (We'll need room for that many tydescs in the closure.)
// (We'll need room for that many tydescs in the closure.)
let
ty
::
t
tydesc_ty
=
ty
::
mk_type
(
cx
.fcx.lcx.ccx.tcx
);
let
ty
::
t
tydesc_ty
=
ty
::
mk_type
(
cx
.fcx.lcx.ccx.tcx
);
let
vec
[
ty
::
t
]
captured_tys
=
let
ty
::
t
[
]
captured_tys
=
vec
::
init_elt
[
ty
::
t
](
tydesc_ty
,
ty_param_count
);
std
::
i
vec
::
init_elt
[
ty
::
t
](
tydesc_ty
,
ty_param_count
);
// Get all the types we've got (some of which we synthesized
// Get all the types we've got (some of which we synthesized
// ourselves) into a vector. The whole things ends up looking
// ourselves) into a vector. The whole things ends up looking
...
@@ -5371,9 +5382,9 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
...
@@ -5371,9 +5382,9 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
// closure_tys = [tydesc_ty, outgoing_fty, [bound_ty1, bound_ty2,
// closure_tys = [tydesc_ty, outgoing_fty, [bound_ty1, bound_ty2,
// ...], [tydesc_ty, tydesc_ty, ...]]
// ...], [tydesc_ty, tydesc_ty, ...]]
let
vec
[
ty
::
t
]
closure_tys
=
let
ty
::
t
[
]
closure_tys
=
[
tydesc_ty
,
outgoing_fty
,
bindings_ty
,
~
[
tydesc_ty
,
outgoing_fty
,
bindings_ty
,
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
captured_tys
)];
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
captured_tys
)];
// Finally, synthesize a type for that whole vector.
// Finally, synthesize a type for that whole vector.
let
ty
::
t
closure_ty
=
let
ty
::
t
closure_ty
=
...
@@ -5745,8 +5756,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args, ast::node_id id) ->
...
@@ -5745,8 +5756,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args, ast::node_id id) ->
auto
body
=
bcx
.build
.GEP
(
vec_val
,
[
C_int
(
0
),
C_int
(
abi
::
vec_elt_data
)]);
auto
body
=
bcx
.build
.GEP
(
vec_val
,
[
C_int
(
0
),
C_int
(
abi
::
vec_elt_data
)]);
auto
pseudo_tup_ty
=
auto
pseudo_tup_ty
=
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
ty
::
mk_imm_tup
(
cx
.fcx.lcx.ccx.tcx
,
vec
::
init_elt
[
ty
::
t
](
unit_ty
,
std
::
ivec
::
init_elt
[
ty
::
t
](
unit_ty
,
vec
::
len
(
args
)));
vec
::
len
[
@
ast
::
expr
](
args
)));
let
int
i
=
0
;
let
int
i
=
0
;
for
(
@
ast
::
expr
e
in
args
)
{
for
(
@
ast
::
expr
e
in
args
)
{
auto
src_res
=
trans_expr
(
bcx
,
e
);
auto
src_res
=
trans_expr
(
bcx
,
e
);
...
@@ -6524,7 +6534,7 @@ fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
...
@@ -6524,7 +6534,7 @@ fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
// Translate the arguments, remembering their types and where the values
// Translate the arguments, remembering their types and where the values
// ended up.
// ended up.
let
vec
[
ty
::
t
]
arg_tys
=
[];
let
ty
::
t
[]
arg_tys
=
~
[];
let
vec
[
ValueRef
]
arg_vals
=
[];
let
vec
[
ValueRef
]
arg_vals
=
[];
for
(
@
ast
::
expr
e
in
args
)
{
for
(
@
ast
::
expr
e
in
args
)
{
auto
e_ty
=
ty
::
expr_ty
(
cx
.fcx.lcx.ccx.tcx
,
e
);
auto
e_ty
=
ty
::
expr_ty
(
cx
.fcx.lcx.ccx.tcx
,
e
);
...
@@ -6535,7 +6545,7 @@ fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
...
@@ -6535,7 +6545,7 @@ fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
bcx
=
arg
.bcx
;
bcx
=
arg
.bcx
;
vec
::
push
[
ValueRef
](
arg_vals
,
arg
.val
);
vec
::
push
[
ValueRef
](
arg_vals
,
arg
.val
);
vec
::
push
[
ty
::
t
](
arg_tys
,
e_ty
)
;
arg_tys
+=
~
[
e_ty
]
;
}
}
// Make the tuple.
// Make the tuple.
...
@@ -6785,13 +6795,13 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
...
@@ -6785,13 +6795,13 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
// the outer object?
// the outer object?
let
vec
[
ast
::
anon_obj_field
]
additional_fields
=
[];
let
vec
[
ast
::
anon_obj_field
]
additional_fields
=
[];
let
vec
[
result
]
additional_field_vals
=
[];
let
vec
[
result
]
additional_field_vals
=
[];
let
vec
[
ty
::
t
]
additional_field_tys
=
[];
let
ty
::
t
[]
additional_field_tys
=
~
[];
alt
(
anon_obj
.fields
)
{
alt
(
anon_obj
.fields
)
{
case
(
none
)
{
}
case
(
none
)
{
}
case
(
some
(
?
fields
))
{
case
(
some
(
?
fields
))
{
additional_fields
=
fields
;
additional_fields
=
fields
;
for
(
ast
::
anon_obj_field
f
in
fields
)
{
for
(
ast
::
anon_obj_field
f
in
fields
)
{
additional_field_tys
+=
[
node_id_type
(
ccx
,
f
.id
)];
additional_field_tys
+=
~
[
node_id_type
(
ccx
,
f
.id
)];
additional_field_vals
+=
[
trans_expr
(
bcx
,
f
.expr
)];
additional_field_vals
+=
[
trans_expr
(
bcx
,
f
.expr
)];
}
}
}
}
...
@@ -6895,9 +6905,9 @@ fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
...
@@ -6895,9 +6905,9 @@ fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
// actually supporting typarams for anon objs yet, but let's
// actually supporting typarams for anon objs yet, but let's
// create space for them in case we ever want them.
// create space for them in case we ever want them.
let
ty
::
t
tydesc_ty
=
ty
::
mk_type
(
ccx
.tcx
);
let
ty
::
t
tydesc_ty
=
ty
::
mk_type
(
ccx
.tcx
);
let
vec
[
ty
::
t
]
tps
=
[];
let
ty
::
t
[]
tps
=
~
[];
for
(
ast
::
ty_param
tp
in
ty_params
)
{
for
(
ast
::
ty_param
tp
in
ty_params
)
{
vec
::
push
[
ty
::
t
](
tps
,
tydesc_ty
)
;
tps
+=
~
[
tydesc_ty
]
;
}
}
// Synthesize a tuple type for typarams: [typaram, ...]
// Synthesize a tuple type for typarams: [typaram, ...]
let
ty
::
t
typarams_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
tps
);
let
ty
::
t
typarams_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
tps
);
...
@@ -6905,8 +6915,8 @@ fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
...
@@ -6905,8 +6915,8 @@ fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
// Tuple type for body:
// Tuple type for body:
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
let
ty
::
t
body_ty
=
let
ty
::
t
body_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
[
tydesc_ty
,
typarams_ty
,
ty
::
mk_imm_tup
(
ccx
.tcx
,
~
[
tydesc_ty
,
typarams_ty
,
fields_ty
,
with_obj_ty
]);
fields_ty
,
with_obj_ty
]);
// Hand this type we've synthesized off to trans_malloc_boxed, which
// Hand this type we've synthesized off to trans_malloc_boxed, which
// allocates a box, including space for a refcount.
// allocates a box, including space for a refcount.
...
@@ -7498,9 +7508,9 @@ fn arg_tys_of_fn(&@crate_ctxt ccx,ast::node_id id) -> vec[ty::arg] {
...
@@ -7498,9 +7508,9 @@ fn arg_tys_of_fn(&@crate_ctxt ccx,ast::node_id id) -> vec[ty::arg] {
fn
populate_fn_ctxt_from_llself
(
@
fn_ctxt
fcx
,
val_self_pair
llself
)
{
fn
populate_fn_ctxt_from_llself
(
@
fn_ctxt
fcx
,
val_self_pair
llself
)
{
auto
bcx
=
llstaticallocas_block_ctxt
(
fcx
);
auto
bcx
=
llstaticallocas_block_ctxt
(
fcx
);
let
vec
[
ty
::
t
]
field_tys
=
[];
let
ty
::
t
[]
field_tys
=
~
[];
for
(
ast
::
obj_field
f
in
bcx
.fcx.lcx.obj_fields
)
{
for
(
ast
::
obj_field
f
in
bcx
.fcx.lcx.obj_fields
)
{
field_tys
+=
[
node_id_type
(
bcx
.fcx.lcx.ccx
,
f
.id
)];
field_tys
+=
~
[
node_id_type
(
bcx
.fcx.lcx.ccx
,
f
.id
)];
}
}
// Synthesize a tuple type for the fields so that GEP_tup_like() can work
// Synthesize a tuple type for the fields so that GEP_tup_like() can work
// its magic.
// its magic.
...
@@ -7761,24 +7771,22 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
...
@@ -7761,24 +7771,22 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
}
else
{
}
else
{
// Otherwise, we have to synthesize a big structural type for the
// Otherwise, we have to synthesize a big structural type for the
// object body.
// object body.
let
vec
[
ty
::
t
]
obj_fields
=
[];
let
ty
::
t
[]
obj_fields
=
~
[];
for
(
ty
::
arg
a
in
arg_tys
)
{
vec
::
push
[
ty
::
t
](
obj_fields
,
a
.ty
)
;
}
for
(
ty
::
arg
a
in
arg_tys
)
{
obj_fields
+=
~
[
a
.ty
]
;
}
// Tuple type for fields: [field, ...]
// Tuple type for fields: [field, ...]
let
ty
::
t
fields_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
obj_fields
);
let
ty
::
t
fields_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
obj_fields
);
auto
tydesc_ty
=
ty
::
mk_type
(
ccx
.tcx
);
auto
tydesc_ty
=
ty
::
mk_type
(
ccx
.tcx
);
let
vec
[
ty
::
t
]
tps
=
[];
let
ty
::
t
[]
tps
=
~
[];
for
(
ast
::
ty_param
tp
in
ty_params
)
{
for
(
ast
::
ty_param
tp
in
ty_params
)
{
tps
+=
~
[
tydesc_ty
];
}
vec
::
push
[
ty
::
t
](
tps
,
tydesc_ty
);
}
// Tuple type for typarams: [typaram, ...]
// Tuple type for typarams: [typaram, ...]
let
ty
::
t
typarams_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
tps
);
let
ty
::
t
typarams_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
tps
);
// Tuple type for body: [tydesc_ty, [typaram, ...], [field, ...]]
// Tuple type for body: [tydesc_ty, [typaram, ...], [field, ...]]
let
ty
::
t
body_ty
=
let
ty
::
t
body_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
[
tydesc_ty
,
typarams_ty
,
fields_ty
]);
ty
::
mk_imm_tup
(
ccx
.tcx
,
~
[
tydesc_ty
,
typarams_ty
,
fields_ty
]);
// Hand this type we've synthesized off to trans_malloc_boxed, which
// Hand this type we've synthesized off to trans_malloc_boxed, which
// allocates a box, including space for a refcount.
// allocates a box, including space for a refcount.
...
@@ -7879,7 +7887,7 @@ fn trans_res_ctor(@local_ctxt cx, &span sp, &ast::_fn dtor,
...
@@ -7879,7 +7887,7 @@ fn trans_res_ctor(@local_ctxt cx, &span sp, &ast::_fn dtor,
auto
bcx
=
new_top_block_ctxt
(
fcx
);
auto
bcx
=
new_top_block_ctxt
(
fcx
);
auto
lltop
=
bcx
.llbb
;
auto
lltop
=
bcx
.llbb
;
auto
arg_t
=
arg_tys_of_fn
(
cx
.ccx
,
ctor_id
)
.
(
0
)
.ty
;
auto
arg_t
=
arg_tys_of_fn
(
cx
.ccx
,
ctor_id
)
.
(
0
)
.ty
;
auto
tup_t
=
ty
::
mk_imm_tup
(
cx
.ccx.tcx
,
[
ty
::
mk_int
(
cx
.ccx.tcx
),
arg_t
]);
auto
tup_t
=
ty
::
mk_imm_tup
(
cx
.ccx.tcx
,
~
[
ty
::
mk_int
(
cx
.ccx.tcx
),
arg_t
]);
auto
arg
=
load_if_immediate
auto
arg
=
load_if_immediate
(
bcx
,
fcx
.llargs
.get
(
dtor
.decl.inputs
.
(
0
)
.id
),
arg_t
);
(
bcx
,
fcx
.llargs
.get
(
dtor
.decl.inputs
.
(
0
)
.id
),
arg_t
);
...
...
src/comp/middle/ty.rs
浏览文件 @
fd0d1cb7
...
@@ -587,7 +587,7 @@ fn mk_imm_vec(&ctxt cx, &t typ) -> t {
...
@@ -587,7 +587,7 @@ fn mk_imm_vec(&ctxt cx, &t typ) -> t {
fn
mk_tup
(
&
ctxt
cx
,
&
mt
[]
tms
)
->
t
{
ret
gen_ty
(
cx
,
ty_tup
(
tms
));
}
fn
mk_tup
(
&
ctxt
cx
,
&
mt
[]
tms
)
->
t
{
ret
gen_ty
(
cx
,
ty_tup
(
tms
));
}
fn
mk_imm_tup
(
&
ctxt
cx
,
&
vec
[
t
]
tys
)
->
t
{
fn
mk_imm_tup
(
&
ctxt
cx
,
&
t
[
]
tys
)
->
t
{
// TODO: map
// TODO: map
let
ty
::
mt
[]
mts
=
~
[];
let
ty
::
mt
[]
mts
=
~
[];
...
@@ -1055,7 +1055,11 @@ fn type_has_pointers(&ctxt cx, &t ty) -> bool {
...
@@ -1055,7 +1055,11 @@ fn type_has_pointers(&ctxt cx, &t ty) -> bool {
case
(
ty_tag
(
?
did
,
?
tps
))
{
case
(
ty_tag
(
?
did
,
?
tps
))
{
auto
variants
=
tag_variants
(
cx
,
did
);
auto
variants
=
tag_variants
(
cx
,
did
);
for
(
variant_info
variant
in
variants
)
{
for
(
variant_info
variant
in
variants
)
{
auto
tup_ty
=
mk_imm_tup
(
cx
,
variant
.args
);
// TODO: Remove this vec->ivec conversion.
auto
args
=
~
[];
for
(
ty
::
t
arg
in
variant
.args
)
{
args
+=
~
[
arg
];
}
auto
tup_ty
=
mk_imm_tup
(
cx
,
args
);
// Perform any type parameter substitutions.
// Perform any type parameter substitutions.
tup_ty
=
substitute_type_params
(
cx
,
tps
,
tup_ty
);
tup_ty
=
substitute_type_params
(
cx
,
tps
,
tup_ty
);
...
@@ -1229,7 +1233,12 @@ fn type_owns_heap_mem(&ctxt cx, &t ty) -> bool {
...
@@ -1229,7 +1233,12 @@ fn type_owns_heap_mem(&ctxt cx, &t ty) -> bool {
case
(
ty_tag
(
?
did
,
?
tps
))
{
case
(
ty_tag
(
?
did
,
?
tps
))
{
auto
variants
=
tag_variants
(
cx
,
did
);
auto
variants
=
tag_variants
(
cx
,
did
);
for
(
variant_info
variant
in
variants
)
{
for
(
variant_info
variant
in
variants
)
{
auto
tup_ty
=
mk_imm_tup
(
cx
,
variant
.args
);
// TODO: Remove this vec->ivec conversion.
auto
args
=
~
[];
for
(
ty
::
t
arg
in
variant
.args
)
{
args
+=
~
[
arg
];
}
auto
tup_ty
=
mk_imm_tup
(
cx
,
args
);
// Perform any type parameter substitutions.
// Perform any type parameter substitutions.
tup_ty
=
substitute_type_params
(
cx
,
tps
,
tup_ty
);
tup_ty
=
substitute_type_params
(
cx
,
tps
,
tup_ty
);
if
(
type_owns_heap_mem
(
cx
,
tup_ty
))
{
result
=
true
;
}
if
(
type_owns_heap_mem
(
cx
,
tup_ty
))
{
result
=
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录