Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
911e46fb
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,发现更多精彩内容 >>
提交
911e46fb
编写于
10月 03, 2016
作者:
S
Scott Olson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update for changes in rustc.
上级
a08f0615
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
42 deletion
+20
-42
src/interpreter/mod.rs
src/interpreter/mod.rs
+15
-26
src/interpreter/terminator/intrinsics.rs
src/interpreter/terminator/intrinsics.rs
+4
-12
src/interpreter/terminator/mod.rs
src/interpreter/terminator/mod.rs
+1
-4
未找到文件。
src/interpreter/mod.rs
浏览文件 @
911e46fb
...
...
@@ -387,7 +387,7 @@ fn intrinsic_with_overflow(
};
let
overflowed
=
self
.intrinsic_overflowing
(
op
,
left
,
right
,
dest
)
?
;
let
offset
=
tup_layout
.
field_offset
(
1
)
.bytes
()
as
isize
;
let
offset
=
tup_layout
.
offsets
[
1
]
.bytes
()
as
isize
;
self
.memory
.write_bool
(
dest
.offset
(
offset
),
overflowed
)
}
...
...
@@ -460,8 +460,7 @@ fn eval_rvalue_into_lvalue(
use
rustc
::
ty
::
layout
::
Layout
::
*
;
match
*
dest_layout
{
Univariant
{
ref
variant
,
..
}
=>
{
let
offsets
=
iter
::
once
(
0
)
.chain
(
variant
.offset_after_field
.iter
()
.map
(|
s
|
s
.bytes
()));
let
offsets
=
variant
.offsets
.iter
()
.map
(|
s
|
s
.bytes
());
self
.assign_fields
(
dest
,
offsets
,
operands
)
?
;
}
...
...
@@ -478,11 +477,14 @@ fn eval_rvalue_into_lvalue(
if
let
mir
::
AggregateKind
::
Adt
(
adt_def
,
variant
,
_
,
_
)
=
*
kind
{
let
discr_val
=
adt_def
.variants
[
variant
]
.disr_val
.to_u64_unchecked
();
let
discr_size
=
discr
.size
()
.bytes
()
as
usize
;
self
.memory
.write_uint
(
dest
,
discr_val
,
discr_size
)
?
;
let
discr_offset
=
variants
[
variant
]
.offsets
[
0
]
.bytes
()
as
isize
;
let
discr_dest
=
dest
.offset
(
discr_offset
);
self
.memory
.write_uint
(
discr_dest
,
discr_val
,
discr_size
)
?
;
let
offsets
=
variants
[
variant
]
.offset_after_field
.iter
()
// Don't include the first offset; it's for the discriminant.
let
field_offsets
=
variants
[
variant
]
.offsets
.iter
()
.skip
(
1
)
.map
(|
s
|
s
.bytes
());
self
.assign_fields
(
dest
,
offsets
,
operands
)
?
;
self
.assign_fields
(
dest
,
field_
offsets
,
operands
)
?
;
}
else
{
bug!
(
"tried to assign {:?} to Layout::General"
,
kind
);
}
...
...
@@ -508,8 +510,7 @@ fn eval_rvalue_into_lvalue(
StructWrappedNullablePointer
{
nndiscr
,
ref
nonnull
,
ref
discrfield
}
=>
{
if
let
mir
::
AggregateKind
::
Adt
(
_
,
variant
,
_
,
_
)
=
*
kind
{
if
nndiscr
==
variant
as
u64
{
let
offsets
=
iter
::
once
(
0
)
.chain
(
nonnull
.offset_after_field
.iter
()
.map
(|
s
|
s
.bytes
()));
let
offsets
=
nonnull
.offsets
.iter
()
.map
(|
s
|
s
.bytes
());
try!
(
self
.assign_fields
(
dest
,
offsets
,
operands
));
}
else
{
for
operand
in
operands
{
...
...
@@ -715,7 +716,7 @@ fn get_field_offset(&self, ty: Ty<'tcx>, field_index: usize) -> EvalResult<'tcx,
use
rustc
::
ty
::
layout
::
Layout
::
*
;
match
*
layout
{
Univariant
{
ref
variant
,
..
}
=>
{
Ok
(
variant
.
field_offset
(
field_index
)
)
Ok
(
variant
.
offsets
[
field_index
]
)
}
FatPointer
{
..
}
=>
{
let
bytes
=
layout
::
FAT_PTR_ADDR
*
self
.memory
.pointer_size
();
...
...
@@ -801,11 +802,11 @@ fn eval_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult<'tcx, Lvalue
use
rustc
::
ty
::
layout
::
Layout
::
*
;
let
field
=
field
.index
();
let
offset
=
match
*
base_layout
{
Univariant
{
ref
variant
,
..
}
=>
variant
.
field_offset
(
field
)
,
Univariant
{
ref
variant
,
..
}
=>
variant
.
offsets
[
field
]
,
General
{
ref
variants
,
..
}
=>
{
if
let
LvalueExtra
::
DowncastVariant
(
variant_idx
)
=
base
.extra
{
// +1 for the discriminant, which is field 0
variants
[
variant_idx
]
.
field_offset
(
field
+
1
)
variants
[
variant_idx
]
.
offsets
[
field
+
1
]
}
else
{
bug!
(
"field access on enum had no variant index"
);
}
...
...
@@ -814,7 +815,9 @@ fn eval_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult<'tcx, Lvalue
assert_eq!
(
field
.index
(),
0
);
return
Ok
(
base
);
}
StructWrappedNullablePointer
{
ref
nonnull
,
..
}
=>
nonnull
.field_offset
(
field
),
StructWrappedNullablePointer
{
ref
nonnull
,
..
}
=>
{
nonnull
.offsets
[
field
]
}
_
=>
bug!
(
"field access on non-product type: {:?}"
,
base_layout
),
};
...
...
@@ -1289,17 +1292,3 @@ fn size(self) -> Size {
}
}
}
trait
StructExt
{
fn
field_offset
(
&
self
,
index
:
usize
)
->
Size
;
}
impl
StructExt
for
layout
::
Struct
{
fn
field_offset
(
&
self
,
index
:
usize
)
->
Size
{
if
index
==
0
{
Size
::
from_bytes
(
0
)
}
else
{
self
.offset_after_field
[
index
-
1
]
}
}
}
src/interpreter/terminator/intrinsics.rs
浏览文件 @
911e46fb
...
...
@@ -246,20 +246,12 @@ fn size_and_align_of_dst(
let
layout
=
self
.type_layout
(
ty
);
debug!
(
"DST {} layout: {:?}"
,
ty
,
layout
);
// Returns size in bytes of all fields except the last one
// (we will be recursing on the last one).
fn
local_prefix_bytes
(
variant
:
&
ty
::
layout
::
Struct
)
->
u64
{
let
fields
=
variant
.offset_after_field
.len
();
if
fields
>
1
{
variant
.offset_after_field
[
fields
-
2
]
.bytes
()
}
else
{
0
}
}
let
(
sized_size
,
sized_align
)
=
match
*
layout
{
ty
::
layout
::
Layout
::
Univariant
{
ref
variant
,
..
}
=>
{
(
local_prefix_bytes
(
variant
),
variant
.align
.abi
())
// The offset of the start of the last field gives the size of the
// sized part of the type.
let
size
=
variant
.offsets
.last
()
.map_or
(
0
,
|
f
|
f
.bytes
());
(
size
,
variant
.align
.abi
())
}
_
=>
{
bug!
(
"size_and_align_of_dst: expcted Univariant for `{}`, found {:#?}"
,
...
...
src/interpreter/terminator/mod.rs
浏览文件 @
911e46fb
...
...
@@ -5,7 +5,6 @@
use
rustc
::
ty
::
layout
::
Layout
;
use
rustc
::
ty
::
subst
::
Substs
;
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
,
BareFnTy
};
use
std
::
iter
;
use
std
::
rc
::
Rc
;
use
syntax
::
codemap
::{
DUMMY_SP
,
Span
};
use
syntax
::{
ast
,
attr
};
...
...
@@ -343,9 +342,7 @@ fn unpack_fn_args(&self, args: &mut Vec<(Value, Ty<'tcx>)>) {
match
(
&
last_ty
.sty
,
last_layout
)
{
(
&
ty
::
TyTuple
(
fields
),
&
Layout
::
Univariant
{
ref
variant
,
..
})
=>
{
let
offsets
=
iter
::
once
(
0
)
.chain
(
variant
.offset_after_field
.iter
()
.map
(|
s
|
s
.bytes
()));
let
offsets
=
variant
.offsets
.iter
()
.map
(|
s
|
s
.bytes
());
let
last_ptr
=
match
last
{
Value
::
ByRef
(
ptr
)
=>
ptr
,
_
=>
bug!
(
"rust-call ABI tuple argument wasn't Value::ByRef"
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录