Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0eb56e60
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,发现更多精彩内容 >>
提交
0eb56e60
编写于
9月 09, 2011
作者:
M
Marijn Haverbeke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Get rid of trans::iter_sequence, use tvec::iter_vec instead
上级
9fb3ec95
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
97 deletion
+15
-97
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+15
-97
未找到文件。
src/comp/middle/trans.rs
浏览文件 @
0eb56e60
...
...
@@ -1744,90 +1744,6 @@ fn iter_variant(cx: @block_ctxt, a_tup: ValueRef,
ret
cx
;
}
// Iterates through a pointer range, until the src* hits the src_lim*.
fn
iter_sequence_raw
(
cx
:
@
block_ctxt
,
dst
:
ValueRef
,
src
:
ValueRef
,
src_lim
:
ValueRef
,
elt_sz
:
ValueRef
,
f
:
&
val_pair_fn
)
->
@
block_ctxt
{
let
bcx
=
cx
;
let
dst_int
:
ValueRef
=
vp2i
(
bcx
,
dst
);
let
src_int
:
ValueRef
=
vp2i
(
bcx
,
src
);
let
src_lim_int
:
ValueRef
=
vp2i
(
bcx
,
src_lim
);
let
cond_cx
=
new_scope_block_ctxt
(
cx
,
"sequence-iter cond"
);
let
body_cx
=
new_scope_block_ctxt
(
cx
,
"sequence-iter body"
);
let
next_cx
=
new_sub_block_ctxt
(
cx
,
"next"
);
Br
(
bcx
,
cond_cx
.llbb
);
let
dst_curr
:
ValueRef
=
Phi
(
cond_cx
,
T_int
(),
[
dst_int
],
[
bcx
.llbb
]);
let
src_curr
:
ValueRef
=
Phi
(
cond_cx
,
T_int
(),
[
src_int
],
[
bcx
.llbb
]);
let
end_test
=
ICmp
(
cond_cx
,
lib
::
llvm
::
LLVMIntULT
,
src_curr
,
src_lim_int
);
CondBr
(
cond_cx
,
end_test
,
body_cx
.llbb
,
next_cx
.llbb
);
let
dst_curr_ptr
=
vi2p
(
body_cx
,
dst_curr
,
T_ptr
(
T_i8
()));
let
src_curr_ptr
=
vi2p
(
body_cx
,
src_curr
,
T_ptr
(
T_i8
()));
let
body_cx
=
f
(
body_cx
,
dst_curr_ptr
,
src_curr_ptr
);
let
dst_next
=
Add
(
body_cx
,
dst_curr
,
elt_sz
);
let
src_next
=
Add
(
body_cx
,
src_curr
,
elt_sz
);
Br
(
body_cx
,
cond_cx
.llbb
);
AddIncomingToPhi
(
dst_curr
,
[
dst_next
],
[
body_cx
.llbb
]);
AddIncomingToPhi
(
src_curr
,
[
src_next
],
[
body_cx
.llbb
]);
ret
next_cx
;
}
fn
iter_sequence_inner
(
cx
:
&@
block_ctxt
,
src
:
ValueRef
,
src_lim
:
ValueRef
,
elt_ty
:
&
ty
::
t
,
f
:
&
val_and_ty_fn
)
->
@
block_ctxt
{
fn
adaptor_fn
(
f
:
val_and_ty_fn
,
elt_ty
:
ty
::
t
,
cx
:
&@
block_ctxt
,
_
dst
:
ValueRef
,
src
:
ValueRef
)
->
@
block_ctxt
{
let
ccx
=
bcx_ccx
(
cx
);
let
sp
=
cx
.sp
;
let
llptrty
=
if
check
type_has_static_size
(
ccx
,
elt_ty
)
{
let
llty
=
type_of
(
ccx
,
sp
,
elt_ty
);
T_ptr
(
llty
)
}
else
{
T_ptr
(
T_ptr
(
T_i8
()))
};
let
p
=
PointerCast
(
cx
,
src
,
llptrty
);
ret
f
(
cx
,
load_if_immediate
(
cx
,
p
,
elt_ty
),
elt_ty
);
}
let
elt_sz
=
size_of
(
cx
,
elt_ty
);
ret
iter_sequence_raw
(
elt_sz
.bcx
,
src
,
src
,
src_lim
,
elt_sz
.val
,
bind
adaptor_fn
(
f
,
elt_ty
,
_
,
_
,
_
));
}
// Iterates through the elements of a vec or str.
fn
iter_sequence
(
cx
:
@
block_ctxt
,
v
:
ValueRef
,
t
:
ty
::
t
,
f
:
&
val_and_ty_fn
)
->
@
block_ctxt
{
fn
iter_sequence_body
(
bcx
:
@
block_ctxt
,
v
:
ValueRef
,
elt_ty
:
ty
::
t
,
f
:
&
val_and_ty_fn
,
trailing_null
:
bool
)
->
@
block_ctxt
{
let
llunit_ty
=
type_of_or_i8
(
bcx
,
elt_ty
);
let
p0
=
tvec
::
get_dataptr
(
bcx
,
v
,
llunit_ty
);
let
len
=
tvec
::
get_fill
(
bcx
,
v
);
if
trailing_null
{
let
unit_sz
=
size_of
(
bcx
,
elt_ty
);
bcx
=
unit_sz
.bcx
;
len
=
Sub
(
bcx
,
len
,
unit_sz
.val
);
}
let
p1
=
vi2p
(
bcx
,
Add
(
bcx
,
vp2i
(
bcx
,
p0
),
len
),
T_ptr
(
llunit_ty
));
ret
iter_sequence_inner
(
bcx
,
p0
,
p1
,
elt_ty
,
f
);
}
alt
ty
::
struct
(
bcx_tcx
(
cx
),
t
)
{
ty
::
ty_vec
(
elt
)
{
ret
iter_sequence_body
(
cx
,
v
,
elt
.ty
,
f
,
false
);
}
ty
::
ty_str
.
{
let
et
=
ty
::
mk_mach
(
bcx_tcx
(
cx
),
ast
::
ty_u8
);
ret
iter_sequence_body
(
cx
,
v
,
et
,
f
,
true
);
}
_
{
bcx_ccx
(
cx
)
.sess
.bug
(
"unexpected type in trans::iter_sequence: "
+
ty_to_str
(
cx
.fcx.lcx.ccx.tcx
,
t
));
}
}
}
fn
lazily_emit_all_tydesc_glue
(
cx
:
&@
block_ctxt
,
static_ti
:
&
option
::
t
<@
tydesc_info
>
)
{
lazily_emit_tydesc_glue
(
cx
,
abi
::
tydesc_field_take_glue
,
static_ti
);
...
...
@@ -2559,8 +2475,6 @@ fn trans_if(cx: &@block_ctxt, cond: &@ast::expr, thn: &ast::blk,
fn
trans_for
(
cx
:
&@
block_ctxt
,
local
:
&@
ast
::
local
,
seq
:
&@
ast
::
expr
,
body
:
&
ast
::
blk
)
->
result
{
// FIXME: We bind to an alias here to avoid a segfault... this is
// obviously a bug.
fn
inner
(
cx
:
&@
block_ctxt
,
local
:
@
ast
::
local
,
curr
:
ValueRef
,
t
:
ty
::
t
,
body
:
&
ast
::
blk
,
outer_next_cx
:
@
block_ctxt
)
->
@
block_ctxt
{
let
next_cx
=
new_sub_block_ctxt
(
cx
,
"next"
);
...
...
@@ -2569,13 +2483,13 @@ fn inner(cx: &@block_ctxt, local: @ast::local, curr: ValueRef, t: ty::t,
option
::
some
::
<@
block_ctxt
>
(
next_cx
),
outer_next_cx
,
"for loop scope"
);
Br
(
cx
,
scope_cx
.llbb
);
let
local_res
=
alloc_local
(
scope_cx
,
local
);
let
bcx
=
copy_val
(
local_res
.bcx
,
INIT
,
local_res
.val
,
curr
,
t
);
add_clean
(
scope_cx
,
local_res
.val
,
t
);
let
bcx
=
trans_alt
::
bind_irrefutable_pat
(
bcx
,
local
.node.pat
,
local_res
.val
,
cx
.fcx.lllocals
,
false
);
let
{
bcx
,
val
:
dst
}
=
alloc_local
(
scope_cx
,
local
);
let
val
=
load_if_immediate
(
bcx
,
PointerCast
(
bcx
,
curr
,
val_ty
(
dst
))
,
t
);
let
bcx
=
copy_val
(
bcx
,
INIT
,
dst
,
val
,
t
);
add_clean
(
scope_cx
,
dst
,
t
);
let
bcx
=
trans_alt
::
bind_irrefutable_pat
(
bcx
,
local
.node.pat
,
dst
,
cx
.fcx.lllocals
,
false
);
bcx
=
trans_block
(
bcx
,
body
,
return
)
.bcx
;
if
!
is_terminated
(
bcx
)
{
Br
(
bcx
,
next_cx
.llbb
);
...
...
@@ -2585,10 +2499,14 @@ fn inner(cx: &@block_ctxt, local: @ast::local, curr: ValueRef, t: ty::t,
}
let
next_cx
=
new_sub_block_ctxt
(
cx
,
"next"
);
let
seq_ty
=
ty
::
expr_ty
(
bcx_tcx
(
cx
),
seq
);
let
seq_res
=
trans_expr
(
cx
,
seq
);
let
bcx
=
iter_sequence
(
seq_res
.bcx
,
seq_res
.val
,
seq_ty
,
bind
inner
(
_
,
local
,
_
,
_
,
body
,
next_cx
));
let
{
bcx
,
val
:
seq
}
=
trans_expr
(
cx
,
seq
);
let
seq
=
PointerCast
(
bcx
,
seq
,
T_ptr
(
T_ptr
(
T_opaque_vec
())));
let
fill
=
tvec
::
get_fill
(
bcx
,
seq
);
if
ty
::
type_is_str
(
bcx_tcx
(
bcx
),
seq_ty
)
{
fill
=
Sub
(
bcx
,
fill
,
C_int
(
1
));
}
let
bcx
=
tvec
::
iter_vec_raw
(
bcx
,
seq
,
seq_ty
,
fill
,
bind
inner
(
_
,
local
,
_
,
_
,
body
,
next_cx
));
Br
(
bcx
,
next_cx
.llbb
);
ret
rslt
(
next_cx
,
C_nil
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录