Implement recursion in mir interpreter without recursion

This commit is contained in:
hkalbasi 2023-07-07 15:07:29 +03:30
parent 3a1054fc1c
commit 4a444e768c
15 changed files with 432 additions and 264 deletions

View file

@ -228,7 +228,7 @@ pub(crate) fn const_eval_query(
}
GeneralConstId::InTypeConstId(c) => db.mir_body(c.into())?,
};
let c = interpret_mir(db, &body, false).0?;
let c = interpret_mir(db, body, false).0?;
Ok(c)
}
@ -241,7 +241,7 @@ pub(crate) fn const_eval_static_query(
Substitution::empty(Interner),
db.trait_environment_for_body(def.into()),
)?;
let c = interpret_mir(db, &body, false).0?;
let c = interpret_mir(db, body, false).0?;
Ok(c)
}
@ -268,7 +268,7 @@ pub(crate) fn const_eval_discriminant_variant(
Substitution::empty(Interner),
db.trait_environment_for_body(def),
)?;
let c = interpret_mir(db, &mir_body, false).0?;
let c = interpret_mir(db, mir_body, false).0?;
let c = try_const_usize(db, &c).unwrap() as i128;
Ok(c)
}
@ -293,7 +293,7 @@ pub(crate) fn eval_to_const(
}
let infer = ctx.clone().resolve_all();
if let Ok(mir_body) = lower_to_mir(ctx.db, ctx.owner, &ctx.body, &infer, expr) {
if let Ok(result) = interpret_mir(db, &mir_body, true).0 {
if let Ok(result) = interpret_mir(db, Arc::new(mir_body), true).0 {
return result;
}
}