@@ -4,9 +4,11 @@ use super::frame::Frame;
44use super :: obj:: objbool;
55use super :: obj:: objbytearray;
66use super :: obj:: objbytes;
7+ use super :: obj:: objcode;
78use super :: obj:: objcomplex;
89use super :: obj:: objdict;
910use super :: obj:: objfloat;
11+ use super :: obj:: objframe;
1012use super :: obj:: objfunction;
1113use super :: obj:: objgenerator;
1214use super :: obj:: objint;
@@ -70,31 +72,44 @@ impl fmt::Display for PyObjectRef {
7072 }
7173}*/
7274
75+ /*
76+ // Idea: implement the iterator trait upon PyObjectRef
77+ impl Iterator for (VirtualMachine, PyObjectRef) {
78+ type Item = char;
79+
80+ fn next(&mut self) -> Option<Self::Item> {
81+ // call method ("_next__")
82+ }
83+ }
84+ */
85+
7386#[ derive( Debug ) ]
7487pub struct PyContext {
75- pub type_type : PyObjectRef ,
76- pub none : PyObjectRef ,
88+ pub bytes_type : PyObjectRef ,
89+ pub bytearray_type : PyObjectRef ,
90+ pub bool_type : PyObjectRef ,
7791pub classmethod_type : PyObjectRef ,
78- pub staticmethod_type : PyObjectRef ,
92+ pub code_type : PyObjectRef ,
7993pub dict_type : PyObjectRef ,
80- pub int_type : PyObjectRef ,
8194pub float_type : PyObjectRef ,
95+ pub frame_type : PyObjectRef ,
96+ pub frozenset_type : PyObjectRef ,
97+ pub generator_type : PyObjectRef ,
98+ pub int_type : PyObjectRef ,
99+ pub iter_type : PyObjectRef ,
82100pub complex_type : PyObjectRef ,
83- pub bytes_type : PyObjectRef ,
84- pub bytearray_type : PyObjectRef ,
85- pub bool_type : PyObjectRef ,
86101pub true_value : PyObjectRef ,
87102pub false_value : PyObjectRef ,
88103pub list_type : PyObjectRef ,
104+ pub none : PyObjectRef ,
89105pub tuple_type : PyObjectRef ,
90106pub set_type : PyObjectRef ,
91- pub frozenset_type : PyObjectRef ,
92- pub iter_type : PyObjectRef ,
107+ pub staticmethod_type : PyObjectRef ,
93108pub super_type : PyObjectRef ,
94109pub str_type : PyObjectRef ,
110+ pub type_type : PyObjectRef ,
95111pub function_type : PyObjectRef ,
96112pub property_type : PyObjectRef ,
97- pub generator_type : PyObjectRef ,
98113pub module_type : PyObjectRef ,
99114pub bound_method_type : PyObjectRef ,
100115pub member_descriptor_type : PyObjectRef ,
@@ -162,12 +177,14 @@ impl PyContext {
162177let frozenset_type =create_type ( "frozenset" , & type_type, & object_type, & dict_type) ;
163178let int_type =create_type ( "int" , & type_type, & object_type, & dict_type) ;
164179let float_type =create_type ( "float" , & type_type, & object_type, & dict_type) ;
180+ let frame_type =create_type ( "frame" , & type_type, & object_type, & dict_type) ;
165181let complex_type =create_type ( "complex" , & type_type, & object_type, & dict_type) ;
166182let bytes_type =create_type ( "bytes" , & type_type, & object_type, & dict_type) ;
167183let bytearray_type =create_type ( "bytearray" , & type_type, & object_type, & dict_type) ;
168184let tuple_type =create_type ( "tuple" , & type_type, & object_type, & dict_type) ;
169185let iter_type =create_type ( "iter" , & type_type, & object_type, & dict_type) ;
170186let bool_type =create_type ( "bool" , & type_type, & int_type, & dict_type) ;
187+ let code_type =create_type ( "code" , & type_type, & int_type, & dict_type) ;
171188let exceptions = exceptions:: ExceptionZoo :: new ( & type_type, & object_type, & dict_type) ;
172189
173190let none =PyObject :: new (
@@ -186,17 +203,19 @@ impl PyContext {
186203 bool_type. clone ( ) ,
187204) ;
188205let context =PyContext {
189- int_type : int_type,
190- float_type : float_type,
206+ bool_type : bool_type,
207+ bytearray_type : bytearray_type,
208+ bytes_type : bytes_type,
209+ code_type : code_type,
191210complex_type : complex_type,
192211classmethod_type : classmethod_type,
212+ int_type : int_type,
213+ float_type : float_type,
214+ frame_type : frame_type,
193215staticmethod_type : staticmethod_type,
194- bytes_type : bytes_type,
195- bytearray_type : bytearray_type,
196216list_type : list_type,
197217set_type : set_type,
198218frozenset_type : frozenset_type,
199- bool_type : bool_type,
200219true_value : true_value,
201220false_value : false_value,
202221tuple_type : tuple_type,
@@ -234,28 +253,42 @@ impl PyContext {
234253 objtuple:: init ( & context) ;
235254 objiter:: init ( & context) ;
236255 objbool:: init ( & context) ;
256+ objcode:: init ( & context) ;
257+ objframe:: init ( & context) ;
237258 exceptions:: init ( & context) ;
238259 context
239260}
240261
241- pub fn int_type ( & self ) ->PyObjectRef {
242- self . int_type . clone ( )
262+ pub fn bytearray_type ( & self ) ->PyObjectRef {
263+ self . bytearray_type . clone ( )
243264}
244265
245- pub fn float_type ( & self ) ->PyObjectRef {
246- self . float_type . clone ( )
266+ pub fn bytes_type ( & self ) ->PyObjectRef {
267+ self . bytes_type . clone ( )
268+ }
269+
270+ pub fn code_type ( & self ) ->PyObjectRef {
271+ self . code_type . clone ( )
247272}
248273
249274pub fn complex_type ( & self ) ->PyObjectRef {
250275self . complex_type . clone ( )
251276}
252277
253- pub fn bytes_type ( & self ) ->PyObjectRef {
254- self . bytes_type . clone ( )
278+ pub fn dict_type ( & self ) ->PyObjectRef {
279+ self . dict_type . clone ( )
255280}
256281
257- pub fn bytearray_type ( & self ) ->PyObjectRef {
258- self . bytearray_type . clone ( )
282+ pub fn float_type ( & self ) ->PyObjectRef {
283+ self . float_type . clone ( )
284+ }
285+
286+ pub fn frame_type ( & self ) ->PyObjectRef {
287+ self . frame_type . clone ( )
288+ }
289+
290+ pub fn int_type ( & self ) ->PyObjectRef {
291+ self . int_type . clone ( )
259292}
260293
261294pub fn list_type ( & self ) ->PyObjectRef {
@@ -282,10 +315,6 @@ impl PyContext {
282315self . iter_type . clone ( )
283316}
284317
285- pub fn dict_type ( & self ) ->PyObjectRef {
286- self . dict_type . clone ( )
287- }
288-
289318pub fn str_type ( & self ) ->PyObjectRef {
290319self . str_type . clone ( )
291320}