| 310 | } |
| 311 | |
| 312 | pub fn get_wto(&mut self, def_id: DefId) -> Wto<'tcx> { |
| 313 | let mir = self.tcx.optimized_mir(def_id); |
| 314 | let wto; |
| 315 | // First see whether the wto has been already computed |
| 316 | if let Some(cached_wto) = self.wto_cache.get(def_id) { |
| 317 | debug!("Using cached w.t.o for {}", self.tcx.item_name(def_id)); |
| 318 | wto = cached_wto.clone(); |
| 319 | } else { |
| 320 | // If not, compute the wto |
| 321 | wto = Wto::new(mir); |
| 322 | debug!( |
| 323 | "Compute the new w.t.o for {}: {:?}", |
| 324 | self.tcx.item_name(def_id), |
| 325 | wto |
| 326 | ); |
| 327 | // Cache the wto |
| 328 | self.wto_cache.insert(def_id, wto.clone()); |
| 329 | } |
| 330 | wto |
| 331 | } |
| 332 | |
| 333 | /// 扫描一个函数:只做“一层”Call 捕获 |
| 334 | /// - 本地 callee:加入 func.callees(浅层信息) |