fn compile_bool_op(
        &mut self,
        op: &ast::BooleanOperator,
        values: &[ast::Expression],
    ) -> Result<(), CompileError> {
        let end_label = self.new_label();

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

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

        // If all values did not qualify, take the value of the last value:
        self.compile_expression(last_value)?;
        self.set_label(end_label);
        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::BooleanOperator,
        values: &[ast::Expression],
    ) -> Result<(), CompileError> {
        let end_label = self.new_label();
        let (last_value, values) = values.split_last().unwrap();
        for value in values {
            self.compile_expression(value)?;
            match op {
                ast::BooleanOperator::And => {
                    self.emit(Instruction::JumpIfFalseOrPop { target: end_label });
                }
                ast::BooleanOperator::Or => {
                    self.emit(Instruction::JumpIfTrueOrPop { target: end_label });
                }
            }
        }
        // If all values did not qualify, take the value of the last value:
        self.compile_expression(last_value)?;
        self.set_label(end_label);
        Ok(())
    }
fn compile_bool_op ( & mut self , op : & ast :: BooleanOperator , values : & [ ast :: Expression ] , ) -> Result < ( ) , CompileError > { let end_label = self . new_label ( ) ; let ( last_value , values ) = values . split_last ( ) . unwrap ( ) ; for value in values { self . compile_expression ( value ) ? ; match op { ast :: BooleanOperator :: And => { self . emit ( Instruction :: JumpIfFalseOrPop { target : end_label } ) ; } ast :: BooleanOperator :: Or => { self . emit ( Instruction :: JumpIfTrueOrPop { target : end_label } ) ; } } } // If all values did not qualify, take the value of the last value: self . compile_expression ( last_value ) ? ; self . set_label ( end_label ) ; Ok ( ( ) ) }
Compile a boolean operation as an expression.
Compile a boolean operation as an expression .
&mut self
op
&ast::BooleanOperator
values
&[ast::Expression]