feat: WIP

This commit is contained in:
2025-08-23 23:47:24 +08:00
parent 65bcfcb47b
commit 2fbd2a26a9
8 changed files with 284 additions and 238 deletions

View File

@@ -22,10 +22,15 @@ impl<'ctx, 'bump> DowngradeCtx<'ctx, 'bump> {
impl DowngradeCtx<'_, '_> {
fn get_ir(&self, id: ExprId) -> &RefCell<Hir> {
// SAFETY: The `ExprId` is guaranteed to be valid and correspond to an expression
// allocated within this context, making the raw index access safe.
let idx = unsafe { id.raw() } - self.ctx.lirs.len() - self.ctx.hirs.len();
if cfg!(debug_assertions) {
self.irs.get(idx).unwrap()
} else {
// SAFETY: The index calculation is guarded by the logic that creates `ExprId`s,
// ensuring it's always within the bounds of the `irs` vector in release builds.
// The debug build's `unwrap()` serves as a runtime check for this invariant.
unsafe { self.irs.get_unchecked(idx) }
}
}