Split Rotate into Rotate2 & Rotate3

This commit is contained in:
Noa 2022-03-10 13:38:08 -06:00
parent e5eb2739b7
commit a4f34f64e9

View file

@ -1122,7 +1122,7 @@ impl Compiler {
self.emit(Instruction::Duplicate); self.emit(Instruction::Duplicate);
self.load_docstring(doc_str); self.load_docstring(doc_str);
self.emit(Instruction::Rotate { amount: 2 }); self.emit(Instruction::Rotate2);
let doc = self.name("__doc__"); let doc = self.name("__doc__");
self.emit(Instruction::StoreAttr { idx: doc }); self.emit(Instruction::StoreAttr { idx: doc });
@ -1498,7 +1498,7 @@ impl Compiler {
self.compile_expression(val)?; self.compile_expression(val)?;
// store rhs for the next comparison in chain // store rhs for the next comparison in chain
self.emit(Instruction::Duplicate); self.emit(Instruction::Duplicate);
self.emit(Instruction::Rotate { amount: 3 }); self.emit(Instruction::Rotate3);
self.emit(Instruction::CompareOperation { self.emit(Instruction::CompareOperation {
op: compile_cmpop(op), op: compile_cmpop(op),
@ -1525,7 +1525,7 @@ impl Compiler {
// early exit left us with stack: `rhs, comparison_result`. We need to clean up rhs. // early exit left us with stack: `rhs, comparison_result`. We need to clean up rhs.
self.switch_to_block(break_block); self.switch_to_block(break_block);
self.emit(Instruction::Rotate { amount: 2 }); self.emit(Instruction::Rotate2);
self.emit(Instruction::Pop); self.emit(Instruction::Pop);
self.switch_to_block(after_block); self.switch_to_block(after_block);
@ -1692,12 +1692,12 @@ impl Compiler {
} }
AugAssignKind::Subscript => { AugAssignKind::Subscript => {
// stack: CONTAINER SLICE RESULT // stack: CONTAINER SLICE RESULT
self.emit(Instruction::Rotate { amount: 3 }); self.emit(Instruction::Rotate3);
self.emit(Instruction::StoreSubscript); self.emit(Instruction::StoreSubscript);
} }
AugAssignKind::Attr { idx } => { AugAssignKind::Attr { idx } => {
// stack: CONTAINER RESULT // stack: CONTAINER RESULT
self.emit(Instruction::Rotate { amount: 2 }); self.emit(Instruction::Rotate2);
self.emit(Instruction::StoreAttr { idx }); self.emit(Instruction::StoreAttr { idx });
} }
} }