MCPcopy Create free account
hub / github.com/BasisResearch/lean.py / decode_lean_obj

Method decode_lean_obj

lean_py/marshal.py:621–634  ·  view source on GitHub ↗

Decode a ``LeanObj`` (raw ``lean_object*``) as a registered inductive. This is the entry point for Path B (tactic): Lean wraps an ``Expr`` via ``Py.ofLeanObj``, Python receives a ``LeanObj``, and this method walks the runtime representation using the type's registry metadata

(self, type_name: str, lean_obj: LeanObj)

Source from the content-addressed store, hash-verified

619 # -- public --------------------------------------------------------------
620
621 def decode_lean_obj(self, type_name: str, lean_obj: LeanObj) -> LeanInductiveValue:
622 """Decode a ``LeanObj`` (raw ``lean_object*``) as a registered inductive.
623
624 This is the entry point for Path B (tactic): Lean wraps an ``Expr``
625 via ``Py.ofLeanObj``, Python receives a ``LeanObj``, and this method
626 walks the runtime representation using the type's registry metadata.
627 """
628 ti = self.registry.find_type(type_name)
629 if ti is None:
630 raise ValueError(f"Type {type_name!r} not found in registry")
631 # Borrow: _decode_inductive reads fields via lean_ctor_get (borrowed
632 # pointers) and lean_inc's each child, so we don't consume the handle.
633 self.ffi.lean_inc(lean_obj.ptr)
634 return self._decode_inductive(ti, lean_obj.ptr)
635
636 def wrapper_for(self, t: TypeRepr) -> TypeWrapper:
637 key = self._key(t)

Callers 2

decode_and_check_propFunction · 0.80
decode_and_check_propFunction · 0.80

Calls 2

_decode_inductiveMethod · 0.95
find_typeMethod · 0.80

Tested by

no test coverage detected