Allocate a new ID for `instance`, or return a cached one if it exists. If a new ID is created, `instance` is added to `propagate_instances_queue`, so that `propagate_instances` can later find all transitive dependencies.
(&mut self, instance: Instance<SmallVec<[CopyOperand; 4]>>)
| 2263 | /// If a new ID is created, `instance` is added to `propagate_instances_queue`, |
| 2264 | /// so that `propagate_instances` can later find all transitive dependencies. |
| 2265 | fn alloc_instance_id(&mut self, instance: Instance<SmallVec<[CopyOperand; 4]>>) -> Word { |
| 2266 | use std::collections::btree_map::Entry; |
| 2267 | |
| 2268 | match self.instances.entry(instance) { |
| 2269 | Entry::Occupied(entry) => *entry.get(), |
| 2270 | Entry::Vacant(entry) => { |
| 2271 | // Get the `Instance` back from the map key, to avoid having to |
| 2272 | // clone it earlier when calling `self.instances.entry(instance)`. |
| 2273 | let instance = entry.key().clone(); |
| 2274 | |
| 2275 | self.propagate_instances_queue.push_back(instance); |
| 2276 | *entry.insert(self.builder.id()) |
| 2277 | } |
| 2278 | } |
| 2279 | } |
| 2280 | |
| 2281 | /// Process all instances seen (by `alloc_instance_id`) up until this point, |
| 2282 | /// to find the full set of instances (transitively) needed by the module. |
no test coverage detected