File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,11 @@ func (vm *Vm) PUSH(obj py.Object) {
74
74
vm .frame .Stack = append (vm .frame .Stack , obj )
75
75
}
76
76
77
+ // Push items to top of vm stack
78
+ func (vm * Vm ) EXTEND (items py.Tuple ) {
79
+ vm .frame .Stack = append (vm .frame .Stack , items ... )
80
+ }
81
+
77
82
// Adds a traceback to the exc passed in for the current vm state
78
83
func (vm * Vm ) AddTraceback (exc * py.ExceptionInfo ) {
79
84
exc .Traceback = & py.Traceback {
@@ -725,7 +730,20 @@ func do_DELETE_NAME(vm *Vm, namei int32) {
725
730
// stack right-to-left.
726
731
func do_UNPACK_SEQUENCE (vm * Vm , count int32 ) {
727
732
defer vm .CheckException ()
728
- vm .NotImplemented ("UNPACK_SEQUENCE" , count )
733
+ it := vm .POP ()
734
+ i := count
735
+ items := make (py.Tuple , count )
736
+ py .Iterate (it , func (item py.Object ) {
737
+ i --
738
+ if i < 0 {
739
+ panic (py .ExceptionNewf (py .ValueError , "Too many values to unpack (expected %d)" , count ))
740
+ }
741
+ items [i ] = item
742
+ })
743
+ if i != 0 {
744
+ panic (py .ExceptionNewf (py .ValueError , "Need more than %d values to unpack (expected %d)" , count - i , count ))
745
+ }
746
+ vm .EXTEND (items )
729
747
}
730
748
731
749
// Implements TOS.name = TOS1, where namei is the index of name in
You can’t perform that action at this time.
0 commit comments