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

Function ground_const

crates/compile/src/ground.rs:100–148  ·  view source on GitHub ↗
(
  constant: &ConstantInfo,
  env: &Env,
  univs: &[Name],
  binds: usize,
  stt: &mut GroundState,
)

Source from the content-addressed store, hash-verified

98 match constant {
99 ConstantInfo::AxiomInfo(val) => &val.cnst.level_params,
100 ConstantInfo::DefnInfo(val) => &val.cnst.level_params,
101 ConstantInfo::ThmInfo(val) => &val.cnst.level_params,
102 ConstantInfo::OpaqueInfo(val) => &val.cnst.level_params,
103 ConstantInfo::QuotInfo(val) => &val.cnst.level_params,
104 ConstantInfo::InductInfo(val) => &val.cnst.level_params,
105 ConstantInfo::CtorInfo(val) => &val.cnst.level_params,
106 ConstantInfo::RecInfo(val) => &val.cnst.level_params,
107 }
108}
109
110#[derive(Default)]
111struct GroundState {
112 expr_cache: FxHashSet<(usize, Expr)>,
113 univ_cache: FxHashSet<Level>,
114}
115
116fn ground_const(
117 constant: &ConstantInfo,
118 env: &Env,
119 univs: &[Name],
120 binds: usize,
121 stt: &mut GroundState,
122) -> Result<(), GroundError> {
123 match constant {
124 ConstantInfo::AxiomInfo(val) => {
125 ground_expr(&val.cnst.typ, env, univs, binds, stt)
126 },
127 ConstantInfo::DefnInfo(val) => {
128 ground_expr(&val.cnst.typ, env, univs, binds, stt)?;
129 ground_expr(&val.value, env, univs, binds, stt)
130 },
131 ConstantInfo::ThmInfo(val) => {
132 ground_expr(&val.cnst.typ, env, univs, binds, stt)?;
133 ground_expr(&val.value, env, univs, binds, stt)
134 },
135 ConstantInfo::OpaqueInfo(val) => {
136 ground_expr(&val.cnst.typ, env, univs, binds, stt)?;
137 ground_expr(&val.value, env, univs, binds, stt)
138 },
139 ConstantInfo::QuotInfo(val) => {
140 ground_expr(&val.cnst.typ, env, univs, binds, stt)
141 },
142 ConstantInfo::InductInfo(val) => {
143 for ctor in &val.ctors {
144 let ci = env.get(ctor).map(|e| e.cloned());
145 match ci.as_ref() {
146 Some(ConstantInfo::CtorInfo(_)) => (),
147 _ => {
148 return Err(GroundError::Indc(Box::new((val.clone(), ci))));
149 },
150 }
151 }

Callers 1

ground_constsFunction · 0.85

Calls 3

ground_exprFunction · 0.85
getMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected