Struct 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§

Source§

impl PartialPath

Source

pub fn from_node( graph: &StackGraph, partials: &mut PartialPaths, node: Handle<Node>, ) -> PartialPath

Creates a new empty partial path starting at a stack graph node.

Source

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.

Source

pub fn equals(&self, partials: &mut PartialPaths, other: &PartialPath) -> bool

Source

pub fn cmp( &self, graph: &StackGraph, partials: &mut PartialPaths, other: &PartialPath, ) -> Ordering

Source

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.

Source

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.

Source

pub fn is_complete(&self, graph: &StackGraph) -> bool

A complete partial path represents a full name binding that resolves a reference to a definition.

Source

pub fn starts_at_endpoint(&self, graph: &StackGraph) -> bool

Source

pub fn ends_at_endpoint(&self, graph: &StackGraph) -> bool

Source

pub fn ends_in_jump(&self, graph: &StackGraph) -> bool

Source

pub fn is_cyclic( &self, graph: &StackGraph, partials: &mut PartialPaths, ) -> Option<Cyclicity>

Returns whether a partial path is cyclic—that is, it starts and ends at the same node, and its postcondition is compatible with its precondition. If the path is cyclic, a tuple is returned indicating whether cycle requires strengthening the pre- or postcondition.

Source

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.

Source

pub fn ensure_forwards(&mut self, partials: &mut PartialPaths)

Ensures that the content of this partial path is in forwards direction.

Source

pub fn largest_symbol_stack_variable(&self) -> u32

Returns the largest value of any symbol stack variable in this partial path.

Source

pub fn largest_scope_stack_variable(&self, partials: &PartialPaths) -> u32

Returns the largest value of any scope stack variable in this partial path.

Source

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.

Source

pub fn display<'a>( &'a self, graph: &'a StackGraph, partials: &'a mut PartialPaths, ) -> impl Display + 'a

Source§

impl PartialPath

Source

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.

Source

pub fn eliminate_precondition_stack_variables( &mut self, partials: &mut PartialPaths, )

Replaces stack variables in the precondition with empty stacks.

Source

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.

Source

pub fn resolve_from_postcondition( &mut self, graph: &StackGraph, partials: &mut PartialPaths, ) -> Result<(), PathResolutionError>

Attempts to resolve any jump to scope node at the end of a partial path from the postcondition scope stack. 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.

Source

pub fn resolve_to_node( &mut self, graph: &StackGraph, partials: &mut PartialPaths, node: Handle<Node>, ) -> Result<(), PathResolutionError>

Resolve any jump to scope node at the end of a partial path to the given node, updating the precondition to include the given node. 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.

Source§

impl PartialPath

Source

pub fn concatenate( &mut self, graph: &StackGraph, partials: &mut PartialPaths, rhs: &PartialPath, ) -> Result<(), PathResolutionError>

Attempts to append a partial path to this one. 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§

Source§

impl Appendable for PartialPath

Source§

fn append_to( &self, graph: &StackGraph, partials: &mut PartialPaths, path: &mut PartialPath, ) -> Result<(), PathResolutionError>

Append this appendable to the given path. Resolving jump nodes and renaming unused_variables is part of the responsibility of this method.
Source§

fn start_node(&self) -> Handle<Node>

Return the start node.
Source§

fn end_node(&self) -> Handle<Node>

Return the end node.
Source§

fn display<'a>( &'a self, graph: &'a StackGraph, partials: &'a mut PartialPaths, ) -> Box<dyn Display + 'a>

Return a Display implementation.
Source§

impl Clone for PartialPath

Source§

fn clone(&self) -> PartialPath

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ForwardCandidates<Handle<PartialPath>, PartialPath, Database, CancellationError> for DatabaseCandidates<'_>

Source§

fn get_forward_candidates<R>(&mut self, path: &PartialPath, result: &mut R)

Get forward candidates for extending the given partial path and add them to the provided result instance. If this instance loads data lazily, this only considers previously loaded data.
Source§

fn get_joining_candidate_degree(&self, path: &PartialPath) -> Degree

Get the number of available candidates that share the given path’s end node.
Source§

fn get_graph_partials_and_db( &mut self, ) -> (&StackGraph, &mut PartialPaths, &Database)

Get the graph, partial path arena, and database backing this candidates instance.
Source§

fn load_forward_candidates( &mut self, _path: &PartialPath, _cancellation_flag: &dyn CancellationFlag, ) -> Result<(), Err>

Load possible forward candidates for the given partial path into this candidates instance. Must be called before [get_forward_candidates] to allow lazy-loading implementations.
Source§

impl ForwardCandidates<Handle<PartialPath>, PartialPath, Database, StorageError> for SQLiteReader

Source§

fn load_forward_candidates( &mut self, path: &PartialPath, cancellation_flag: &dyn CancellationFlag, ) -> Result<(), StorageError>

Load possible forward candidates for the given partial path into this candidates instance. Must be called before [get_forward_candidates] to allow lazy-loading implementations.
Source§

fn get_forward_candidates<R>(&mut self, path: &PartialPath, result: &mut R)

Get forward candidates for extending the given partial path and add them to the provided result instance. If this instance loads data lazily, this only considers previously loaded data.
Source§

fn get_joining_candidate_degree(&self, path: &PartialPath) -> Degree

Get the number of available candidates that share the given path’s end node.
Source§

fn get_graph_partials_and_db( &mut self, ) -> (&StackGraph, &mut PartialPaths, &Database)

Get the graph, partial path arena, and database backing this candidates instance.
Source§

impl Into<PartialPath> for sg_partial_path

Source§

fn into(self) -> PartialPath

Converts this type into the (usually inferred) input type.
Source§

impl ToAppendable<Handle<PartialPath>, PartialPath> for Database

Source§

fn get_appendable<'a>( &'a self, handle: &'a Handle<PartialPath>, ) -> &'a PartialPath

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.