@@ -141,17 +141,16 @@ func do_BINARY_MODULO(vm *Vm, arg int32) {
141
141
142
142
// Implements TOS = TOS1 + TOS.
143
143
func do_BINARY_ADD (vm * Vm , arg int32 ) {
144
- // FIXME not a very good implementation ;-)
145
- b := vm .POP ().(py.Int )
146
- a := vm .POP ().(py.Int )
147
- c := a + b
148
- vm .PUSH (py .Int (c ))
149
- vm .NotImplemented ("BINARY_ADD" , arg )
144
+ b := vm .POP ()
145
+ a := vm .POP ()
146
+ vm .PUSH (py .Add (a , b ))
150
147
}
151
148
152
149
// Implements TOS = TOS1 - TOS.
153
150
func do_BINARY_SUBTRACT (vm * Vm , arg int32 ) {
154
- vm .NotImplemented ("BINARY_SUBTRACT" , arg )
151
+ b := vm .POP ()
152
+ a := vm .POP ()
153
+ vm .PUSH (py .Sub (a , b ))
155
154
}
156
155
157
156
// Implements TOS = TOS1[TOS].
@@ -217,12 +216,16 @@ func do_INPLACE_MODULO(vm *Vm, arg int32) {
217
216
218
217
// Implements in-place TOS = TOS1 + TOS.
219
218
func do_INPLACE_ADD (vm * Vm , arg int32 ) {
220
- vm .NotImplemented ("INPLACE_ADD" , arg )
219
+ b := vm .POP ()
220
+ a := vm .POP ()
221
+ vm .PUSH (py .Iadd (a , b ))
221
222
}
222
223
223
224
// Implements in-place TOS = TOS1 - TOS.
224
225
func do_INPLACE_SUBTRACT (vm * Vm , arg int32 ) {
225
- vm .NotImplemented ("INPLACE_SUBTRACT" , arg )
226
+ b := vm .POP ()
227
+ a := vm .POP ()
228
+ vm .PUSH (py .Isub (a , b ))
226
229
}
227
230
228
231
// Implements in-place TOS = TOS1 << TOS.
@@ -867,5 +870,10 @@ func Run(globals, locals py.StringDict, code *py.Code) (err error) {
867
870
vm .extended = false
868
871
jumpTable [opcode ](vm , arg )
869
872
}
873
+ if len (vm .stack ) != 1 {
874
+ fmt .Printf ("vmstack = %v\n " , vm .stack )
875
+ panic ("vm stack should only have 1 entry on at this point" )
876
+ }
877
+ // return vm.POP()
870
878
return nil
871
879
}
0 commit comments