Skip to main content

AstNode

Struct AstNode 

Source
pub struct AstNode {
    pub stmt: AstStatement,
    pub id: AstId,
    pub location: SourceLocation,
    pub metadata: Option<MetaData>,
}

Fields§

§stmt: AstStatement§id: AstId§location: SourceLocation§metadata: Option<MetaData>

Implementations§

Source§

impl AstNode

Source

pub fn get_as_list(&self) -> Vec<&AstNode>

Returns the statement in a singleton list, or the contained statements if the statement is already a list

Source

pub fn get_location(&self) -> SourceLocation

Source

pub fn set_location(&mut self, location: SourceLocation)

Source

pub fn get_id(&self) -> AstId

Source

pub fn get_stmt(&self) -> &AstStatement

Source

pub fn get_stmt_mut(&mut self) -> &mut AstStatement

Source

pub fn get_stmt_peeled(&self) -> &AstStatement

Similar to AstNode::get_stmt with the exception of peeling parenthesized expressions. For example if called on ((1)) this function would return a AstStatement::Literal ignoring the parenthesized expressions altogether.

Source

pub fn is_struct_literal_initializer(&self) -> bool

Returns true if this node represents a struct literal initializer, i.e. a (possibly parenthesized) expression list or named assignment like (a := 1, b := 2) or (field := value).

Source

pub fn get_node_peeled(&self) -> &AstNode

Source

pub fn get_metadata(&self) -> Option<&MetaData>

Source

pub fn has_direct_access(&self) -> bool

Returns true if the current statement has a direct access.

Source

pub fn is_cast_prefix_eligible(&self) -> bool

returns true if this AST Statement is a literal or reference that can be prefixed with a type-cast (e.g. INT#23)

Source

pub fn is_flat_reference(&self) -> bool

Returns true if the current statement is a flat reference (e.g. a)

Source

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

Returns the reference-name if this is a flat reference like a, or None if this is no flat reference

Source

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

Source

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

Source

pub fn is_empty_statement(&self) -> bool

Source

pub fn is_assignment(&self) -> bool

Source

pub fn is_output_assignment(&self) -> bool

Source

pub fn is_reference(&self) -> bool

Source

pub fn is_member_access(&self) -> bool

Source

pub fn get_initial_base(&self) -> Option<&AstNode>

Source

pub fn get_identifier(&self) -> Option<&AstNode>

Source

pub fn is_call(&self) -> bool

Source

pub fn is_hardware_access(&self) -> bool

Source

pub fn is_array_access(&self) -> bool

Source

pub fn is_pointer_access(&self) -> bool

Source

pub fn is_this(&self) -> bool

Source

pub fn is_this_deref(&self) -> bool

Source

pub fn is_paren(&self) -> bool

Source

pub fn is_expression_list(&self) -> bool

Source

pub fn is_super(&self) -> bool

Source

pub fn is_super_deref(&self) -> bool

Source

pub fn is_super_or_super_deref(&self) -> bool

Source

pub fn has_super_metadata(&self) -> bool

Source

pub fn has_super_metadata_deref(&self) -> bool

Source

pub fn can_be_assigned_to(&self) -> bool

Source

pub fn new( stmt: AstStatement, id: AstId, location: impl Into<SourceLocation>, ) -> AstNode

Source

pub fn new_literal( kind: AstLiteral, id: AstId, location: SourceLocation, ) -> AstNode

Source

pub fn new_integer(value: i128, id: AstId, location: SourceLocation) -> AstNode

Source

pub fn new_real(value: String, id: AstId, location: SourceLocation) -> AstNode

Source

pub fn new_string( value: impl Into<String>, is_wide: bool, id: AstId, location: SourceLocation, ) -> AstNode

Source

pub fn is_zero(&self) -> bool

Returns true if the given token is an integer or float and zero.

Source

pub fn is_binary_expression(&self) -> bool

Source

pub fn is_literal_array(&self) -> bool

Source

pub fn is_literal(&self) -> bool

Source

pub fn is_literal_integer(&self) -> bool

Source

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

Source

pub fn is_identifier(&self) -> bool

Source

pub fn is_default_value(&self) -> bool

Source

pub fn negate(self: AstNode, id_provider: IdProvider) -> AstNode

Negates the given element by adding it to a not expression

Source

pub fn is_template(&self) -> bool

Source

pub fn with_metadata(self, metadata: MetaData) -> AstNode

Source

pub fn is_deref(&self) -> bool

Source

pub fn get_call_operator(&self) -> Option<&AstNode>

Source

pub fn get_ref_expr_mut(&mut self) -> Option<&mut ReferenceExpr>

Source

pub fn get_deref_expr(&self) -> Option<&ReferenceExpr>

Source

pub fn get_base_ref_expr(&self) -> Option<&AstNode>

Source

pub fn get_base_ref_expr_mut(&mut self) -> Option<&mut AstNode>

Source

pub fn as_string(&self) -> String

Source

pub fn is_real(&self) -> bool

Source

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

Returns the identifier of the left-hand side if this is an assignment statement

Trait Implementations§

Source§

impl Clone for AstNode

Source§

fn clone(&self) -> AstNode

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 AstNode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AstNode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AstNode
where 'de: 'static,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&AstNode> for SourceLocation

Source§

fn from(value: &AstNode) -> Self

Converts to this type from the input type.
Source§

impl From<AstNode> for MetaData

Source§

fn from(value: AstNode) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for AstNode

Source§

fn eq(&self, other: &AstNode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AstNode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'__deriveMoreLifetime> TryFrom<&'__deriveMoreLifetime AstStatement> for &'__deriveMoreLifetime Box<AstNode>

Source§

type Error = TryIntoError<&'__deriveMoreLifetime AstStatement>

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

fn try_from( value: &'__deriveMoreLifetime AstStatement, ) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'__deriveMoreLifetime> TryFrom<&'__deriveMoreLifetime mut AstStatement> for &'__deriveMoreLifetime mut Box<AstNode>

Source§

type Error = TryIntoError<&'__deriveMoreLifetime mut AstStatement>

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

fn try_from( value: &'__deriveMoreLifetime mut AstStatement, ) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<AstStatement> for Box<AstNode>

Source§

type Error = TryIntoError<AstStatement>

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

fn try_from(value: AstStatement) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Walker for AstNode

Source§

fn walk<V>(&self, visitor: &mut V)
where V: AstVisitor,

Source§

impl WalkerMut for AstNode

Source§

fn walk<V>(&mut self, visitor: &mut V)
where V: AstVisitorMut,

Source§

impl StructuralPartialEq for AstNode

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,