Skip to content

Commit a63696d

Browse files
author
Rafael Avila de Espindola
committed
Add a more specialized decl_native_fn_and_pair. Native functions now have
the right name.
1 parent 2936371 commit a63696d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ TEST_XFAILS_RUSTC := $(filter-out \
507507
linear-for-loop.rs \
508508
multiline-comment.rs \
509509
mutual-recursion-group.rs \
510+
native2.rs \
510511
obj-drop.rs \
511512
obj-recursion.rs \
512513
obj-with-vec.rs \

src/comp/middle/trans.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4062,12 +4062,24 @@ fn decl_fn_and_pair(@crate_ctxt cx,
40624062
cx.fn_pairs.insert(id, gvar);
40634063
}
40644064

4065+
fn decl_native_fn_and_pair(@crate_ctxt cx,
4066+
str name,
4067+
&ast.ann ann,
4068+
ast.def_id id) {
4069+
4070+
auto llpairty = node_type(cx, ann);
4071+
auto llfty = get_pair_fn_ty(llpairty);
4072+
4073+
let ValueRef llfn = decl_fastcall_fn(cx.llmod, name, llfty);
4074+
cx.item_ids.insert(id, llfn);
4075+
}
4076+
40654077
fn collect_native_item(&@crate_ctxt cx, @ast.native_item i) -> @crate_ctxt {
40664078
alt (i.node) {
40674079
case (ast.native_item_fn(?name, _, _, ?fid, ?ann)) {
40684080
cx.native_items.insert(fid, i);
40694081
if (! cx.obj_methods.contains_key(fid)) {
4070-
decl_fn_and_pair(cx, "fn", name, ann, fid);
4082+
decl_native_fn_and_pair(cx, name, ann, fid);
40714083
}
40724084
}
40734085
case (_) { /* fall through */ }

0 commit comments

Comments
 (0)