5
5
use super :: objcode:: PyCodeRef ;
6
6
use super :: objdict:: PyDictRef ;
7
7
use crate :: frame:: FrameRef ;
8
- use crate :: pyobject:: { PyContext , PyResult } ;
8
+ use crate :: pyobject:: { PyContext , PyObjectRef , PyResult } ;
9
9
use crate :: vm:: VirtualMachine ;
10
10
11
11
pub fn init ( context : & PyContext ) {
12
12
extend_class ! ( context, & context. frame_type, {
13
13
"__new__" => context. new_rustfunc( FrameRef :: new) ,
14
14
"__repr__" => context. new_rustfunc( FrameRef :: repr) ,
15
15
"f_locals" => context. new_property( FrameRef :: flocals) ,
16
+ "f_globals" => context. new_property( FrameRef :: f_globals) ,
16
17
"f_code" => context. new_property( FrameRef :: fcode) ,
18
+ "f_back" => context. new_property( FrameRef :: f_back) ,
19
+ "f_lasti" => context. new_property( FrameRef :: f_lasti) ,
17
20
} ) ;
18
21
}
19
22
@@ -27,11 +30,24 @@ impl FrameRef {
27
30
"<frame object at .. >" . to_string ( )
28
31
}
29
32
33
+ fn f_globals ( self , _vm : & VirtualMachine ) -> PyDictRef {
34
+ self . scope . globals . clone ( )
35
+ }
36
+
30
37
fn flocals ( self , _vm : & VirtualMachine ) -> PyDictRef {
31
38
self . scope . get_locals ( )
32
39
}
33
40
34
41
fn fcode ( self , vm : & VirtualMachine ) -> PyCodeRef {
35
42
vm. ctx . new_code_object ( self . code . clone ( ) )
36
43
}
44
+
45
+ fn f_back ( self , vm : & VirtualMachine ) -> PyObjectRef {
46
+ // TODO: how to retrieve the upper stack frame??
47
+ vm. ctx . none ( )
48
+ }
49
+
50
+ fn f_lasti ( self , vm : & VirtualMachine ) -> PyObjectRef {
51
+ vm. ctx . new_int ( * self . lasti . borrow ( ) )
52
+ }
37
53
}
0 commit comments