(obj: LeanBorrowed<'_>)
| 674 | } |
| 675 | |
| 676 | /// Decode an `@& Array Lean.Name` FFI argument into a `Vec<Name>`. |
| 677 | /// |
| 678 | /// Uses a fresh `GlobalCache` to deduplicate shared sub-names within the |
| 679 | /// array (the cache keys by pointer identity, so repeat prefixes like |
| 680 | /// `Lean.Meta.Grind.Arith.Cutsat` are decoded once). Callers don't need |
| 681 | /// to manage the cache; it's dropped when this function returns. |
| 682 | /// |
| 683 | /// Preferred over going through `String` + `parse_name` at the FFI |
| 684 | /// boundary: Lean's `Name.toString` adds `«»` escaping for components |
| 685 | /// that aren't valid identifiers, and the resulting string doesn't |
| 686 | /// round-trip through a naive split-on-`.` parser. By decoding the |
| 687 | /// structured `Lean.Name` directly we match the kernel's stored `Name`s |
| 688 | /// exactly (same component strings, same content hash). |
| 689 | pub fn decode_name_array(arr: &LeanArray<LeanBorrowed<'_>>) -> Vec<Name> { |
| 690 | let global = GlobalCache::new(); |
| 691 | arr.map(|obj| decode_name(obj, &global)) |
| 692 | } |
| 693 | |
| 694 | fn decode_level(obj: LeanBorrowed<'_>, cache: &mut Cache<'_>) -> Level { |
| 695 | let ptr = obj.as_raw(); |
| 696 | if let Some(cached) = cache.local.univs.get(&ptr) { |
| 697 | return cached.clone(); |
| 698 | } |
| 699 | let level = if obj.is_scalar() { |
| 700 | Level::zero() |
no test coverage detected