plotnik_lib/bytecode/
sections.rs1use super::ids::StringId;
4
5#[derive(Clone, Copy, Debug, Default)]
11#[repr(C)]
12pub struct Slice {
13 pub ptr: u16,
14 pub len: u16,
15}
16
17impl Slice {
18 #[inline]
19 pub fn range(self) -> std::ops::Range<usize> {
20 let start = self.ptr as usize;
21 start..start + self.len as usize
22 }
23}
24
25#[derive(Clone, Copy, Debug)]
27#[repr(C)]
28pub struct NodeSymbol {
29 pub(crate) id: u16,
31 pub(crate) name: StringId,
33}
34
35impl NodeSymbol {
36 pub fn new(id: u16, name: StringId) -> Self {
38 Self { id, name }
39 }
40
41 pub fn id(&self) -> u16 {
42 self.id
43 }
44 pub fn name(&self) -> StringId {
45 self.name
46 }
47}
48
49#[derive(Clone, Copy, Debug)]
51#[repr(C)]
52pub struct FieldSymbol {
53 pub(crate) id: u16,
55 pub(crate) name: StringId,
57}
58
59impl FieldSymbol {
60 pub fn new(id: u16, name: StringId) -> Self {
62 Self { id, name }
63 }
64
65 pub fn id(&self) -> u16 {
66 self.id
67 }
68 pub fn name(&self) -> StringId {
69 self.name
70 }
71}
72
73#[derive(Clone, Copy, Debug)]
75#[repr(C)]
76pub struct TriviaEntry {
77 pub(crate) node_type: u16,
78}
79
80impl TriviaEntry {
81 pub fn new(node_type: u16) -> Self {
83 Self { node_type }
84 }
85
86 pub fn node_type(&self) -> u16 {
87 self.node_type
88 }
89}