fn opcode_gt_inner(
        &mut self, chunk: &Chunk, i: usize, v1: &Value, v2: &Value,
    ) -> i32 {
        match (&*v1, &*v2) {
            (Value::BigInt(n1), Value::BigInt(n2)) => {
                let res = if n2 > n1 { 1 } else { 0 };
                self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                return 1;
            }
            (Value::BigInt(_), Value::Int(n2)) => {
                return self.opcode_eq_inner(chunk, i, v1, &int_to_bigint(*n2));
            }
            (Value::Int(n1), Value::BigInt(_)) => {
                return self.opcode_eq_inner(chunk, i, &int_to_bigint(*n1), v2);
            }
            (Value::Int(n1), Value::Int(n2)) => {
                let res = if n2 > n1 { 1 } else { 0 };
                self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                return 1;
            }
            (Value::BigInt(n1), Value::Float(_)) => {
                return self.opcode_eq_inner(chunk, i, &bigint_to_float(n1), v2);
            }
            (Value::Float(_), Value::BigInt(n2)) => {
                return self.opcode_eq_inner(chunk, i, v1, &bigint_to_float(n2));
            }
            (Value::Int(n1), Value::Float(_)) => {
                return self.opcode_eq_inner(chunk, i, &int_to_float(*n1), v2);
            }
            (Value::Float(_), Value::Int(n2)) => {
                return self.opcode_eq_inner(chunk, i, v1, &int_to_float(*n2));
            }
            (Value::Float(n1), Value::Float(n2)) => {
                let res = if n2 > n1 { 1 } else { 0 };
                self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                return 1;
            }
            (_, _) => {
                let n1_opt = v1.to_int();
                let n2_opt = v2.to_int();
                match (n1_opt, n2_opt) {
                    (Some(n1), Some(n2)) => {
                        let res = if n2 > n1 { 1 } else { 0 };
                        self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                        return 1;
                    }
                    _ => {}
                }
                let n1_opt = v1.to_bigint();
                let n2_opt = v2.to_bigint();
                match (n1_opt, n2_opt) {
                    (Some(n1), Some(n2)) => {
                        let res = if n2 > n1 { 1 } else { 0 };
                        self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                        return 1;
                    }
                    _ => {}
                }
                let n1_opt = v1.to_float();
                let n2_opt = v2.to_float();
                match (n1_opt, n2_opt) {
                    (Some(n1), Some(n2)) => {
                        let res = if n2 > n1 { 1 } else { 0 };
                        self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                        return 1;
                    }
                    _ => {}
                }
                let i1_str_pre = v1.to_string();
                let i1_str_opt = to_string_2(&i1_str_pre);
                let i2_str_pre = v2.to_string();
                let i2_str_opt = to_string_2(&i2_str_pre);
                match (i1_str_opt, i2_str_opt) {
                    (Some(n1), Some(n2)) => {
                        let res = if n2 > n1 { 1 } else { 0 };
                        self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                        return 1;
                    }
                    _ => {}
                }
                return 0;
            }
        }
    }
/// Helper function for checking whether one value is greater than
/// another, and placing a boolean onto the stack indicating
/// whether that is so.  Returns an integer indicating whether the
/// values were able to be compared.
Helper function for checking whether one value is greater than
another, and placing a boolean onto the stack indicating
whether that is so.  Returns an integer indicating whether the
values were able to be compared.
Helper function for checking whether one value is greater than another and placing a boolean onto the stack indicating whether that is so . Returns an integer indicating whether the values were able to be compared .
fn opcode_gt_inner(
        &mut self, chunk: &Chunk, i: usize, v1: &Value, v2: &Value,
    ) -> i32 {
        match (&*v1, &*v2) {
            (Value::BigInt(n1), Value::BigInt(n2)) => {
                let res = if n2 > n1 { 1 } else { 0 };
                self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                return 1;
            }
            (Value::BigInt(_), Value::Int(n2)) => {
                return self.opcode_eq_inner(chunk, i, v1, &int_to_bigint(*n2));
            }
            (Value::Int(n1), Value::BigInt(_)) => {
                return self.opcode_eq_inner(chunk, i, &int_to_bigint(*n1), v2);
            }
            (Value::Int(n1), Value::Int(n2)) => {
                let res = if n2 > n1 { 1 } else { 0 };
                self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                return 1;
            }
            (Value::BigInt(n1), Value::Float(_)) => {
                return self.opcode_eq_inner(chunk, i, &bigint_to_float(n1), v2);
            }
            (Value::Float(_), Value::BigInt(n2)) => {
                return self.opcode_eq_inner(chunk, i, v1, &bigint_to_float(n2));
            }
            (Value::Int(n1), Value::Float(_)) => {
                return self.opcode_eq_inner(chunk, i, &int_to_float(*n1), v2);
            }
            (Value::Float(_), Value::Int(n2)) => {
                return self.opcode_eq_inner(chunk, i, v1, &int_to_float(*n2));
            }
            (Value::Float(n1), Value::Float(n2)) => {
                let res = if n2 > n1 { 1 } else { 0 };
                self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                return 1;
            }
            (_, _) => {
                let n1_opt = v1.to_int();
                let n2_opt = v2.to_int();
                match (n1_opt, n2_opt) {
                    (Some(n1), Some(n2)) => {
                        let res = if n2 > n1 { 1 } else { 0 };
                        self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                        return 1;
                    }
                    _ => {}
                }
                let n1_opt = v1.to_bigint();
                let n2_opt = v2.to_bigint();
                match (n1_opt, n2_opt) {
                    (Some(n1), Some(n2)) => {
                        let res = if n2 > n1 { 1 } else { 0 };
                        self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                        return 1;
                    }
                    _ => {}
                }
                let n1_opt = v1.to_float();
                let n2_opt = v2.to_float();
                match (n1_opt, n2_opt) {
                    (Some(n1), Some(n2)) => {
                        let res = if n2 > n1 { 1 } else { 0 };
                        self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                        return 1;
                    }
                    _ => {}
                }
                let i1_str_pre = v1.to_string();
                let i1_str_opt = to_string_2(&i1_str_pre);
                let i2_str_pre = v2.to_string();
                let i2_str_opt = to_string_2(&i2_str_pre);
                match (i1_str_opt, i2_str_opt) {
                    (Some(n1), Some(n2)) => {
                        let res = if n2 > n1 { 1 } else { 0 };
                        self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
                        return 1;
                    }
                    _ => {}
                }
                return 0;
            }
        }
    }
fn opcode_gt_inner ( & mut self , chunk : & Chunk , i : usize , v1 : & Value , v2 : & Value , ) -> i32 { match ( & * v1 , & * v2 ) { ( Value :: BigInt ( n1 ) , Value :: BigInt ( n2 ) ) => { let res = if n2 > n1 { 1 } else { 0 } ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( res ) ) ) ) ; return 1 ; } ( Value :: BigInt ( _ ) , Value :: Int ( n2 ) ) => { return self . opcode_eq_inner ( chunk , i , v1 , & int_to_bigint ( * n2 ) ) ; } ( Value :: Int ( n1 ) , Value :: BigInt ( _ ) ) => { return self . opcode_eq_inner ( chunk , i , & int_to_bigint ( * n1 ) , v2 ) ; } ( Value :: Int ( n1 ) , Value :: Int ( n2 ) ) => { let res = if n2 > n1 { 1 } else { 0 } ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( res ) ) ) ) ; return 1 ; } ( Value :: BigInt ( n1 ) , Value :: Float ( _ ) ) => { return self . opcode_eq_inner ( chunk , i , & bigint_to_float ( n1 ) , v2 ) ; } ( Value :: Float ( _ ) , Value :: BigInt ( n2 ) ) => { return self . opcode_eq_inner ( chunk , i , v1 , & bigint_to_float ( n2 ) ) ; } ( Value :: Int ( n1 ) , Value :: Float ( _ ) ) => { return self . opcode_eq_inner ( chunk , i , & int_to_float ( * n1 ) , v2 ) ; } ( Value :: Float ( _ ) , Value :: Int ( n2 ) ) => { return self . opcode_eq_inner ( chunk , i , v1 , & int_to_float ( * n2 ) ) ; } ( Value :: Float ( n1 ) , Value :: Float ( n2 ) ) => { let res = if n2 > n1 { 1 } else { 0 } ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( res ) ) ) ) ; return 1 ; } ( _ , _ ) => { let n1_opt = v1 . to_int ( ) ; let n2_opt = v2 . to_int ( ) ; match ( n1_opt , n2_opt ) { ( Some ( n1 ) , Some ( n2 ) ) => { let res = if n2 > n1 { 1 } else { 0 } ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( res ) ) ) ) ; return 1 ; } _ => { } } let n1_opt = v1 . to_bigint ( ) ; let n2_opt = v2 . to_bigint ( ) ; match ( n1_opt , n2_opt ) { ( Some ( n1 ) , Some ( n2 ) ) => { let res = if n2 > n1 { 1 } else { 0 } ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( res ) ) ) ) ; return 1 ; } _ => { } } let n1_opt = v1 . to_float ( ) ; let n2_opt = v2 . to_float ( ) ; match ( n1_opt , n2_opt ) { ( Some ( n1 ) , Some ( n2 ) ) => { let res = if n2 > n1 { 1 } else { 0 } ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( res ) ) ) ) ; return 1 ; } _ => { } } let i1_str_pre = v1 . to_string ( ) ; let i1_str_opt = to_string_2 ( & i1_str_pre ) ; let i2_str_pre = v2 . to_string ( ) ; let i2_str_opt = to_string_2 ( & i2_str_pre ) ; match ( i1_str_opt , i2_str_opt ) { ( Some ( n1 ) , Some ( n2 ) ) => { let res = if n2 > n1 { 1 } else { 0 } ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( res ) ) ) ) ; return 1 ; } _ => { } } return 0 ; } } }
Helper function for checking whether one value is greater than
another, and placing a boolean onto the stack indicating
whether that is so.
Helper function for checking whether one value is greater than another and placing a boolean onto the stack indicating whether that is so .
&mut self
chunk
&Chunk
i
usize
v1
&Value
v2
&Value