Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b039be1e
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,发现更多精彩内容 >>
提交
b039be1e
编写于
1月 14, 2011
作者:
G
Graydon Hoare
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass tydescs to parametric fns.
上级
fe1a4ab2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
6 deletion
+33
-6
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+33
-6
未找到文件。
src/comp/middle/trans.rs
浏览文件 @
b039be1e
...
@@ -311,6 +311,7 @@ fn type_of(@crate_ctxt cx, @ty.t t) -> TypeRef {
...
@@ -311,6 +311,7 @@ fn type_of(@crate_ctxt cx, @ty.t t) -> TypeRef {
ret
llty
;
ret
llty
;
}
}
// NB: this function must match the ABI assumptions of trans_args exactly.
fn
type_of_fn_full
(
@
crate_ctxt
cx
,
fn
type_of_fn_full
(
@
crate_ctxt
cx
,
option
.t
[
TypeRef
]
obj_self
,
option
.t
[
TypeRef
]
obj_self
,
vec
[
ty
.arg
]
inputs
,
vec
[
ty
.arg
]
inputs
,
...
@@ -1758,17 +1759,20 @@ fn get_pat_union_ptr(@block_ctxt cx, vec[@ast.pat] subpats, ValueRef llval)
...
@@ -1758,17 +1759,20 @@ fn get_pat_union_ptr(@block_ctxt cx, vec[@ast.pat] subpats, ValueRef llval)
type
lval_result
=
rec
(
result
res
,
type
lval_result
=
rec
(
result
res
,
bool
is_mem
,
bool
is_mem
,
option
.t
[
vec
[
ValueRef
]]
lltys
,
option
.t
[
ValueRef
]
llobj
);
option
.t
[
ValueRef
]
llobj
);
fn
lval_mem
(
@
block_ctxt
cx
,
ValueRef
val
)
->
lval_result
{
fn
lval_mem
(
@
block_ctxt
cx
,
ValueRef
val
)
->
lval_result
{
ret
rec
(
res
=
res
(
cx
,
val
),
ret
rec
(
res
=
res
(
cx
,
val
),
is_mem
=
true
,
is_mem
=
true
,
lltys
=
none
[
vec
[
ValueRef
]],
llobj
=
none
[
ValueRef
]);
llobj
=
none
[
ValueRef
]);
}
}
fn
lval_val
(
@
block_ctxt
cx
,
ValueRef
val
)
->
lval_result
{
fn
lval_val
(
@
block_ctxt
cx
,
ValueRef
val
)
->
lval_result
{
ret
rec
(
res
=
res
(
cx
,
val
),
ret
rec
(
res
=
res
(
cx
,
val
),
is_mem
=
false
,
is_mem
=
false
,
lltys
=
none
[
vec
[
ValueRef
]],
llobj
=
none
[
ValueRef
]);
llobj
=
none
[
ValueRef
]);
}
}
...
@@ -1800,11 +1804,19 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
...
@@ -1800,11 +1804,19 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
auto
fn_item
=
cx
.fcx.ccx.items
.get
(
did
);
auto
fn_item
=
cx
.fcx.ccx.items
.get
(
did
);
auto
monoty
=
node_ann_type
(
cx
.fcx.ccx
,
ann
);
auto
monoty
=
node_ann_type
(
cx
.fcx.ccx
,
ann
);
auto
tys
=
ty
.resolve_ty_params
(
fn_item
,
monoty
);
auto
tys
=
ty
.resolve_ty_params
(
fn_item
,
monoty
);
auto
vt
=
none
[
vec
[
ValueRef
]];
// TODO: build a closure with the type parameters that
if
(
_
vec
.len
[
@
ty
.t
](
tys
)
!=
0u
)
{
// result
let
vec
[
ValueRef
]
tydescs
=
vec
();
for
(
@
ty
.t
t
in
tys
)
{
append
[
ValueRef
](
tydescs
,
get_tydesc
(
cx
,
t
));
}
vt
=
some
[
vec
[
ValueRef
]](
tydescs
);
}
ret
lval_val
(
cx
,
cx
.fcx.ccx.fn_pairs
.get
(
did
));
auto
lv
=
lval_val
(
cx
,
cx
.fcx.ccx.fn_pairs
.get
(
did
));
ret
rec
(
lltys
=
vt
with
lv
);
}
}
case
(
ast
.def_obj
(
?
did
))
{
case
(
ast
.def_obj
(
?
did
))
{
check
(
cx
.fcx.ccx.fn_pairs
.contains_key
(
did
));
check
(
cx
.fcx.ccx.fn_pairs
.contains_key
(
did
));
...
@@ -1952,9 +1964,13 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
...
@@ -1952,9 +1964,13 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
}
}
impure
fn
trans_args
(
@
block_ctxt
cx
,
ValueRef
llclosure
,
// NB: this function must match the ABI assumptions of type_of_fn_full exactly.
impure
fn
trans_args
(
@
block_ctxt
cx
,
ValueRef
llclosure
,
option
.t
[
ValueRef
]
llobj
,
option
.t
[
ValueRef
]
llobj
,
&
vec
[
@
ast
.expr
]
es
,
@
ty
.t
fn_ty
)
option
.t
[
vec
[
ValueRef
]]
lltydescs
,
&
vec
[
@
ast
.expr
]
es
,
@
ty
.t
fn_ty
)
->
tup
(
@
block_ctxt
,
vec
[
ValueRef
])
{
->
tup
(
@
block_ctxt
,
vec
[
ValueRef
])
{
let
vec
[
ValueRef
]
vs
=
vec
(
cx
.fcx.lltaskptr
);
let
vec
[
ValueRef
]
vs
=
vec
(
cx
.fcx.lltaskptr
);
let
@
block_ctxt
bcx
=
cx
;
let
@
block_ctxt
bcx
=
cx
;
...
@@ -1965,6 +1981,15 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
...
@@ -1965,6 +1981,15 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
case
(
_
)
{
fail
;
}
case
(
_
)
{
fail
;
}
}
}
alt
(
lltydescs
)
{
case
(
some
[
vec
[
ValueRef
]](
?
tys
))
{
for
(
ValueRef
t
in
tys
)
{
vs
+=
t
;
}
}
case
(
_
)
{
}
}
alt
(
llobj
)
{
alt
(
llobj
)
{
case
(
some
[
ValueRef
](
?
ob
))
{
case
(
some
[
ValueRef
](
?
ob
))
{
// Every object is always found in memory,
// Every object is always found in memory,
...
@@ -2250,7 +2275,9 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
...
@@ -2250,7 +2275,9 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
}
}
auto
fn_ty
=
ty
.expr_ty
(
f
);
auto
fn_ty
=
ty
.expr_ty
(
f
);
auto
ret_ty
=
ty
.ann_to_type
(
ann
);
auto
ret_ty
=
ty
.ann_to_type
(
ann
);
auto
args_res
=
trans_args
(
f_res
.res.bcx
,
llclosure
,
f_res
.llobj
,
auto
args_res
=
trans_args
(
f_res
.res.bcx
,
llclosure
,
f_res
.llobj
,
f_res
.lltys
,
args
,
fn_ty
);
args
,
fn_ty
);
auto
real_retval
=
args_res
._0.build
.FastCall
(
faddr
,
args_res
._1
);
auto
real_retval
=
args_res
._0.build
.FastCall
(
faddr
,
args_res
._1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录