| 146 | } |
| 147 | |
| 148 | pub fn apply(mut self) -> Vec<PartialVMError> { |
| 149 | let function_def_len = self.module.function_defs.len(); |
| 150 | |
| 151 | let mut mutation_map = BTreeMap::new(); |
| 152 | for mutation in self |
| 153 | .mutations |
| 154 | .take() |
| 155 | .expect("mutations should always be present") |
| 156 | { |
| 157 | let picked_idx = mutation.function_def.index(function_def_len); |
| 158 | mutation_map |
| 159 | .entry(picked_idx) |
| 160 | .or_insert_with(Vec::new) |
| 161 | .push(mutation); |
| 162 | } |
| 163 | |
| 164 | let mut results = vec![]; |
| 165 | |
| 166 | for (idx, mutations) in mutation_map { |
| 167 | results.extend(self.apply_one(idx, mutations)); |
| 168 | } |
| 169 | results |
| 170 | } |
| 171 | |
| 172 | fn apply_one( |
| 173 | &mut self, |