Struct moore_vhdl::term::TermContext
source · [−]pub struct TermContext<C, S, D> {
pub ctx: C,
pub scope: S,
/* private fields */
}
Expand description
A context within which termification can occur.
Fields
ctx: C
The underlying scoreboard context.
scope: S
The scope within which the terms will resolve their names.
Implementations
sourceimpl<C, S, D> TermContext<C, S, D>
impl<C, S, D> TermContext<C, S, D>
sourcepub fn fold<'t>(&self, term: Spanned<Term<'t>>) -> Spanned<Term<'t>>
pub fn fold<'t>(&self, term: Spanned<Term<'t>>) -> Spanned<Term<'t>>
Perform term folding.
This is a post-processing step that should be applied to all terms once
they are constructed. Folding applies transformations to the terms, e.g.
changing Ident(Type|Subtype)
to TypeMark
, or gobbling up subtype
constraints where appropriate.
sourceimpl<'a, C, S, D> TermContext<C, S, D> where
Self: DefSpecificTermContext<'a, D>,
Self: ScopeSpecificTermContext<'a, S, D>,
C: DiagEmitter + Copy,
S: Copy,
D: Copy,
impl<'a, C, S, D> TermContext<C, S, D> where
Self: DefSpecificTermContext<'a, D>,
Self: ScopeSpecificTermContext<'a, S, D>,
C: DiagEmitter + Copy,
S: Copy,
D: Copy,
sourcepub fn termify_literal(
&self,
ast: Spanned<&Literal>
) -> Result<Spanned<Term<'a>>>
pub fn termify_literal(
&self,
ast: Spanned<&Literal>
) -> Result<Spanned<Term<'a>>>
Map an AST literal to a term.
sourcepub fn ensure_resolved<'t>(
&self,
term: Spanned<Term<'t>>
) -> Result<Spanned<Term<'t>>>
pub fn ensure_resolved<'t>(
&self,
term: Spanned<Term<'t>>
) -> Result<Spanned<Term<'t>>>
Make sure the term is not an unresolved name.
This function emits a diagnostic if the term is Term::Unresolved(..)
.
It is non-recursive.
sourcepub fn termify_compound_name(
&self,
ast: &CompoundName
) -> Result<Spanned<Term<'a>>>
pub fn termify_compound_name(
&self,
ast: &CompoundName
) -> Result<Spanned<Term<'a>>>
Map an AST compound name to a term.
sourcepub fn termify_name(
&self,
name: Spanned<ResolvableName>
) -> Result<Spanned<Term<'a>>>
pub fn termify_name(
&self,
name: Spanned<ResolvableName>
) -> Result<Spanned<Term<'a>>>
Map a resolvable name to a term.
This function is the bottom of the pit. Names are resolved here and mapped to the corresponding term. Calling functions may then proceed to handle the term as they see fit, usually inspecting what exact kind the term is of.
sourcepub fn termify_paren_elems(
&self,
elems: &ParenElems
) -> Result<Spanned<Term<'a>>>
pub fn termify_paren_elems(
&self,
elems: &ParenElems
) -> Result<Spanned<Term<'a>>>
Map multiple parenthesis elements to a term.
sourcepub fn termify_subtype_ind(
&self,
subty: &SubtypeInd
) -> Result<Spanned<Term<'a>>>
pub fn termify_subtype_ind(
&self,
subty: &SubtypeInd
) -> Result<Spanned<Term<'a>>>
Map an AST subtype indication to a term.
sourceimpl<'sbc, 'lazy, 'sb, 'ast, 'ctx> TermContext<&'sbc ScoreContext<'lazy, 'sb, 'ast, 'ctx>, ScopeRef, Def> where
'lazy: 'sbc,
'sb: 'lazy,
'ast: 'sb,
'ctx: 'sb,
impl<'sbc, 'lazy, 'sb, 'ast, 'ctx> TermContext<&'sbc ScoreContext<'lazy, 'sb, 'ast, 'ctx>, ScopeRef, Def> where
'lazy: 'sbc,
'sb: 'lazy,
'ast: 'sb,
'ctx: 'sb,
sourcepub fn new(
ctx: &'sbc ScoreContext<'lazy, 'sb, 'ast, 'ctx>,
scope: ScopeRef
) -> Self
pub fn new(
ctx: &'sbc ScoreContext<'lazy, 'sb, 'ast, 'ctx>,
scope: ScopeRef
) -> Self
Create a new termification context.
sourcepub fn termify_latent_name(
&self,
name: LatentName<'ast>
) -> Result<Spanned<Term<'_>>>
pub fn termify_latent_name(
&self,
name: LatentName<'ast>
) -> Result<Spanned<Term<'_>>>
Map a latent name to a term.
sourcepub fn term_to_expr(&self, term: Spanned<Term<'_>>) -> Result<ExprRef>
pub fn term_to_expr(&self, term: Spanned<Term<'_>>) -> Result<ExprRef>
Map a term to an expression and schedule the necessary tasks.
sourcepub fn term_to_expr_spanned(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<ExprRef>>
pub fn term_to_expr_spanned(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<ExprRef>>
Same as term_to_expr
, but the result is spanned.
sourcepub fn term_to_expr_raw(&self, term: Spanned<Term<'_>>) -> Result<Expr>
pub fn term_to_expr_raw(&self, term: Spanned<Term<'_>>) -> Result<Expr>
Map a term to an expression.
sourcepub fn term_to_type_mark(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<TypeMarkRef>>
pub fn term_to_type_mark(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<TypeMarkRef>>
Map a term to a type mark.
sourcepub fn fold_term_as_type<'t>(
&self,
term: Spanned<Term<'t>>
) -> Result<Spanned<Term<'t>>>
pub fn fold_term_as_type<'t>(
&self,
term: Spanned<Term<'t>>
) -> Result<Spanned<Term<'t>>>
Perform term folding expecting to yield a type.
This is a pre-processing step on terms. It is applied as soon as it is
clear that a certain term should yield a type, e.g. when mapping to a
subtype indication. This function performs certain precedence swaps and
combines terms into higher level ones, e.g. Term::SubtypeInd
.
sourcepub fn term_to_subtype_ind(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<SubtypeInd>>
pub fn term_to_subtype_ind(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<SubtypeInd>>
Map a term to a subtype indication.
sourcepub fn term_to_resolution_indication(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<()>>
pub fn term_to_resolution_indication(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<()>>
Map a term to a resolution indication.
sourcepub fn term_to_constraint(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<Constraint>>
pub fn term_to_constraint(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<Constraint>>
Map a term to a constraint.
sourcepub fn term_to_array_constraint(
&self,
span: Span,
terms: Vec<Spanned<Term<'_>>>,
elem: Option<Spanned<Term<'_>>>
) -> Result<Spanned<ArrayConstraint>>
pub fn term_to_array_constraint(
&self,
span: Span,
terms: Vec<Spanned<Term<'_>>>,
elem: Option<Spanned<Term<'_>>>
) -> Result<Spanned<ArrayConstraint>>
Map a term to an array constraint.
sourcepub fn term_to_record_constraint(
&self,
span: Span,
terms: Vec<Spanned<Term<'_>>>
) -> Result<Spanned<RecordConstraint>>
pub fn term_to_record_constraint(
&self,
span: Span,
terms: Vec<Spanned<Term<'_>>>
) -> Result<Spanned<RecordConstraint>>
Map a term to a record constraint.
sourcepub fn term_to_element_constraint(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<ElementConstraint>>
pub fn term_to_element_constraint(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<ElementConstraint>>
Map a term to an element constraint.
sourcepub fn term_to_discrete_range(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<DiscreteRange>>
pub fn term_to_discrete_range(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<DiscreteRange>>
Map a term to a discrete range.
sourcepub fn term_to_range(&self, term: Spanned<Term<'_>>) -> Result<Spanned<Range>>
pub fn term_to_range(&self, term: Spanned<Term<'_>>) -> Result<Spanned<Range>>
Map a term to a range.
sourcepub fn term_to_ident(&self, term: Spanned<Term<'_>>) -> Result<Spanned<Def>>
pub fn term_to_ident(&self, term: Spanned<Term<'_>>) -> Result<Spanned<Def>>
Map a term to a definition.
This works for terms that are actually identifiers.
sourcepub fn term_to_label(&self, term: Spanned<Term<'_>>) -> Result<Spanned<StmtRef>>
pub fn term_to_label(&self, term: Spanned<Term<'_>>) -> Result<Spanned<StmtRef>>
Map a term to a label.
Returns the statement the label refers to.
sourcepub fn term_to_signal(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<SignalRef>>
pub fn term_to_signal(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<SignalRef>>
Map a term to a signal.
sourcepub fn term_to_choice(&self, term: Spanned<Term<'_>>) -> Result<Spanned<Choice>>
pub fn term_to_choice(&self, term: Spanned<Term<'_>>) -> Result<Spanned<Choice>>
Map a term to a choice.
See IEEE 1076-2008 section 9.3.3.1. A choice can be a simple expression,
a discrete range, an identifier, or the keyword others
.
sourcepub fn term_to_aggregate(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<AggregateRef>>
pub fn term_to_aggregate(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<AggregateRef>>
Map a term to an aggregate.
See IEEE 1076-2008 section 9.3.3.1.
sourcepub fn term_to_assoc_list(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<AssocList>>
pub fn term_to_assoc_list(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<AssocList>>
Map a term to an association list.
See IEEE 1076-2008 section 6.5.7.
sourcepub fn term_to_assoc_actual(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<AssocActual>>
pub fn term_to_assoc_actual(
&self,
term: Spanned<Term<'_>>
) -> Result<Spanned<AssocActual>>
Map a term to an association actual.
sourceimpl<'t> TermContext<AllocContext<'t>, &'t ScopeData<'t>, Def2<'t>>
impl<'t> TermContext<AllocContext<'t>, &'t ScopeData<'t>, Def2<'t>>
sourcepub fn new2(ctx: AllocContext<'t>) -> Self
pub fn new2(ctx: AllocContext<'t>) -> Self
Create a new termification context.
Trait Implementations
sourceimpl<'t, C: DiagEmitter, S> DefSpecificTermContext<'t, Def> for TermContext<C, S, Def>
impl<'t, C: DiagEmitter, S> DefSpecificTermContext<'t, Def> for TermContext<C, S, Def>
sourceimpl<'t, C: DiagEmitter, S> DefSpecificTermContext<'t, Def2<'t>> for TermContext<C, S, Def2<'t>>
impl<'t, C: DiagEmitter, S> DefSpecificTermContext<'t, Def2<'t>> for TermContext<C, S, Def2<'t>>
sourceimpl<C: DiagEmitter, S, D> DiagEmitter for TermContext<C, S, D>
impl<C: DiagEmitter, S, D> DiagEmitter for TermContext<C, S, D>
sourcefn emit(&self, diag: DiagBuilder2)
fn emit(&self, diag: DiagBuilder2)
Emit a diagnostic message.
sourceimpl<'t> ScopeSpecificTermContext<'t, &'t ScopeData<'t>, Def2<'t>> for TermContext<AllocContext<'t>, &'t ScopeData<'t>, Def2<'t>>
impl<'t> ScopeSpecificTermContext<'t, &'t ScopeData<'t>, Def2<'t>> for TermContext<AllocContext<'t>, &'t ScopeData<'t>, Def2<'t>>
sourcefn termify_name_in_scope(
&self,
name: Spanned<ResolvableName>,
scope: &'t ScopeData<'t>
) -> Result<Spanned<Term<'t>>>
fn termify_name_in_scope(
&self,
name: Spanned<ResolvableName>,
scope: &'t ScopeData<'t>
) -> Result<Spanned<Term<'t>>>
Map a resolvable name to a term, resolving it within a scope.
fn maybe_selectable_scope(&self, term: &Term<'t>) -> Option<&'t ScopeData<'t>>
sourceimpl<'t, 'sbc, 'lazy, 'sb, 'ast, 'ctx> ScopeSpecificTermContext<'t, ScopeRef, Def> for TermContext<&'sbc ScoreContext<'lazy, 'sb, 'ast, 'ctx>, ScopeRef, Def> where
'lazy: 'sbc,
'sb: 'lazy,
'ast: 'sb,
'ctx: 'sb,
impl<'t, 'sbc, 'lazy, 'sb, 'ast, 'ctx> ScopeSpecificTermContext<'t, ScopeRef, Def> for TermContext<&'sbc ScoreContext<'lazy, 'sb, 'ast, 'ctx>, ScopeRef, Def> where
'lazy: 'sbc,
'sb: 'lazy,
'ast: 'sb,
'ctx: 'sb,
sourcefn termify_name_in_scope(
&self,
name: Spanned<ResolvableName>,
scope: ScopeRef
) -> Result<Spanned<Term<'t>>>
fn termify_name_in_scope(
&self,
name: Spanned<ResolvableName>,
scope: ScopeRef
) -> Result<Spanned<Term<'t>>>
Map a resolvable name to a term, resolving it within a scope.
fn maybe_selectable_scope(&self, term: &Term<'t>) -> Option<ScopeRef>
Auto Trait Implementations
impl<C, S, D> RefUnwindSafe for TermContext<C, S, D> where
C: RefUnwindSafe,
D: RefUnwindSafe,
S: RefUnwindSafe,
impl<C, S, D> Send for TermContext<C, S, D> where
C: Send,
D: Send,
S: Send,
impl<C, S, D> Sync for TermContext<C, S, D> where
C: Sync,
D: Sync,
S: Sync,
impl<C, S, D> Unpin for TermContext<C, S, D> where
C: Unpin,
D: Unpin,
S: Unpin,
impl<C, S, D> UnwindSafe for TermContext<C, S, D> where
C: UnwindSafe,
D: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more