use std::collections::{HashMap, LinkedList}; pub type ClassId = usize; #[derive(Debug, Clone)] pub(crate) struct TypeIndex { pub type_name: String, pub index: usize, } impl TypeIndex { pub(crate) fn new(type_name: String, index: usize) -> Self { Self { type_name, index } } } #[derive(Debug, Clone)] pub struct Class { pub id: ClassId, pub initialized: bool, pub name: String, pub superclass: Option, pub all_superclasses: LinkedList, // all superclasses in a flat list pub interfaces: Vec, pub all_interfaces: Vec, // all interfaces and their parents in a flat list // lookup index and type from the name of the declared class and then field pub(crate) object_field_mapping: HashMap>, pub(crate) static_field_mapping: HashMap>, // pub(crate) static_field_data: Vec // moved to classmanager } impl PartialEq for Class { fn eq(&self, other: &Self) -> bool { self.id == other.id } } impl Class { /// gets the number of non-static fields on the class pub(crate) fn n_object_fields(&self) -> usize { self.object_field_mapping .iter() .map(|(_, v)| v.len()) .reduce(|acc, e| acc + e) .unwrap_or(0) } }