Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3bbf2fd7
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,发现更多精彩内容 >>
提交
3bbf2fd7
编写于
5月 21, 2018
作者:
O
Oliver Schneider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove Pointer::zero in favor of Pointer::from
上级
d7324631
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
16 addition
and
21 deletion
+16
-21
src/librustc/mir/interpret/mod.rs
src/librustc/mir/interpret/mod.rs
+7
-4
src/librustc_mir/hair/cx/mod.rs
src/librustc_mir/hair/cx/mod.rs
+2
-4
src/librustc_mir/hair/pattern/mod.rs
src/librustc_mir/hair/pattern/mod.rs
+2
-4
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/interpret/eval_context.rs
+1
-2
src/librustc_mir/interpret/memory.rs
src/librustc_mir/interpret/memory.rs
+3
-6
src/librustc_mir/interpret/place.rs
src/librustc_mir/interpret/place.rs
+1
-1
未找到文件。
src/librustc/mir/interpret/mod.rs
浏览文件 @
3bbf2fd7
...
...
@@ -115,15 +115,18 @@ pub struct Pointer {
pub
offset
:
Size
,
}
/// Produces a `Pointer` which points to the beginning of the Allocation
impl
From
<
AllocId
>
for
Pointer
{
fn
from
(
alloc_id
:
AllocId
)
->
Self
{
Pointer
::
new
(
alloc_id
,
Size
::
ZERO
)
}
}
impl
<
'tcx
>
Pointer
{
pub
fn
new
(
alloc_id
:
AllocId
,
offset
:
Size
)
->
Self
{
Pointer
{
alloc_id
,
offset
}
}
pub
fn
zero
(
alloc_id
:
AllocId
)
->
Self
{
Pointer
::
new
(
alloc_id
,
Size
::
ZERO
)
}
pub
(
crate
)
fn
wrapping_signed_offset
<
C
:
HasDataLayout
>
(
self
,
i
:
i64
,
cx
:
C
)
->
Self
{
Pointer
::
new
(
self
.alloc_id
,
...
...
src/librustc_mir/hair/cx/mod.rs
浏览文件 @
3bbf2fd7
...
...
@@ -182,16 +182,14 @@ pub fn const_eval_literal(
LitKind
::
Str
(
ref
s
,
_
)
=>
{
let
s
=
s
.as_str
();
let
id
=
self
.tcx
.allocate_bytes
(
s
.as_bytes
());
let
ptr
=
Pointer
::
zero
(
id
);
ConstValue
::
ScalarPair
(
Scalar
::
Ptr
(
ptr
),
Scalar
::
Ptr
(
id
.into
()
),
Scalar
::
from_u128
(
s
.len
()
as
u128
),
)
},
LitKind
::
ByteStr
(
ref
data
)
=>
{
let
id
=
self
.tcx
.allocate_bytes
(
data
);
let
ptr
=
Pointer
::
zero
(
id
);
ConstValue
::
Scalar
(
ptr
.into
())
ConstValue
::
Scalar
(
Scalar
::
Ptr
(
id
.into
()))
},
LitKind
::
Byte
(
n
)
=>
ConstValue
::
Scalar
(
Scalar
::
Bytes
(
n
as
u128
)),
LitKind
::
Int
(
n
,
_
)
if
neg
=>
{
...
...
src/librustc_mir/hair/pattern/mod.rs
浏览文件 @
3bbf2fd7
...
...
@@ -1128,16 +1128,14 @@ fn lit_to_const<'a, 'tcx>(lit: &'tcx ast::LitKind,
LitKind
::
Str
(
ref
s
,
_
)
=>
{
let
s
=
s
.as_str
();
let
id
=
tcx
.allocate_bytes
(
s
.as_bytes
());
let
ptr
=
Pointer
::
zero
(
id
);
ConstValue
::
ScalarPair
(
Scalar
::
Ptr
(
ptr
),
Scalar
::
Ptr
(
id
.into
()
),
Scalar
::
from_u128
(
s
.len
()
as
u128
),
)
},
LitKind
::
ByteStr
(
ref
data
)
=>
{
let
id
=
tcx
.allocate_bytes
(
data
);
let
ptr
=
Pointer
::
zero
(
id
);
ConstValue
::
Scalar
(
ptr
.into
())
ConstValue
::
Scalar
(
Scalar
::
Ptr
(
id
.into
()))
},
LitKind
::
Byte
(
n
)
=>
ConstValue
::
Scalar
(
Scalar
::
Bytes
(
n
as
u128
)),
LitKind
::
Int
(
n
,
_
)
=>
{
...
...
src/librustc_mir/interpret/eval_context.rs
浏览文件 @
3bbf2fd7
...
...
@@ -1019,8 +1019,7 @@ pub fn read_global_as_value(&mut self, gid: GlobalId<'tcx>, ty: Ty<'tcx>) -> Eva
.lock
()
.intern_static
(
gid
.instance
.def_id
());
let
layout
=
self
.layout_of
(
ty
)
?
;
let
ptr
=
Pointer
::
zero
(
alloc_id
);
return
Ok
(
Value
::
ByRef
(
ptr
.into
(),
layout
.align
))
return
Ok
(
Value
::
ByRef
(
Scalar
::
Ptr
(
alloc_id
.into
()),
layout
.align
))
}
let
cv
=
self
.const_eval
(
gid
)
?
;
self
.const_to_value
(
&
cv
.val
,
ty
)
...
...
src/librustc_mir/interpret/memory.rs
浏览文件 @
3bbf2fd7
...
...
@@ -72,13 +72,11 @@ pub fn allocations<'x>(
}
pub
fn
create_fn_alloc
(
&
mut
self
,
instance
:
Instance
<
'tcx
>
)
->
Pointer
{
let
id
=
self
.tcx.alloc_map
.lock
()
.create_fn_alloc
(
instance
);
Pointer
::
zero
(
id
)
self
.tcx.alloc_map
.lock
()
.create_fn_alloc
(
instance
)
.into
()
}
pub
fn
allocate_bytes
(
&
mut
self
,
bytes
:
&
[
u8
])
->
Pointer
{
let
id
=
self
.tcx
.allocate_bytes
(
bytes
);
Pointer
::
zero
(
id
)
self
.tcx
.allocate_bytes
(
bytes
)
.into
()
}
/// kind is `None` for statics
...
...
@@ -109,8 +107,7 @@ pub fn allocate(
align
:
Align
,
kind
:
Option
<
MemoryKind
<
M
::
MemoryKinds
>>
,
)
->
EvalResult
<
'tcx
,
Pointer
>
{
let
id
=
self
.allocate_value
(
Allocation
::
undef
(
size
,
align
),
kind
)
?
;
Ok
(
Pointer
::
zero
(
id
))
self
.allocate_value
(
Allocation
::
undef
(
size
,
align
),
kind
)
.map
(
Pointer
::
from
)
}
pub
fn
reallocate
(
...
...
src/librustc_mir/interpret/place.rs
浏览文件 @
3bbf2fd7
...
...
@@ -210,7 +210,7 @@ pub fn eval_place(&mut self, mir_place: &mir::Place<'tcx>) -> EvalResult<'tcx, P
};
let
alloc
=
Machine
::
init_static
(
self
,
cid
)
?
;
Place
::
Ptr
{
ptr
:
Pointer
::
zero
(
alloc
)
.into
(
),
ptr
:
Scalar
::
Ptr
(
alloc
.into
()
),
align
:
layout
.align
,
extra
:
PlaceExtra
::
None
,
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录