fic/base/refs.rs
1//! What a name in a body resolves to, by id: a variable, and what declared
2//! it.
3
4use serde::Serialize;
5
6use super::id::{BodyVarId, ChanId, ConstId, LocalVarId};
7
8/// What a variable name denotes.
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
10pub enum VarRef {
11 /// A body variable of the enclosing process or event.
12 Body(BodyVarId),
13 /// A local variable of the enclosing program.
14 Local(LocalVarId),
15 /// A system const.
16 Const(ConstId),
17}
18
19/// What declared a body variable.
20#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
21pub enum BodyVarKind {
22 /// A process parameter, in scope for the whole body; read-only.
23 Param,
24 /// A process `x: T;`, in scope from there to the end of its sequence.
25 Decl,
26 /// A receive binder `c?x`, in scope for the prefix's continuation.
27 Binder {
28 /// The channel received on.
29 chan: ChanId,
30 },
31 /// An event carrier, in scope for the whole event; read-only.
32 Carrier,
33 /// An event `x: T;`, in scope from there to the end of the event.
34 EventDecl,
35}