Struct stack_graphs::partial::PartialPath
source · [−]#[repr(C)]pub struct PartialPath {
pub start_node: Handle<Node>,
pub end_node: Handle<Node>,
pub symbol_stack_precondition: PartialSymbolStack,
pub symbol_stack_postcondition: PartialSymbolStack,
pub scope_stack_precondition: PartialScopeStack,
pub scope_stack_postcondition: PartialScopeStack,
pub edges: PartialPathEdgeList,
}
Expand description
A portion of a name-binding path.
Partial paths can be computed incrementally, in which case all of the edges in the partial path belong to a single file. At query time, we can efficiently concatenate partial paths to yield a name-binding path.
Paths describe the contents of the symbol stack and scope stack at the end of the path. Partial paths, on the other hand, have preconditions and postconditions for each stack. The precondition describes what the stack must look like for us to be able to concatenate this partial path onto the end of a path. The postcondition describes what the resulting stack looks like after doing so.
The preconditions can contain scope stack variables, which describe parts of the scope stack (or parts of a scope symbol’s attached scope list) whose contents we don’t care about. The postconditions can also refer to those variables, and describe how those variable parts of the input scope stacks are carried through unmodified into the resulting scope stack.
Fields
start_node: Handle<Node>
end_node: Handle<Node>
symbol_stack_precondition: PartialSymbolStack
symbol_stack_postcondition: PartialSymbolStack
scope_stack_precondition: PartialScopeStack
scope_stack_postcondition: PartialScopeStack
edges: PartialPathEdgeList
Implementations
sourceimpl PartialPath
impl PartialPath
sourcepub fn from_node(
graph: &StackGraph,
partials: &mut PartialPaths,
node: Handle<Node>
) -> Result<PartialPath, PathResolutionError>
pub fn from_node(
graph: &StackGraph,
partials: &mut PartialPaths,
node: Handle<Node>
) -> Result<PartialPath, PathResolutionError>
Creates a new empty partial path starting at a stack graph node.
sourcepub fn shadows(&self, partials: &mut PartialPaths, other: &PartialPath) -> bool
pub fn shadows(&self, partials: &mut PartialPaths, other: &PartialPath) -> bool
Returns whether one path shadows another. Note that shadowing is not commutative — if path A shadows path B, the reverse is not true.
pub fn equals(&self, partials: &mut PartialPaths, other: &PartialPath) -> bool
pub fn cmp(
&self,
graph: &StackGraph,
partials: &mut PartialPaths,
other: &PartialPath
) -> Ordering
sourcepub fn starts_at_reference(&self, graph: &StackGraph) -> bool
pub fn starts_at_reference(&self, graph: &StackGraph) -> bool
Returns whether a partial path represents the start of a name binding from a reference to a definition.
sourcepub fn ends_at_definition(&self, graph: &StackGraph) -> bool
pub fn ends_at_definition(&self, graph: &StackGraph) -> bool
Returns whether a partial path represents the end of a name binding from a reference to a definition.
sourcepub fn is_complete(&self, graph: &StackGraph) -> bool
pub fn is_complete(&self, graph: &StackGraph) -> bool
A complete partial path represents a full name binding that resolves a reference to a definition.
sourcepub fn is_complete_as_possible(&self, graph: &StackGraph) -> bool
pub fn is_complete_as_possible(&self, graph: &StackGraph) -> bool
A partial path is as complete as possible if we cannot extend it any further within the current file. This represents the maximal amount of work that we can pre-compute at index time.
sourcepub fn is_productive(&self, partials: &mut PartialPaths) -> bool
pub fn is_productive(&self, partials: &mut PartialPaths) -> bool
Returns whether a partial path is “productive” — that is, whether it adds useful information to a path. Non-productive paths are ignored.
sourcepub fn ensure_both_directions(&mut self, partials: &mut PartialPaths)
pub fn ensure_both_directions(&mut self, partials: &mut PartialPaths)
Ensures that the content of this partial path is available in both forwards and backwards directions.
sourcepub fn ensure_forwards(&mut self, partials: &mut PartialPaths)
pub fn ensure_forwards(&mut self, partials: &mut PartialPaths)
Ensures that the content of this partial path is in forwards direction.
sourcepub fn largest_symbol_stack_variable(&self) -> u32
pub fn largest_symbol_stack_variable(&self) -> u32
Returns the largest value of any symbol stack variable in this partial path.
sourcepub fn largest_scope_stack_variable(&self, partials: &PartialPaths) -> u32
pub fn largest_scope_stack_variable(&self, partials: &PartialPaths) -> u32
Returns the largest value of any scope stack variable in this partial path.
sourcepub fn fresh_scope_stack_variable(
&self,
partials: &PartialPaths
) -> ScopeStackVariable
pub fn fresh_scope_stack_variable(
&self,
partials: &PartialPaths
) -> ScopeStackVariable
Returns a fresh scope stack variable that is not already used anywhere in this partial path.
pub fn display<'a>(
&'a self,
graph: &'a StackGraph,
partials: &'a mut PartialPaths
) -> impl Display + 'a
sourceimpl PartialPath
impl PartialPath
sourcepub fn ensure_no_overlapping_variables(
&mut self,
partials: &mut PartialPaths,
other: &PartialPath
)
pub fn ensure_no_overlapping_variables(
&mut self,
partials: &mut PartialPaths,
other: &PartialPath
)
Modifies this partial path so that it has no symbol or scope stack variables in common with another partial path.
sourcepub fn append(
&mut self,
graph: &StackGraph,
partials: &mut PartialPaths,
edge: Edge
) -> Result<(), PathResolutionError>
pub fn append(
&mut self,
graph: &StackGraph,
partials: &mut PartialPaths,
edge: Edge
) -> Result<(), PathResolutionError>
Attempts to append an edge to the end of a partial path. If the edge is not a valid extension of this partial path, we return an error describing why.
sourcepub fn resolve(
&mut self,
graph: &StackGraph,
partials: &mut PartialPaths
) -> Result<(), PathResolutionError>
pub fn resolve(
&mut self,
graph: &StackGraph,
partials: &mut PartialPaths
) -> Result<(), PathResolutionError>
Attempts to resolve any jump to scope node at the end of a partial path. If the partial path does not end in a jump to scope node, we do nothing. If it does, and we cannot resolve it, then we return an error describing why.
sourcepub fn extend_from_file<R: Extend<PartialPath>>(
&self,
graph: &StackGraph,
partials: &mut PartialPaths,
file: Handle<File>,
result: &mut R
)
pub fn extend_from_file<R: Extend<PartialPath>>(
&self,
graph: &StackGraph,
partials: &mut PartialPaths,
file: Handle<File>,
result: &mut R
)
Attempts to extend one partial path as part of the partial-path-finding algorithm, using
only outgoing edges that belong to a particular file. When calling this function, you are
responsible for ensuring that graph
already contains data for all of the possible edges
that we might want to extend path
with.
The resulting extended partial paths will be added to result
. We have you pass that in
as a parameter, instead of building it up ourselves, so that you have control over which
particular collection type to use, and so that you can reuse result collections across
multiple calls.
sourceimpl PartialPath
impl PartialPath
sourcepub fn concatenate(
&mut self,
graph: &StackGraph,
partials: &mut PartialPaths,
rhs: &PartialPath
) -> Result<(), PathResolutionError>
pub fn concatenate(
&mut self,
graph: &StackGraph,
partials: &mut PartialPaths,
rhs: &PartialPath
) -> Result<(), PathResolutionError>
Attempts to concatenate two partial paths. If the postcondition of the “left” partial path is not compatible with the precondition of the “right” path, we return an error describing why.
If the left- and right-hand partial paths have any symbol or scope stack variables in common, then we ensure that the variables bind to the same values on both sides. It’s your responsibility to update the two partial paths so that they have no variables in common, if that’s needed for your use case.
Trait Implementations
sourceimpl Clone for PartialPath
impl Clone for PartialPath
sourcefn clone(&self) -> PartialPath
fn clone(&self) -> PartialPath
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Into<PartialPath> for sg_partial_path
impl Into<PartialPath> for sg_partial_path
sourcefn into(self) -> PartialPath
fn into(self) -> PartialPath
Converts this type into the (usually inferred) input type.
Auto Trait Implementations
impl !RefUnwindSafe for PartialPath
impl Send for PartialPath
impl Sync for PartialPath
impl Unpin for PartialPath
impl UnwindSafe for PartialPath
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> FmtForward for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes self
to use its Binary
implementation when Debug
-formatted.
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes self
to use its Display
implementation when
Debug
-formatted. Read more
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes self
to use its LowerExp
implementation when
Debug
-formatted. Read more
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes self
to use its LowerHex
implementation when
Debug
-formatted. Read more
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes self
to use its Octal
implementation when Debug
-formatted.
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes self
to use its Pointer
implementation when
Debug
-formatted. Read more
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes self
to use its UpperExp
implementation when
Debug
-formatted. Read more
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes self
to use its UpperHex
implementation when
Debug
-formatted. Read more
impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
Pipes by value. This is generally the method you want to use. Read more
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows self
and passes that borrow into the pipe function. Read more
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows self
and passes that borrow into the pipe function. Read more
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.borrow()
into the pipe function. Read more
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.as_ref()
into the pipe function.
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.deref()
into the pipe function.
impl<T> Tap for T
impl<T> Tap for T
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Immutable access to the Borrow<B>
of a value. Read more
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the BorrowMut<B>
of a value. Read more
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Immutable access to the AsRef<R>
view of a value. Read more
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Mutable access to the AsMut<R>
view of a value. Read more
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the Deref::Target
of a value. Read more
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the Deref::Target
of a value. Read more
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls .tap()
only in debug builds, and is erased in release builds.
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more