(obj: LeanBorrowed<'_>, cache: &mut Cache<'_>)
| 721 | |
| 722 | fn 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 | |
| 730 | fn 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 | |
| 753 | fn 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 => { |
no test coverage detected