File tree 2 files changed +18
-28
lines changed
2 files changed +18
-28
lines changed Original file line number Diff line number Diff line change 1
1
// Evaluate opcodes
2
2
package vm
3
3
4
+ // FIXME vm.result -> retval
5
+ // vm.exit -> vm.why
6
+ // why codes
7
+
4
8
// FIXME make opcode its own type so can stringer
5
9
6
10
// FIXME use LocalVars instead of storing everything in the Locals dict
@@ -485,28 +489,15 @@ func do_PRINT_EXPR(vm *Vm, arg int32) {
485
489
// Terminates a loop due to a break statement.
486
490
func do_BREAK_LOOP (vm * Vm , arg int32 ) {
487
491
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
493
493
}
494
494
495
495
// Continues a loop due to a continue statement. target is the address
496
496
// to jump to (which should be a FOR_ITER instruction).
497
497
func do_CONTINUE_LOOP (vm * Vm , target int32 ) {
498
498
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
510
501
}
511
502
512
503
// Iterate v argcnt times and store the results on the stack (via decreasing
Original file line number Diff line number Diff line change 74
74
assert a == 12
75
75
76
76
doc = "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
89
88
90
89
# End with this
91
90
doc = "finished"
You can’t perform that action at this time.
0 commit comments