From 32822f9052627bc0ad7beaff9d234b9e4687fe54 Mon Sep 17 00:00:00 2001 From: lyken Date: Tue, 27 Aug 2024 17:39:54 +0800 Subject: [PATCH] gep_index must be u32 --- nac3core/src/codegen/model/structure.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nac3core/src/codegen/model/structure.rs b/nac3core/src/codegen/model/structure.rs index c158bd94..c91f42aa 100644 --- a/nac3core/src/codegen/model/structure.rs +++ b/nac3core/src/codegen/model/structure.rs @@ -31,7 +31,7 @@ pub trait FieldTraversal<'ctx> { #[derive(Debug, Clone, Copy)] pub struct GepField { /// The GEP index of this field. This is the index to use with `build_gep`. - pub gep_index: u64, + pub gep_index: u32, /// The cosmetic name of this field. pub name: &'static str, /// The [`Model`] of this field's type. @@ -41,7 +41,7 @@ pub struct GepField { /// A traversal to calculate the GEP index of fields. pub struct GepFieldTraversal { /// The current GEP index. - gep_index_counter: u64, + gep_index_counter: u32, } impl<'ctx> FieldTraversal<'ctx> for GepFieldTraversal { @@ -302,7 +302,7 @@ impl<'ctx, S: StructKind<'ctx>> Instance<'ctx, Struct> { GetField: FnOnce(S::Fields) -> GepField, { let field = get_field(self.model.0.fields()); - let val = self.value.get_field_at_index(field.gep_index as u32).unwrap(); + let val = self.value.get_field_at_index(field.gep_index).unwrap(); field.model.check_value(generator, ctx, val).unwrap() } } @@ -325,7 +325,7 @@ impl<'ctx, S: StructKind<'ctx>> Instance<'ctx, Ptr>> { ctx.builder .build_in_bounds_gep( self.value, - &[llvm_i32.const_zero(), llvm_i32.const_int(field.gep_index, false)], + &[llvm_i32.const_zero(), llvm_i32.const_int(u64::from(field.gep_index), false)], field.name, ) .unwrap()