hydro_lang/location/
process.rs1use std::fmt::{Debug, Formatter};
2use std::marker::PhantomData;
3
4use super::{Location, LocationId};
5use crate::compile::builder::FlowState;
6use crate::staging_util::Invariant;
7
8pub struct Process<'a, ProcessTag = ()> {
9 pub(crate) id: usize,
10 pub(crate) flow_state: FlowState,
11 pub(crate) _phantom: Invariant<'a, ProcessTag>,
12}
13
14impl<P> Debug for Process<'_, P> {
15 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
16 write!(f, "Process({})", self.id)
17 }
18}
19
20impl<P> Eq for Process<'_, P> {}
21impl<P> PartialEq for Process<'_, P> {
22 fn eq(&self, other: &Self) -> bool {
23 self.id == other.id && FlowState::ptr_eq(&self.flow_state, &other.flow_state)
24 }
25}
26
27impl<P> Clone for Process<'_, P> {
28 fn clone(&self) -> Self {
29 Process {
30 id: self.id,
31 flow_state: self.flow_state.clone(),
32 _phantom: PhantomData,
33 }
34 }
35}
36
37impl<'a, P> super::dynamic::DynLocation for Process<'a, P> {
38 fn id(&self) -> LocationId {
39 LocationId::Process(self.id)
40 }
41
42 fn flow_state(&self) -> &FlowState {
43 &self.flow_state
44 }
45
46 fn is_top_level() -> bool {
47 true
48 }
49}
50
51impl<'a, P> Location<'a> for Process<'a, P> {
52 type Root = Self;
53
54 fn root(&self) -> Self::Root {
55 self.clone()
56 }
57}