@@ -1707,22 +1707,9 @@ func (vm *Vm) UnwindExceptHandler(frame *py.Frame, block *py.TryBlock){
17071707//
17081708// This is the equivalent of PyEval_EvalFrame
17091709func 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+ }
17261713
17271714// FIXME
17281715// if (co->co_flags & CO_GENERATOR){
@@ -1742,12 +1729,11 @@ func RunFrame(frame *py.Frame) (res py.Object, err error){
17421729
17431730var opcode OpCode
17441731var arg int32
1732+ opcodes := frame .Code .Code
17451733for vm .why == whyNot {
1746- frame := vm .frame
17471734if debugging {
17481735debugf ("* %4d:" , frame .Lasti )
17491736 }
1750- opcodes := frame .Code .Code
17511737opcode = OpCode (opcodes [frame .Lasti ])
17521738frame .Lasti ++
17531739if opcode .HAS_ARG (){
@@ -1767,7 +1753,7 @@ func RunFrame(frame *py.Frame) (res py.Object, err error){
17671753 }
17681754 }
17691755vm .extended = false
1770- err = jumpTable [opcode ](vm , arg )
1756+ err = jumpTable [opcode ](& vm , arg )
17711757if err != nil {
17721758// FIXME shouldn't be doing this - just use err?
17731759if errExcInfo , ok := err .(py.ExceptionInfo ); ok {
@@ -1778,11 +1764,9 @@ func RunFrame(frame *py.Frame) (res py.Object, err error){
17781764vm .SetException (py .MakeException (err ))
17791765 }
17801766 }
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{
17861770// if t, ok := vm.TOP().(*py.Type); ok{
17871771// if debugging{debugf(" * TOP = %#v\n", t) }
17881772// }
@@ -1794,9 +1778,8 @@ func RunFrame(frame *py.Frame) (res py.Object, err error){
17941778
17951779// Something exceptional has happened - unwind the block stack
17961780// and find out what
1797- for vm .why != whyNot && vm . frame .Block != nil {
1781+ for vm .why != whyNot && frame .Block != nil {
17981782// Peek at the current block.
1799- frame := vm .frame
18001783b := frame .Block
18011784if debugging {
18021785debugf ("*** Unwinding %#v vm %#v\n " , b , vm )
0 commit comments