@@ -1707,22 +1707,9 @@ func (vm *Vm) UnwindExceptHandler(frame *py.Frame, block *py.TryBlock) {
1707
1707
//
1708
1708
// This is the equivalent of PyEval_EvalFrame
1709
1709
func RunFrame (frame * py.Frame ) (res py.Object , err error ) {
1710
- vm := NewVm (frame )
1711
- // defer func() {
1712
- // if r := recover(); r != nil {
1713
- // switch x := r.(type) {
1714
- // case error:
1715
- // err = x
1716
- // case string:
1717
- // err = errors.New(x)
1718
- // default:
1719
- // err = errors.New(fmt.Sprintf("Unknown error '%s'", x))
1720
- // }
1721
- // if debugging { debugf("*** Exception raised %v\n", r) }
1722
- // // Dump the goroutine stack
1723
- // debug.PrintStack()
1724
- // }
1725
- // }()
1710
+ var vm = Vm {
1711
+ frame : frame ,
1712
+ }
1726
1713
1727
1714
// FIXME
1728
1715
// if (co->co_flags & CO_GENERATOR) {
@@ -1742,12 +1729,11 @@ func RunFrame(frame *py.Frame) (res py.Object, err error) {
1742
1729
1743
1730
var opcode OpCode
1744
1731
var arg int32
1732
+ opcodes := frame .Code .Code
1745
1733
for vm .why == whyNot {
1746
- frame := vm .frame
1747
1734
if debugging {
1748
1735
debugf ("* %4d:" , frame .Lasti )
1749
1736
}
1750
- opcodes := frame .Code .Code
1751
1737
opcode = OpCode (opcodes [frame .Lasti ])
1752
1738
frame .Lasti ++
1753
1739
if opcode .HAS_ARG () {
@@ -1767,7 +1753,7 @@ func RunFrame(frame *py.Frame) (res py.Object, err error) {
1767
1753
}
1768
1754
}
1769
1755
vm .extended = false
1770
- err = jumpTable [opcode ](vm , arg )
1756
+ err = jumpTable [opcode ](& vm , arg )
1771
1757
if err != nil {
1772
1758
// FIXME shouldn't be doing this - just use err?
1773
1759
if errExcInfo , ok := err .(py.ExceptionInfo ); ok {
@@ -1778,11 +1764,9 @@ func RunFrame(frame *py.Frame) (res py.Object, err error) {
1778
1764
vm .SetException (py .MakeException (err ))
1779
1765
}
1780
1766
}
1781
- if vm .frame != nil {
1782
- if debugging {
1783
- debugf ("* Stack = %#v\n " , vm .frame .Stack )
1784
- }
1785
- // if len(vm.frame.Stack) > 0 {
1767
+ if debugging {
1768
+ debugf ("* Stack = %#v\n " , frame .Stack )
1769
+ // if len(frame.Stack) > 0 {
1786
1770
// if t, ok := vm.TOP().(*py.Type); ok {
1787
1771
// if debugging { debugf(" * TOP = %#v\n", t) }
1788
1772
// }
@@ -1794,9 +1778,8 @@ func RunFrame(frame *py.Frame) (res py.Object, err error) {
1794
1778
1795
1779
// Something exceptional has happened - unwind the block stack
1796
1780
// and find out what
1797
- for vm .why != whyNot && vm . frame .Block != nil {
1781
+ for vm .why != whyNot && frame .Block != nil {
1798
1782
// Peek at the current block.
1799
- frame := vm .frame
1800
1783
b := frame .Block
1801
1784
if debugging {
1802
1785
debugf ("*** Unwinding %#v vm %#v\n " , b , vm )
0 commit comments