@@ -316,7 +316,9 @@ impl Frame {
316316 vm. call_method ( & dict_obj, "__setitem__" , vec ! [ key, value] ) ?;
317317 Ok ( None )
318318 }
319- bytecode:: Instruction :: BinaryOperation { ref op } => self . execute_binop ( vm, op) ,
319+ bytecode:: Instruction :: BinaryOperation { ref op, inplace } => {
320+ self . execute_binop ( vm, op, * inplace)
321+ }
320322 bytecode:: Instruction :: LoadAttr { ref name } => self . load_attr ( vm, name) ,
321323 bytecode:: Instruction :: StoreAttr { ref name } => self . store_attr ( vm, name) ,
322324 bytecode:: Instruction :: DeleteAttr { ref name } => self . delete_attr ( vm, name) ,
@@ -893,23 +895,39 @@ impl Frame {
893895 & mut self ,
894896 vm : & mut VirtualMachine ,
895897 op : & bytecode:: BinaryOperator ,
898+ inplace : bool ,
896899 ) -> FrameResult {
897900 let b_ref = self . pop_value ( ) ;
898901 let a_ref = self . pop_value ( ) ;
899902 let value = match * op {
903+ bytecode:: BinaryOperator :: Subtract if inplace => vm. _isub ( a_ref, b_ref) ,
900904 bytecode:: BinaryOperator :: Subtract => vm. _sub ( a_ref, b_ref) ,
905+ bytecode:: BinaryOperator :: Add if inplace => vm. _iadd ( a_ref, b_ref) ,
901906 bytecode:: BinaryOperator :: Add => vm. _add ( a_ref, b_ref) ,
907+ bytecode:: BinaryOperator :: Multiply if inplace => vm. _imul ( a_ref, b_ref) ,
902908 bytecode:: BinaryOperator :: Multiply => vm. _mul ( a_ref, b_ref) ,
909+ bytecode:: BinaryOperator :: MatrixMultiply if inplace => vm. _imatmul ( a_ref, b_ref) ,
903910 bytecode:: BinaryOperator :: MatrixMultiply => vm. _matmul ( a_ref, b_ref) ,
911+ bytecode:: BinaryOperator :: Power if inplace => vm. _ipow ( a_ref, b_ref) ,
904912 bytecode:: BinaryOperator :: Power => vm. _pow ( a_ref, b_ref) ,
913+ bytecode:: BinaryOperator :: Divide if inplace => vm. _itruediv ( a_ref, b_ref) ,
905914 bytecode:: BinaryOperator :: Divide => vm. _truediv ( a_ref, b_ref) ,
915+ bytecode:: BinaryOperator :: FloorDivide if inplace => vm. _ifloordiv ( a_ref, b_ref) ,
906916 bytecode:: BinaryOperator :: FloorDivide => vm. _floordiv ( a_ref, b_ref) ,
917+ // TODO: Subscript should probably have its own op
918+ bytecode:: BinaryOperator :: Subscript if inplace => unreachable ! ( ) ,
907919 bytecode:: BinaryOperator :: Subscript => self . subscript ( vm, a_ref, b_ref) ,
920+ bytecode:: BinaryOperator :: Modulo if inplace => vm. _imod ( a_ref, b_ref) ,
908921 bytecode:: BinaryOperator :: Modulo => vm. _mod ( a_ref, b_ref) ,
922+ bytecode:: BinaryOperator :: Lshift if inplace => vm. _ilshift ( a_ref, b_ref) ,
909923 bytecode:: BinaryOperator :: Lshift => vm. _lshift ( a_ref, b_ref) ,
924+ bytecode:: BinaryOperator :: Rshift if inplace => vm. _irshift ( a_ref, b_ref) ,
910925 bytecode:: BinaryOperator :: Rshift => vm. _rshift ( a_ref, b_ref) ,
926+ bytecode:: BinaryOperator :: Xor if inplace => vm. _ixor ( a_ref, b_ref) ,
911927 bytecode:: BinaryOperator :: Xor => vm. _xor ( a_ref, b_ref) ,
928+ bytecode:: BinaryOperator :: Or if inplace => vm. _ior ( a_ref, b_ref) ,
912929 bytecode:: BinaryOperator :: Or => vm. _or ( a_ref, b_ref) ,
930+ bytecode:: BinaryOperator :: And if inplace => vm. _iand ( a_ref, b_ref) ,
913931 bytecode:: BinaryOperator :: And => vm. _and ( a_ref, b_ref) ,
914932 } ?;
915933
0 commit comments