Extract a normalized module from a `CompiledModule`. The module `m` should be verified. Nothing will break here if that is not the case, but there is little point in computing a normalized representation of a module that won't verify (since it can't be published).
(m: &CompiledModule)
| 101 | /// Nothing will break here if that is not the case, but there is little point in computing a |
| 102 | /// normalized representation of a module that won't verify (since it can't be published). |
| 103 | pub fn new(m: &CompiledModule) -> Self { |
| 104 | let friends = m.immediate_friends(); |
| 105 | let structs = m.struct_defs().iter().map(|d| Struct::new(m, d)).collect(); |
| 106 | let exposed_functions = m |
| 107 | .function_defs() |
| 108 | .iter() |
| 109 | .filter(|func_def| { |
| 110 | let is_vis_exposed = match func_def.visibility { |
| 111 | Visibility::Public | Visibility::Friend => true, |
| 112 | Visibility::Private => false, |
| 113 | }; |
| 114 | let is_entry_exposed = func_def.is_entry; |
| 115 | is_vis_exposed || is_entry_exposed |
| 116 | }) |
| 117 | .map(|func_def| Function::new(m, func_def)) |
| 118 | .collect(); |
| 119 | |
| 120 | Self { |
| 121 | file_format_version: m.version(), |
| 122 | address: *m.address(), |
| 123 | name: m.name().to_owned(), |
| 124 | friends, |
| 125 | structs, |
| 126 | exposed_functions, |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | pub fn module_id(&self) -> ModuleId { |
| 131 | ModuleId::new(self.address, self.name.clone()) |
nothing calls this directly
no test coverage detected