Currently, we construct if / else statements separately:
/// Creates a new if statement
pub fn new_if<C, E>(condition: C, then_block: Vec<E>) -> ControlFlowNode
where
C: Into<ExprKind>,
E: Into<AstKind>,
{
ControlFlowNode::new(
ControlFlowType::If,
Some(condition),
then_block
.into_iter()
.map(Into::into)
.collect::<Vec<AstKind>>(),
)
}
/// Creates a new else statement
pub fn new_else<T>(else_block: Vec<T>) -> ControlFlowNode
where
T: Into<AstKind>,
{
ControlFlowNode::new(
ControlFlowType::Else,
None::<ExprKind>,
else_block
.into_iter()
.map(Into::into)
.collect::<Vec<AstKind>>(),
)
}
Instead, we should shift to a unified if / else block with an optional else body if one exists. This will make transformations easier.
We will need to change ControlFlowNode to reflect this change.
Currently, we construct
if/elsestatements separately:Instead, we should shift to a unified
if/elseblock with an optionalelsebody if one exists. This will make transformations easier.We will need to change
ControlFlowNodeto reflect this change.