ScopeGraph

Struct ScopeGraph 

Source
pub struct ScopeGraph<'storage, LABEL: Label, DATA, CMPL> { /* private fields */ }
Expand description

Scope Graph data structure.

As a data structure, scope graphs are simple graphs with labeled nodes and labeled, directed edges.

This trait has three type parameters:

  • LABEL: the type of the edge labels.
  • DATA: the type of the scope/node labels.
  • CMPL: metadata that guarantees query stability (i.e., query results remain valid in the future).

The data structure has been designed for typical scope graph usage scenario’s. For example, there is no support for removing scopes or edges, as this usually does not happen in scope graphs. In addition, there is no data type for edges, as edges should only be traversed, but never leak outside the scope graph structure. Finally, although not made explicit, LABEL should be a finite, iterable set.

Implementations§

Source§

impl<LABEL: Clone + RenderScopeLabel + Label, DATA: RenderScopeData + Clone, CMPL: Completeness<LABEL, DATA>> ScopeGraph<'_, LABEL, DATA, CMPL>

Source

pub fn render<W: Write>( &self, output: &mut W, settings: RenderSettings, ) -> Result<()>

Available on crate feature dot only.

Visualize the entire scope graph as a graph, by emitting a graphviz dot file.

Note: you can also visualize a single regular expression this way

Source

pub fn render_to( &self, path: impl AsRef<Path>, settings: RenderSettings, ) -> Result<()>

Available on crate feature dot only.

render directly to a file.

Source§

impl<LABEL: Hash + Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>
where CMPL: CriticalEdgeBasedCompleteness<LABEL, DATA>,

Source

pub fn add_scope_with<I>(&self, data: DATA, open_edges: I) -> Scope
where I: IntoIterator<Item = LABEL>,

Adds a new scope with some open edges.

Source

pub fn add_scope_closed(&self, data: DATA) -> Scope

Adds a new scope with no open edges.

Source§

impl<LABEL: Hash + Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>
where DATA: Default, CMPL: CriticalEdgeBasedCompleteness<LABEL, DATA>,

Source

pub fn add_scope_default_with<I>(&self, open_edges: I) -> Scope
where I: IntoIterator<Item = LABEL>,

Adds a new scope with some open edges and default data.

Source

pub fn add_scope_default_closed(&self) -> Scope

Adds a new scope with no open edges and default data.

Source§

impl<'storage, LABEL: Label, DATA, CMPL> ScopeGraph<'storage, LABEL, DATA, CMPL>

Source

pub fn query<'rslv>( &'rslv self, ) -> Query<'storage, 'rslv, 'rslv, LABEL, DATA, CMPL, (), DefaultDataWellformedness, DefaultLabelOrder, DefaultDataEquivalence>
where 'storage: 'rslv,

Build a query over the scope graph.

Source§

impl<'storage, LABEL: Label, DATA, CMPL> ScopeGraph<'storage, LABEL, DATA, CMPL>

Source

pub fn new(storage: &'storage Storage, completeness: CMPL) -> Self

Creates a new, empty, scope graph.

You must supply a Storage object, in which the scope graph can allocate memory, and a Completeness strategy, that defines how the scope graph should deal with query stability.

Source§

impl<'sg, LABEL: Label, DATA> ScopeGraph<'sg, LABEL, DATA, UncheckedCompleteness>

Source

pub unsafe fn raw(storage: &'sg Storage) -> Self

Creates a new scope graph with UncheckedCompleteness as its completeness validation.

§Safety

Unsafe, because UncheckedCompleteness does not actually guarantee query stability.

Source§

impl<LABEL: Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>
where CMPL: Completeness<LABEL, DATA>,

Source

pub fn add_scope(&self, data: DATA) -> Scope

Add a new scope to the scope graph, with data as its label.

Source

pub fn get_data(&self, scope: Scope) -> &DATA

Get the data associated with a scope.

Source

pub fn get_edges(&self, src: Scope, lbl: LABEL) -> CMPL::GetEdgesResult<'_>

Get the targets of the outgoing edges of a scope with some label.

Permission for this operation is checked by CMPL.

Source§

impl<LABEL: Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>
where CMPL: Implicit<LABEL, DATA>,

Source

pub fn add_edge( &self, src: Scope, lbl: LABEL, dst: Scope, ) -> CMPL::NewEdgeResult

Add a new edge in the scope graph.

Permission for this is checked by CMPL.

Source

pub fn add_decl( &self, src: Scope, lbl: LABEL, data: DATA, ) -> CMPL::NewEdgeResult

Utility function to add declarations (i.e., scopes with data, without any outgoing edges).

It performs (roughly) the following operation:

fn add_decl(&self, src: Scope, lbl: LABEL, data: DATA) -> CMPL::NewEdgeResult {
    let s_data = self.add_scope(data);
    self.add_edge(src, lbl, s_data);
}
Source§

impl<LABEL: Hash + Label + Copy + Debug, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>
where CMPL: UserClosed<LABEL, DATA>,

Source

pub fn ext_edge<'ext>( &'ext self, ext: &ScopeExtPerm<'ext, LABEL, DATA, CMPL>, dst: Scope, ) -> CMPL::NewEdgeResult

Add a new edge in the scope graph.

Permission for this is checked by CMPL.

Source

pub fn ext_decl<'ext>( &'ext self, ext: &ScopeExtPerm<'ext, LABEL, DATA, CMPL>, data: DATA, ) -> CMPL::NewEdgeResult

Utility function to add declarations (i.e., scopes with data, without any outgoing edges).

It performs (roughly) the following operation:

fn ext_decl(&self, src: Scope, lbl: LABEL, data: DATA) -> CMPL::NewEdgeResult {
    let s_data = self.add_scope(data);
    self.ext_edge(src, lbl, s_data);
}
Source§

impl<LABEL: Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>
where DATA: Default, CMPL: Completeness<LABEL, DATA>,

Source

pub fn add_scope_default(&self) -> Scope

Add a new scope to the scope graph, with default data.

Trait Implementations§

Source§

impl<LABEL: Label + Debug, DATA: Debug, CMPL: Debug> Debug for ScopeGraph<'_, LABEL, DATA, CMPL>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'storage, LABEL, DATA, CMPL> !Freeze for ScopeGraph<'storage, LABEL, DATA, CMPL>

§

impl<'storage, LABEL, DATA, CMPL> !RefUnwindSafe for ScopeGraph<'storage, LABEL, DATA, CMPL>

§

impl<'storage, LABEL, DATA, CMPL> !Send for ScopeGraph<'storage, LABEL, DATA, CMPL>

§

impl<'storage, LABEL, DATA, CMPL> !Sync for ScopeGraph<'storage, LABEL, DATA, CMPL>

§

impl<'storage, LABEL, DATA, CMPL> Unpin for ScopeGraph<'storage, LABEL, DATA, CMPL>
where CMPL: Unpin,

§

impl<'storage, LABEL, DATA, CMPL> !UnwindSafe for ScopeGraph<'storage, LABEL, DATA, CMPL>

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> 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, 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.