Skip to main content

Node

Enum Node 

Source
pub enum Node {
Show 40 variants StructOffset { origin: CodeOrigin, struct_name: String, field: String, }, Sizeof { origin: CodeOrigin, struct_name: String, }, Immediate { origin: CodeOrigin, value: i128, }, Add { origin: CodeOrigin, left: Box<Node>, right: Box<Node>, }, Sub { origin: CodeOrigin, left: Box<Node>, right: Box<Node>, }, Mul { origin: CodeOrigin, left: Box<Node>, right: Box<Node>, }, Neg { origin: CodeOrigin, child: Box<Node>, }, Or { origin: CodeOrigin, left: Box<Node>, right: Box<Node>, }, And { origin: CodeOrigin, left: Box<Node>, right: Box<Node>, }, Xor { origin: CodeOrigin, left: Box<Node>, right: Box<Node>, }, Bitnot { origin: CodeOrigin, child: Box<Node>, }, StringLiteral { origin: CodeOrigin, value: String, }, Register { origin: CodeOrigin, name: String, }, FpRegister { origin: CodeOrigin, name: String, }, VecRegister { origin: CodeOrigin, name: String, }, SpecialRegister { name: String, }, Variable { origin: CodeOrigin, name: String, original_name: String, }, Address { origin: CodeOrigin, base: Box<Node>, offset: Box<Node>, }, BaseIndex { origin: CodeOrigin, base: Box<Node>, index: Box<Node>, scale: Box<Node>, offset: Box<Node>, }, AbsoluteAddress { origin: CodeOrigin, address: Box<Node>, }, Instruction { origin: CodeOrigin, opcode: String, operands: Vec<Node>, annotation: Option<String>, }, Error { origin: CodeOrigin, }, ConstExpr { origin: CodeOrigin, value: TokenStream, }, ConstDecl { origin: CodeOrigin, variable: Box<Node>, value: Box<Node>, }, Label { origin: CodeOrigin, name: String, }, LocalLabel { origin: CodeOrigin, name: String, }, LabelReference { origin: CodeOrigin, label: String, offset: i64, }, LocalLabelReference { origin: CodeOrigin, label: String, }, Sequence { origin: CodeOrigin, list: Vec<Node>, }, True, False, Setting { origin: CodeOrigin, name: String, }, AndPred { origin: CodeOrigin, left: Box<Node>, right: Box<Node>, }, OrPred { origin: CodeOrigin, left: Box<Node>, right: Box<Node>, }, NotPred { origin: CodeOrigin, child: Box<Node>, }, Skip { origin: CodeOrigin, }, IfThenElse { origin: CodeOrigin, predicate: Box<Node>, then_case: Box<Node>, else_case: Box<Node>, }, Macro { origin: CodeOrigin, name: Option<String>, variables: Vec<Node>, body: Box<Node>, }, MacroCall { origin: CodeOrigin, name: String, operands: Vec<Node>, annotation: Option<String>, original_name: String, }, RustConst { origin: CodeOrigin, ident: String, expr: Expr, },
}
Expand description

Holds one offlineasm syntax tree node.

Variants§

§

StructOffset

Fields

§origin: CodeOrigin
§struct_name: String
§field: String
§

Sizeof

Fields

§origin: CodeOrigin
§struct_name: String
§

Immediate

Holds an integer literal or folded immediate.

Fields

§origin: CodeOrigin
§value: i128
§

Add

Fields

§origin: CodeOrigin
§left: Box<Node>
§right: Box<Node>
§

Sub

Fields

§origin: CodeOrigin
§left: Box<Node>
§right: Box<Node>
§

Mul

Fields

§origin: CodeOrigin
§left: Box<Node>
§right: Box<Node>
§

Neg

Fields

§origin: CodeOrigin
§child: Box<Node>
§

Or

Fields

§origin: CodeOrigin
§left: Box<Node>
§right: Box<Node>
§

And

Fields

§origin: CodeOrigin
§left: Box<Node>
§right: Box<Node>
§

Xor

Fields

§origin: CodeOrigin
§left: Box<Node>
§right: Box<Node>
§

Bitnot

Fields

§origin: CodeOrigin
§child: Box<Node>
§

StringLiteral

Fields

§origin: CodeOrigin
§value: String
§

Register

Fields

§origin: CodeOrigin
§name: String
§

FpRegister

Fields

§origin: CodeOrigin
§name: String
§

VecRegister

Fields

§origin: CodeOrigin
§name: String
§

SpecialRegister

Fields

§name: String
§

Variable

Fields

§origin: CodeOrigin
§name: String
§original_name: String
§

Address

Fields

§origin: CodeOrigin
§base: Box<Node>
§offset: Box<Node>
§

BaseIndex

Fields

§origin: CodeOrigin
§base: Box<Node>
§index: Box<Node>
§scale: Box<Node>
§offset: Box<Node>
§

AbsoluteAddress

Fields

§origin: CodeOrigin
§address: Box<Node>
§

Instruction

Fields

§origin: CodeOrigin
§opcode: String
§operands: Vec<Node>
§annotation: Option<String>
§

Error

Fields

§origin: CodeOrigin
§

ConstExpr

Holds the (possibly $param-unsubstituted) tokens of a const { ... } block, or of the narrower constexpr(...)/ constexpr a::b::c forms used in an address’s scale position.

Fields

§origin: CodeOrigin
§

ConstDecl

Fields

§origin: CodeOrigin
§variable: Box<Node>
§value: Box<Node>
§

Label

Fields

§origin: CodeOrigin
§name: String
§

LocalLabel

Fields

§origin: CodeOrigin
§name: String
§

LabelReference

Fields

§origin: CodeOrigin
§label: String
§offset: i64
§

LocalLabelReference

Fields

§origin: CodeOrigin
§label: String
§

Sequence

Fields

§origin: CodeOrigin
§list: Vec<Node>
§

True

§

False

§

Setting

Fields

§origin: CodeOrigin
§name: String
§

AndPred

Fields

§origin: CodeOrigin
§left: Box<Node>
§right: Box<Node>
§

OrPred

Fields

§origin: CodeOrigin
§left: Box<Node>
§right: Box<Node>
§

NotPred

Fields

§origin: CodeOrigin
§child: Box<Node>
§

Skip

Fields

§origin: CodeOrigin
§

IfThenElse

Fields

§origin: CodeOrigin
§predicate: Box<Node>
§then_case: Box<Node>
§else_case: Box<Node>
§

Macro

Fields

§origin: CodeOrigin
§variables: Vec<Node>
§body: Box<Node>
§

MacroCall

Fields

§origin: CodeOrigin
§name: String
§operands: Vec<Node>
§annotation: Option<String>
§original_name: String
§

RustConst

Fields

§origin: CodeOrigin
§ident: String
§expr: Expr

Implementations§

Source§

impl Node

Source

pub fn origin_string(&self) -> String

Returns the origin string, or <builtin> when absent.

Source

pub fn origin(&self) -> Option<&CodeOrigin>

Returns the origin, when the node carries one.

Source

pub fn origin_cloned(&self) -> CodeOrigin

Clones the origin, or a builtin origin when absent.

Source

pub fn children(&self) -> Vec<&Node>

Lists the direct children.

Source

pub fn descendants(&self) -> Vec<&Node>

Lists all descendants depth-first.

Source

pub fn flatten_vec(&self) -> Vec<&Node>

Lists the node plus all descendants.

Source

pub fn is_address(&self) -> bool

Reports whether the node is an address form.

Source

pub fn is_label_node(&self) -> bool

Reports whether the node references a label.

Source

pub fn is_rust_const(&self) -> bool

Reports whether the node is a symbolic Rust const placeholder.

Source

pub fn is_immediate(&self) -> bool

Reports whether the node is an immediate expression.

Source

pub fn is_register_node(&self) -> bool

Reports whether the node names a register.

Source

pub fn is_immediate_operand(&self) -> bool

Reports whether the node is an immediate operand.

Source

pub fn variable_name(&self) -> Option<&str>

Returns the variable name, when the node is a variable.

Source

pub fn immediate_value(&self) -> Option<i128>

Returns the literal value, when the node is an immediate.

Source

pub fn with_offset(&self, extra: i128) -> Option<Node>

Copies an address node with extra added to its offset.

Returns None when the node is not an address form.

Source

pub fn plus_offset(&self, extra: i128) -> Option<Node>

Copies a label reference with extra added to its offset.

Returns None when the node is not a label reference or extra does not fit in an i64.

Source

pub fn scale_value(&self) -> Result<i128, String>

Returns the scale of a BaseIndex node.

§Errors

Returns an error if the node is not a BaseIndex, or if its scale is not 1, 2, 4, or 8.

Source

pub fn scale_shift(&self) -> Result<u32, String>

Returns the shift matching the scale of a BaseIndex node.

§Errors

Returns an error for any reason Node::scale_value can.

Source

pub fn dump(&self) -> String

Renders the canonical text of the node.

Offset keys and error messages use this form.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Send for Node

§

impl !Sync for Node

§

impl Forget for Node

§

impl Freeze for Node

§

impl Move for Node

§

impl RefUnwindSafe for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.