Enum bend::hvm::ast::Tree

source ·
pub enum Tree {
    Era,
    Num {
        val: u32,
    },
    Ref {
        nam: String,
    },
    Ctr {
        lab: u16,
        ports: Vec<Tree>,
    },
    Op {
        fst: Box<Tree>,
        snd: Box<Tree>,
    },
    Mat {
        zero: Box<Tree>,
        succ: Box<Tree>,
        out: Box<Tree>,
    },
    Var {
        nam: String,
    },
}
Expand description

An AST node representing an interaction net tree.

Trees in interaction nets are inductively defined as either wires, or an agent with all of its auxiliary ports (if any) connected to trees.

Here, the wires at the leaves of the tree are represented with Tree::Var, where the variable name is shared between both sides of the wire.

Variants§

§

Era

A nilary eraser node.

§

Num

A native 60-bit integer.

Fields

§val: u32
§

Ref

A nilary node, referencing a named net.

Fields

§

Ctr

A n-ary interaction combinator.

Fields

§lab: u16

The label of the combinator. (Combinators with the same label annihilate, and combinators with different labels commute.)

§ports: Vec<Tree>

The auxiliary ports of this node.

  • 0 ports: this behaves identically to an eraser node.
  • 1 port: this behaves identically to a wire.
  • 2 ports: this is a standard binary combinator node.
  • 3+ ports: equivalent to right-chained binary nodes; (a b c) is equivalent to (a (b c)).

The length of this vector must be less than MAX_ARITY.

§

Op

A binary node representing an operation on native integers.

The principal port connects to the left operand.

Fields

§fst: Box<Tree>

An auxiliary port; connects to the right operand.

§snd: Box<Tree>

An auxiliary port; connects to the output.

§

Mat

A binary node representing a match on native integers.

The principal port connects to the integer to be matched on.

Fields

§zero: Box<Tree>

An auxiliary port; connects to the zero branch.

§succ: Box<Tree>

An auxiliary port; connects to the a CTR with label 0 containing the predecessor and the output of the succ branch.

§out: Box<Tree>

An auxiliary port; connects to the output.

§

Var

One side of a wire; the other side will have the same name.

Fields

Implementations§

source§

impl Tree

source

pub fn children( &self ) -> impl ExactSizeIterator + DoubleEndedIterator<Item = &Tree>

source

pub fn children_mut( &mut self ) -> impl ExactSizeIterator + DoubleEndedIterator<Item = &mut Tree>

source

pub fn legacy_mat(arms: Tree, out: Tree) -> Option<Tree>

Trait Implementations§

source§

impl Clone for Tree

source§

fn clone(&self) -> Tree

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Tree

source§

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

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

impl Default for Tree

source§

fn default() -> Tree

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

impl Display for Tree

source§

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

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

impl Drop for Tree

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl FromStr for Tree

§

type Err = String

The associated error which can be returned from parsing.
source§

fn from_str(str: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Tree

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Tree

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Tree

source§

impl StructuralPartialEq for Tree

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnwindSafe for Tree

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<'t, T> Place<'t, T> for T

source§

fn place(loaned: LoanedMut<'t, T>, place: &'t mut T)

source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.