@@ -93,6 +93,54 @@ impl ByteRepr for S {
9393 }
9494 }
9595}
96+ #[ derive( ) ]
97+ pub struct Boxed_int_ {
98+ pub v : Value < i32 > ,
99+ pub tag : Value < i32 > ,
100+ }
101+ impl Boxed_int_ {
102+ pub fn Boxed_int_ ( x : i32 , t : i32 ) -> Self {
103+ let x: Value < i32 > = Rc :: new ( RefCell :: new ( x) ) ;
104+ let t: Value < i32 > = Rc :: new ( RefCell :: new ( t) ) ;
105+ let mut this = Self {
106+ v : Rc :: new ( RefCell :: new ( ( * x. borrow ( ) ) ) ) ,
107+ tag : Rc :: new ( RefCell :: new ( ( * t. borrow ( ) ) ) ) ,
108+ } ;
109+ this
110+ }
111+ }
112+ impl Clone for Boxed_int_ {
113+ fn clone ( & self ) -> Self {
114+ let mut this = Self {
115+ v : Rc :: new ( RefCell :: new ( ( * self . v . borrow ( ) ) ) ) ,
116+ tag : Rc :: new ( RefCell :: new ( ( * self . tag . borrow ( ) ) ) ) ,
117+ } ;
118+ this
119+ }
120+ }
121+ impl Default for Boxed_int_ {
122+ fn default ( ) -> Self {
123+ Boxed_int_ {
124+ v : <Value < i32 > >:: default ( ) ,
125+ tag : <Value < i32 > >:: default ( ) ,
126+ }
127+ }
128+ }
129+ impl ByteRepr for Boxed_int_ {
130+ fn byte_size ( ) -> usize {
131+ 8
132+ }
133+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
134+ ( * self . v . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
135+ ( * self . tag . borrow ( ) ) . to_bytes ( & mut buf[ 4 ..8 ] ) ;
136+ }
137+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
138+ Self {
139+ v : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
140+ tag : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 4 ..8 ] ) ) ) ,
141+ }
142+ }
143+ }
96144pub fn main ( ) {
97145 std:: process:: exit ( main_0 ( ) ) ;
98146}
@@ -104,5 +152,8 @@ fn main_0() -> i32 {
104152 assert ! ( ( ( * ( * ( * s. borrow( ) ) . c. borrow( ) ) . y. borrow( ) ) == 4 ) ) ;
105153 assert ! ( ( ( * ( * ( * s. borrow( ) ) . d. borrow( ) ) . x. borrow( ) ) == 3 ) ) ;
106154 assert ! ( ( ( * ( * ( * s. borrow( ) ) . d. borrow( ) ) . y. borrow( ) ) == 4 ) ) ;
155+ let boxed: Value < Boxed_int_ > = Rc :: new ( RefCell :: new ( Boxed_int_ :: Boxed_int_ ( { 5 } , { 9 } ) ) ) ;
156+ assert ! ( ( ( * ( * boxed. borrow( ) ) . v. borrow( ) ) == 5 ) ) ;
157+ assert ! ( ( ( * ( * boxed. borrow( ) ) . tag. borrow( ) ) == 9 ) ) ;
107158 return 0 ;
108159}
0 commit comments