File tree Expand file tree Collapse file tree 2 files changed +18
-28
lines changed Expand file tree Collapse file tree 2 files changed +18
-28
lines changed Original file line number Diff line number Diff line change 11// Evaluate opcodes
22package vm
33
4+ // FIXME vm.result -> retval
5+ // vm.exit -> vm.why
6+ // why codes
7+
48// FIXME make opcode its own type so can stringer
59
610// FIXME use LocalVars instead of storing everything in the Locals dict
@@ -485,28 +489,15 @@ func do_PRINT_EXPR(vm *Vm, arg int32) {
485489// Terminates a loop due to a break statement.
486490func do_BREAK_LOOP (vm * Vm , arg int32 ) {
487491 defer vm .CheckException ()
488- // Jump
489- vm .frame .Lasti = vm .frame .Block .Handler
490- // Reset the stack (FIXME?)
491- vm .frame .Stack = vm .frame .Stack [:vm .frame .Block .Level ]
492- vm .frame .PopBlock ()
492+ vm .exit = exitBreak
493493}
494494
495495// Continues a loop due to a continue statement. target is the address
496496// to jump to (which should be a FOR_ITER instruction).
497497func do_CONTINUE_LOOP (vm * Vm , target int32 ) {
498498 defer vm .CheckException ()
499- switch vm .frame .Block .Type {
500- case SETUP_LOOP :
501- case SETUP_WITH :
502- vm .NotImplemented ("CONTINUE_LOOP WITH" , target )
503- case SETUP_EXCEPT :
504- vm .NotImplemented ("CONTINUE_LOOP EXCEPT" , target )
505- case SETUP_FINALLY :
506- vm .NotImplemented ("CONTINUE_LOOP FINALLY" , target )
507- default :
508- }
509- vm .frame .Lasti = vm .frame .Block .Handler
499+ vm .result = py .Int (target )
500+ vm .exit = exitContinue
510501}
511502
512503// Iterate v argcnt times and store the results on the stack (via decreasing
Original file line number Diff line number Diff line change 7474assert a == 12
7575
7676doc = "For continue in try/finally"
77- # FIXME doesn't work yet!
78- # ok = False
79- # a = 0
80- # for i in (1,2,3,4,5):
81- # if i == 3:
82- # try:
83- # continue
84- # finally:
85- # ok = True
86- # a += i
87- # assert a == 12
88- # assert ok
77+ ok = False
78+ a = 0
79+ for i in (1 ,2 ,3 ,4 ,5 ):
80+ if i == 3 :
81+ try :
82+ continue
83+ finally :
84+ ok = True
85+ a += i
86+ assert a == 12
87+ assert ok
8988
9089# End with this
9190doc = "finished"
You can’t perform that action at this time.
0 commit comments