Struct Context

Source
pub struct Context<O, D>
where O: Operation,
{ pub graph: CompilationResult<O>, pub data: D, }
Expand description

A compilation context. This stores the current parse graph.

Fields§

§graph: CompilationResult<O>

The parse graph.

§data: D

Data given by the consumer.

Implementations§

Source§

impl<O, D> Context<O, D>
where O: Operation,

Source

pub fn new(data: D) -> Self

Create a new Context.

Source

pub fn add_node(&mut self, operation: O) -> NodeIndex

Add a node to the parse graph.

Source

pub fn add_binary_operation( &mut self, operation: O, left: NodeIndex, right: NodeIndex, ) -> NodeIndex

Add a binary operation node to the parse graph and edges for the left and right operands.

Source

pub fn add_unary_operation( &mut self, operation: O, parent: NodeIndex, ) -> NodeIndex

Add a unary operation node to the parse graph and an edge for the unary operand.

Source

pub fn add_edge(&mut self, from: NodeIndex, to: NodeIndex, edge: EdgeInfo)

Add an edge between from and to.

Trait Implementations§

Source§

impl<O, D: Clone> Clone for Context<O, D>
where O: Operation + Clone,

Source§

fn clone(&self) -> Context<O, D>

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<O, D: Debug> Debug for Context<O, D>
where O: Operation + Debug,

Source§

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

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

impl<'de, O, D> Deserialize<'de> for Context<O, D>
where O: Operation + Deserialize<'de>, D: Deserialize<'de>,

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<O, D> Serialize for Context<O, D>
where O: Operation + Serialize, D: Serialize,

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

Auto Trait Implementations§

§

impl<O, D> Freeze for Context<O, D>
where D: Freeze,

§

impl<O, D> RefUnwindSafe for Context<O, D>

§

impl<O, D> Send for Context<O, D>
where D: Send, O: Send,

§

impl<O, D> Sync for Context<O, D>
where D: Sync, O: Sync,

§

impl<O, D> Unpin for Context<O, D>
where D: Unpin, O: Unpin,

§

impl<O, D> UnwindSafe for Context<O, D>
where D: UnwindSafe, O: UnwindSafe,

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