Trait llhd::value::Context
[−]
[src]
pub trait Context: AsContext { fn try_value(&self, value: &ValueRef) -> Option<&Value>; fn parent(&self) -> Option<&Context> { ... } fn value(&self, value: &ValueRef) -> &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<&Value>
Try to resolve a ValueRef
to an actual &Value
reference. May fail if
the value is not known to the context.
Provided Methods
fn parent(&self) -> Option<&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) -> &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.
Implementors
impl<'tctx> Context for ModuleContext<'tctx>
impl<'tctx> Context for FunctionContext<'tctx>
impl<'tctx> Context for ProcessContext<'tctx>
impl<'tctx> Context for EntityContext<'tctx>