pub enum Ir {
Recv(Type),
Send(Type),
Call(Option<Index>),
Choose(Vec<Option<Index>>),
Offer(Vec<Option<Index>>),
Split {
tx_only: Option<Index>,
rx_only: Option<Index>,
},
Loop(Option<Index>),
Break(Index),
Continue(Index),
Type(Type),
Error,
}
Expand description
The “kind” of a CFG node. CFG nodes have additional data stored in CfgNode
which is always
the same types and fields for every node, so we separate into the Ir
variant and CfgNode
wrapper/entry struct.
Variants§
Recv(Type)
Indicating receiving a value of some type.
Send(Type)
Indicating sending a value of some type.
Call(Option<Index>)
Call
nodes act somewhat like a call/cc, and run their body continuation in the same scope
as they are called all the way to “Done” before running their own continuation.
Choose(Vec<Option<Index>>)
Choose
nodes have a list of continuations which supersede their “next” pointer. Before
scope resolution, these continuations may be extended by their “implicit” subsequent
continuation, which is stored in the “next” pointer of the node. The scope resolution pass
“lowers” this next pointer continuation into the arms of the Choose
, and so after scope
resolution all Choose
nodes’ next pointers should be None
.
Offer(Vec<Option<Index>>)
Like Choose
, Offer
nodes have a list of choices, and after scope resolution have no
continuation.
Split
Split
nodes have a transmit-only half and a receive-only half. The nodes’ semantics are
similar to Call
.
Loop(Option<Index>)
Early on, loops may have a body; however, after scope resolution, all loops should have
their bodies be Some
. So post scope resolution, this field may be unwrapped.
Break(Index)
Break
nodes directly reference the loop that they break. They can be considered as a
direct reference to the “next” pointer of the referenced loop node.
Continue(Index)
Like break nodes, Continue
nodes directly reference the loop that they continue.
Semantically they can be considered a reference to the body of the loop, but as they are a
special construct in the target language, we don’t resolve them that way.
Type(Type)
A “directly injected” type.
Error
Emitted when we need to have a node to put errors on but need to not reason about its behavior.