liblisa::semantics::default::computation

Trait AsComputationRef

pub trait AsComputationRef {
    // Required method
    fn as_internal(&self) -> ComputationRef<'_, '_>;

    // Provided methods
    fn to_synthesized_computation(&self) -> SynthesizedComputation { ... }
    fn expr(&self) -> Expr<'_> { ... }
    fn arg_interpretation(&self) -> &[Arg] { ... }
    fn if_zero<A: AsComputationRef, B: AsComputationRef>(
        &self,
        if_zero: &A,
        if_nonzero: &B,
    ) -> SynthesizedComputation { ... }
    fn chain(&self, other: &impl AsComputationRef) -> SynthesizedComputation
       where Self: Debug { ... }
    fn and(&self, other: &SynthesizedComputation) -> SynthesizedComputation
       where Self: Debug { ... }
    fn or(&self, other: &SynthesizedComputation) -> SynthesizedComputation
       where Self: Debug { ... }
    fn not(&self) -> SynthesizedComputation { ... }
    fn not_crop(&self) -> SynthesizedComputation { ... }
    fn consts(&self) -> &[i128] { ... }
}
Expand description

Provides generic methods that work on references to computations.

Required Methods§

fn as_internal(&self) -> ComputationRef<'_, '_>

Return a ComputationRef.

Provided Methods§

fn to_synthesized_computation(&self) -> SynthesizedComputation

Return an owned SynthesizedComputation.

fn expr(&self) -> Expr<'_>

Return a reference to the expression used in the template.

fn arg_interpretation(&self) -> &[Arg]

Returns the argument interpretations of the computation.

fn if_zero<A: AsComputationRef, B: AsComputationRef>( &self, if_zero: &A, if_nonzero: &B, ) -> SynthesizedComputation

Returns a new expression that returns if_zero if the current expression is equal to 0, and returns if_nonzero otherwise.

fn chain(&self, other: &impl AsComputationRef) -> SynthesizedComputation
where Self: Debug,

Concatenates the operations of the two computations. In and of itself, this produces a computation that ends with two values on the evaluation stack. The last value is normally popped and returned, which would be the result of other.

This method is only useful if you want to then perform an operation that uses the results of both computations. For example, chaining the results of two computations and then adding the Op::Add operation to compute the sum of both computations.

fn and(&self, other: &SynthesizedComputation) -> SynthesizedComputation
where Self: Debug,

Returns a computation that computes the bitwise AND of both computations.

fn or(&self, other: &SynthesizedComputation) -> SynthesizedComputation
where Self: Debug,

Returns a computation that computes the bitwise OR of both computations.

fn not(&self) -> SynthesizedComputation

Returns a computation that computes the bitwise NOT of the computation.

fn not_crop(&self) -> SynthesizedComputation

Returns a computation that computes the bitwise NOT of the computation, and then crops the result to 1 bit.

fn consts(&self) -> &[i128]

Returns the constants used in this computation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§