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

Function compare_const

crates/compile/src/compile.rs:2807–2834  ·  view source on GitHub ↗

Compare two mutual constants with caching. Dispatches to the appropriate type-specific comparator (defn, indc, recr). Different-kind constants are ordered by kind tag.

(
  x: &MutConst,
  y: &MutConst,
  mut_ctx: &MutCtx,
  cache: &mut BlockCache,
  stt: &CompileState,
)

Source from the content-addressed store, hash-verified

2805 },
2806 (LevelData::Succ(_, _), _) => Ok(SOrd::lt(true)),
2807 (_, LevelData::Succ(_, _)) => Ok(SOrd::gt(true)),
2808 (LevelData::Max(xl, xr, _), LevelData::Max(yl, yr, _)) => {
2809 SOrd::try_compare(compare_level(xl, yl, x_ctx, y_ctx)?, || {
2810 compare_level(xr, yr, x_ctx, y_ctx)
2811 })
2812 },
2813 (LevelData::Max(_, _, _), _) => Ok(SOrd::lt(true)),
2814 (_, LevelData::Max(_, _, _)) => Ok(SOrd::gt(true)),
2815 (LevelData::Imax(xl, xr, _), LevelData::Imax(yl, yr, _)) => {
2816 SOrd::try_compare(compare_level(xl, yl, x_ctx, y_ctx)?, || {
2817 compare_level(xr, yr, x_ctx, y_ctx)
2818 })
2819 },
2820 (LevelData::Imax(_, _, _), _) => Ok(SOrd::lt(true)),
2821 (_, LevelData::Imax(_, _, _)) => Ok(SOrd::gt(true)),
2822 (LevelData::Param(x, _), LevelData::Param(y, _)) => {
2823 match (
2824 x_ctx.iter().position(|n| x == n),
2825 y_ctx.iter().position(|n| y == n),
2826 ) {
2827 (Some(xi), Some(yi)) => Ok(SOrd::cmp(&xi, &yi)),
2828 (None, _) => Err(CompileError::UnknownUnivParam {
2829 curr: String::new(),
2830 param: x.pretty(),
2831 }),
2832 (_, None) => Err(CompileError::UnknownUnivParam {
2833 curr: String::new(),
2834 param: y.pretty(),
2835 }),
2836 }
2837 },

Callers 2

eq_constFunction · 0.85
mergeFunction · 0.85

Calls 7

compare_defnFunction · 0.85
compare_indcFunction · 0.85
compare_recrFunction · 0.85
mut_const_kindFunction · 0.85
nameMethod · 0.45
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected