@@ -10,9 +10,8 @@ use std::collections::hash_map::HashMap;
10
10
11
11
use super :: builtins;
12
12
use super :: bytecode;
13
- use super :: frame:: { ExecutionResult , Frame } ;
13
+ use super :: frame:: ExecutionResult ;
14
14
use super :: obj:: objcode:: copy_code;
15
- use super :: obj:: objframe;
16
15
use super :: obj:: objgenerator;
17
16
use super :: obj:: objiter;
18
17
use super :: obj:: objsequence;
@@ -58,21 +57,25 @@ impl VirtualMachine {
58
57
}
59
58
60
59
pub fn run_code_obj ( & mut self , code : PyObjectRef , scope : PyObjectRef ) -> PyResult {
61
- self . run_frame_full ( Frame :: new ( code, scope) )
60
+ let frame = self . ctx . new_frame ( code, scope) ;
61
+ self . run_frame_full ( frame)
62
62
}
63
63
64
- pub fn run_frame_full ( & mut self , frame : Frame ) -> PyResult {
64
+ pub fn run_frame_full ( & mut self , frame : PyObjectRef ) -> PyResult {
65
65
match self . run_frame ( frame) ? {
66
66
ExecutionResult :: Return ( value) => Ok ( value) ,
67
67
_ => panic ! ( "Got unexpected result from function" ) ,
68
68
}
69
69
}
70
70
71
- pub fn run_frame ( & mut self , frame : Frame ) -> Result < ExecutionResult , PyObjectRef > {
72
- let frame = self . ctx . new_frame ( frame ) ;
71
+ pub fn run_frame ( & mut self , frame : PyObjectRef ) -> Result < ExecutionResult , PyObjectRef > {
72
+ let result ;
73
73
self . frames . push ( frame. clone ( ) ) ;
74
- let mut frame = objframe:: get_value ( & frame) ;
75
- let result = frame. run ( self ) ;
74
+ if let PyObjectKind :: Frame { ref mut frame } = frame. borrow_mut ( ) . kind {
75
+ result = frame. run ( self ) ;
76
+ } else {
77
+ panic ! ( "Frame doesn't contain a frame: {:?}" , frame) ;
78
+ }
76
79
self . frames . pop ( ) ;
77
80
result
78
81
}
@@ -276,7 +279,7 @@ impl VirtualMachine {
276
279
self . fill_scope_from_args ( & code_object, & scope, args, defaults) ?;
277
280
278
281
// Construct frame:
279
- let frame = Frame :: new ( code. clone ( ) , scope) ;
282
+ let frame = self . ctx . new_frame ( code. clone ( ) , scope) ;
280
283
281
284
// If we have a generator, create a new generator
282
285
if code_object. is_generator {
0 commit comments