@@ -4,9 +4,11 @@ use super::frame::Frame;
4
4
use super :: obj:: objbool;
5
5
use super :: obj:: objbytearray;
6
6
use super :: obj:: objbytes;
7
+ use super :: obj:: objcode;
7
8
use super :: obj:: objcomplex;
8
9
use super :: obj:: objdict;
9
10
use super :: obj:: objfloat;
11
+ use super :: obj:: objframe;
10
12
use super :: obj:: objfunction;
11
13
use super :: obj:: objgenerator;
12
14
use super :: obj:: objint;
@@ -70,31 +72,44 @@ impl fmt::Display for PyObjectRef {
70
72
}
71
73
}*/
72
74
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
+
73
86
#[ derive( Debug ) ]
74
87
pub 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 ,
77
91
pub classmethod_type : PyObjectRef ,
78
- pub staticmethod_type : PyObjectRef ,
92
+ pub code_type : PyObjectRef ,
79
93
pub dict_type : PyObjectRef ,
80
- pub int_type : PyObjectRef ,
81
94
pub 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 ,
82
100
pub complex_type : PyObjectRef ,
83
- pub bytes_type : PyObjectRef ,
84
- pub bytearray_type : PyObjectRef ,
85
- pub bool_type : PyObjectRef ,
86
101
pub true_value : PyObjectRef ,
87
102
pub false_value : PyObjectRef ,
88
103
pub list_type : PyObjectRef ,
104
+ pub none : PyObjectRef ,
89
105
pub tuple_type : PyObjectRef ,
90
106
pub set_type : PyObjectRef ,
91
- pub frozenset_type : PyObjectRef ,
92
- pub iter_type : PyObjectRef ,
107
+ pub staticmethod_type : PyObjectRef ,
93
108
pub super_type : PyObjectRef ,
94
109
pub str_type : PyObjectRef ,
110
+ pub type_type : PyObjectRef ,
95
111
pub function_type : PyObjectRef ,
96
112
pub property_type : PyObjectRef ,
97
- pub generator_type : PyObjectRef ,
98
113
pub module_type : PyObjectRef ,
99
114
pub bound_method_type : PyObjectRef ,
100
115
pub member_descriptor_type : PyObjectRef ,
@@ -162,12 +177,14 @@ impl PyContext {
162
177
let frozenset_type = create_type ( "frozenset" , & type_type, & object_type, & dict_type) ;
163
178
let int_type = create_type ( "int" , & type_type, & object_type, & dict_type) ;
164
179
let float_type = create_type ( "float" , & type_type, & object_type, & dict_type) ;
180
+ let frame_type = create_type ( "frame" , & type_type, & object_type, & dict_type) ;
165
181
let complex_type = create_type ( "complex" , & type_type, & object_type, & dict_type) ;
166
182
let bytes_type = create_type ( "bytes" , & type_type, & object_type, & dict_type) ;
167
183
let bytearray_type = create_type ( "bytearray" , & type_type, & object_type, & dict_type) ;
168
184
let tuple_type = create_type ( "tuple" , & type_type, & object_type, & dict_type) ;
169
185
let iter_type = create_type ( "iter" , & type_type, & object_type, & dict_type) ;
170
186
let bool_type = create_type ( "bool" , & type_type, & int_type, & dict_type) ;
187
+ let code_type = create_type ( "code" , & type_type, & int_type, & dict_type) ;
171
188
let exceptions = exceptions:: ExceptionZoo :: new ( & type_type, & object_type, & dict_type) ;
172
189
173
190
let none = PyObject :: new (
@@ -186,17 +203,19 @@ impl PyContext {
186
203
bool_type. clone ( ) ,
187
204
) ;
188
205
let 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,
191
210
complex_type : complex_type,
192
211
classmethod_type : classmethod_type,
212
+ int_type : int_type,
213
+ float_type : float_type,
214
+ frame_type : frame_type,
193
215
staticmethod_type : staticmethod_type,
194
- bytes_type : bytes_type,
195
- bytearray_type : bytearray_type,
196
216
list_type : list_type,
197
217
set_type : set_type,
198
218
frozenset_type : frozenset_type,
199
- bool_type : bool_type,
200
219
true_value : true_value,
201
220
false_value : false_value,
202
221
tuple_type : tuple_type,
@@ -234,28 +253,42 @@ impl PyContext {
234
253
objtuple:: init ( & context) ;
235
254
objiter:: init ( & context) ;
236
255
objbool:: init ( & context) ;
256
+ objcode:: init ( & context) ;
257
+ objframe:: init ( & context) ;
237
258
exceptions:: init ( & context) ;
238
259
context
239
260
}
240
261
241
- pub fn int_type ( & self ) -> PyObjectRef {
242
- self . int_type . clone ( )
262
+ pub fn bytearray_type ( & self ) -> PyObjectRef {
263
+ self . bytearray_type . clone ( )
243
264
}
244
265
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 ( )
247
272
}
248
273
249
274
pub fn complex_type ( & self ) -> PyObjectRef {
250
275
self . complex_type . clone ( )
251
276
}
252
277
253
- pub fn bytes_type ( & self ) -> PyObjectRef {
254
- self . bytes_type . clone ( )
278
+ pub fn dict_type ( & self ) -> PyObjectRef {
279
+ self . dict_type . clone ( )
255
280
}
256
281
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 ( )
259
292
}
260
293
261
294
pub fn list_type ( & self ) -> PyObjectRef {
@@ -282,10 +315,6 @@ impl PyContext {
282
315
self . iter_type . clone ( )
283
316
}
284
317
285
- pub fn dict_type ( & self ) -> PyObjectRef {
286
- self . dict_type . clone ( )
287
- }
288
-
289
318
pub fn str_type ( & self ) -> PyObjectRef {
290
319
self . str_type . clone ( )
291
320
}
0 commit comments