Struct leo_asg::scope::Scope[][src]

pub struct Scope<'a> {
    pub context: AsgContext<'a>,
    pub id: u32,
    pub parent_scope: Cell<Option<&'a Scope<'a>>>,
    pub function: Cell<Option<&'a Function<'a>>>,
    pub circuit_self: Cell<Option<&'a Circuit<'a>>>,
    pub variables: RefCell<IndexMap<String, &'a Variable<'a>>>,
    pub functions: RefCell<IndexMap<String, &'a Function<'a>>>,
    pub circuits: RefCell<IndexMap<String, &'a Circuit<'a>>>,
    pub input: Cell<Option<Input<'a>>>,
}

An abstract data type that track the current bindings for variables, functions, and circuits.

Fields

context: AsgContext<'a>id: u32

The unique id of the scope.

parent_scope: Cell<Option<&'a Scope<'a>>>

The parent scope that this scope inherits.

function: Cell<Option<&'a Function<'a>>>

The function definition that this scope occurs in.

circuit_self: Cell<Option<&'a Circuit<'a>>>

The circuit definition that this scope occurs in.

variables: RefCell<IndexMap<String, &'a Variable<'a>>>

Maps variable name => variable.

functions: RefCell<IndexMap<String, &'a Function<'a>>>

Maps function name => function.

circuits: RefCell<IndexMap<String, &'a Circuit<'a>>>

Maps circuit name => circuit.

input: Cell<Option<Input<'a>>>

The main input to the program.

Implementations

impl<'a> Scope<'a>[src]

pub fn resolve_variable(&self, name: &str) -> Option<&'a Variable<'a>>[src]

Returns a reference to the variable corresponding to the name.

If the current scope did not have this name present, then the parent scope is checked. If there is no parent scope, then None is returned.

pub fn resolve_current_function(&self) -> Option<&'a Function<'_>>[src]

Returns a reference to the current function.

If the current scope did not have a function present, then the parent scope is checked. If there is no parent scope, then None is returned.

pub fn resolve_input(&self) -> Option<Input<'a>>[src]

Returns a reference to the current input.

If the current scope did not have an input present, then the parent scope is checked. If there is no parent scope, then None is returned.

pub fn resolve_function(&self, name: &str) -> Option<&'a Function<'a>>[src]

Returns a reference to the function corresponding to the name.

If the current scope did not have this name present, then the parent scope is checked. If there is no parent scope, then None is returned.

pub fn resolve_circuit(&self, name: &str) -> Option<&'a Circuit<'a>>[src]

Returns a reference to the circuit corresponding to the name.

If the current scope did not have this name present, then the parent scope is checked. If there is no parent scope, then None is returned.

pub fn resolve_circuit_self(&self) -> Option<&'a Circuit<'a>>[src]

Returns a reference to the current circuit.

If the current scope did not have a circuit self present, then the parent scope is checked. If there is no parent scope, then None is returned.

pub fn make_subscope(self: &'a Scope<'a>) -> &'a Scope<'a>[src]

Returns a new scope given a parent scope.

pub fn resolve_ast_type(
    &self,
    type_: &Type
) -> Result<Type<'a>, AsgConvertError>
[src]

Returns the type returned by the current scope.

Trait Implementations

impl<'a> Clone for Scope<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Scope<'a>

impl<'a> !Send for Scope<'a>

impl<'a> !Sync for Scope<'a>

impl<'a> Unpin for Scope<'a>

impl<'a> !UnwindSafe for Scope<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.