Struct chalk_engine::table::Table
source · pub(crate) struct Table<I: Interner> {
pub(crate) table_goal: UCanonical<InEnvironment<Goal<I>>>,
pub(crate) coinductive_goal: bool,
floundered: bool,
answers: Vec<Answer<I>>,
answers_hash: FxHashMap<Canonical<AnswerSubst<I>>, bool>,
strands: VecDeque<Canonical<Strand<I>>>,
pub(crate) answer_mode: AnswerMode,
}
Fields§
§table_goal: UCanonical<InEnvironment<Goal<I>>>
The goal this table is trying to solve (also the key to look it up).
coinductive_goal: bool
A goal is coinductive if it can assume itself to be true, more or less. This is true for auto traits.
floundered: bool
True if this table is floundered, meaning that it doesn’t have enough types specified for us to solve.
answers: Vec<Answer<I>>
Stores the answers that we have found thus far. When we get a request for an answer N, we will first check this vector.
answers_hash: FxHashMap<Canonical<AnswerSubst<I>>, bool>
An alternative storage for the answers we have so far, used to
detect duplicates. Not every answer in answers
will be
represented here – we discard answers from answers_hash
(but not answers
) when better answers arrive (in particular,
answers with no ambiguity).
FIXME – Ideally we would exclude the region constraints and delayed subgoals from the hash, but that’s a bit tricky to do with the current canonicalization setup. It should be ok not to do so though it can result in more answers than we need.
strands: VecDeque<Canonical<Strand<I>>>
Stores the active strands that we can “pull on” to find more answers.
answer_mode: AnswerMode
Implementations§
source§impl<I: Interner> Table<I>
impl<I: Interner> Table<I>
pub(crate) fn new( table_goal: UCanonical<InEnvironment<Goal<I>>>, coinductive_goal: bool, ) -> Table<I>
sourcepub(crate) fn enqueue_strand(&mut self, strand: Canonical<Strand<I>>)
pub(crate) fn enqueue_strand(&mut self, strand: Canonical<Strand<I>>)
Push a strand to the back of the queue of strands to be processed.
pub(crate) fn strands_mut( &mut self, ) -> impl Iterator<Item = &mut Canonical<Strand<I>>>
pub(crate) fn strands(&self) -> impl Iterator<Item = &Canonical<Strand<I>>>
pub(crate) fn take_strands(&mut self) -> VecDeque<Canonical<Strand<I>>>
sourcepub(crate) fn dequeue_next_strand_that(
&mut self,
test: impl Fn(&Canonical<Strand<I>>) -> bool,
) -> Option<Canonical<Strand<I>>>
pub(crate) fn dequeue_next_strand_that( &mut self, test: impl Fn(&Canonical<Strand<I>>) -> bool, ) -> Option<Canonical<Strand<I>>>
Remove the next strand from the queue that meets the given criteria
sourcepub(crate) fn mark_floundered(&mut self)
pub(crate) fn mark_floundered(&mut self)
Mark the table as floundered – this also discards all pre-existing answers, as they are no longer relevant.
sourcepub(crate) fn is_floundered(&self) -> bool
pub(crate) fn is_floundered(&self) -> bool
Returns true if the table is floundered.
sourcepub(crate) fn push_answer(&mut self, answer: Answer<I>) -> Option<AnswerIndex>
pub(crate) fn push_answer(&mut self, answer: Answer<I>) -> Option<AnswerIndex>
Adds answer
to our list of answers, unless it is already present.
Returns true if answer
was added.
§Panics
This will panic if a previous answer with the same substitution
was marked as ambgiuous, but the new answer is not. No current
tests trigger this case, and assumptions upstream assume that when
true
is returned here, that a new answer was added (instead of an)
existing answer replaced.