forked from M-Labs/nac3
gep_index must be u32
This commit is contained in:
parent
6283036815
commit
32822f9052
|
@ -31,7 +31,7 @@ pub trait FieldTraversal<'ctx> {
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct GepField<M> {
|
pub struct GepField<M> {
|
||||||
/// The GEP index of this field. This is the index to use with `build_gep`.
|
/// 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.
|
/// The cosmetic name of this field.
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
/// The [`Model`] of this field's type.
|
/// The [`Model`] of this field's type.
|
||||||
|
@ -41,7 +41,7 @@ pub struct GepField<M> {
|
||||||
/// A traversal to calculate the GEP index of fields.
|
/// A traversal to calculate the GEP index of fields.
|
||||||
pub struct GepFieldTraversal {
|
pub struct GepFieldTraversal {
|
||||||
/// The current GEP index.
|
/// The current GEP index.
|
||||||
gep_index_counter: u64,
|
gep_index_counter: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx> FieldTraversal<'ctx> for GepFieldTraversal {
|
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>,
|
GetField: FnOnce(S::Fields<GepFieldTraversal>) -> GepField<M>,
|
||||||
{
|
{
|
||||||
let field = get_field(self.model.0.fields());
|
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()
|
field.model.check_value(generator, ctx, val).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ impl<'ctx, S: StructKind<'ctx>> Instance<'ctx, Ptr<Struct<S>>> {
|
||||||
ctx.builder
|
ctx.builder
|
||||||
.build_in_bounds_gep(
|
.build_in_bounds_gep(
|
||||||
self.value,
|
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,
|
field.name,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
Loading…
Reference in New Issue