pub fn try_map_to_input_with_bound_expr(
        &self,
        mut expr: MirScalarExpr,
        index: usize,
        equivalences: &[Vec<MirScalarExpr>],
    ) -> Option<MirScalarExpr> {
        // TODO (wangandi): Consider changing this code to be post-order
        // instead of pre-order? `lookup_inputs` traverses all the nodes in
        // `e` anyway, so we end up visiting nodes in `e` multiple times
        // here. Alternatively, consider having the future `PredicateKnowledge`
        // take over the responsibilities of this code?
        expr.visit_mut_pre_post(
            &mut |e| {
                let mut inputs = self.lookup_inputs(e);
                if let Some(first_input) = inputs.next() {
                    if inputs.next().is_none() && first_input == index {
                        // there is only one input, and it is equal to index, so we're
                        // good. do not continue the recursion
                        return Some(vec![]);
                    }
                }

                if let Some(bound_expr) = self.find_bound_expr(e, &[index], equivalences) {
                    // Replace the subexpression with the equivalent one from input `index`
                    *e = bound_expr;
                    // The entire subexpression has been rewritten, so there is
                    // no need to visit any child expressions.
                    Some(vec![])
                } else {
                    None
                }
            },
            &mut |_| {},
        );
        // if the localization attempt is successful, all columns in `expr`
        // should only come from input `index`
        let mut inputs_after_localization = self.lookup_inputs(&expr);
        if let Some(first_input) = inputs_after_localization.next() {
            if inputs_after_localization.next().is_none() && first_input == index {
                return Some(self.map_expr_to_local(expr));
            }
        }
        None
    }
/// Try to rewrite an expression from the global context so that all the
/// columns point to the `index` input by replacing subexpressions with their
/// bound equivalents in the `index`th input if necessary.
/// The return value, if not None, is in the context of the `index`th input
Try to rewrite an expression from the global context so that all the
columns point to the `index` input by replacing subexpressions with their
bound equivalents in the `index`th input if necessary.
The return value, if not None, is in the context of the `index`th input
Try to rewrite an expression from the global context so that all the columns point to the ` index ` input by replacing subexpressions with their bound equivalents in the ` index ` th input if necessary . The return value if not None is in the context of the ` index ` th input
pub fn try_map_to_input_with_bound_expr(
        &self,
        mut expr: MirScalarExpr,
        index: usize,
        equivalences: &[Vec<MirScalarExpr>],
    ) -> Option<MirScalarExpr> {
        // TODO (wangandi): Consider changing this code to be post-order
        // instead of pre-order? `lookup_inputs` traverses all the nodes in
        // `e` anyway, so we end up visiting nodes in `e` multiple times
        // here. Alternatively, consider having the future `PredicateKnowledge`
        // take over the responsibilities of this code?
        expr.visit_mut_pre_post(
            &mut |e| {
                let mut inputs = self.lookup_inputs(e);
                if let Some(first_input) = inputs.next() {
                    if inputs.next().is_none() && first_input == index {
                        // there is only one input, and it is equal to index, so we're
                        // good. do not continue the recursion
                        return Some(vec![]);
                    }
                }
                if let Some(bound_expr) = self.find_bound_expr(e, &[index], equivalences) {
                    // Replace the subexpression with the equivalent one from input `index`
                    *e = bound_expr;
                    // The entire subexpression has been rewritten, so there is
                    // no need to visit any child expressions.
                    Some(vec![])
                } else {
                    None
                }
            },
            &mut |_| {},
        );
        // if the localization attempt is successful, all columns in `expr`
        // should only come from input `index`
        let mut inputs_after_localization = self.lookup_inputs(&expr);
        if let Some(first_input) = inputs_after_localization.next() {
            if inputs_after_localization.next().is_none() && first_input == index {
                return Some(self.map_expr_to_local(expr));
            }
        }
        None
    }
pub fn try_map_to_input_with_bound_expr ( & self , mut expr : MirScalarExpr , index : usize , equivalences : & [ Vec < MirScalarExpr > ] , ) -> Option < MirScalarExpr > { // TODO (wangandi): Consider changing this code to be post-order // instead of pre-order? `lookup_inputs` traverses all the nodes in // `e` anyway, so we end up visiting nodes in `e` multiple times // here. Alternatively, consider having the future `PredicateKnowledge` // take over the responsibilities of this code? expr . visit_mut_pre_post ( & mut | e | { let mut inputs = self . lookup_inputs ( e ) ; if let Some ( first_input ) = inputs . next ( ) { if inputs . next ( ) . is_none ( ) && first_input == index { // there is only one input, and it is equal to index, so we're // good. do not continue the recursion return Some ( vec ! [ ] ) ; } } if let Some ( bound_expr ) = self . find_bound_expr ( e , & [ index ] , equivalences ) { // Replace the subexpression with the equivalent one from input `index` * e = bound_expr ; // The entire subexpression has been rewritten, so there is // no need to visit any child expressions. Some ( vec ! [ ] ) } else { None } } , & mut | _ | { } , ) ; // if the localization attempt is successful, all columns in `expr` // should only come from input `index` let mut inputs_after_localization = self . lookup_inputs ( & expr ) ; if let Some ( first_input ) = inputs_after_localization . next ( ) { if inputs_after_localization . next ( ) . is_none ( ) && first_input == index { return Some ( self . map_expr_to_local ( expr ) ) ; } } None }
Try to rewrite an expression from the global context so that all the
columns point to the `index` input by replacing subexpressions with their
bound equivalents in the `index`th input if necessary.
Try to rewrite an expression from the global context so that all the columns point to the ` index ` input by replacing subexpressions with their bound equivalents in the ` index ` th input if necessary .
&self
expr
MirScalarExpr
index
usize
equivalences
&[Vec<MirScalarExpr>]
&self
expr
MirScalarExpr
index
usize
equivalences
&[Vec<MirScalarExpr>]