Skip to content

Commit

Permalink
Add match conditions to rich AST representation
Browse files Browse the repository at this point in the history
  • Loading branch information
fpottbaecker committed Jan 6, 2024
1 parent 8ddce7f commit 8efa234
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions compiler/frontend/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,22 @@ impl ToRichIr for Match {
}
impl ToRichIr for MatchCase {
fn build_rich_ir(&self, builder: &mut RichIrBuilder) {
builder.push("case ", None, EnumSet::empty());
self.pattern.build_rich_ir(builder);
if let Some(box condition) = &self.condition {
builder.push(", ", None, EnumSet::empty());
builder.indent();
builder.push_newline();
builder.push("condition ", None, EnumSet::empty());
condition.build_rich_ir(builder);
}
builder.push(" -> ", None, EnumSet::empty());
builder.indent();
builder.push_foldable(|builder| builder.push_children_multiline(&self.body));
if self.condition.is_some() {
builder.dedent();
}
builder.dedent();
}
}
impl ToRichIr for OrPattern {
Expand Down

0 comments on commit 8efa234

Please sign in to comment.