@@ -94,25 +94,14 @@ pub fn main() {
9494}
9595fn main_0 ( ) -> i32 {
9696 let c: Value < Counted > = Rc :: new ( RefCell :: new ( Counted :: new ( ) ) ) ;
97- let f: Value < FnPtr < fn ( ) -> i32 > > = Rc :: new ( RefCell :: new ( {
98- #[ derive( Record , ByteRepr ) ]
99- #[ byte_size( 8 ) ]
100- struct Captures {
101- #[ offset( 0 ) ]
102- #[ byte_size( 8 ) ]
103- c : Counted ,
97+ let f: Value < FnPtr < fn ( ) -> i32 > > = Rc :: new ( RefCell :: new ( lambda ! (
98+ {
99+ let c: Value <Counted > = Rc :: new( RefCell :: new( Counted :: copy_from( { c. as_pointer( ) } ) ) ) ;
100+ } ,
101+ || -> i32 {
102+ return ( ( { ( * self . c. borrow( ) ) . copies } * 10 ) + { ( * self . c. borrow( ) ) . moves } ) ;
104103 }
105- FnPtr :: < fn ( ) -> i32 > :: with_captures (
106- Captures {
107- c : Counted :: copy_from ( { c. as_pointer ( ) } ) ,
108- } ,
109- ( |this : Ptr < Captures > | {
110- return ( ( { ( * this. upgrade ( ) . deref ( ) ) . c . copies } * 10 ) + {
111- ( * this. upgrade ( ) . deref ( ) ) . c . moves
112- } ) ;
113- } ) ,
114- )
115- } ) ) ;
104+ ) ) ) ;
116105 assert ! ( ( ( { ( * f. borrow( ) ) . call( ) } ) == 10 ) ) ;
117106 let g: Value < FnPtr < fn ( ) -> i32 > > = Rc :: new ( RefCell :: new ( ( * f. borrow ( ) ) . clone ( ) ) ) ;
118107 assert ! ( ( ( { ( * g. borrow( ) ) . call( ) } ) == 20 ) ) ;
@@ -121,23 +110,15 @@ fn main_0() -> i32 {
121110 assert ! ( ( ( { ( * h. borrow( ) ) . call( ) } ) == 11 ) ) ;
122111 let returned: Value < i32 > = Rc :: new ( RefCell :: new ( {
123112 ( {
124- {
125- # [ derive ( Record , ByteRepr ) ]
126- # [ byte_size ( 8 ) ]
127- struct Captures {
128- # [ offset ( 0 ) ]
129- # [ byte_size ( 8 ) ]
130- c : Counted ,
113+ lambda ! (
114+ {
115+ let c : Value < Counted > =
116+ Rc :: new ( RefCell :: new ( Counted :: copy_from ( { c . as_pointer ( ) } ) ) ) ;
117+ } ,
118+ || -> Counted {
119+ return Counted :: copy_from ( { self . c . as_pointer ( ) } ) ;
131120 }
132- FnPtr :: < fn ( ) -> Counted > :: with_captures (
133- Captures {
134- c : Counted :: copy_from ( { c. as_pointer ( ) } ) ,
135- } ,
136- ( |this : Ptr < Captures > | {
137- return Counted :: copy_from ( { field_ptr ! ( this, c) } ) ;
138- } ) ,
139- )
140- }
121+ )
141122 . call ( )
142123 } )
143124 . copies
@@ -146,57 +127,40 @@ fn main_0() -> i32 {
146127 let arr: Value < Box < [ Counted ] > > = Rc :: new ( RefCell :: new ( Box :: new (
147128 std:: array:: from_fn :: < _ , 2 , _ > ( |_| Counted :: new ( ) ) ,
148129 ) ) ) ;
149- let a: Value < FnPtr < fn ( ) -> i32 > > = Rc :: new ( RefCell :: new ( {
150- #[ derive( Record , ByteRepr ) ]
151- #[ byte_size( 16 ) ]
152- struct Captures {
153- #[ offset( 0 ) ]
154- #[ byte_size( 16 ) ]
155- arr : Value < Box < [ Counted ] > > ,
130+ let a: Value < FnPtr < fn ( ) -> i32 > > = Rc :: new ( RefCell :: new ( lambda ! (
131+ {
132+ let arr: Value <Box <[ Counted ] >> = Rc :: new( RefCell :: new( Box :: new(
133+ std:: array:: from_fn:: <_, 2 , _>( |__i: usize | {
134+ Counted :: copy_from( { ( arr. as_pointer( ) as Ptr <Counted >) . offset( __i) } )
135+ } ) ,
136+ ) ) ) ;
137+ } ,
138+ || -> i32 {
139+ return ( { ( * self . arr. borrow( ) ) [ ( 0 ) as usize ] . copies } + {
140+ ( * self . arr. borrow( ) ) [ ( 1 ) as usize ] . copies
141+ } ) ;
156142 }
157- FnPtr :: < fn ( ) -> i32 > :: with_captures (
158- Captures {
159- arr : Rc :: new ( RefCell :: new ( Box :: new ( std:: array:: from_fn :: < _ , 2 , _ > (
160- |__i : usize | {
161- Counted :: copy_from ( { ( arr. as_pointer ( ) as Ptr < Counted > ) . offset ( __i) } )
162- } ,
163- ) ) ) ) ,
164- } ,
165- ( |this : Ptr < Captures > | {
166- return ( { ( * this. with ( |__s| __s. arr . clone ( ) ) . borrow ( ) ) [ ( 0 ) as usize ] . copies } + {
167- ( * this. with ( |__s| __s. arr . clone ( ) ) . borrow ( ) ) [ ( 1 ) as usize ] . copies
168- } ) ;
169- } ) ,
170- )
171- } ) ) ;
143+ ) ) ) ;
172144 assert ! ( ( ( { ( * a. borrow( ) ) . call( ) } ) == 2 ) ) ;
173145 let a2: Value < FnPtr < fn ( ) -> i32 > > = Rc :: new ( RefCell :: new ( ( * a. borrow ( ) ) . clone ( ) ) ) ;
174146 assert ! ( ( ( { ( * a2. borrow( ) ) . call( ) } ) == 4 ) ) ;
175147 {
176- let m: Value < FnPtr < fn ( ) > > = Rc :: new ( RefCell :: new ( {
177- #[ derive( Record , ByteRepr ) ]
178- #[ byte_size( 1 ) ]
179- struct Captures {
180- #[ offset( 0 ) ]
181- #[ byte_size( 1 ) ]
182- d : Dropped ,
183- }
184- FnPtr :: < fn ( ) > :: with_captures ( Captures { d : Dropped :: new ( ) } , ( |this : Ptr < Captures > | { } ) )
185- } ) ) ;
148+ let m: Value < FnPtr < fn ( ) > > = Rc :: new ( RefCell :: new ( lambda ! (
149+ {
150+ let d: Value <Dropped > = Rc :: new( RefCell :: new( Dropped :: new( ) ) ) ;
151+ } ,
152+ || { }
153+ ) ) ) ;
186154 let m2: Value < FnPtr < fn ( ) > > = Rc :: new ( RefCell :: new ( ( * m. borrow_mut ( ) ) . clone ( ) ) ) ;
187155 }
188156 assert ! ( ( drops_0. with( |rc| * rc. borrow( ) ) == 2 ) ) ;
189157 {
190- let k: Value < FnPtr < fn ( ) > > = Rc :: new ( RefCell :: new ( {
191- #[ derive( Record , ByteRepr ) ]
192- #[ byte_size( 1 ) ]
193- struct Captures {
194- #[ offset( 0 ) ]
195- #[ byte_size( 1 ) ]
196- d : Dropped ,
197- }
198- FnPtr :: < fn ( ) > :: with_captures ( Captures { d : Dropped :: new ( ) } , ( |this : Ptr < Captures > | { } ) )
199- } ) ) ;
158+ let k: Value < FnPtr < fn ( ) > > = Rc :: new ( RefCell :: new ( lambda ! (
159+ {
160+ let d: Value <Dropped > = Rc :: new( RefCell :: new( Dropped :: new( ) ) ) ;
161+ } ,
162+ || { }
163+ ) ) ) ;
200164 let k2: Value < FnPtr < fn ( ) > > = Rc :: new ( RefCell :: new ( ( * k. borrow ( ) ) . clone ( ) ) ) ;
201165 }
202166 assert ! ( ( drops_0. with( |rc| * rc. borrow( ) ) == 4 ) ) ;
0 commit comments