luaur_code_gen/functions/
get_scale_encoding.rs1macro_rules! CODEGEN_ASSERT {
2 ($expr:expr) => {
3 assert!($expr);
4 };
5}
6
7pub fn get_scale_encoding(scale: u8) -> u8 {
8 const SCALES: [u8; 9] = [0xff, 0, 1, 0xff, 2, 0xff, 0xff, 0xff, 3];
9
10 CODEGEN_ASSERT!(scale < 9 && SCALES[scale as usize] != 0xff);
11 SCALES[scale as usize]
12}