Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9c07f424
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,发现更多精彩内容 >>
提交
9c07f424
编写于
7月 23, 2017
作者:
O
Oliver Schneider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use rustc traits instead of our own
上级
4d38f8df
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
21 deletion
+19
-21
src/librustc_mir/interpret/cast.rs
src/librustc_mir/interpret/cast.rs
+1
-1
src/librustc_mir/interpret/memory.rs
src/librustc_mir/interpret/memory.rs
+14
-16
src/librustc_mir/interpret/value.rs
src/librustc_mir/interpret/value.rs
+4
-4
未找到文件。
src/librustc_mir/interpret/cast.rs
浏览文件 @
9c07f424
...
...
@@ -4,7 +4,7 @@
use
error
::{
EvalResult
,
EvalError
};
use
eval_context
::
EvalContext
;
use
value
::
PrimVal
;
use
memory
::{
MemoryPointer
,
HasDataLayout
};
use
memory
::{
MemoryPointer
,
PointerArithmetic
};
impl
<
'a
,
'tcx
>
EvalContext
<
'a
,
'tcx
>
{
pub
(
super
)
fn
cast_primval
(
...
...
src/librustc_mir/interpret/memory.rs
浏览文件 @
9c07f424
...
...
@@ -68,30 +68,30 @@ pub struct MemoryPointer {
pub
offset
:
u64
,
}
impl
MemoryPointer
{
impl
<
'tcx
>
MemoryPointer
{
pub
fn
new
(
alloc_id
:
AllocId
,
offset
:
u64
)
->
Self
{
MemoryPointer
{
alloc_id
,
offset
}
}
pub
(
crate
)
fn
wrapping_signed_offset
<
'a
,
L
:
HasDataLayout
<
'a
>
>
(
self
,
i
:
i64
,
l
:
L
)
->
Self
{
pub
(
crate
)
fn
wrapping_signed_offset
<
L
:
PointerArithmetic
>
(
self
,
i
:
i64
,
l
:
L
)
->
Self
{
MemoryPointer
::
new
(
self
.alloc_id
,
l
.wrapping_signed_offset
(
self
.offset
,
i
))
}
pub
(
crate
)
fn
overflowing_signed_offset
<
'a
,
L
:
HasDataLayout
<
'a
>
>
(
self
,
i
:
i128
,
l
:
L
)
->
(
Self
,
bool
)
{
pub
(
crate
)
fn
overflowing_signed_offset
<
L
:
PointerArithmetic
>
(
self
,
i
:
i128
,
l
:
L
)
->
(
Self
,
bool
)
{
let
(
res
,
over
)
=
l
.overflowing_signed_offset
(
self
.offset
,
i
);
(
MemoryPointer
::
new
(
self
.alloc_id
,
res
),
over
)
}
pub
(
crate
)
fn
signed_offset
<
'a
,
'tcx
,
L
:
HasDataLayout
<
'a
>
>
(
self
,
i
:
i64
,
l
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
pub
(
crate
)
fn
signed_offset
<
L
:
PointerArithmetic
>
(
self
,
i
:
i64
,
l
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
Ok
(
MemoryPointer
::
new
(
self
.alloc_id
,
l
.signed_offset
(
self
.offset
,
i
)
?
))
}
pub
(
crate
)
fn
overflowing_offset
<
'a
,
L
:
HasDataLayout
<
'a
>
>
(
self
,
i
:
u64
,
l
:
L
)
->
(
Self
,
bool
)
{
pub
(
crate
)
fn
overflowing_offset
<
L
:
PointerArithmetic
>
(
self
,
i
:
u64
,
l
:
L
)
->
(
Self
,
bool
)
{
let
(
res
,
over
)
=
l
.overflowing_offset
(
self
.offset
,
i
);
(
MemoryPointer
::
new
(
self
.alloc_id
,
res
),
over
)
}
pub
(
crate
)
fn
offset
<
'a
,
'tcx
,
L
:
HasDataLayout
<
'a
>
>
(
self
,
i
:
u64
,
l
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
pub
(
crate
)
fn
offset
<
L
:
PointerArithmetic
>
(
self
,
i
:
u64
,
l
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
Ok
(
MemoryPointer
::
new
(
self
.alloc_id
,
l
.offset
(
self
.offset
,
i
)
?
))
}
}
...
...
@@ -1183,9 +1183,7 @@ fn memory(&self) -> &Memory<'a, 'tcx> {
// Pointer arithmetic
////////////////////////////////////////////////////////////////////////////////
pub
(
crate
)
trait
HasDataLayout
<
'a
>
:
Copy
{
fn
data_layout
(
self
)
->
&
'a
TargetDataLayout
;
pub
trait
PointerArithmetic
:
layout
::
HasDataLayout
{
// These are not supposed to be overriden.
//// Trunace the given value to the pointer size; also return whether there was an overflow
...
...
@@ -1236,17 +1234,17 @@ fn wrapping_signed_offset(self, val: u64, i: i64) -> u64 {
}
}
impl
<
'a
>
HasDataLayout
<
'a
>
for
&
'a
TargetDataLayout
{
impl
<
T
:
layout
::
HasDataLayout
>
PointerArithmetic
for
T
{}
impl
<
'a
,
'tcx
>
layout
::
HasDataLayout
for
&
'a
Memory
<
'a
,
'tcx
>
{
#[inline]
fn
data_layout
(
self
)
->
&
'a
TargetDataLayout
{
self
fn
data_layout
(
&
self
)
->
&
TargetDataLayout
{
self
.layout
}
}
impl
<
'a
,
'b
,
'tcx
,
T
>
HasDataLayout
<
'a
>
for
&
'b
T
where
T
:
HasMemory
<
'a
,
'tcx
>
{
impl
<
'a
,
'tcx
>
layout
::
HasDataLayout
for
&
'a
EvalContext
<
'a
,
'tcx
>
{
#[inline]
fn
data_layout
(
self
)
->
&
'a
TargetDataLayout
{
fn
data_layout
(
&
self
)
->
&
TargetDataLayout
{
self
.memory
()
.layout
}
}
src/librustc_mir/interpret/value.rs
浏览文件 @
9c07f424
...
...
@@ -2,7 +2,7 @@
#![allow(float_cmp)]
use
error
::{
EvalError
,
EvalResult
};
use
memory
::{
Memory
,
MemoryPointer
,
HasMemory
,
HasDataLayout
};
use
memory
::{
Memory
,
MemoryPointer
,
HasMemory
,
PointerArithmetic
};
pub
(
super
)
fn
bytes_to_f32
(
bytes
:
u128
)
->
f32
{
f32
::
from_bits
(
bytes
as
u32
)
...
...
@@ -59,7 +59,7 @@ pub fn into_inner_primval(self) -> PrimVal {
self
.primval
}
pub
(
crate
)
fn
signed_offset
<
'a
,
L
:
HasDataLayout
<
'a
>
>
(
self
,
i
:
i64
,
layout
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
pub
(
crate
)
fn
signed_offset
<
L
:
PointerArithmetic
>
(
self
,
i
:
i64
,
layout
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
match
self
.primval
{
PrimVal
::
Bytes
(
b
)
=>
{
assert_eq!
(
b
as
u64
as
u128
,
b
);
...
...
@@ -70,7 +70,7 @@ pub(crate) fn signed_offset<'a, L: HasDataLayout<'a>>(self, i: i64, layout: L) -
}
}
pub
(
crate
)
fn
offset
<
'a
,
L
:
HasDataLayout
<
'a
>
>
(
self
,
i
:
u64
,
layout
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
pub
(
crate
)
fn
offset
<
L
:
PointerArithmetic
>
(
self
,
i
:
u64
,
layout
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
match
self
.primval
{
PrimVal
::
Bytes
(
b
)
=>
{
assert_eq!
(
b
as
u64
as
u128
,
b
);
...
...
@@ -81,7 +81,7 @@ pub(crate) fn offset<'a, L: HasDataLayout<'a>>(self, i: u64, layout: L) -> EvalR
}
}
pub
(
crate
)
fn
wrapping_signed_offset
<
'a
,
L
:
HasDataLayout
<
'a
>
>
(
self
,
i
:
i64
,
layout
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
pub
(
crate
)
fn
wrapping_signed_offset
<
L
:
PointerArithmetic
>
(
self
,
i
:
i64
,
layout
:
L
)
->
EvalResult
<
'tcx
,
Self
>
{
match
self
.primval
{
PrimVal
::
Bytes
(
b
)
=>
{
assert_eq!
(
b
as
u64
as
u128
,
b
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录