fn compile_bool_op(&mut self, op: &ast::Boolop, values: &[ast::Expr]) -> CompileResult<()> {
        let after_block = self.new_block();

        let (last_value, values) = values.split_last().unwrap();
        for value in values {
            self.compile_expression(value)?;

            match op {
                ast::Boolop::And => {
                    self.emit(Instruction::JumpIfFalseOrPop {
                        target: after_block,
                    });
                }
                ast::Boolop::Or => {
                    self.emit(Instruction::JumpIfTrueOrPop {
                        target: after_block,
                    });
                }
            }
        }

        // If all values did not qualify, take the value of the last value:
        self.compile_expression(last_value)?;
        self.switch_to_block(after_block);
        Ok(())
    }
/// Compile a boolean operation as an expression.
/// This means, that the last value remains on the stack.
Compile a boolean operation as an expression.
This means, that the last value remains on the stack.
Compile a boolean operation as an expression . This means that the last value remains on the stack .
fn compile_bool_op(&mut self, op: &ast::Boolop, values: &[ast::Expr]) -> CompileResult<()> {
        let after_block = self.new_block();
        let (last_value, values) = values.split_last().unwrap();
        for value in values {
            self.compile_expression(value)?;
            match op {
                ast::Boolop::And => {
                    self.emit(Instruction::JumpIfFalseOrPop {
                        target: after_block,
                    });
                }
                ast::Boolop::Or => {
                    self.emit(Instruction::JumpIfTrueOrPop {
                        target: after_block,
                    });
                }
            }
        }
        // If all values did not qualify, take the value of the last value:
        self.compile_expression(last_value)?;
        self.switch_to_block(after_block);
        Ok(())
    }
fn compile_bool_op ( & mut self , op : & ast :: Boolop , values : & [ ast :: Expr ] ) -> CompileResult < ( ) > { let after_block = self . new_block ( ) ; let ( last_value , values ) = values . split_last ( ) . unwrap ( ) ; for value in values { self . compile_expression ( value ) ? ; match op { ast :: Boolop :: And => { self . emit ( Instruction :: JumpIfFalseOrPop { target : after_block , } ) ; } ast :: Boolop :: Or => { self . emit ( Instruction :: JumpIfTrueOrPop { target : after_block , } ) ; } } } // If all values did not qualify, take the value of the last value: self . compile_expression ( last_value ) ? ; self . switch_to_block ( after_block ) ; Ok ( ( ) ) }
Compile a boolean operation as an expression.
Compile a boolean operation as an expression .
&mut self
op
&ast::Boolop
values
&[ast::Expr]