mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-24 18:12:28 +03:00
compound assignments
This commit is contained in:
parent
4185f6f6d2
commit
02e5f57eed
@ -239,6 +239,47 @@ impl ReconstructingReducer for Canonicalizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reduce_assign(&mut self, assign: &AssignStatement, assignee: Assignee, value: Expression) -> AssignStatement {
|
||||||
|
match value {
|
||||||
|
Expression::Value(value) => {
|
||||||
|
let left = Box::new(Expression::Identifier(assignee.identifier.clone()));
|
||||||
|
let right = Box::new(Expression::Value(value));
|
||||||
|
let op = match assign.operation {
|
||||||
|
AssignOperation::Assign => BinaryOperation::Eq,
|
||||||
|
AssignOperation::Add => BinaryOperation::Add,
|
||||||
|
AssignOperation::Sub => BinaryOperation::Sub,
|
||||||
|
AssignOperation::Mul => BinaryOperation::Mul,
|
||||||
|
AssignOperation::Div => BinaryOperation::Div,
|
||||||
|
AssignOperation::Pow => BinaryOperation::Pow,
|
||||||
|
AssignOperation::Or => BinaryOperation::Or,
|
||||||
|
AssignOperation::And => BinaryOperation::And,
|
||||||
|
AssignOperation::BitOr => BinaryOperation::BitOr,
|
||||||
|
AssignOperation::BitAnd => BinaryOperation::BitAnd,
|
||||||
|
AssignOperation::BitXor => BinaryOperation::BitXor,
|
||||||
|
AssignOperation::Shr => BinaryOperation::Shr,
|
||||||
|
AssignOperation::ShrSigned => BinaryOperation::ShrSigned,
|
||||||
|
AssignOperation::Shl => BinaryOperation::Shl,
|
||||||
|
AssignOperation::Mod => BinaryOperation::Mod,
|
||||||
|
};
|
||||||
|
|
||||||
|
let value = Expression::Binary(BinaryExpression {
|
||||||
|
left,
|
||||||
|
right,
|
||||||
|
op,
|
||||||
|
span: assign.span.clone(),
|
||||||
|
});
|
||||||
|
|
||||||
|
AssignStatement {
|
||||||
|
operation: assign.operation.clone(),
|
||||||
|
assignee,
|
||||||
|
value,
|
||||||
|
span: assign.span.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => assign.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fn reduce_circuit(&mut self, _circuit: &Circuit, circuit_name: Identifier, members: Vec<CircuitMember>) -> Circuit {
|
// fn reduce_circuit(&mut self, _circuit: &Circuit, circuit_name: Identifier, members: Vec<CircuitMember>) -> Circuit {
|
||||||
// Circuit {
|
// Circuit {
|
||||||
// circuit_name: circuit_name.clone(),
|
// circuit_name: circuit_name.clone(),
|
||||||
|
Loading…
Reference in New Issue
Block a user