Skip to content

Commit 4ac4d03

Browse files
committed
Update the function declarations with rust abi. A cdecl
fn write(int fd, rustrt.vbuf buf, uint count) -> int; compiles to declare i32 @Write(i32, i8*, i32) and a rust fn vec_buf[T](vec[T] v, uint offset) -> vbuf; compiles to declare i8* @vec_buf(%task*, %tydesc*, %"vec[<P0:2>]", i32) which I think is the correct declaration for both :-)
1 parent 0120571 commit 4ac4d03

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/comp/middle/trans.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,18 @@ fn type_of_fn(@crate_ctxt cx,
513513
fn type_of_native_fn(@crate_ctxt cx, ast.native_abi abi,
514514
vec[ty.arg] inputs,
515515
@ty.t output) -> TypeRef {
516-
let vec[TypeRef] atys = type_of_explicit_args(cx, inputs);
516+
let vec[TypeRef] atys = vec();
517+
if (abi == ast.native_abi_rust) {
518+
atys += T_taskptr(cx.tn);
519+
auto t = ty.ty_native_fn(abi, inputs, output);
520+
auto ty_param_count = ty.count_ty_params(plain_ty(t));
521+
auto i = 0u;
522+
while (i < ty_param_count) {
523+
atys += T_ptr(T_tydesc(cx.tn));
524+
i += 1u;
525+
}
526+
}
527+
atys += type_of_explicit_args(cx, inputs);
517528
ret T_fn(atys, type_of_inner(cx, output));
518529
}
519530

0 commit comments

Comments
 (0)