fn generate_expr(&mut self, expr: HirScalarExpr, context_box: BoxId) -> BoxScalarExpr {
        match expr {
            HirScalarExpr::Literal(row, col_type) => BoxScalarExpr::Literal(row, col_type),
            HirScalarExpr::Column(c) => {
                let context_box = match c.level {
                    0 => context_box,
                    _ => self.context_stack[self.context_stack.len() - c.level],
                };
                BoxScalarExpr::ColumnReference(self.find_column_within_box(context_box, c.column))
            }
            HirScalarExpr::CallNullary(func) => BoxScalarExpr::CallNullary(func),
            HirScalarExpr::CallUnary { func, expr } => BoxScalarExpr::CallUnary {
                func,
                expr: Box::new(self.generate_expr(*expr, context_box)),
            },
            HirScalarExpr::CallBinary { func, expr1, expr2 } => BoxScalarExpr::CallBinary {
                func,
                expr1: Box::new(self.generate_expr(*expr1, context_box)),
                expr2: Box::new(self.generate_expr(*expr2, context_box)),
            },
            HirScalarExpr::CallVariadic { func, exprs } => BoxScalarExpr::CallVariadic {
                func,
                exprs: exprs
                    .into_iter()
                    .map(|expr| self.generate_expr(expr, context_box))
                    .collect::<Vec<_>>(),
            },
            HirScalarExpr::If { cond, then, els } => BoxScalarExpr::If {
                cond: Box::new(self.generate_expr(*cond, context_box)),
                then: Box::new(self.generate_expr(*then, context_box)),
                els: Box::new(self.generate_expr(*els, context_box)),
            },
            HirScalarExpr::Select(mut expr) => {
                let box_id = self.within_context(context_box, &mut move |generator| -> BoxId {
                    generator.generate_select(expr.take())
                });
                let quantifier_id =
                    self.model
                        .make_quantifier(QuantifierType::Scalar, box_id, context_box);
                BoxScalarExpr::ColumnReference(ColumnReference {
                    quantifier_id,
                    position: 0,
                })
            }
            _ => panic!("unsupported expression type {:?}", expr),
        }
    }
/// Lowers the given expression within the context of the given box.
///
/// Note that this method may add new quantifiers to the box for subquery
/// expressions.
Lowers the given expression within the context of the given box.
Note that this method may add new quantifiers to the box for subquery
expressions.
Lowers the given expression within the context of the given box . Note that this method may add new quantifiers to the box for subquery expressions .
fn generate_expr(&mut self, expr: HirScalarExpr, context_box: BoxId) -> BoxScalarExpr {
        match expr {
            HirScalarExpr::Literal(row, col_type) => BoxScalarExpr::Literal(row, col_type),
            HirScalarExpr::Column(c) => {
                let context_box = match c.level {
                    0 => context_box,
                    _ => self.context_stack[self.context_stack.len() - c.level],
                };
                BoxScalarExpr::ColumnReference(self.find_column_within_box(context_box, c.column))
            }
            HirScalarExpr::CallNullary(func) => BoxScalarExpr::CallNullary(func),
            HirScalarExpr::CallUnary { func, expr } => BoxScalarExpr::CallUnary {
                func,
                expr: Box::new(self.generate_expr(*expr, context_box)),
            },
            HirScalarExpr::CallBinary { func, expr1, expr2 } => BoxScalarExpr::CallBinary {
                func,
                expr1: Box::new(self.generate_expr(*expr1, context_box)),
                expr2: Box::new(self.generate_expr(*expr2, context_box)),
            },
            HirScalarExpr::CallVariadic { func, exprs } => BoxScalarExpr::CallVariadic {
                func,
                exprs: exprs
                    .into_iter()
                    .map(|expr| self.generate_expr(expr, context_box))
                    .collect::<Vec<_>>(),
            },
            HirScalarExpr::If { cond, then, els } => BoxScalarExpr::If {
                cond: Box::new(self.generate_expr(*cond, context_box)),
                then: Box::new(self.generate_expr(*then, context_box)),
                els: Box::new(self.generate_expr(*els, context_box)),
            },
            HirScalarExpr::Select(mut expr) => {
                let box_id = self.within_context(context_box, &mut move |generator| -> BoxId {
                    generator.generate_select(expr.take())
                });
                let quantifier_id =
                    self.model
                        .make_quantifier(QuantifierType::Scalar, box_id, context_box);
                BoxScalarExpr::ColumnReference(ColumnReference {
                    quantifier_id,
                    position: 0,
                })
            }
            _ => panic!("unsupported expression type {:?}", expr),
        }
    }
fn generate_expr ( & mut self , expr : HirScalarExpr , context_box : BoxId ) -> BoxScalarExpr { match expr { HirScalarExpr :: Literal ( row , col_type ) => BoxScalarExpr :: Literal ( row , col_type ) , HirScalarExpr :: Column ( c ) => { let context_box = match c . level { 0 => context_box , _ => self . context_stack [ self . context_stack . len ( ) - c . level ] , } ; BoxScalarExpr :: ColumnReference ( self . find_column_within_box ( context_box , c . column ) ) } HirScalarExpr :: CallNullary ( func ) => BoxScalarExpr :: CallNullary ( func ) , HirScalarExpr :: CallUnary { func , expr } => BoxScalarExpr :: CallUnary { func , expr : Box :: new ( self . generate_expr ( * expr , context_box ) ) , } , HirScalarExpr :: CallBinary { func , expr1 , expr2 } => BoxScalarExpr :: CallBinary { func , expr1 : Box :: new ( self . generate_expr ( * expr1 , context_box ) ) , expr2 : Box :: new ( self . generate_expr ( * expr2 , context_box ) ) , } , HirScalarExpr :: CallVariadic { func , exprs } => BoxScalarExpr :: CallVariadic { func , exprs : exprs . into_iter ( ) . map ( | expr | self . generate_expr ( expr , context_box ) ) . collect :: < Vec < _ > > ( ) , } , HirScalarExpr :: If { cond , then , els } => BoxScalarExpr :: If { cond : Box :: new ( self . generate_expr ( * cond , context_box ) ) , then : Box :: new ( self . generate_expr ( * then , context_box ) ) , els : Box :: new ( self . generate_expr ( * els , context_box ) ) , } , HirScalarExpr :: Select ( mut expr ) => { let box_id = self . within_context ( context_box , & mut move | generator | -> BoxId { generator . generate_select ( expr . take ( ) ) } ) ; let quantifier_id = self . model . make_quantifier ( QuantifierType :: Scalar , box_id , context_box ) ; BoxScalarExpr :: ColumnReference ( ColumnReference { quantifier_id , position : 0 , } ) } _ => panic ! ( " " expr ) , } }
Lowers the given expression within the context of the given box.
Lowers the given expression within the context of the given box .
&mut self
expr
HirScalarExpr
context_box
BoxId
&mut self
expr
HirScalarExpr
context_box
BoxId