mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Remove Instruction::IsOperation
This commit is contained in:
@@ -2223,6 +2223,8 @@ impl Compiler<'_> {
|
||||
});
|
||||
}
|
||||
|
||||
use bytecode::TestOperator::*;
|
||||
|
||||
// Emit instructions:
|
||||
// 1. Load the new tuple of attribute names.
|
||||
self.emit_load_const(ConstantData::Tuple {
|
||||
@@ -2235,7 +2237,7 @@ impl Compiler<'_> {
|
||||
// 4. Load None.
|
||||
self.emit_load_const(ConstantData::None);
|
||||
// 5. Compare with IS_OP 1.
|
||||
emit!(self, Instruction::IsOperation(true));
|
||||
emit!(self, Instruction::TestOperation { op: IsNot });
|
||||
|
||||
// At this point the TOS is a tuple of (nargs + n_attrs) attributes (or None).
|
||||
pc.on_top += 1;
|
||||
@@ -2351,7 +2353,7 @@ impl Compiler<'_> {
|
||||
// emit!(self, Instruction::CopyItem { index: 1_u32 });
|
||||
// self.emit_load_const(ConstantData::None);
|
||||
// // TODO: should be is
|
||||
// emit!(self, Instruction::IsOperation(true));
|
||||
// emit!(self, Instruction::TestOperation::IsNot);
|
||||
// self.jump_to_fail_pop(pc, JumpOp::PopJumpIfFalse)?;
|
||||
|
||||
// // Unpack the tuple of values.
|
||||
|
||||
@@ -30,7 +30,7 @@ expression: "compile_exec(\"\\\nclass Test:\n pass\n\nt = Test()\nmatch t:\n
|
||||
14 MatchClass (0)
|
||||
15 CopyItem (1)
|
||||
16 LoadConst (None)
|
||||
17 IsOperation (true)
|
||||
17 TestOperation (IsNot)
|
||||
18 JumpIfFalse (27)
|
||||
19 UnpackSequence (0)
|
||||
20 Pop
|
||||
|
||||
@@ -437,9 +437,6 @@ pub enum Instruction {
|
||||
TestOperation {
|
||||
op: Arg<TestOperator>,
|
||||
},
|
||||
/// If the argument is true, perform IS NOT. Otherwise perform the IS operation.
|
||||
// TODO: duplication of TestOperator::{Is,IsNot}. Fix later.
|
||||
IsOperation(Arg<bool>),
|
||||
CompareOperation {
|
||||
op: Arg<ComparisonOperator>,
|
||||
},
|
||||
@@ -1227,8 +1224,7 @@ impl Instruction {
|
||||
BinaryOperation { .. }
|
||||
| BinaryOperationInplace { .. }
|
||||
| TestOperation { .. }
|
||||
| CompareOperation { .. }
|
||||
| IsOperation(..) => -1,
|
||||
| CompareOperation { .. } => -1,
|
||||
BinarySubscript => -1,
|
||||
CopyItem { .. } => 1,
|
||||
Pop => -1,
|
||||
@@ -1436,7 +1432,6 @@ impl Instruction {
|
||||
BinarySubscript => w!(BinarySubscript),
|
||||
LoadAttr { idx } => w!(LoadAttr, name = idx),
|
||||
TestOperation { op } => w!(TestOperation, ?op),
|
||||
IsOperation(neg) => w!(IsOperation, neg),
|
||||
CompareOperation { op } => w!(CompareOperation, ?op),
|
||||
CopyItem { index } => w!(CopyItem, index),
|
||||
Pop => w!(Pop),
|
||||
|
||||
@@ -851,14 +851,6 @@ impl ExecutingFrame<'_> {
|
||||
bytecode::Instruction::UnaryOperation { op } => self.execute_unary_op(vm, op.get(arg)),
|
||||
bytecode::Instruction::TestOperation { op } => self.execute_test(vm, op.get(arg)),
|
||||
bytecode::Instruction::CompareOperation { op } => self.execute_compare(vm, op.get(arg)),
|
||||
bytecode::Instruction::IsOperation(neg) => {
|
||||
let a = self.pop_value();
|
||||
let b = self.pop_value();
|
||||
// xor with neg to invert the result if needed
|
||||
let result = vm.ctx.new_bool(a.is(b.as_ref()) ^ neg.get(arg));
|
||||
self.push_value(result.into());
|
||||
Ok(None)
|
||||
}
|
||||
bytecode::Instruction::ReturnValue => {
|
||||
let value = self.pop_value();
|
||||
self.unwind_blocks(vm, UnwindReason::Returning { value })
|
||||
|
||||
Reference in New Issue
Block a user