diff --git a/nac3core/src/codegen/model/array.rs b/nac3core/src/codegen/model/array.rs index a6933023..4d7927a1 100644 --- a/nac3core/src/codegen/model/array.rs +++ b/nac3core/src/codegen/model/array.rs @@ -12,7 +12,7 @@ use super::*; /// Trait for Rust structs identifying length values for [`Array`]. pub trait ArrayLen: fmt::Debug + Clone + Copy { - fn get_length(&self) -> u32; + fn length(&self) -> u32; } /// A statically known length. @@ -24,13 +24,13 @@ pub struct Len; pub struct AnyLen(pub u32); impl ArrayLen for Len { - fn get_length(&self) -> u32 { + fn length(&self) -> u32 { N } } impl ArrayLen for AnyLen { - fn get_length(&self) -> u32 { + fn length(&self) -> u32 { self.0 } } @@ -49,7 +49,7 @@ pub struct Array { impl<'ctx, Len: ArrayLen, Item: ModelBase<'ctx>> ModelBase<'ctx> for Array { fn get_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> { let item = self.item.get_type_impl(size_t, ctx); - item.array_type(self.len.get_length()).into() + item.array_type(self.len.length()).into() } fn check_type_impl( @@ -62,11 +62,11 @@ impl<'ctx, Len: ArrayLen, Item: ModelBase<'ctx>> ModelBase<'ctx> for Array> Instance<'ctx, Ptr /// Like `gep` but `i` is a constant. pub fn gep_const(&self, ctx: &CodeGenContext<'ctx, '_>, i: u64) -> Instance<'ctx, Ptr> { assert!( - i < u64::from(self.model.0.len.get_length()), + i < u64::from(self.model.0.len.length()), "Index {i} is out of bounds. Array length = {}", - self.model.0.len.get_length() + self.model.0.len.length() ); let i = ctx.ctx.i32_type().const_int(i, false);