You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
868 B

use crate::defines::PointerSize;
#[cfg(test)]
use serde_derive::{Deserialize, Serialize};
#[derive(Eq, PartialEq, Debug)]
#[cfg_attr(test, derive(Serialize, Deserialize))]
pub enum PrimitiveType {
Void,
Int8,
Int16,
Int32,
Int64,
UInt8,
UInt16,
UInt32,
UInt64,
Float,
Double,
Bool,
}
#[allow(dead_code)]
pub fn get_primitive_type_byte_size(t: PrimitiveType) -> PointerSize {
match t {
PrimitiveType::Void => 0,
PrimitiveType::Int8 => 1,
PrimitiveType::Int16 => 2,
PrimitiveType::Int32 => 4,
PrimitiveType::Int64 => 8,
PrimitiveType::UInt8 => 1,
PrimitiveType::UInt16 => 2,
PrimitiveType::UInt32 => 4,
PrimitiveType::UInt64 => 8,
PrimitiveType::Float => 4,
PrimitiveType::Double => 8,
PrimitiveType::Bool => 1,
}
}