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

Function rs_get_pre_sharing_exprs

crates/ffi/src/compile.rs:953–1051  ·  view source on GitHub ↗
(
  rust_env: *const RustCompiledEnv,
  lowlink_name: LeanOwned,
  out_buf: LeanByteArray<LeanOwned>,
)

Source from the content-addressed store, hash-verified

951 let addr = match rust_env.compile_state.name_to_addr.get(&name) {
952 Some(a) => a.clone(),
953 None => {
954 return 0;
955 },
956 };
957
958 // Get the constant (note: contains post-sharing expressions)
959 let constant = match rust_env.compile_state.env.get_const(&addr) {
960 Some(c) => c,
961 None => {
962 return 0;
963 },
964 };
965
966 // Extract root expressions from the constant info
967 let root_exprs: Vec<Arc<IxonExpr>> = match &constant.info {
968 ConstantInfo::Defn(def) => vec![def.typ.clone(), def.value.clone()],
969 ConstantInfo::Axio(ax) => vec![ax.typ.clone()],
970 ConstantInfo::Quot(q) => vec![q.typ.clone()],
971 ConstantInfo::Recr(rec) => {
972 let mut exprs = vec![rec.typ.clone()];
973 for rule in &rec.rules {
974 exprs.push(rule.rhs.clone());
975 }
976 exprs
977 },
978 // Projections don't contain expressions directly
979 ConstantInfo::CPrj(_)
980 | ConstantInfo::RPrj(_)
981 | ConstantInfo::IPrj(_)
982 | ConstantInfo::DPrj(_) => {
983 vec![]
984 },
985 ConstantInfo::Muts(muts) => {
986 let mut exprs = Vec::new();
987 for mc in muts {
988 match mc {
989 ixon::constant::MutConst::Defn(def) => {
990 exprs.push(def.typ.clone());
991 exprs.push(def.value.clone());
992 },
993 ixon::constant::MutConst::Indc(ind) => {
994 exprs.push(ind.typ.clone());
995 for ctor in &ind.ctors {
996 exprs.push(ctor.typ.clone());
997 }
998 },
999 ixon::constant::MutConst::Recr(rec) => {
1000 exprs.push(rec.typ.clone());
1001 for rule in &rec.rules {
1002 exprs.push(rule.rhs.clone());
1003 }
1004 },
1005 }
1006 }
1007 exprs
1008 },
1009 };
1010

Callers

nothing calls this directly

Calls 8

decode_nameFunction · 0.85
unshare_exprFunction · 0.85
put_exprFunction · 0.85
pushMethod · 0.80
getMethod · 0.45
cloneMethod · 0.45
get_constMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected