MCPcopy Create free account
hub / github.com/diem/move / new

Method new

language/move-binary-format/src/normalized.rs:103–128  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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())

Callers

nothing calls this directly

Calls 15

VectorClass · 0.85
TypeParameterClass · 0.85
ReferenceClass · 0.85
immediate_friendsMethod · 0.80
to_ownedMethod · 0.80
mapMethod · 0.45
iterMethod · 0.45
struct_defsMethod · 0.45
filterMethod · 0.45
function_defsMethod · 0.45
versionMethod · 0.45
addressMethod · 0.45

Tested by

no test coverage detected