More flexible map_user and fold for new constructor nodes (#53)

* make fold.rs file

* Split user_map steps

* Fold for new constructor nodes
This commit is contained in:
Jeong, YunWon 2023-05-18 00:16:04 +09:00 committed by GitHub
parent 205ee80033
commit b48834fe2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 2516 additions and 833 deletions

View file

@ -15,8 +15,12 @@ impl ConstantOptimizer {
impl<U> crate::fold::Fold<U> for ConstantOptimizer {
type TargetU = U;
type Error = std::convert::Infallible;
type UserContext = ();
#[inline(always)]
fn will_map_user(&mut self, _user: &U) -> Self::UserContext {}
#[inline]
fn map_user(&mut self, user: U) -> Result<Self::TargetU, Self::Error> {
fn map_user(&mut self, user: U, _context: ()) -> Result<Self::TargetU, Self::Error> {
Ok(user)
}
fn fold_expr(&mut self, node: crate::Expr<U>) -> Result<crate::Expr<U>, Self::Error> {