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

Method build_rule_rhs

crates/kernel/src/inductive.rs:3572–3830  ·  view source on GitHub ↗

Build the rule RHS for a single constructor. The RHS is: `λ (params) (motives) (minors) (fields), minor[idx] fields ihs` where each IH = `λ (xs...), rec[target] params motives minors indices (field xs...)`

(
    &mut self,
    member_idx: usize,
    ctor_local_idx: usize,
    ctor_id: &KId<M>,
    member: &FlatBlockMember<M>,
    flat: &[FlatBlockMember<M>],
    peer_recs: &[KId<M>],
    rec_ty_for_memb

Source from the content-addressed store, hash-verified

3570 let is_large = univ_offset > 0;
3571 let n_params = u64_to_usize::<M>(n_params_u64)?;
3572 let mut generated_with_rules = generated_snapshot;
3573
3574 for gi in 0..flat.len() {
3575 let member = &flat[gi];
3576 let rec_ty_for_member = generated_with_rules[gi].ty.clone();
3577 let mut rules = Vec::with_capacity(member.ctors.len());
3578 for (ci, ctor_id) in member.ctors.iter().enumerate() {
3579 let ctor_fields = match self.get_const(ctor_id)? {
3580 KConst::Ctor { fields, .. } => fields,
3581 _ => {
3582 return Err(TcError::Other(
3583 "populate_recursor_rules_from_block: ctor not found".into(),
3584 ));
3585 },
3586 };
3587 let rhs = self.build_rule_rhs(
3588 gi,
3589 ci,
3590 ctor_id,
3591 member,
3592 &flat,
3593 &peer_recs,
3594 &rec_ty_for_member,
3595 n_params,
3596 is_large,
3597 univ_offset,
3598 )?;
3599 rules.push(super::constant::RecRule {
3600 ctor: ctor_id.name.clone(),
3601 fields: ctor_fields,
3602 rhs,
3603 });
3604 }
3605 generated_with_rules[gi].rules = rules;
3606 }
3607
3608 if let Some(cached) = self.env.recursor_cache.get_mut(ind_block_id) {
3609 if cached.len() != generated_with_rules.len() {
3610 return Err(TcError::Other(format!(
3611 "populate_recursor_rules_from_block: cache changed length: cached={} generated={}",
3612 cached.len(),
3613 generated_with_rules.len()
3614 )));
3615 }
3616 for (dst, src) in cached.iter_mut().zip(generated_with_rules.into_iter())
3617 {
3618 dst.rules = src.rules;
3619 }
3620 }
3621
3622 Ok(())
3623 }
3624
3625 /// Build the rule RHS for a single constructor.
3626 ///
3627 /// The RHS is: `λ (params) (motives) (minors) (fields), minor[idx] fields ihs`
3628 /// where each IH = `λ (xs...), rec[target] params motives minors indices (field xs...)`
3629 fn build_rule_rhs(

Calls 15

liftFunction · 0.85
substFunction · 0.85
sortFunction · 0.85
whnfMethod · 0.80
internMethod · 0.80
is_rec_fieldMethod · 0.80
build_rule_ihMethod · 0.80
pushMethod · 0.80
truncateMethod · 0.80
varFunction · 0.70
appFunction · 0.70

Tested by

no test coverage detected