chap 2.5.0

Chap is an easy to learn, interpretive, scripting language written in Rust
Documentation
use crate::builtin_function::control_flow::jump::jump;
use crate::common::data_type::DataType;
use crate::common::errors::Result;
use crate::runtime::Runtime;
use crate::{
    builtin_function::utils::param_to_datatype,
    common::{errors::ChapError, executable::ExecutableLine},
};

// this function can't jump to a tag that is not added to runtime.executables
pub fn jump_if_not(runtime: &mut Runtime, executable: &ExecutableLine) -> Result<()> {
    let p2 = param_to_datatype(runtime, executable.params.get(1), executable.line_number)?;

    let b = match p2 {
        DataType::Bool(b) => b,
        _ => {
            return Err(ChapError::runtime_with_msg(
                executable.line_number,
                "jump_if_not function needs bool as second param".to_string(),
            ));
        }
    };

    if !b {
        jump(runtime, executable)?;
    }
    Ok(())
}