forked from M-Labs/nac3
Add string registration in NAC
This commit is contained in:
parent
3d087160ca
commit
29130d3ef4
@ -1081,10 +1081,7 @@ impl InnerResolver {
|
||||
arr_global.set_initializer(&arr);
|
||||
|
||||
let val = arr_ty.const_named_struct(&[
|
||||
arr_global
|
||||
.as_pointer_value()
|
||||
.const_cast(ty.ptr_type(AddressSpace::default()))
|
||||
.into(),
|
||||
arr_global.as_pointer_value().const_cast(ty.ptr_type(AddressSpace::default())).into(),
|
||||
size_t.const_int(len as u64, false).into(),
|
||||
]);
|
||||
|
||||
@ -1144,10 +1141,8 @@ impl InnerResolver {
|
||||
super::CompileError::new_err(format!("Error getting element {i}: {e}"))
|
||||
})?
|
||||
.unwrap();
|
||||
let value = ctx
|
||||
.builder
|
||||
.build_int_z_extend(value.into_int_value(), llvm_usize, "")
|
||||
.unwrap();
|
||||
let value =
|
||||
ctx.builder.build_int_z_extend(value.into_int_value(), llvm_usize, "").unwrap();
|
||||
Ok(value)
|
||||
})
|
||||
.collect::<Result<Vec<_>, PyErr>>()?;
|
||||
@ -1178,9 +1173,7 @@ impl InnerResolver {
|
||||
let value = self
|
||||
.get_obj_value(py, elem, ctx, generator, ndarray_dtype)
|
||||
.map_err(|e| {
|
||||
super::CompileError::new_err(format!(
|
||||
"Error getting element {i}: {e}"
|
||||
))
|
||||
super::CompileError::new_err(format!("Error getting element {i}: {e}"))
|
||||
})?
|
||||
.unwrap();
|
||||
|
||||
@ -1286,17 +1279,16 @@ impl InnerResolver {
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
let ndarray = llvm_ndarray
|
||||
.as_base_type()
|
||||
.get_element_type()
|
||||
.into_struct_type()
|
||||
.const_named_struct(&[
|
||||
let ndarray =
|
||||
llvm_ndarray.as_base_type().get_element_type().into_struct_type().const_named_struct(
|
||||
&[
|
||||
ndarray_itemsize.into(),
|
||||
ndarray_ndims.into(),
|
||||
ndarray_shape.into(),
|
||||
ndarray_strides.into(),
|
||||
ndarray_data.into(),
|
||||
]);
|
||||
],
|
||||
);
|
||||
|
||||
let ndarray_global = ctx.module.add_global(
|
||||
llvm_ndarray.as_base_type().get_element_type().into_struct_type(),
|
||||
@ -1363,8 +1355,7 @@ impl InnerResolver {
|
||||
let global_str = format!("{id}_option");
|
||||
{
|
||||
if self.global_value_ids.read().contains_key(&id) {
|
||||
let global =
|
||||
ctx.module.get_global(&global_str).unwrap_or_else(|| {
|
||||
let global = ctx.module.get_global(&global_str).unwrap_or_else(|| {
|
||||
ctx.module.add_global(
|
||||
v.get_type(),
|
||||
Some(AddressSpace::default()),
|
||||
@ -1419,13 +1410,7 @@ impl InnerResolver {
|
||||
let values: Result<Option<Vec<_>>, _> = fields
|
||||
.iter()
|
||||
.map(|(name, ty, _)| {
|
||||
self.get_obj_value(
|
||||
py,
|
||||
obj.getattr(name.to_string().as_str())?,
|
||||
ctx,
|
||||
generator,
|
||||
*ty,
|
||||
)
|
||||
self.get_obj_value(py, obj.getattr(name.to_string().as_str())?, ctx, generator, *ty)
|
||||
.map_err(|e| {
|
||||
super::CompileError::new_err(format!("Error getting field {name}: {e}"))
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user