Struct rtlola_hir::hir::RtLolaHir
source · [−]pub struct RtLolaHir<M: HirMode> { /* private fields */ }
Expand description
This struct constitutes the Mid-Level Intermediate Representation (MIR) of an RTLola specification.
The RtLolaHir is specifically designed to allow for convenient manipulation and analysis. Hence, it is perfect for working on the specification rather than work with it.
Most Notable Structs and Enums
- RtLolaMir is the root data structure representing the specification.
- Output represents a single output stream. The data structure is enriched with information regarding streams accessing it or accessed by it and much more. For input streams confer Input.
- StreamReference used for referencing streams within the Mir.
- Expression represents an expression. It contains its ExpressionKind and its type. The latter contains all information specific to a certain kind of expression such as sub-expressions of operators.
Type-State
The Hir follows a type-state pattern. To this end, it has a type parameter, its HirMode. The Hir starts in the BaseMode and progresses through different stages until reaching CompleteMode.
Each stage constitutes another level of refinement and adds functionality. The functionality can be accesses by importing the respective trait and requiring the mode of the Hir to implement the trait.
The following traits exist.
- DepAnaTrait provides access to a dependency graph (see petgraph) and functions to access immediate neighbors of streams. Obtained via determine_evaluation_order.
- TypedTrait provides type information. Obtained via check_types.
- OrderedTrait provides information regarding the evaluation order of streams. Obtained via determine_evaluation_order.
- MemBoundTrait provides information on how many values of a stream have to be kept in memory at the same time. Obtained via determine_memory_bounds.
Progression through different stages is managed by the HirStage trait, in particular HirStage::progress.
See Also
- rtlola_frontend for an overview regarding different representations.
- from_ast / fully_analyzed to obtain an RtLolaHir for a specification in form of an Ast.
- RtLolaHir for a data structs designed for working _on_it.
- RtLolaAst, which is the most basic and down-to-syntax data structure available for RTLola.
Implementations
sourceimpl<M: HirMode + TypedTrait> RtLolaHir<M>
impl<M: HirMode + TypedTrait> RtLolaHir<M>
sourcepub fn select(&self) -> StreamSelector<'_, M, All>
pub fn select(&self) -> StreamSelector<'_, M, All>
Creates a StreamSelector to query the HIR for different classes of output streams.
sourceimpl<M: HirMode> RtLolaHir<M>
impl<M: HirMode> RtLolaHir<M>
sourcepub fn inputs(&self) -> impl Iterator<Item = &Input>
pub fn inputs(&self) -> impl Iterator<Item = &Input>
Provides access to an iterator over all input streams.
sourcepub fn outputs(&self) -> impl Iterator<Item = &Output>
pub fn outputs(&self) -> impl Iterator<Item = &Output>
Provides access to an iterator over all output streams.
sourcepub fn triggers(&self) -> impl Iterator<Item = &Trigger>
pub fn triggers(&self) -> impl Iterator<Item = &Trigger>
Provides access to an iterator over all triggers.
sourcepub fn num_inputs(&self) -> usize
pub fn num_inputs(&self) -> usize
Yields the number of input streams present in the Hir. Not necessarily equal to the number of input streams in the specification.
sourcepub fn num_outputs(&self) -> usize
pub fn num_outputs(&self) -> usize
Yields the number of output streams present in the Hir. Not necessarily equal to the number of output streams in the specification.
sourcepub fn num_triggers(&self) -> usize
pub fn num_triggers(&self) -> usize
Yields the number of triggers present in the Hir. Not necessarily equal to the number of triggers in the specification.
sourcepub fn all_streams(&self) -> impl Iterator<Item = StreamReference> + '_
pub fn all_streams(&self) -> impl Iterator<Item = StreamReference> + '_
Provides access to an iterator over all streams, i.e., inputs, outputs, and triggers.
sourcepub fn get_input_with_name(&self, name: &str) -> Option<&Input>
pub fn get_input_with_name(&self, name: &str) -> Option<&Input>
Retrieves an input stream based on its name. Fails if no such input stream exists.
sourcepub fn get_output_with_name(&self, name: &str) -> Option<&Output>
pub fn get_output_with_name(&self, name: &str) -> Option<&Output>
Retrieves an output stream based on its name. Fails if no such output stream exists.
sourcepub fn output(&self, sref: StreamReference) -> Option<&Output>
pub fn output(&self, sref: StreamReference) -> Option<&Output>
Retrieves an output stream based on a stream reference. Fails if no such stream exists or sref
is a StreamReference::In.
sourcepub fn input(&self, sref: StreamReference) -> Option<&Input>
pub fn input(&self, sref: StreamReference) -> Option<&Input>
Retrieves an input stream based on a stream reference. Fails if no such stream exists or sref
is a StreamReference::Out.
sourcepub fn window_refs(&self) -> Vec<WindowReference>
pub fn window_refs(&self) -> Vec<WindowReference>
Provides access to a collection of references for all windows occurring in the Hir.
sourcepub fn sliding_windows(&self) -> Vec<&Window<SlidingAggr>>
pub fn sliding_windows(&self) -> Vec<&Window<SlidingAggr>>
Provides access to a collection of references for all sliding windows occurring in the Hir.
sourcepub fn discrete_windows(&self) -> Vec<&Window<DiscreteAggr>>
pub fn discrete_windows(&self) -> Vec<&Window<DiscreteAggr>>
Provides access to a collection of references for all discrete windows occurring in the Hir.
sourcepub fn expression(&self, id: ExprId) -> &Expression
pub fn expression(&self, id: ExprId) -> &Expression
sourcepub fn func_declaration(&self, func_name: &str) -> &FuncDecl
pub fn func_declaration(&self, func_name: &str) -> &FuncDecl
Retrieves a function declaration for a given function name.
Panic
Panics if the declaration does not exist.
sourcepub fn single_sliding(&self, window: WindowReference) -> Window<SlidingAggr>
pub fn single_sliding(&self, window: WindowReference) -> Window<SlidingAggr>
sourcepub fn single_discrete(&self, window: WindowReference) -> Window<DiscreteAggr>
pub fn single_discrete(&self, window: WindowReference) -> Window<DiscreteAggr>
sourcepub fn expr(&self, sr: StreamReference) -> &Expression
pub fn expr(&self, sr: StreamReference) -> &Expression
Retrieves the stream expression of a particular output stream or trigger.
Panic
Panics if the reference is a StreamReference::In or the stream does not exist.
sourcepub fn act_cond(&self, sr: StreamReference) -> Option<&Expression>
pub fn act_cond(&self, sr: StreamReference) -> Option<&Expression>
Retrieves the expression representing the activation condition of a particular output stream or trigger or None
for input references.
Panic
Panics if the stream does not exist.
sourcepub fn spawn(&self, sr: StreamReference) -> Option<SpawnDef<'_>>
pub fn spawn(&self, sr: StreamReference) -> Option<SpawnDef<'_>>
Retrieves the spawn definition of a particular output stream or trigger or None
for input references.
Panic
Panics if the stream does not exist.
sourcepub fn filter(&self, sr: StreamReference) -> Option<&Expression>
pub fn filter(&self, sr: StreamReference) -> Option<&Expression>
Retrieves the expression representing the filter condition of a particular output stream or trigger or None
for input references.
Panic
Panics if the stream does not exist.
sourcepub fn close(&self, sr: StreamReference) -> Option<&Expression>
pub fn close(&self, sr: StreamReference) -> Option<&Expression>
Retrieves the expression representing the close condition of a particular output stream or trigger or None
for input references.
Panic
Panics if the stream does not exist.
sourcepub fn names(&self) -> HashMap<StreamReference, &str>
pub fn names(&self) -> HashMap<StreamReference, &str>
Generates a map from a StreamReference to the name of the corresponding stream.
sourceimpl RtLolaHir<BaseMode>
impl RtLolaHir<BaseMode>
sourcepub fn check_types(self) -> Result<RtLolaHir<TypedMode>, RtLolaError>
pub fn check_types(self) -> Result<RtLolaHir<TypedMode>, RtLolaError>
Returns the RtLolaHir with the type information for each stream and expression
The function returns the RtLolaHir after the type analysis. The new mode implements the same functionality as the BaseMode and additionally holds for each stream and expression its StreamType. The function moves the information of the previous mode to the new one and therefore destroys the current mode.
Fails
The function fails if the type checker finds a type error in the specification and returns a string with a detailed description.
sourceimpl RtLolaHir<TypedMode>
impl RtLolaHir<TypedMode>
sourcepub fn analyze_dependencies(self) -> Result<RtLolaHir<DepAnaMode>, RtLolaError>
pub fn analyze_dependencies(self) -> Result<RtLolaHir<DepAnaMode>, RtLolaError>
Returns the RtLolaHir with additional information about the dependencies between streams
The function returns the RtLolaHir after the dependency analysis. The new mode implements the same functionality as the TypedMode and additionally contains the dependencies between streams in the specification. The function moves the information of the previous mode to the new one and therefore destroys the current mode.
Fails
The function returns a RtLolaError if the specification is not well-formed.
sourceimpl RtLolaHir<DepAnaMode>
impl RtLolaHir<DepAnaMode>
sourcepub fn determine_evaluation_order(
self
) -> Result<RtLolaHir<OrderedMode>, RtLolaError>
pub fn determine_evaluation_order(
self
) -> Result<RtLolaHir<OrderedMode>, RtLolaError>
sourceimpl RtLolaHir<OrderedMode>
impl RtLolaHir<OrderedMode>
sourcepub fn determine_memory_bounds(
self
) -> Result<RtLolaHir<MemBoundMode>, RtLolaError>
pub fn determine_memory_bounds(
self
) -> Result<RtLolaHir<MemBoundMode>, RtLolaError>
sourceimpl RtLolaHir<MemBoundMode>
impl RtLolaHir<MemBoundMode>
sourcepub fn finalize(self) -> Result<RtLolaHir<CompleteMode>, RtLolaError>
pub fn finalize(self) -> Result<RtLolaHir<CompleteMode>, RtLolaError>
Returns the RtLolaHir in the last mode
The function returns the RtLolaHir in the CompleteMode. This mode indicates that the RtLolaHir has passed all analyzes and now contains all information. The function moves the information of the previous mode to the new one and therefore destroys the current mode.
Trait Implementations
sourceimpl HirStage for RtLolaHir<TypedMode>
impl HirStage for RtLolaHir<TypedMode>
type NextStage = DepAnaMode
type NextStage = DepAnaMode
Defines the next mode that is produced by the progress
function
sourceimpl HirStage for RtLolaHir<DepAnaMode>
impl HirStage for RtLolaHir<DepAnaMode>
type NextStage = OrderedMode
type NextStage = OrderedMode
Defines the next mode that is produced by the progress
function
sourceimpl HirStage for RtLolaHir<OrderedMode>
impl HirStage for RtLolaHir<OrderedMode>
type NextStage = MemBoundMode
type NextStage = MemBoundMode
Defines the next mode that is produced by the progress
function
sourceimpl HirStage for RtLolaHir<MemBoundMode>
impl HirStage for RtLolaHir<MemBoundMode>
type NextStage = CompleteMode
type NextStage = CompleteMode
Defines the next mode that is produced by the progress
function
Auto Trait Implementations
impl<M> RefUnwindSafe for RtLolaHir<M> where
M: RefUnwindSafe,
impl<M> Send for RtLolaHir<M> where
M: Send,
impl<M> Sync for RtLolaHir<M> where
M: Sync,
impl<M> Unpin for RtLolaHir<M> where
M: Unpin,
impl<M> UnwindSafe for RtLolaHir<M> where
M: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more