[][src]Trait llhd::Context

pub trait Context: AsContext {
    fn try_value(&self, value: &ValueRef) -> Option<&dyn Value>;

    fn parent(&self) -> Option<&dyn Context> { ... }
fn value(&self, value: &ValueRef) -> &dyn Value { ... }
fn ty(&self, value: &ValueRef) -> Type { ... }
fn name(&self, value: &ValueRef) -> Option<&str> { ... } }

A context is anything that can resolve the name and type of a ValueRef. Contexts are expected to form a hierarchy, such that a context wrapping e.g. a function falls back to a parent context wrapping the module if a value cannot be appropriately resolved.

Required methods

fn try_value(&self, value: &ValueRef) -> Option<&dyn Value>

Try to resolve a ValueRef to an actual &Value reference. May fail if the value is not known to the context.

Loading content...

Provided methods

fn parent(&self) -> Option<&dyn Context>

Get the parent context to which value resolution shall escalate. May return None for the context at the top of the hierarchy.

fn value(&self, value: &ValueRef) -> &dyn Value

Resolve a ValueRef to an actual &Value reference. Panics if the value is unknown to this context and its parents.

fn ty(&self, value: &ValueRef) -> Type

Get the type of a value.

fn name(&self, value: &ValueRef) -> Option<&str>

Get the name of a value.

Loading content...

Implementors

impl<'tctx> Context for EntityContext<'tctx>
[src]

fn value(&self, value: &ValueRef) -> &dyn Value
[src]

fn ty(&self, value: &ValueRef) -> Type
[src]

fn name(&self, value: &ValueRef) -> Option<&str>
[src]

impl<'tctx> Context for FunctionContext<'tctx>
[src]

fn value(&self, value: &ValueRef) -> &dyn Value
[src]

fn ty(&self, value: &ValueRef) -> Type
[src]

fn name(&self, value: &ValueRef) -> Option<&str>
[src]

impl<'tctx> Context for ModuleContext<'tctx>
[src]

fn parent(&self) -> Option<&dyn Context>
[src]

fn value(&self, value: &ValueRef) -> &dyn Value
[src]

fn ty(&self, value: &ValueRef) -> Type
[src]

fn name(&self, value: &ValueRef) -> Option<&str>
[src]

impl<'tctx> Context for ProcessContext<'tctx>
[src]

fn value(&self, value: &ValueRef) -> &dyn Value
[src]

fn ty(&self, value: &ValueRef) -> Type
[src]

fn name(&self, value: &ValueRef) -> Option<&str>
[src]

Loading content...