| 452 | /// Creates a new [Kind::Dimension] token. |
| 453 | #[inline] |
| 454 | pub(crate) fn new_dimension( |
| 455 | is_float: bool, |
| 456 | has_sign: bool, |
| 457 | num_len: u32, |
| 458 | unit_len: u32, |
| 459 | value: f32, |
| 460 | atom: u8, |
| 461 | ) -> Self { |
| 462 | debug_assert!(num_len <= 4097); |
| 463 | let num_len = (num_len << 12) & HALF_LENGTH_MASK; |
| 464 | let is_known_unit = if unit_len < 32 { ((atom != 0) as u32) << 7 } else { 0 }; |
| 465 | let unit_len = if is_known_unit == 0 { unit_len } else { unit_len << 7 | (atom as u32 & 0b1111111) }; |
| 466 | let flags: u32 = Kind::Dimension as u32 | is_known_unit | ((is_float as u32) << 5) | ((has_sign as u32) << 6); |
| 467 | Self(((flags << 24) & KIND_MASK) | ((num_len | unit_len) & LENGTH_MASK), value.to_bits()) |
| 468 | } |
| 469 | |
| 470 | /// Creates a new [Kind::BadString] token. Bad Strings are like String tokens but during lexing they failed to fully tokenize |
| 471 | /// into a proper string token, usually due to containing newline characters. |