<commit_before>use stack::Stack;

/// Represents a builtin function
#[derive(Debug, Clone, PartialEq)]
pub enum Builtin {
    Dot,
    Plus,
    Minus,
    Star,
    Slash,
    Abs,
    And,
    Or,
    Xor,
    Equals,
    LessThan,
    GreaterThan,
    LessEqual,
    GreaterEqual,
    Emit,
    Dup,
    Swap,
    Over,
    Rot,
    Tuck,
    Drop,
}

impl Builtin {
    pub fn call(&self, stack: &mut Stack) {
        macro_rules! stackexpr {
            ( $($aname:ident : $atype:ty),+ => $value:expr ) => {
                {
                    $(
                        let $aname: $atype = stack.pop();
                    )+
                    stack.push($value)
                }
            }
        }
        match *self {
            Builtin::Dot => print!("{}", stack.pop::<i32>()),
            Builtin::Plus => stackexpr!(n2: i32, n1: i32 => n1 + n2),
            Builtin::Minus => stackexpr!(n2: i32, n1: i32 => n1 - n2),
            Builtin::Star => stackexpr!(n2: i32, n1: i32 => n1 * n2),
            Builtin::Slash => stackexpr!(n2: i32, n1: i32 => n1 / n2),
            Builtin::Abs => stackexpr!(n: i32 => n.abs()),
            Builtin::And => stackexpr!(n2: i32, n1: i32 => n1 & n2),
            Builtin::Or => stackexpr!(n2: i32, n1: i32 => n1 | n2),
            Builtin::Xor => stackexpr!(n2: i32, n1: i32 => n1 ^ n2),
            Builtin::Equals => stackexpr!(n2: i32, n1: i32 => n1 == n2),
            Builtin::LessThan => stackexpr!(n2: i32, n1: i32 => n1 < n2),
            Builtin::GreaterThan => stackexpr!(n2: i32, n1: i32 => n1 > n2),
            Builtin::LessEqual => stackexpr!(n2: i32, n1: i32 => n1 <= n2),
            Builtin::GreaterEqual => stackexpr!(n2: i32, n1: i32 => n1 >= n2),
            Builtin::Emit => print!("{}", stack.pop::<char>()),
            Builtin::Dup => {
                let n: i32 = stack.peak();
                stack.push(n);
            }
            Builtin::Swap => {
                let n2: i32 = stack.pop();
                let n1: i32 = stack.pop();
                stack.push(n2);
                stack.push(n1);
            }
            Builtin::Over => {
                let n2: i32 = stack.pop();
                let n1: i32 = stack.pop();
                stack.push(n1);
                stack.push(n2);
                stack.push(n1);
            }
            Builtin::Rot => {
                let n3: i32 = stack.pop();
                let n2: i32 = stack.pop();
                let n1: i32 = stack.pop();
                stack.push(n1);
                stack.push(n3);
                stack.push(n2);
            }
            Builtin::Tuck => {
                let n2: i32 = stack.pop();
                let n1: i32 = stack.pop();
                stack.push(n2);
                stack.push(n1);
                stack.push(n2);
            }
            Builtin::Drop => {
                stack.pop::<i32>();
            }
        }
    }
}
<commit_msg>use self::Builtin::* in defintion of Builtin.call()<commit_after>use stack::Stack;

/// Represents a builtin function
#[derive(Debug, Clone, PartialEq)]
pub enum Builtin {
    Dot,
    Plus,
    Minus,
    Star,
    Slash,
    Abs,
    And,
    Or,
    Xor,
    Equals,
    LessThan,
    GreaterThan,
    LessEqual,
    GreaterEqual,
    Emit,
    Dup,
    Swap,
    Over,
    Rot,
    Tuck,
    Drop,
}

impl Builtin {
    pub fn call(&self, stack: &mut Stack) {
        macro_rules! stackexpr {
            ( $($aname:ident : $atype:ty),+ => $value:expr ) => {
                {
                    $(
                        let $aname: $atype = stack.pop();
                    )+
                    stack.push($value)
                }
            }
        }

        use self::Builtin::*;
        match *self {
            Dot => print!("{}", stack.pop::<i32>()),
            Plus => stackexpr!(n2: i32, n1: i32 => n1 + n2),
            Minus => stackexpr!(n2: i32, n1: i32 => n1 - n2),
            Star => stackexpr!(n2: i32, n1: i32 => n1 * n2),
            Slash => stackexpr!(n2: i32, n1: i32 => n1 / n2),
            Abs => stackexpr!(n: i32 => n.abs()),
            And => stackexpr!(n2: i32, n1: i32 => n1 & n2),
            Or => stackexpr!(n2: i32, n1: i32 => n1 | n2),
            Xor => stackexpr!(n2: i32, n1: i32 => n1 ^ n2),
            Equals => stackexpr!(n2: i32, n1: i32 => n1 == n2),
            LessThan => stackexpr!(n2: i32, n1: i32 => n1 < n2),
            GreaterThan => stackexpr!(n2: i32, n1: i32 => n1 > n2),
            LessEqual => stackexpr!(n2: i32, n1: i32 => n1 <= n2),
            GreaterEqual => stackexpr!(n2: i32, n1: i32 => n1 >= n2),
            Emit => print!("{}", stack.pop::<char>()),
            Dup => {
                let n: i32 = stack.peak();
                stack.push(n);
            }
            Swap => {
                let n2: i32 = stack.pop();
                let n1: i32 = stack.pop();
                stack.push(n2);
                stack.push(n1);
            }
            Over => {
                let n2: i32 = stack.pop();
                let n1: i32 = stack.pop();
                stack.push(n1);
                stack.push(n2);
                stack.push(n1);
            }
            Rot => {
                let n3: i32 = stack.pop();
                let n2: i32 = stack.pop();
                let n1: i32 = stack.pop();
                stack.push(n1);
                stack.push(n3);
                stack.push(n2);
            }
            Tuck => {
                let n2: i32 = stack.pop();
                let n1: i32 = stack.pop();
                stack.push(n2);
                stack.push(n1);
                stack.push(n2);
            }
            Drop => {
                stack.pop::<i32>();
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.15849843587069865, 'fraction_numerical': 0.049356969064998264, 'mean_word_length': 1.2185813415574402, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '714676', 'n_tokens_mistral': 2117, 'n_tokens_neox': 1988, 'n_words': 419}