Compile an Inductive. The inductive type gets its own arena. Each constructor gets its own arena via compile_constructor. No CtorMeta duplication — ConstantMeta::Indc only stores constructor name addresses.
( ind: &Ind, mut_ctx: &MutCtx, cache: &mut BlockCache, stt: &CompileState, )
| 2161 | typ: rewritten[indices[0]].clone(), |
| 2162 | ctors: new_ctors, |
| 2163 | }) |
| 2164 | }, |
| 2165 | (MutConstKind::Recr, IxonMutConst::Recr(rec)) => { |
| 2166 | let new_rules: Vec<RecursorRule> = rec |
| 2167 | .rules |
| 2168 | .into_iter() |
| 2169 | .enumerate() |
| 2170 | .map(|(ri, rule)| RecursorRule { |
| 2171 | fields: rule.fields, |
| 2172 | rhs: rewritten[indices[ri + 1]].clone(), |
| 2173 | }) |
| 2174 | .collect(); |
| 2175 | IxonMutConst::Recr(Recursor { |
| 2176 | k: rec.k, |
| 2177 | is_unsafe: rec.is_unsafe, |
| 2178 | lvls: rec.lvls, |
| 2179 | params: rec.params, |
| 2180 | indices: rec.indices, |
| 2181 | motives: rec.motives, |
| 2182 | minors: rec.minors, |
| 2183 | typ: rewritten[indices[0]].clone(), |
| 2184 | rules: new_rules, |
| 2185 | }) |
| 2186 | }, |
| 2187 | _ => unreachable!("layout mismatch"), |
| 2188 | }; |
| 2189 | new_consts.push(new_mc); |
| 2190 | } |
| 2191 | |
| 2192 | let constant = |
| 2193 | Constant::with_tables(ConstantInfo::Muts(new_consts), sharing, refs, univs); |
| 2194 | MutualBlockSharingResult { constant, hash_consed_size } |
| 2195 | } |
| 2196 | |
| 2197 | /// Helper enum for tracking mutual constant layout during sharing. |
| 2198 | #[derive(Clone, Copy)] |
| 2199 | enum MutConstKind { |
| 2200 | Defn, |
| 2201 | Indc, |
| 2202 | Recr, |
| 2203 | } |
| 2204 | |
| 2205 | // =========================================================================== |
| 2206 | // Constant compilation |
| 2207 | // =========================================================================== |
| 2208 | |
| 2209 | /// Compile a Definition. |
| 2210 | /// Arena persists across type + value within a constant. |
| 2211 | pub fn compile_definition( |
| 2212 | def: &Def, |
| 2213 | mut_ctx: &MutCtx, |
| 2214 | cache: &mut BlockCache, |
| 2215 | stt: &CompileState, |
| 2216 | ) -> Result<(Definition, ConstantMeta), CompileError> { |
| 2217 | cache.compiling = Some(def.name.clone()); |
| 2218 | let univ_params = &def.level_params; |
| 2219 | |
| 2220 | // Compile type expression (arena grows) |
no test coverage detected