mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
pass pointer to C as first argument
This commit is contained in:
parent
b2e05b92d1
commit
1b149d215d
1 changed files with 6 additions and 5 deletions
|
@ -6238,7 +6238,7 @@ fn build_foreign_symbol<'a, 'ctx, 'env>(
|
||||||
.void_type()
|
.void_type()
|
||||||
.fn_type(&function_arguments(env, &cc_argument_types), false),
|
.fn_type(&function_arguments(env, &cc_argument_types), false),
|
||||||
CCReturn::ByPointer => {
|
CCReturn::ByPointer => {
|
||||||
cc_argument_types.push(return_type.ptr_type(AddressSpace::Generic).into());
|
cc_argument_types.insert(0, return_type.ptr_type(AddressSpace::Generic).into());
|
||||||
env.context
|
env.context
|
||||||
.void_type()
|
.void_type()
|
||||||
.fn_type(&function_arguments(env, &cc_argument_types), false)
|
.fn_type(&function_arguments(env, &cc_argument_types), false)
|
||||||
|
@ -6285,6 +6285,11 @@ fn build_foreign_symbol<'a, 'ctx, 'env>(
|
||||||
RocReturn::ByPointer => fastcc_parameters.pop().unwrap().into_pointer_value(),
|
RocReturn::ByPointer => fastcc_parameters.pop().unwrap().into_pointer_value(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let CCReturn::ByPointer = cc_return {
|
||||||
|
cc_arguments.push(return_pointer.into());
|
||||||
|
cc_argument_types.remove(0);
|
||||||
|
}
|
||||||
|
|
||||||
let it = fastcc_parameters.into_iter().zip(cc_argument_types.iter());
|
let it = fastcc_parameters.into_iter().zip(cc_argument_types.iter());
|
||||||
for (param, cc_type) in it {
|
for (param, cc_type) in it {
|
||||||
if param.get_type() == *cc_type {
|
if param.get_type() == *cc_type {
|
||||||
|
@ -6296,10 +6301,6 @@ fn build_foreign_symbol<'a, 'ctx, 'env>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let CCReturn::ByPointer = cc_return {
|
|
||||||
cc_arguments.push(return_pointer.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
let call = env.builder.build_call(cc_function, &cc_arguments, "tmp");
|
let call = env.builder.build_call(cc_function, &cc_arguments, "tmp");
|
||||||
call.set_call_convention(C_CALL_CONV);
|
call.set_call_convention(C_CALL_CONV);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue