@@ -58,21 +58,72 @@ impl ByteRepr for view {
5858 }
5959 }
6060}
61+ #[ derive( Default ) ]
62+ pub struct entry {
63+ pub id : Value < i32 > ,
64+ }
65+ impl Clone for entry {
66+ fn clone ( & self ) -> Self {
67+ Self {
68+ id : Rc :: new ( RefCell :: new ( ( * self . id . borrow ( ) ) . clone ( ) ) ) ,
69+ }
70+ }
71+ }
72+ impl ByteRepr for entry {
73+ fn byte_size ( ) -> usize {
74+ 4
75+ }
76+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
77+ ( * self . id . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
78+ }
79+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
80+ Self {
81+ id : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
82+ }
83+ }
84+ }
85+ thread_local ! (
86+ pub static e0_0: Value <entry> = Rc :: new( RefCell :: new( entry {
87+ id: Rc :: new( RefCell :: new( 1 ) ) ,
88+ } ) ) ;
89+ ) ;
90+ thread_local ! (
91+ pub static e1_1: Value <entry> = Rc :: new( RefCell :: new( entry {
92+ id: Rc :: new( RefCell :: new( 2 ) ) ,
93+ } ) ) ;
94+ ) ;
95+ thread_local ! (
96+ pub static registry_2: Value <Box <[ Ptr <entry>] >> = Rc :: new( RefCell :: new( Box :: new( [
97+ ( e0_0. with( Value :: clone) . as_pointer( ) ) ,
98+ ( e1_1. with( Value :: clone) . as_pointer( ) ) ,
99+ Ptr :: <entry>:: null( ) ,
100+ ] ) ) ) ;
101+ ) ;
102+ pub fn get_registry_3 ( out : Ptr < Ptr < Ptr < entry > > > ) {
103+ let out: Value < Ptr < Ptr < Ptr < entry > > > > = Rc :: new ( RefCell :: new ( out) ) ;
104+ let __rhs = ( registry_2. with ( Value :: clone) . as_pointer ( ) as Ptr < Ptr < entry > > )
105+ . reinterpret_cast :: < Ptr < entry > > ( ) ;
106+ ( * out. borrow ( ) ) . write ( __rhs) ;
107+ }
61108pub fn main ( ) {
62109 std:: process:: exit ( main_0 ( ) ) ;
63110}
64111fn main_0 ( ) -> i32 {
65112 let text: Value < Box < [ u8 ] > > = Rc :: new ( RefCell :: new ( Box :: from ( * b"hi\0 " ) ) ) ;
66113 let cp: Value < Ptr < u8 > > = Rc :: new ( RefCell :: new ( ( text. as_pointer ( ) as Ptr < u8 > ) ) ) ;
67- let u: Value < Ptr < u8 > > = Rc :: new ( RefCell :: new ( ( * cp. borrow ( ) ) . reinterpret_cast :: < u8 > ( ) ) ) ;
114+ let u: Value < Ptr < u8 > > = Rc :: new ( RefCell :: new (
115+ ( ( * cp. borrow ( ) ) . reinterpret_cast :: < u8 > ( ) ) . clone ( ) ,
116+ ) ) ;
68117 assert ! ( ( ( ( ( ( ( * u. borrow( ) ) . offset( ( 0 ) as isize ) . read( ) ) as i32 ) == ( 'h' as i32 ) ) as i32 ) != 0 ) ) ;
69118 assert ! ( ( ( ( ( ( ( * u. borrow( ) ) . offset( ( 1 ) as isize ) . read( ) ) as i32 ) == ( 'i' as i32 ) ) as i32 ) != 0 ) ) ;
70119 let h: Value < header > = Rc :: new ( RefCell :: new ( header {
71120 tag : Rc :: new ( RefCell :: new ( 7 ) ) ,
72121 size : Rc :: new ( RefCell :: new ( 32 ) ) ,
73122 } ) ) ;
74123 let hp: Value < Ptr < header > > = Rc :: new ( RefCell :: new ( ( h. as_pointer ( ) ) ) ) ;
75- let v: Value < Ptr < view > > = Rc :: new ( RefCell :: new ( ( * hp. borrow ( ) ) . reinterpret_cast :: < view > ( ) ) ) ;
124+ let v: Value < Ptr < view > > = Rc :: new ( RefCell :: new (
125+ ( ( * hp. borrow ( ) ) . reinterpret_cast :: < view > ( ) ) . clone ( ) ,
126+ ) ) ;
76127 assert ! ( ( ( ( ( * ( * ( * v. borrow( ) ) . upgrade( ) . deref( ) ) . tag. borrow( ) ) == 7 ) as i32 ) != 0 ) ) ;
77128 let data: Value < Box < [ u8 ] > > = Rc :: new ( RefCell :: new ( Box :: from ( * b"hi\0 " ) ) ) ;
78129 let vp: Value < AnyPtr > = Rc :: new ( RefCell :: new (
@@ -99,5 +150,27 @@ fn main_0() -> i32 {
99150 }
100151 . reinterpret_cast :: < u8 > ( ) ;
101152 assert ! ( ( ( ( ( * sel. borrow( ) ) . is_null( ) ) as i32 ) != 0 ) ) ;
153+ let avail: Value < Ptr < Ptr < entry > > > = Rc :: new ( RefCell :: new ( Ptr :: < Ptr < entry > > :: null ( ) ) ) ;
154+ ( { get_registry_3 ( ( avail. as_pointer ( ) ) ) } ) ;
155+ assert ! ( ( ( ( !( ( * avail. borrow( ) ) . is_null( ) ) ) as i32 ) != 0 ) ) ;
156+ assert ! (
157+ ( ( ( ( * ( * ( ( * avail. borrow( ) ) . offset( ( 0 ) as isize ) . read( ) )
158+ . upgrade( )
159+ . deref( ) )
160+ . id
161+ . borrow( ) )
162+ == 1 ) as i32 )
163+ != 0 )
164+ ) ;
165+ assert ! (
166+ ( ( ( ( * ( * ( ( * avail. borrow( ) ) . offset( ( 1 ) as isize ) . read( ) )
167+ . upgrade( )
168+ . deref( ) )
169+ . id
170+ . borrow( ) )
171+ == 2 ) as i32 )
172+ != 0 )
173+ ) ;
174+ assert ! ( ( ( ( ( ( * avail. borrow( ) ) . offset( ( 2 ) as isize ) . read( ) ) . is_null( ) ) as i32 ) != 0 ) ) ;
102175 return 0 ;
103176}
0 commit comments