StructKind::{traverse -> iter}_fields
This commit is contained in:
parent
e0524c19eb
commit
d1c7a8ee50
|
@ -193,13 +193,13 @@ pub trait StructKind<'ctx>: fmt::Debug + Clone + Copy {
|
||||||
/// Traverse through all fields of this [`StructKind`].
|
/// Traverse through all fields of this [`StructKind`].
|
||||||
///
|
///
|
||||||
/// Only used internally in this module for implementing other components.
|
/// Only used internally in this module for implementing other components.
|
||||||
fn traverse_fields<F: FieldTraversal<'ctx>>(&self, traversal: &mut F) -> Self::Fields<F>;
|
fn iter_fields<F: FieldTraversal<'ctx>>(&self, traversal: &mut F) -> Self::Fields<F>;
|
||||||
|
|
||||||
/// Get a convenience structure to get a struct field's GEP index through its corresponding Rust field.
|
/// Get a convenience structure to get a struct field's GEP index through its corresponding Rust field.
|
||||||
///
|
///
|
||||||
/// Only used internally in this module for implementing other components.
|
/// Only used internally in this module for implementing other components.
|
||||||
fn fields(&self) -> Self::Fields<GepFieldTraversal> {
|
fn fields(&self) -> Self::Fields<GepFieldTraversal> {
|
||||||
self.traverse_fields(&mut GepFieldTraversal { gep_index_counter: 0 })
|
self.iter_fields(&mut GepFieldTraversal { gep_index_counter: 0 })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the LLVM [`StructType`] of this [`StructKind`].
|
/// Get the LLVM [`StructType`] of this [`StructKind`].
|
||||||
|
@ -209,7 +209,7 @@ pub trait StructKind<'ctx>: fmt::Debug + Clone + Copy {
|
||||||
ctx: &'ctx Context,
|
ctx: &'ctx Context,
|
||||||
) -> StructType<'ctx> {
|
) -> StructType<'ctx> {
|
||||||
let mut traversal = TypeFieldTraversal { generator, ctx, field_types: Vec::new() };
|
let mut traversal = TypeFieldTraversal { generator, ctx, field_types: Vec::new() };
|
||||||
self.traverse_fields(&mut traversal);
|
self.iter_fields(&mut traversal);
|
||||||
|
|
||||||
ctx.struct_type(&traversal.field_types, false)
|
ctx.struct_type(&traversal.field_types, false)
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ impl<'ctx, S: StructKind<'ctx>> Model<'ctx> for Struct<S> {
|
||||||
errors: Vec::new(),
|
errors: Vec::new(),
|
||||||
scrutinee: ty,
|
scrutinee: ty,
|
||||||
};
|
};
|
||||||
self.0.traverse_fields(&mut traversal);
|
self.0.iter_fields(&mut traversal);
|
||||||
|
|
||||||
// Check the number of fields.
|
// Check the number of fields.
|
||||||
let exp_num_fields = traversal.gep_index_counter;
|
let exp_num_fields = traversal.gep_index_counter;
|
||||||
|
|
Loading…
Reference in New Issue