Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b3cf793b
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,发现更多精彩内容 >>
提交
b3cf793b
编写于
7月 11, 2010
作者:
G
Graydon Hoare
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix post-stmt drop calculations. Closes #106.
上级
30c4070e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
10 deletion
+40
-10
src/Makefile
src/Makefile
+1
-0
src/boot/me/typestate.ml
src/boot/me/typestate.ml
+30
-10
src/test/run-pass/vec-late-init.rs
src/test/run-pass/vec-late-init.rs
+9
-0
未找到文件。
src/Makefile
浏览文件 @
b3cf793b
...
...
@@ -464,6 +464,7 @@ TEST_XFAILS_LLVM := $(addprefix test/run-pass/, \
vec-append.rs
\
vec-concat.rs
\
vec-drop.rs
\
vec-late-init.rs
\
vec-slice.rs
\
vec.rs
\
writealias.rs
\
...
...
src/boot/me/typestate.ml
浏览文件 @
b3cf793b
...
...
@@ -988,23 +988,30 @@ let lifecycle_visitor
* used later on in translation.
*)
let
(
live_block_slots
:
(
node_id
Stack
.
t
)
Stack
.
t
)
=
Stack
.
create
()
in
let
(
live_block_slots
:
(
node_id
,
unit
)
Hashtbl
.
t
)
=
Hashtbl
.
create
0
in
let
(
block_slots
:
(
node_id
Stack
.
t
)
Stack
.
t
)
=
Stack
.
create
()
in
let
(
implicit_init_block_slots
:
(
node_id
,
node_id
)
Hashtbl
.
t
)
=
Hashtbl
.
create
0
in
let
push_slot
sl
=
Stack
.
push
sl
(
Stack
.
top
block_slots
)
in
let
mark_slot_init
sl
=
Stack
.
push
sl
(
Stack
.
top
live_block_slots
)
Hashtbl
.
replace
live_block_slots
sl
(
)
in
let
visit_block_pre
b
=
Stack
.
push
(
Stack
.
create
()
)
live_
block_slots
;
Stack
.
push
(
Stack
.
create
()
)
block_slots
;
begin
match
htab_search
implicit_init_block_slots
b
.
id
with
None
->
()
|
Some
slot
->
mark_slot_init
slot
|
Some
slot
->
push_slot
slot
;
mark_slot_init
slot
end
;
inner
.
Walk
.
visit_block_pre
b
in
...
...
@@ -1026,7 +1033,7 @@ let lifecycle_visitor
let
visit_block_post
b
=
inner
.
Walk
.
visit_block_post
b
;
let
blk_
live
=
Stack
.
pop
live_
block_slots
in
let
blk_
slots
=
Stack
.
pop
block_slots
in
let
stmts
=
b
.
node
in
let
len
=
Array
.
length
stmts
in
if
len
>
0
...
...
@@ -1038,8 +1045,13 @@ let lifecycle_visitor
|
Ast
.
STMT_be
_
->
()
(* Taken care of in visit_stmt_post below. *)
|
_
->
let
slots
=
stk_elts_from_top
blk_live
in
note_drops
s
slots
let
slots
=
stk_elts_from_bot
blk_slots
in
let
live
=
List
.
filter
(
fun
i
->
Hashtbl
.
mem
live_block_slots
i
)
slots
in
note_drops
s
live
end
;
in
...
...
@@ -1081,6 +1093,9 @@ let lifecycle_visitor
init_lval
lv_dst
end
;
|
Ast
.
STMT_decl
(
Ast
.
DECL_slot
(
_
,
sloti
))
->
push_slot
sloti
.
id
|
Ast
.
STMT_init_rec
(
lv_dst
,
_
,
_
)
|
Ast
.
STMT_init_tup
(
lv_dst
,
_
)
|
Ast
.
STMT_init_vec
(
lv_dst
,
_
)
...
...
@@ -1117,9 +1132,14 @@ let lifecycle_visitor
match
s
.
node
with
Ast
.
STMT_ret
_
|
Ast
.
STMT_be
_
->
let
stks
=
stk_elts_from_top
live_block_slots
in
let
slots
=
List
.
concat
(
List
.
map
stk_elts_from_top
stks
)
in
note_drops
s
slots
let
stks
=
stk_elts_from_top
block_slots
in
let
slots
=
List
.
concat
(
List
.
map
stk_elts_from_bot
stks
)
in
let
live
=
List
.
filter
(
fun
i
->
Hashtbl
.
mem
live_block_slots
i
)
slots
in
note_drops
s
live
|
_
->
()
in
...
...
src/test/run-pass/vec-late-init.rs
0 → 100644
浏览文件 @
b3cf793b
fn
main
()
{
let
vec
[
int
]
later
;
if
(
true
)
{
later
=
vec
(
1
);
}
else
{
later
=
vec
(
2
);
}
log
later
.
(
0
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录