make str/list C abi safe

This commit is contained in:
Folkert 2021-08-25 20:45:47 +02:00
parent ce6ab15139
commit 4990e543fa
3 changed files with 7 additions and 8 deletions

View File

@ -188,7 +188,7 @@ impl<'a, 'ctx, 'env> Env<'a, 'ctx, 'env> {
///
/// on 64-bit systems, this is i128
/// on 32-bit systems, this is i64
pub fn str_list_int(&self) -> IntType<'ctx> {
pub fn str_list_c_abi(&self) -> IntType<'ctx> {
crate::llvm::convert::str_list_int(self.context, self.ptr_bytes)
}
@ -5223,7 +5223,7 @@ fn to_cc_type_builtin<'a, 'ctx, 'env>(
| Builtin::Float32
| Builtin::Float16 => basic_type_from_builtin(env, builtin),
Builtin::Str | Builtin::EmptyStr | Builtin::List(_) | Builtin::EmptyList => {
env.str_list_int().into()
env.str_list_c_abi().into()
}
Builtin::Dict(_, _) | Builtin::Set(_) | Builtin::EmptyDict | Builtin::EmptySet => {
// TODO verify this is what actually happens

View File

@ -61,7 +61,7 @@ fn pass_list_cc<'a, 'ctx, 'env>(
complex_bitcast(
env.builder,
list,
env.str_list_int().into(),
env.str_list_c_abi().into(),
"to_str_list_int",
)
}
@ -929,7 +929,6 @@ pub fn incrementing_elem_loop<'a, 'ctx, 'env, LoopFn>(
where
LoopFn: FnMut(IntValue<'ctx>, BasicValueEnum<'ctx>),
{
let ctx = env.context;
let builder = env.builder;
incrementing_index_loop(env, parent, len, index_name, |index| {

View File

@ -253,7 +253,7 @@ pub fn str_to_utf8<'a, 'ctx, 'env>(
let string = complex_bitcast(
env.builder,
original_wrapper.into(),
env.str_list_int().into(),
env.str_list_c_abi().into(),
"to_utf8",
);
@ -279,13 +279,13 @@ pub fn str_from_utf8_range<'a, 'ctx, 'env>(
complex_bitcast(
env.builder,
list_wrapper.into(),
env.str_list_int().into(),
env.str_list_c_abi().into(),
"to_i128",
),
complex_bitcast(
env.builder,
count_and_start.into(),
env.str_list_int().into(),
env.str_list_c_abi().into(),
"to_i128",
),
result_ptr.into(),
@ -333,7 +333,7 @@ pub fn str_from_utf8<'a, 'ctx, 'env>(
complex_bitcast(
env.builder,
original_wrapper.into(),
env.str_list_int().into(),
env.str_list_c_abi().into(),
"to_i128",
),
result_ptr.into(),