harn-vm 0.7.29

Async bytecode virtual machine for the Harn programming language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::chunk::Op;
use crate::value::{VmError, VmValue};

impl super::super::Vm {
    pub(super) fn try_execute_logical_op(&mut self, op: u8) -> Result<bool, VmError> {
        if op == Op::Not as u8 {
            let v = self.pop()?;
            self.stack.push(VmValue::Bool(!v.is_truthy()));
        } else {
            return Ok(false);
        }
        Ok(true)
    }
}