@@ -6,54 +6,27 @@ use std::io::prelude::*;
66use std:: io:: { Read , Seek , Write } ;
77use std:: os:: fd:: AsFd ;
88use std:: rc:: { Rc , Weak } ;
9- #[ derive( Default ) ]
10- pub struct iter {
11- pub p : Value < Ptr < i32 > > ,
12- }
13- impl Clone for iter {
14- fn clone ( & self ) -> Self {
15- let mut this = Self {
16- p : Rc :: new ( RefCell :: new ( ( * self . p . borrow ( ) ) . clone ( ) ) ) ,
17- } ;
18- this
19- }
20- }
21- impl ByteRepr for iter { }
22- #[ derive( Default ) ]
23- pub struct const_iter {
24- pub p : Value < Ptr < i32 > > ,
25- }
26- impl const_iter {
27- pub fn const_iter ( o : Ptr < iter > ) -> Self {
28- let mut this = Self {
29- p : Rc :: new ( RefCell :: new ( ( * ( * o. upgrade ( ) . deref ( ) ) . p . borrow ( ) ) . clone ( ) ) ) ,
30- } ;
31- this
32- }
33- }
34- impl Clone for const_iter {
35- fn clone ( & self ) -> Self {
36- let mut this = Self {
37- p : Rc :: new ( RefCell :: new ( Ptr :: < i32 > :: null ( ) ) ) ,
38- } ;
39- this
40- }
41- }
42- impl ByteRepr for const_iter { }
43- pub fn sink_0 ( i : const_iter ) {
44- let i: Value < const_iter > = Rc :: new ( RefCell :: new ( i) ) ;
45- }
469pub fn main ( ) {
4710 std:: process:: exit ( main_0 ( ) ) ;
4811}
4912fn main_0 ( ) -> i32 {
50- let buf: Value < Box < [ i32 ] > > = Rc :: new ( RefCell :: new ( Box :: new ( [ 0 , 0 ] ) ) ) ;
51- let it: Value < iter > = Rc :: new ( RefCell :: new ( iter {
52- p : Rc :: new ( RefCell :: new ( ( buf. as_pointer ( ) as Ptr < i32 > ) ) ) ,
53- } ) ) ;
54- ( {
55- let _i: const_iter = const_iter:: const_iter ( it. as_pointer ( ) ) ;
56- sink_0 ( _i)
57- } ) ;
58- return 0 ;
13+ let m: Value < BTreeMap < i32 , Value < i32 > > > = Rc :: new ( RefCell :: new ( BTreeMap :: new ( ) ) ) ;
14+ ( m. as_pointer ( ) as Ptr < BTreeMap < i32 , Value < i32 > > > )
15+ . with_mut ( |__v : & mut BTreeMap < i32 , Value < i32 > > | {
16+ __v. entry ( 0 . clone ( ) )
17+ . or_insert_with ( || Rc :: new ( RefCell :: new ( <i32 >:: default ( ) ) ) )
18+ . as_pointer ( )
19+ } )
20+ . write ( 1 ) ;
21+ let end: Value < RefcountMapIter < i32 , i32 > > = Rc :: new ( RefCell :: new ( RefcountMapIter :: end (
22+ ( m. as_pointer ( ) as Ptr < BTreeMap < i32 , Value < i32 > > > ) ,
23+ ) ) ) ;
24+ let const_it: Value < RefcountMapIter < i32 , i32 > > = Rc :: new ( RefCell :: new (
25+ RefcountMapIter :: find_key ( ( m. as_pointer ( ) as Ptr < BTreeMap < i32 , Value < i32 > > > ) , & 0 ) ,
26+ ) ) ;
27+ return if ( * const_it. borrow ( ) ) == ( * end. borrow ( ) ) {
28+ 0
29+ } else {
30+ 1
31+ } ;
5932}
0 commit comments