feat: add expression statements and assign expressions

This commit is contained in:
2026-04-21 23:18:13 +02:00
parent 3fe307eff8
commit 68ec14e541
7 changed files with 190 additions and 5 deletions
+18
View File
@@ -272,6 +272,9 @@ impl FuncBuilder {
});
}
}
TypedStmtKind::Expression { expr } => {
self.lower_expr(expr);
}
}
}
@@ -309,6 +312,21 @@ impl FuncBuilder {
Operand::Copy(temp)
}
TypedExprKind::Assign { lval, rval } => {
let rval_op = self.lower_expr(rval);
let local_id = match &lval.kind {
TypedExprKind::Identifier { name } => self.lookup(name),
_ => panic!("invalid lval in MIR lowering"),
};
self.emit_stmt(Statement {
kind: StatementKind::Assign(local_id, Rvalue::Use(rval_op.clone())),
span: expr.span,
});
rval_op
}
}
}
}