Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
75fddee7
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,发现更多精彩内容 >>
未验证
提交
75fddee7
编写于
6月 19, 2017
作者:
O
Oliver Schneider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify the return lvalue
上级
a2baeb51
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
19 addition
and
12 deletion
+19
-12
src/eval_context.rs
src/eval_context.rs
+3
-4
src/lvalue.rs
src/lvalue.rs
+9
-1
src/step.rs
src/step.rs
+2
-2
src/terminator/drop.rs
src/terminator/drop.rs
+1
-1
src/terminator/mod.rs
src/terminator/mod.rs
+4
-4
未找到文件。
src/eval_context.rs
浏览文件 @
75fddee7
...
...
@@ -66,8 +66,7 @@ pub struct Frame<'tcx> {
pub
return_to_block
:
StackPopCleanup
,
/// The location where the result of the current stack frame should be written to.
/// None if the function is a diverging function
pub
return_lvalue
:
Option
<
Lvalue
<
'tcx
>>
,
pub
return_lvalue
:
Lvalue
<
'tcx
>
,
/// The list of locals for this stack frame, stored in order as
/// `[arguments..., variables..., temporaries...]`. The locals are stored as `Option<Value>`s.
...
...
@@ -272,7 +271,7 @@ pub fn push_stack_frame(
instance
:
ty
::
Instance
<
'tcx
>
,
span
:
codemap
::
Span
,
mir
:
&
'tcx
mir
::
Mir
<
'tcx
>
,
return_lvalue
:
Option
<
Lvalue
<
'tcx
>
>
,
return_lvalue
:
Lvalue
<
'tcx
>
,
return_to_block
:
StackPopCleanup
,
)
->
EvalResult
<
'tcx
>
{
::
log_settings
::
settings
()
.indentation
+=
1
;
...
...
@@ -329,7 +328,7 @@ pub(super) fn pop_stack_frame(&mut self) -> EvalResult<'tcx> {
::
log_settings
::
settings
()
.indentation
-=
1
;
let
frame
=
self
.stack
.pop
()
.expect
(
"tried to pop a stack frame, but there were none"
);
match
frame
.return_to_block
{
StackPopCleanup
::
MarkStatic
(
mutable
)
=>
if
let
Lvalue
::
Global
(
id
)
=
frame
.return_lvalue
.expect
(
"diverging static"
)
{
StackPopCleanup
::
MarkStatic
(
mutable
)
=>
if
let
Lvalue
::
Global
(
id
)
=
frame
.return_lvalue
{
let
global_value
=
self
.globals
.get_mut
(
&
id
)
.expect
(
"global should have been cached (static)"
);
match
global_value
.value
{
...
...
src/lvalue.rs
浏览文件 @
75fddee7
...
...
@@ -64,6 +64,14 @@ pub struct Global<'tcx> {
}
impl
<
'tcx
>
Lvalue
<
'tcx
>
{
/// Produces an Lvalue that will error if attempted to be read from
pub
fn
undef
()
->
Self
{
Lvalue
::
Ptr
{
ptr
:
PrimVal
::
Undef
,
extra
:
LvalueExtra
::
None
,
}
}
pub
fn
zst
()
->
Self
{
Self
::
from_ptr
(
Pointer
::
zst_ptr
())
}
...
...
@@ -148,7 +156,7 @@ pub(super) fn eval_and_read_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> Eva
pub
(
super
)
fn
eval_lvalue
(
&
mut
self
,
mir_lvalue
:
&
mir
::
Lvalue
<
'tcx
>
)
->
EvalResult
<
'tcx
,
Lvalue
<
'tcx
>>
{
use
rustc
::
mir
::
Lvalue
::
*
;
let
lvalue
=
match
*
mir_lvalue
{
Local
(
mir
::
RETURN_POINTER
)
=>
self
.frame
()
.return_lvalue
.expect
(
"diverging function returned"
)
,
Local
(
mir
::
RETURN_POINTER
)
=>
self
.frame
()
.return_lvalue
,
Local
(
local
)
=>
Lvalue
::
Local
{
frame
:
self
.stack
.len
()
-
1
,
local
,
field
:
None
},
Static
(
ref
static_
)
=>
{
...
...
src/step.rs
浏览文件 @
75fddee7
...
...
@@ -192,7 +192,7 @@ fn global_item(
instance
,
span
,
mir
,
Some
(
Lvalue
::
Global
(
cid
)
),
Lvalue
::
Global
(
cid
),
cleanup
,
)
});
...
...
@@ -235,7 +235,7 @@ fn visit_constant(&mut self, constant: &mir::Constant<'tcx>, location: mir::Loca
this
.ecx
.push_stack_frame
(
this
.instance
,
constant
.span
,
mir
,
Some
(
Lvalue
::
Global
(
cid
)
),
Lvalue
::
Global
(
cid
),
StackPopCleanup
::
MarkStatic
(
false
),
)
});
...
...
src/terminator/drop.rs
浏览文件 @
75fddee7
...
...
@@ -49,7 +49,7 @@ pub(crate) fn drop(&mut self, arg: Value, mut instance: ty::Instance<'tcx>, ty:
instance
,
span
,
mir
,
Some
(
Lvalue
::
zst
()
),
Lvalue
::
zst
(
),
StackPopCleanup
::
None
,
)
?
;
...
...
src/terminator/mod.rs
浏览文件 @
75fddee7
...
...
@@ -30,7 +30,7 @@ pub(super) fn eval_terminator(
use
rustc
::
mir
::
TerminatorKind
::
*
;
match
terminator
.kind
{
Return
=>
{
self
.dump_local
(
self
.frame
()
.return_lvalue
.expect
(
"diverging function returned"
)
);
self
.dump_local
(
self
.frame
()
.return_lvalue
);
self
.pop_stack_frame
()
?
}
...
...
@@ -430,8 +430,8 @@ fn eval_fn_call_inner(
Err
(
other
)
=>
return
Err
(
other
),
};
let
(
return_lvalue
,
return_to_block
)
=
match
destination
{
Some
((
lvalue
,
block
))
=>
(
Some
(
lvalue
)
,
StackPopCleanup
::
Goto
(
block
)),
None
=>
(
None
,
StackPopCleanup
::
None
),
Some
((
lvalue
,
block
))
=>
(
lvalue
,
StackPopCleanup
::
Goto
(
block
)),
None
=>
(
Lvalue
::
undef
()
,
StackPopCleanup
::
None
),
};
self
.push_stack_frame
(
...
...
@@ -606,7 +606,7 @@ fn call_c_abi(
f_instance
,
mir
.span
,
mir
,
Some
(
Lvalue
::
zst
()
),
Lvalue
::
zst
(
),
StackPopCleanup
::
Goto
(
dest_block
),
)
?
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录