MCPcopy Create free account
hub / github.com/argumentcomputer/ix / decode_source_info

Function decode_source_info

crates/ffi/src/lean_env.rs:676–697  ·  view source on GitHub ↗
(obj: LeanBorrowed<'_>)

Source from the content-addressed store, hash-verified

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).
689pub fn decode_name_array(arr: &LeanArray<LeanBorrowed<'_>>) -> Vec<Name> {
690 let global = GlobalCache::new();
691 arr.map(|obj| decode_name(obj, &global))
692}
693
694fn 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()

Callers 1

decode_syntaxFunction · 0.85

Calls 2

decode_substringFunction · 0.85
tagMethod · 0.80

Tested by

no test coverage detected