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>
impl<LABEL: Clone + RenderScopeLabel + Label, DATA: RenderScopeData + Clone, CMPL: Completeness<LABEL, DATA>> ScopeGraph<'_, LABEL, DATA, CMPL>
Sourcepub fn render<W: Write>(
&self,
output: &mut W,
settings: RenderSettings,
) -> Result<()>
Available on crate feature dot only.
pub fn render<W: Write>( &self, output: &mut W, settings: RenderSettings, ) -> Result<()>
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§impl<LABEL: Hash + Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>where
CMPL: CriticalEdgeBasedCompleteness<LABEL, DATA>,
impl<LABEL: Hash + Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>where
CMPL: CriticalEdgeBasedCompleteness<LABEL, DATA>,
Sourcepub fn add_scope_with<I>(&self, data: DATA, open_edges: I) -> Scopewhere
I: IntoIterator<Item = LABEL>,
pub fn add_scope_with<I>(&self, data: DATA, open_edges: I) -> Scopewhere
I: IntoIterator<Item = LABEL>,
Adds a new scope with some open edges.
Sourcepub fn add_scope_closed(&self, data: DATA) -> Scope
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>,
impl<LABEL: Hash + Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>where
DATA: Default,
CMPL: CriticalEdgeBasedCompleteness<LABEL, DATA>,
Sourcepub fn add_scope_default_with<I>(&self, open_edges: I) -> Scopewhere
I: IntoIterator<Item = LABEL>,
pub fn add_scope_default_with<I>(&self, open_edges: I) -> Scopewhere
I: IntoIterator<Item = LABEL>,
Adds a new scope with some open edges and default data.
Sourcepub fn add_scope_default_closed(&self) -> Scope
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>
impl<'storage, LABEL: Label, DATA, CMPL> ScopeGraph<'storage, LABEL, DATA, CMPL>
Sourcepub fn query<'rslv>(
&'rslv self,
) -> Query<'storage, 'rslv, 'rslv, LABEL, DATA, CMPL, (), DefaultDataWellformedness, DefaultLabelOrder, DefaultDataEquivalence>where
'storage: 'rslv,
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>
impl<'storage, LABEL: Label, DATA, CMPL> ScopeGraph<'storage, LABEL, DATA, CMPL>
Sourcepub fn new(storage: &'storage Storage, completeness: CMPL) -> Self
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>
impl<'sg, LABEL: Label, DATA> ScopeGraph<'sg, LABEL, DATA, UncheckedCompleteness>
Sourcepub unsafe fn raw(storage: &'sg Storage) -> Self
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>,
impl<LABEL: Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>where
CMPL: Completeness<LABEL, DATA>,
Sourcepub fn add_scope(&self, data: DATA) -> Scope
pub fn add_scope(&self, data: DATA) -> Scope
Add a new scope to the scope graph, with data as its label.
Sourcepub fn get_edges(&self, src: Scope, lbl: LABEL) -> CMPL::GetEdgesResult<'_>
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>,
impl<LABEL: Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>where
CMPL: Implicit<LABEL, DATA>,
Sourcepub fn add_edge(
&self,
src: Scope,
lbl: LABEL,
dst: Scope,
) -> CMPL::NewEdgeResult
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.
Sourcepub fn add_decl(
&self,
src: Scope,
lbl: LABEL,
data: DATA,
) -> CMPL::NewEdgeResult
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>,
impl<LABEL: Hash + Label + Copy + Debug, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>where
CMPL: UserClosed<LABEL, DATA>,
Sourcepub fn ext_edge<'ext>(
&'ext self,
ext: &ScopeExtPerm<'ext, LABEL, DATA, CMPL>,
dst: Scope,
) -> CMPL::NewEdgeResult
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.
Sourcepub fn ext_decl<'ext>(
&'ext self,
ext: &ScopeExtPerm<'ext, LABEL, DATA, CMPL>,
data: DATA,
) -> CMPL::NewEdgeResult
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>,
impl<LABEL: Label, DATA, CMPL> ScopeGraph<'_, LABEL, DATA, CMPL>where
DATA: Default,
CMPL: Completeness<LABEL, DATA>,
Sourcepub fn add_scope_default(&self) -> Scope
pub fn add_scope_default(&self) -> Scope
Add a new scope to the scope graph, with default data.