(obj: LeanBorrowed<'_>, cache: &mut Cache<'_>)
| 638 | list: LeanList<LeanBorrowed<'a>>, |
| 639 | ) -> Vec<LeanBorrowed<'a>> { |
| 640 | list.to_vec() |
| 641 | } |
| 642 | |
| 643 | /// Collect list elements as LeanShared handles for cross-thread use. |
| 644 | /// The caller should have already MT-marked the parent list via `LeanShared::new`, |
| 645 | /// so `lean_mark_mt` on each element is a single `lean_is_st` check (fast no-op). |
| 646 | fn collect_list_shared(list: LeanList<LeanBorrowed<'_>>) -> Vec<LeanShared> { |
| 647 | list.iter().map(|b| LeanShared::new(b.to_owned_ref())).collect() |
| 648 | } |
| 649 | |
| 650 | // Name decoding with global cache |
| 651 | pub fn decode_name(obj: LeanBorrowed<'_>, global: &GlobalCache) -> Name { |
| 652 | let ptr = obj.as_raw(); |
| 653 | // Fast path: check if already cached |
| 654 | if let Some(name) = global.names.get(&ptr) { |
| 655 | return name.clone(); |
| 656 | } |
| 657 | |
| 658 | // Compute the name |
| 659 | let name = if obj.is_scalar() { |
| 660 | Name::anon() |
| 661 | } else { |
| 662 | let n = LeanIxName::from_ctor(obj.as_ctor()); |
| 663 | let pre = decode_name(n.get_obj(0), global); |
| 664 | let pos = n.get_obj(1); |
| 665 | match n.as_ctor().tag() { |
| 666 | 1 => Name::str(pre, pos.as_string().to_string()), |
| 667 | 2 => Name::num(pre, LeanNat::to_nat(&pos)), |
| 668 | tag => unreachable!("Invalid Lean.Name tag: {tag}"), |
| 669 | } |
no test coverage detected