pub enum NodeTypeIR {
Any,
Named(Option<NonZeroU16>),
Anonymous(Option<NonZeroU16>),
}Expand description
Node type constraint for Match instructions.
Distinguishes between named nodes ((identifier)), anonymous nodes ("text"),
and wildcards (_, (_)). Encoded in bytecode header byte bits 5-4.
node_kind | Value | Meaning | node_type=0 | node_type>0 |
|---|---|---|---|---|
00 | Any | _ pattern | No check | (invalid) |
01 | Named | (_)/(t) | Check is_named() | Check kind_id() |
10 | Anon | "text" | Check !is_named() | Check kind_id() |
11 | - | Reserved | Error | Error |
Variants§
Any
Any node (_ pattern) - no type check performed.
Named(Option<NonZeroU16>)
Named node constraint ((_) or (identifier)).
None= any named node (checkis_named())Some(id)= specific named type (checkkind_id())
Anonymous(Option<NonZeroU16>)
Anonymous node constraint ("text" literals).
None= any anonymous node (check!is_named())Some(id)= specific anonymous type (checkkind_id())
Implementations§
Source§impl NodeTypeIR
impl NodeTypeIR
Sourcepub fn to_bytes(self) -> (u8, u16)
pub fn to_bytes(self) -> (u8, u16)
Encode to bytecode: returns (node_kind bits, node_type value).
node_kind is 2 bits for header byte bits 5-4.
node_type is u16 for bytes 2-3.
Sourcepub fn from_bytes(node_kind: u8, node_type: u16) -> Self
pub fn from_bytes(node_kind: u8, node_type: u16) -> Self
Decode from bytecode: node_kind bits (2 bits) and node_type value (u16).
Sourcepub fn type_id(&self) -> Option<NonZeroU16>
pub fn type_id(&self) -> Option<NonZeroU16>
Check if this represents a specific type ID (not a wildcard).
Sourcepub fn is_anonymous(&self) -> bool
pub fn is_anonymous(&self) -> bool
Check if this is an Anonymous constraint (wildcard or specific).
Trait Implementations§
Source§impl Clone for NodeTypeIR
impl Clone for NodeTypeIR
Source§fn clone(&self) -> NodeTypeIR
fn clone(&self) -> NodeTypeIR
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NodeTypeIR
impl Debug for NodeTypeIR
Source§impl Default for NodeTypeIR
impl Default for NodeTypeIR
Source§fn default() -> NodeTypeIR
fn default() -> NodeTypeIR
Returns the “default value” for a type. Read more
Source§impl PartialEq for NodeTypeIR
impl PartialEq for NodeTypeIR
impl Copy for NodeTypeIR
impl Eq for NodeTypeIR
impl StructuralPartialEq for NodeTypeIR
Auto Trait Implementations§
impl Freeze for NodeTypeIR
impl RefUnwindSafe for NodeTypeIR
impl Send for NodeTypeIR
impl Sync for NodeTypeIR
impl Unpin for NodeTypeIR
impl UnwindSafe for NodeTypeIR
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.