mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-27 04:01:47 +03:00
Fix SSA pass
This commit is contained in:
parent
3227f9bdb4
commit
1a9c95ce05
@ -297,30 +297,6 @@ impl StatementConsumer for StaticSingleAssigner<'_> {
|
|||||||
statements
|
statements
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes the expressions associated with the `FinalizeStatement`, returning the simplified `FinalizeStatement`.
|
|
||||||
fn consume_finalize(&mut self, input: FinalizeStatement) -> Self::Output {
|
|
||||||
let mut statements = Vec::new();
|
|
||||||
|
|
||||||
// Process the arguments, accumulating any statements produced.
|
|
||||||
let arguments = input
|
|
||||||
.arguments
|
|
||||||
.into_iter()
|
|
||||||
.map(|argument| {
|
|
||||||
let (argument, stmts) = self.consume_expression(argument);
|
|
||||||
statements.extend(stmts);
|
|
||||||
argument
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
// Construct and accumulate a simplified finalize statement.
|
|
||||||
statements.push(Statement::Finalize(FinalizeStatement {
|
|
||||||
arguments,
|
|
||||||
span: input.span,
|
|
||||||
}));
|
|
||||||
|
|
||||||
statements
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Consumes the expressions associated with the `IncrementStatement`, returning a simplified `IncrementStatement`.
|
/// Consumes the expressions associated with the `IncrementStatement`, returning a simplified `IncrementStatement`.
|
||||||
fn consume_increment(&mut self, input: IncrementStatement) -> Self::Output {
|
fn consume_increment(&mut self, input: IncrementStatement) -> Self::Output {
|
||||||
// First consume the expression associated with the amount.
|
// First consume the expression associated with the amount.
|
||||||
@ -351,9 +327,23 @@ impl StatementConsumer for StaticSingleAssigner<'_> {
|
|||||||
// Consume the return expression.
|
// Consume the return expression.
|
||||||
let (expression, mut statements) = self.consume_expression(input.expression);
|
let (expression, mut statements) = self.consume_expression(input.expression);
|
||||||
|
|
||||||
|
// Consume the finalize arguments if they exist.
|
||||||
|
// Process the arguments, accumulating any statements produced.
|
||||||
|
let finalize_args = input.finalize_args.map(|arguments| {
|
||||||
|
arguments
|
||||||
|
.into_iter()
|
||||||
|
.map(|argument| {
|
||||||
|
let (argument, stmts) = self.consume_expression(argument);
|
||||||
|
statements.extend(stmts);
|
||||||
|
argument
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
});
|
||||||
|
|
||||||
// Add the simplified return statement to the list of produced statements.
|
// Add the simplified return statement to the list of produced statements.
|
||||||
statements.push(Statement::Return(ReturnStatement {
|
statements.push(Statement::Return(ReturnStatement {
|
||||||
expression,
|
expression,
|
||||||
|
finalize_args,
|
||||||
span: input.span,
|
span: input.span,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user