11use super :: bytecode;
2+ use super :: exceptions;
23use super :: objdict;
34use super :: objfunction;
45use super :: objint;
@@ -54,6 +55,7 @@ pub struct PyContext {
5455 pub bound_method_type : PyObjectRef ,
5556 pub member_descriptor_type : PyObjectRef ,
5657 pub object : PyObjectRef ,
58+ pub base_exception_type : PyObjectRef ,
5759}
5860
5961/*
@@ -95,21 +97,24 @@ impl PyContext {
9597 tuple_type : type_type. clone ( ) ,
9698 dict_type : dict_type. clone ( ) ,
9799 none : PyObject :: new ( PyObjectKind :: None , type_type. clone ( ) ) ,
98- object : object_type,
100+ object : object_type. clone ( ) ,
99101 function_type : function_type,
100102 bound_method_type : bound_method_type,
101103 member_descriptor_type : member_descriptor_type,
102- type_type : type_type,
104+ type_type : type_type. clone ( ) ,
105+ base_exception_type : exceptions:: create_base_exception_type ( type_type. clone ( ) , object_type. clone ( ) ) ,
103106 } ;
104107 objtype:: init ( & context) ;
105108 objlist:: init ( & context) ;
106109 objobject:: init ( & context) ;
107110 objdict:: init ( & context) ;
111+ // TODO: create exception hierarchy here?
112+ // exceptions::create_zoo(&context);
108113 context
109114 }
110115
111116 pub fn new_int ( & self , i : i32 ) -> PyObjectRef {
112- PyObject :: new ( PyObjectKind :: Integer { value : i } , self . type_type . clone ( ) )
117+ PyObject :: new ( PyObjectKind :: Integer { value : i } , self . int_type . clone ( ) )
113118 }
114119
115120 pub fn new_float ( & self , i : f64 ) -> PyObjectRef {
@@ -127,7 +132,7 @@ impl PyContext {
127132 pub fn new_tuple ( & self , elements : Vec < PyObjectRef > ) -> PyObjectRef {
128133 PyObject :: new (
129134 PyObjectKind :: Tuple { elements : elements } ,
130- self . type_type . clone ( ) ,
135+ self . tuple_type . clone ( ) ,
131136 )
132137 }
133138
0 commit comments