Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5fe80a0d
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,发现更多精彩内容 >>
提交
5fe80a0d
编写于
8月 26, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rt: Allow closures to be logged
上级
b894069a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
11 deletion
+52
-11
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+6
-2
src/rt/rust_shape.cpp
src/rt/rust_shape.cpp
+11
-7
src/rt/rust_shape.h
src/rt/rust_shape.h
+35
-2
未找到文件。
src/comp/middle/trans.rs
浏览文件 @
5fe80a0d
...
...
@@ -942,11 +942,12 @@ fn trans_stack_local_derived_tydesc(cx: &@block_ctxt, llsz: ValueRef,
ret
llmyroottydesc
;
}
// Objects
store their type parameters differently (in the object itself
// rather than in the type descriptor).
// Objects
and closures store their type parameters differently (in the object
//
or closure itself
rather than in the type descriptor).
tag
ty_param_storage
{
tps_normal
;
tps_obj
(
uint
);
tps_fn
(
uint
);
}
fn
get_derived_tydesc
(
cx
:
&@
block_ctxt
,
t
:
ty
::
t
,
escapes
:
bool
,
...
...
@@ -1004,10 +1005,13 @@ fn get_derived_tydesc(cx: &@block_ctxt, t: ty::t, escapes: bool,
bld
::
PointerCast
(
bcx
,
llparamtydescs
,
T_ptr
(
T_ptr
(
bcx_ccx
(
bcx
)
.tydesc_type
)));
// The top bit indicates whether this type descriptor describes an object
// (0) or a function (1).
let
obj_params
;
alt
storage
{
tps_normal
.
{
obj_params
=
0u
;
}
tps_obj
(
np
)
{
obj_params
=
np
;
}
tps_fn
(
np
)
{
obj_params
=
0x80000000u
|
np
;
}
}
let
v
;
...
...
src/rt/rust_shape.cpp
浏览文件 @
5fe80a0d
...
...
@@ -42,7 +42,17 @@ type_param::make(const type_desc **tydescs, unsigned n_tydescs,
return
ptrs
;
}
// Constructs type parameters from an object shape. This is a bit messy,
// Constructs type parameters from a function shape. This is a bit messy,
// because it requires that the function shape have a specific format.
type_param
*
type_param
::
from_fn_shape
(
const
uint8_t
*
sp
,
ptr
dp
,
arena
&
arena
)
{
const
type_desc
*
tydesc
=
bump_dp
<
const
type_desc
*>
(
dp
);
const
type_desc
**
descs
=
(
const
type_desc
**
)(
dp
+
tydesc
->
size
);
unsigned
n_tydescs
=
tydesc
->
n_obj_params
&
0x7fffffff
;
return
make
(
descs
,
n_tydescs
,
arena
);
}
// Constructs type parameters from an object shape. This is also a bit messy,
// because it requires that the object shape have a specific format.
type_param
*
type_param
::
from_obj_shape
(
const
uint8_t
*
sp
,
ptr
dp
,
arena
&
arena
)
{
...
...
@@ -460,12 +470,6 @@ log::walk_vec(bool align, bool is_pod, const std::pair<ptr,ptr> &data) {
out
<<
"]"
;
}
void
log
::
walk_obj
(
bool
align
)
{
out
<<
"obj"
;
data
<
log
,
ptr
>::
walk_obj_contents
(
align
,
dp
);
}
void
log
::
walk_variant
(
bool
align
,
tag_info
&
tinfo
,
uint32_t
variant_id
,
const
std
::
pair
<
const
uint8_t
*
,
const
uint8_t
*>
...
...
src/rt/rust_shape.h
浏览文件 @
5fe80a0d
...
...
@@ -245,6 +245,8 @@ public:
const
rust_shape_tables
*
tables
;
const
type_param
*
params
;
// subparameters
// Constructs type parameters from a function shape.
static
type_param
*
from_fn_shape
(
const
uint8_t
*
sp
,
ptr
dp
,
arena
&
arena
);
// Creates type parameters from an object shape description.
static
type_param
*
from_obj_shape
(
const
uint8_t
*
sp
,
ptr
dp
,
arena
&
arena
);
...
...
@@ -718,6 +720,7 @@ template<typename T,typename U>
class
data
:
public
ctxt
<
data
<
T
,
U
>
>
{
protected:
void
walk_box_contents
(
bool
align
);
void
walk_fn_contents
(
bool
align
,
ptr
&
dp
);
void
walk_obj_contents
(
bool
align
,
ptr
&
dp
);
void
walk_variant
(
bool
align
,
tag_info
&
tinfo
,
uint32_t
variant
);
...
...
@@ -894,6 +897,28 @@ data<T,U>::walk_tag(bool align, tag_info &tinfo) {
dp
=
end_dp
;
}
template
<
typename
T
,
typename
U
>
void
data
<
T
,
U
>::
walk_fn_contents
(
bool
align
,
ptr
&
dp
)
{
dp
+=
sizeof
(
void
*
);
// Skip over the code pointer.
uint8_t
*
box_ptr
=
bump_dp
<
uint8_t
*>
(
dp
);
type_desc
*
subtydesc
=
*
reinterpret_cast
<
type_desc
**>
(
box_ptr
+
sizeof
(
void
*
));
ptr
closure_dp
(
box_ptr
+
sizeof
(
void
*
));
if
(
!
box_ptr
)
return
;
arena
arena
;
type_param
*
params
=
type_param
::
from_fn_shape
(
subtydesc
->
shape
,
closure_dp
,
arena
);
closure_dp
+=
sizeof
(
void
*
);
T
sub
(
*
static_cast
<
T
*>
(
this
),
subtydesc
->
shape
,
params
,
subtydesc
->
shape_tables
,
closure_dp
);
sub
.
walk
(
true
);
}
template
<
typename
T
,
typename
U
>
void
data
<
T
,
U
>::
walk_obj_contents
(
bool
align
,
ptr
&
dp
)
{
...
...
@@ -967,7 +992,16 @@ private:
data
<
log
,
ptr
>::
walk_box_contents
(
align
);
}
void
walk_fn
(
bool
align
)
{
out
<<
"fn"
;
}
void
walk_fn
(
bool
align
)
{
out
<<
"fn"
;
data
<
log
,
ptr
>::
walk_fn_contents
(
align
,
dp
);
}
void
walk_obj
(
bool
align
)
{
out
<<
"obj"
;
data
<
log
,
ptr
>::
walk_obj_contents
(
align
,
dp
);
}
void
walk_port
(
bool
align
)
{
out
<<
"port"
;
}
void
walk_chan
(
bool
align
)
{
out
<<
"chan"
;
}
void
walk_task
(
bool
align
)
{
out
<<
"task"
;
}
...
...
@@ -988,7 +1022,6 @@ private:
void
walk_struct
(
bool
align
,
const
uint8_t
*
end_sp
);
void
walk_vec
(
bool
align
,
bool
is_pod
,
const
std
::
pair
<
ptr
,
ptr
>
&
data
);
void
walk_obj
(
bool
align
);
void
walk_variant
(
bool
align
,
tag_info
&
tinfo
,
uint32_t
variant_id
,
const
std
::
pair
<
const
uint8_t
*
,
const
uint8_t
*>
variant_ptr_and_end
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录