forked from M-Labs/nac3
1
0
Fork 0

StructKind::{traverse -> iter}_fields

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

View File

@ -193,13 +193,13 @@ pub trait StructKind<'ctx>: fmt::Debug + Clone + Copy {
/// Traverse through all fields of this [`StructKind`].
///
/// 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.
///
/// Only used internally in this module for implementing other components.
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`].
@ -209,7 +209,7 @@ pub trait StructKind<'ctx>: fmt::Debug + Clone + Copy {
ctx: &'ctx Context,
) -> StructType<'ctx> {
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)
}
@ -270,7 +270,7 @@ impl<'ctx, S: StructKind<'ctx>> Model<'ctx> for Struct<S> {
errors: Vec::new(),
scrutinee: ty,
};
self.0.traverse_fields(&mut traversal);
self.0.iter_fields(&mut traversal);
// Check the number of fields.
let exp_num_fields = traversal.gep_index_counter;