diff --git a/src/valid/mod.rs b/src/valid/mod.rs index 25fdf20ccc..033d967818 100644 --- a/src/valid/mod.rs +++ b/src/valid/mod.rs @@ -124,10 +124,18 @@ bitflags::bitflags! { #[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] pub struct ModuleInfo { + type_flags: Vec, functions: Vec, entry_points: Vec, } +impl ops::Index> for ModuleInfo { + type Output = TypeFlags; + fn index(&self, handle: Handle) -> &Self::Output { + &self.type_flags[handle.index()] + } +} + impl ops::Index> for ModuleInfo { type Output = FunctionInfo; fn index(&self, handle: Handle) -> &Self::Output { @@ -346,6 +354,12 @@ impl Validator { } } + let mut mod_info = ModuleInfo { + type_flags: Vec::with_capacity(module.types.len()), + functions: Vec::with_capacity(module.functions.len()), + entry_points: Vec::with_capacity(module.entry_points.len()), + }; + for (handle, ty) in module.types.iter() { let ty_info = self .validate_type(handle, &module.types, &module.constants) @@ -357,6 +371,7 @@ impl Validator { } .with_span_handle(handle, &module.types) })?; + mod_info.type_flags.push(ty_info.flags); self.types[handle.index()] = ty_info; } @@ -373,11 +388,6 @@ impl Validator { })?; } - let mut mod_info = ModuleInfo { - functions: Vec::with_capacity(module.functions.len()), - entry_points: Vec::with_capacity(module.entry_points.len()), - }; - for (handle, fun) in module.functions.iter() { match self.validate_function(fun, module, &mod_info, false) { Ok(info) => mod_info.functions.push(info), diff --git a/src/valid/type.rs b/src/valid/type.rs index 083501c67d..aee6d0f3e5 100644 --- a/src/valid/type.rs +++ b/src/valid/type.rs @@ -9,6 +9,8 @@ bitflags::bitflags! { /// /// [`Type`]: crate::Type /// [`Validator`]: crate::valid::Validator + #[cfg_attr(feature = "serialize", derive(serde::Serialize))] + #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[repr(transparent)] pub struct TypeFlags: u8 { /// Can be used for data variables. diff --git a/tests/out/analysis/collatz.info.ron b/tests/out/analysis/collatz.info.ron index f334394441..3896cd9437 100644 --- a/tests/out/analysis/collatz.info.ron +++ b/tests/out/analysis/collatz.info.ron @@ -1,4 +1,18 @@ ( + type_flags: [ + ( + bits: 223, + ), + ( + bits: 21, + ), + ( + bits: 21, + ), + ( + bits: 223, + ), + ], functions: [ ( flags: ( diff --git a/tests/out/analysis/shadow.info.ron b/tests/out/analysis/shadow.info.ron index 01a3c96554..54731d00ec 100644 --- a/tests/out/analysis/shadow.info.ron +++ b/tests/out/analysis/shadow.info.ron @@ -1,4 +1,99 @@ ( + type_flags: [ + ( + bits: 223, + ), + ( + bits: 223, + ), + ( + bits: 223, + ), + ( + bits: 223, + ), + ( + bits: 199, + ), + ( + bits: 223, + ), + ( + bits: 64, + ), + ( + bits: 64, + ), + ( + bits: 223, + ), + ( + bits: 70, + ), + ( + bits: 70, + ), + ( + bits: 223, + ), + ( + bits: 223, + ), + ( + bits: 6, + ), + ( + bits: 6, + ), + ( + bits: 6, + ), + ( + bits: 215, + ), + ( + bits: 215, + ), + ( + bits: 21, + ), + ( + bits: 21, + ), + ( + bits: 6, + ), + ( + bits: 6, + ), + ( + bits: 6, + ), + ( + bits: 6, + ), + ( + bits: 70, + ), + ( + bits: 70, + ), + ( + bits: 6, + ), + ( + bits: 6, + ), + ( + bits: 70, + ), + ( + bits: 64, + ), + ( + bits: 64, + ), + ], functions: [ ( flags: (