forked from M-Labs/nac3
1
0
Fork 0

gep_index must be u32

This commit is contained in:
lyken 2024-08-27 17:39:54 +08:00
parent 6283036815
commit 32822f9052
No known key found for this signature in database
GPG Key ID: 3BD5FC6AC8325DD8
1 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@ pub trait FieldTraversal<'ctx> {
#[derive(Debug, Clone, Copy)]
pub struct GepField<M> {
/// 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<M> {
/// 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<S>> {
GetField: FnOnce(S::Fields<GepFieldTraversal>) -> GepField<M>,
{
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<Struct<S>>> {
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()