fn type_check_math(
        &self,
        left: &ParsedType,
        right: &ParsedType,
        op: &BinopKind,
    ) -> ParsedType {
        // In C all arithmetic is defined such that if one operator is allowed
        // all are technically supported.
        // i.e. no '+' operator for strings (but you can add the pointers)
        // TODO: If we ever support operator overloading clearly this will have
        //       to change...
        // NOTE: we currently don't support you doing arithmetic
        let left_def = self.get_typedef(left);
        let right_def = self.get_typedef(right);

        // TODO: Support pointer arithmetic

        match (left_def, right_def) {
            (
                Some(TypeDefinition::Integral {
                    size: left_size,
                    signedness: left_signedness,
                    ..
                }),
                Some(TypeDefinition::Integral {
                    size: right_size,
                    signedness: right_signedness,
                    ..
                }),
            ) => {
                if left_signedness == right_signedness {
                    if left_size > right_size {
                        left.clone()
                    } else {
                        right.clone()
                    }
                } else {
                    warn!("Can't perform an operation on two objects differing in signedness, perform a cast.\n
                           Operation {:?} is not valid on types {:?} and {:?}", op, left, right);
                    ParsedType::Unknown
                }
            }
            (
                Some(TypeDefinition::FloatingPt {
                    size: left_size, ..
                }),
                Some(TypeDefinition::FloatingPt {
                    size: right_size, ..
                }),
            ) => {
                if left_size > right_size {
                    left.clone()
                } else {
                    right.clone()
                }
            }
            _ => {
                // TODO: If one is a floating point and the other is an
                //       integral type then it's fine
                warn!(
                    "Operation {:?} is not valid on types {:?} and {:?}",
                    op, left, right
                );
                ParsedType::Unknown
            }
        }
    }
/// Type check an arithmetic expression and return the resultant type
/// i.e. u8 + i8 is an error
///      u8 + u16 => u16
///      i16 + i64 => i64
///      f32 + i64 is an error
///      f32 + f64 => f64
Type check an arithmetic expression and return the resultant type
i.e.
Type check an arithmetic expression and return the resultant type i . e .
fn type_check_math(
        &self,
        left: &ParsedType,
        right: &ParsedType,
        op: &BinopKind,
    ) -> ParsedType {
        // In C all arithmetic is defined such that if one operator is allowed
        // all are technically supported.
        // i.e. no '+' operator for strings (but you can add the pointers)
        // TODO: If we ever support operator overloading clearly this will have
        //       to change...
        // NOTE: we currently don't support you doing arithmetic
        let left_def = self.get_typedef(left);
        let right_def = self.get_typedef(right);
        // TODO: Support pointer arithmetic
        match (left_def, right_def) {
            (
                Some(TypeDefinition::Integral {
                    size: left_size,
                    signedness: left_signedness,
                    ..
                }),
                Some(TypeDefinition::Integral {
                    size: right_size,
                    signedness: right_signedness,
                    ..
                }),
            ) => {
                if left_signedness == right_signedness {
                    if left_size > right_size {
                        left.clone()
                    } else {
                        right.clone()
                    }
                } else {
                    warn!("Can't perform an operation on two objects differing in signedness, perform a cast.\n
                           Operation {:?} is not valid on types {:?} and {:?}", op, left, right);
                    ParsedType::Unknown
                }
            }
            (
                Some(TypeDefinition::FloatingPt {
                    size: left_size, ..
                }),
                Some(TypeDefinition::FloatingPt {
                    size: right_size, ..
                }),
            ) => {
                if left_size > right_size {
                    left.clone()
                } else {
                    right.clone()
                }
            }
            _ => {
                // TODO: If one is a floating point and the other is an
                //       integral type then it's fine
                warn!(
                    "Operation {:?} is not valid on types {:?} and {:?}",
                    op, left, right
                );
                ParsedType::Unknown
            }
        }
    }
fn type_check_math ( & self , left : & ParsedType , right : & ParsedType , op : & BinopKind , ) -> ParsedType { // In C all arithmetic is defined such that if one operator is allowed // all are technically supported. // i.e. no '+' operator for strings (but you can add the pointers) // TODO: If we ever support operator overloading clearly this will have //       to change... // NOTE: we currently don't support you doing arithmetic let left_def = self . get_typedef ( left ) ; let right_def = self . get_typedef ( right ) ; // TODO: Support pointer arithmetic match ( left_def , right_def ) { ( Some ( TypeDefinition :: Integral { size : left_size , signedness : left_signedness , .. } ) , Some ( TypeDefinition :: Integral { size : right_size , signedness : right_signedness , .. } ) , ) => { if left_signedness == right_signedness { if left_size > right_size { left . clone ( ) } else { right . clone ( ) } } else { warn ! ( " \n " op left right ) ; ParsedType :: Unknown } } ( Some ( TypeDefinition :: FloatingPt { size : left_size , .. } ) , Some ( TypeDefinition :: FloatingPt { size : right_size , .. } ) , ) => { if left_size > right_size { left . clone ( ) } else { right . clone ( ) } } _ => { // TODO: If one is a floating point and the other is an //       integral type then it's fine warn ! ( " " op left right ) ; ParsedType :: Unknown } } }
Type check an arithmetic expression and return the resultant type
i.e.
Type check an arithmetic expression and return the resultant type i . e .
&self
left
&ParsedType
right
&ParsedType
op
&BinopKind