11use super :: bytecode;
22use super :: exceptions;
3+ use super :: obj:: objbytes;
34use super :: obj:: objdict;
45use super :: obj:: objfloat;
56use super :: obj:: objint;
@@ -52,6 +53,7 @@ pub struct PyContext {
5253 pub dict_type : PyObjectRef ,
5354 pub int_type : PyObjectRef ,
5455 pub float_type : PyObjectRef ,
56+ pub bytes_type : PyObjectRef ,
5557 pub bool_type : PyObjectRef ,
5658 pub list_type : PyObjectRef ,
5759 pub tuple_type : PyObjectRef ,
@@ -114,6 +116,7 @@ impl PyContext {
114116 let list_type = create_type ( "list" , & type_type, & object_type, & dict_type) ;
115117 let int_type = create_type ( "int" , & type_type, & object_type, & dict_type) ;
116118 let float_type = create_type ( "float" , & type_type, & object_type, & dict_type) ;
119+ let bytes_type = create_type ( "bytes" , & type_type, & object_type, & dict_type) ;
117120 let tuple_type = create_type ( "tuple" , & type_type, & object_type, & dict_type) ;
118121 let bool_type = create_type ( "bool" , & type_type, & object_type, & dict_type) ;
119122 let exceptions = exceptions:: ExceptionZoo :: new ( & type_type, & object_type, & dict_type) ;
@@ -126,6 +129,7 @@ impl PyContext {
126129 let context = PyContext {
127130 int_type : int_type,
128131 float_type : float_type,
132+ bytes_type : bytes_type,
129133 list_type : list_type,
130134 bool_type : bool_type,
131135 tuple_type : tuple_type,
@@ -146,6 +150,7 @@ impl PyContext {
146150 objfunction:: init ( & context) ;
147151 objint:: init ( & context) ;
148152 objfloat:: init ( & context) ;
153+ objbytes:: init ( & context) ;
149154 objstr:: init ( & context) ;
150155 objbool:: init ( & context) ;
151156 exceptions:: init ( & context) ;
@@ -162,6 +167,10 @@ impl PyContext {
162167 self . float_type . clone ( )
163168 }
164169
170+ pub fn bytes_type ( & self ) -> PyObjectRef {
171+ self . bytes_type . clone ( )
172+ }
173+
165174 pub fn list_type ( & self ) -> PyObjectRef {
166175 self . list_type . clone ( )
167176 }
@@ -547,6 +556,9 @@ pub enum PyObjectKind {
547556 Boolean {
548557 value : bool ,
549558 } ,
559+ Bytes {
560+ value : Vec < u8 > ,
561+ } ,
550562 List {
551563 elements : Vec < PyObjectRef > ,
552564 } ,
@@ -604,6 +616,7 @@ impl fmt::Debug for PyObjectKind {
604616 & PyObjectKind :: String { ref value } => write ! ( f, "str \" {}\" " , value) ,
605617 & PyObjectKind :: Integer { ref value } => write ! ( f, "int {}" , value) ,
606618 & PyObjectKind :: Float { ref value } => write ! ( f, "float {}" , value) ,
619+ & PyObjectKind :: Bytes { ref value } => write ! ( f, "bytes {:?}" , value) ,
607620 & PyObjectKind :: Boolean { ref value } => write ! ( f, "boolean {}" , value) ,
608621 & PyObjectKind :: List { elements : _ } => write ! ( f, "list" ) ,
609622 & PyObjectKind :: Tuple { elements : _ } => write ! ( f, "tuple" ) ,
@@ -651,6 +664,7 @@ impl PyObject {
651664 PyObjectKind :: String { ref value } => value. clone ( ) ,
652665 PyObjectKind :: Integer { ref value } => format ! ( "{:?}" , value) ,
653666 PyObjectKind :: Float { ref value } => format ! ( "{:?}" , value) ,
667+ PyObjectKind :: Bytes { ref value } => format ! ( "b'{:?}'" , value) ,
654668 PyObjectKind :: Boolean { ref value } => format ! ( "{:?}" , value) ,
655669 PyObjectKind :: List { ref elements } => format ! (
656670 "[{}]" ,
0 commit comments