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

Function decode_syntax

crates/ffi/src/lean_env.rs:723–756  ·  view source on GitHub ↗
(obj: LeanBorrowed<'_>, cache: &mut Cache<'_>)

Source from the content-addressed store, hash-verified

721
722fn decode_substring(obj: LeanBorrowed<'_>) -> Substring {
723 let s = LeanIxSubstring::from_ctor(obj.as_ctor());
724 let str = s.get_obj(0).as_string().to_string();
725 let start_pos = LeanNat::to_nat(&s.get_obj(1));
726 let stop_pos = LeanNat::to_nat(&s.get_obj(2));
727 Substring { str, start_pos, stop_pos }
728}
729
730fn decode_source_info(obj: LeanBorrowed<'_>) -> SourceInfo {
731 if obj.is_scalar() {
732 return SourceInfo::None;
733 }
734 let si = LeanIxSourceInfo::from_ctor(obj.as_ctor());
735 match si.as_ctor().tag() {
736 0 => {
737 let leading = decode_substring(si.get_obj(0));
738 let pos = LeanNat::to_nat(&si.get_obj(1));
739 let trailing = decode_substring(si.get_obj(2));
740 let end_pos = LeanNat::to_nat(&si.get_obj(3));
741 SourceInfo::Original(leading, pos, trailing, end_pos)
742 },
743 1 => {
744 let pos = LeanNat::to_nat(&si.get_obj(0));
745 let end_pos = LeanNat::to_nat(&si.get_obj(1));
746 let canonical = si.get_num_8(0) != 0;
747 SourceInfo::Synthetic(pos, end_pos, canonical)
748 },
749 tag => unreachable!("Invalid Lean.SourceInfo tag: {tag}"),
750 }
751}
752
753fn decode_syntax_preresolved(
754 obj: LeanBorrowed<'_>,
755 cache: &mut Cache<'_>,
756) -> SyntaxPreresolved {
757 let p = LeanIxSyntaxPreresolved::from_ctor(obj.as_ctor());
758 match p.as_ctor().tag() {
759 0 => {

Callers 1

decode_name_data_valueFunction · 0.85

Calls 9

decode_source_infoFunction · 0.85
decode_nameFunction · 0.85
NodeClass · 0.85
decode_substringFunction · 0.85
collect_list_borrowedFunction · 0.85
tagMethod · 0.80
as_arrayMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected