luaur_code_gen/records/
patch.rs1use crate::enums::kind::Kind;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4#[repr(C)]
5pub struct Patch {
6 pub(crate) kind_and_label: u32,
9 pub(crate) location: u32,
10}
11
12impl Patch {
13 #[inline]
14 pub(crate) fn kind(&self) -> Kind {
15 unsafe { core::mem::transmute((self.kind_and_label & 0x3) as i32) }
16 }
17
18 #[inline]
19 pub(crate) fn label(&self) -> u32 {
20 self.kind_and_label >> 2
21 }
22
23 #[inline]
24 pub(crate) fn set_kind(&mut self, kind: Kind) {
25 self.kind_and_label = (self.kind_and_label & !0x3) | ((kind as u32) & 0x3);
26 }
27
28 #[inline]
29 pub(crate) fn set_label(&mut self, label: u32) {
30 self.kind_and_label = (self.kind_and_label & 0x3) | (label << 2);
31 }
32}