@@ -640,7 +640,7 @@ op_arg_enum!(
640640 ImportStar = 2 ,
641641 // StopIterationError = 3,
642642 // AsyncGenWrap = 4,
643- // UnaryPositive = 5,
643+ UnaryPositive = 5 ,
644644 /// Convert list to tuple
645645 ListToTuple = 6 ,
646646 /// Type parameter related
@@ -758,11 +758,11 @@ pub enum Instruction {
758758 StoreSubscript ,
759759 // 40: TO_BOOL
760760 ToBool ,
761- // 41: UNARY_INVERT - placeholder (RustPython uses UnaryOperation)
761+ // 41: UNARY_INVERT
762762 UnaryInvert ,
763- // 42: UNARY_NEGATIVE - placeholder
763+ // 42: UNARY_NEGATIVE
764764 UnaryNegative ,
765- // 43: UNARY_NOT - placeholder
765+ // 43: UNARY_NOT
766766 UnaryNot ,
767767 // ==================== With-argument instructions (opcode >= 44) ====================
768768 // 44: WITH_EXCEPT_START
@@ -1091,11 +1091,8 @@ pub enum Instruction {
10911091 SetExcInfo ,
10921092 // 139: SUBSCRIPT
10931093 Subscript ,
1094- // 140: UNARY_OP (combines UNARY_*)
1095- UnaryOperation {
1096- op : Arg < UnaryOperator > ,
1097- } ,
1098- // 141-148: Reserved (padding to keep RESUME at 149)
1094+ // 140-148: Reserved (padding to keep RESUME at 149)
1095+ Reserved140 ,
10991096 Reserved141 ,
11001097 Reserved142 ,
11011098 Reserved143 ,
@@ -1538,18 +1535,6 @@ impl fmt::Display for BinaryOperator {
15381535 }
15391536}
15401537
1541- op_arg_enum ! (
1542- /// The possible unary operators
1543- #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
1544- #[ repr( u8 ) ]
1545- pub enum UnaryOperator {
1546- Not = 0 ,
1547- Invert = 1 ,
1548- Minus = 2 ,
1549- Plus = 3 ,
1550- }
1551- ) ;
1552-
15531538op_arg_enum ! (
15541539 /// Whether or not to invert the operation.
15551540 #[ repr( u8 ) ]
@@ -1910,23 +1895,21 @@ impl Instruction {
19101895 /// # Examples
19111896 ///
19121897 /// ```
1913- /// use rustpython_compiler_core::bytecode::{Arg, Instruction, Label, UnaryOperator };
1898+ /// use rustpython_compiler_core::bytecode::{Arg, Instruction, Label};
19141899 /// let (target, jump_arg) = Arg::new(Label(0xF));
19151900 /// let jump_instruction = Instruction::Jump { target };
1916- /// let (op, invert_arg) = Arg::new(UnaryOperator::Invert);
1917- /// let invert_instruction = Instruction::UnaryOperation { op };
19181901 /// assert_eq!(jump_instruction.stack_effect(jump_arg, true), 0);
1919- /// assert_eq!(invert_instruction.stack_effect(invert_arg, false), 0);
19201902 /// ```
19211903 ///
19221904 pub fn stack_effect ( & self , arg : OpArg , jump : bool ) -> i32 {
19231905 match self {
19241906 // Dummy/placeholder instructions (never executed)
1925- Cache | Reserved3 | Reserved17 | Reserved141 | Reserved142 | Reserved143
1926- | Reserved144 | Reserved145 | Reserved146 | Reserved147 | Reserved148 => 0 ,
1907+ Cache | Reserved3 | Reserved17 | Reserved140 | Reserved141 | Reserved142
1908+ | Reserved143 | Reserved144 | Reserved145 | Reserved146 | Reserved147 | Reserved148 => {
1909+ 0
1910+ }
19271911 BinarySlice | EndFor | ExitInitCheck | GetYieldFromIter | InterpreterExit
1928- | LoadAssertionError | LoadLocals | PushNull | ReturnGenerator | StoreSlice
1929- | UnaryInvert | UnaryNegative | UnaryNot => 0 ,
1912+ | LoadAssertionError | LoadLocals | PushNull | ReturnGenerator | StoreSlice => 0 ,
19301913 BuildConstKeyMap { .. }
19311914 | CopyFreeVars { .. }
19321915 | DictMerge { .. }
@@ -1959,7 +1942,6 @@ impl Instruction {
19591942 StoreAttr { .. } => -2 ,
19601943 DeleteAttr { .. } => -1 ,
19611944 LoadConst { .. } => 1 ,
1962- UnaryOperation { .. } => 0 ,
19631945 BinaryOp { .. } | CompareOperation { .. } => -1 ,
19641946 BinarySubscript => -1 ,
19651947 CopyItem { .. } => 1 ,
@@ -2086,6 +2068,9 @@ impl Instruction {
20862068 MatchKeys => 1 , // Pop 2 (subject, keys), push 3 (subject, keys_or_none, values_or_none)
20872069 MatchClass ( _) => -2 ,
20882070 ExtendedArg => 0 ,
2071+ UnaryInvert => 0 ,
2072+ UnaryNegative => 0 ,
2073+ UnaryNot => 0 ,
20892074 }
20902075 }
20912076
@@ -2158,8 +2143,8 @@ impl Instruction {
21582143 match self {
21592144 // Dummy/placeholder instructions
21602145 Cache => w ! ( CACHE ) ,
2161- Reserved3 | Reserved17 | Reserved141 | Reserved142 | Reserved143 | Reserved144
2162- | Reserved145 | Reserved146 | Reserved147 | Reserved148 => w ! ( RESERVED ) ,
2146+ Reserved3 | Reserved17 | Reserved140 | Reserved141 | Reserved142 | Reserved143
2147+ | Reserved144 | Reserved145 | Reserved146 | Reserved147 | Reserved148 => w ! ( RESERVED ) ,
21632148 BinarySlice => w ! ( BINARY_SLICE ) ,
21642149 EndFor => w ! ( END_FOR ) ,
21652150 ExitInitCheck => w ! ( EXIT_INIT_CHECK ) ,
@@ -2302,7 +2287,6 @@ impl Instruction {
23022287 Subscript => w ! ( SUBSCRIPT ) ,
23032288 Swap { index } => w ! ( SWAP , index) ,
23042289 ToBool => w ! ( TO_BOOL ) ,
2305- UnaryOperation { op } => w ! ( UNARY_OP , ?op) ,
23062290 UnpackEx { args } => w ! ( UNPACK_EX , args) ,
23072291 UnpackSequence { size } => w ! ( UNPACK_SEQUENCE , size) ,
23082292 WithExceptStart => w ! ( WITH_EXCEPT_START ) ,
0 commit comments