@@ -33,8 +33,9 @@ objects so they can be GCed
3333
3434import (
3535 // "fmt"
36- "github.com/ncw/gpython/py"
3736 "runtime/debug"
37+
38+ "github.com/ncw/gpython/py"
3839)
3940
4041const (
@@ -536,7 +537,9 @@ func do_UNPACK_EX(vm *Vm, counts int32) {
536537// Calls set.add(TOS1[-i], TOS). Used to implement set comprehensions.
537538func do_SET_ADD (vm * Vm , i int32 ) {
538539 defer vm .CheckException ()
539- vm .NotImplemented ("SET_ADD" , i )
540+ w := vm .POP ()
541+ v := vm .PEEK (int (i ))
542+ v .(* py.Set ).Add (w )
540543}
541544
542545// Calls list.append(TOS[-i], TOS). Used to implement list
@@ -553,7 +556,13 @@ func do_LIST_APPEND(vm *Vm, i int32) {
553556// Calls dict.setitem(TOS1[-i], TOS, TOS1). Used to implement dict comprehensions.
554557func do_MAP_ADD (vm * Vm , i int32 ) {
555558 defer vm .CheckException ()
556- vm .NotImplemented ("MAP_ADD" , i )
559+ key := vm .TOP ()
560+ value := vm .SECOND ()
561+ vm .DROPN (2 )
562+ dict := vm .PEEK (int (i ))
563+ // FIXME assert(PyDict_CheckExact(dict));
564+ // err = PyDict_SetItem(map, key, value); /* v[w] = u */
565+ py .SetItem (dict , key , value )
557566}
558567
559568// Returns with TOS to the caller of the function.
0 commit comments