feat: add expression statements and assign expressions
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user