@@ -5,12 +5,12 @@ use crate::bit_machine::{ExecutionError, SetTracker};
5
5
use crate :: dag:: { DagLike , InternalSharing , MaxSharing , PostOrderIterItem } ;
6
6
use crate :: jet:: Jet ;
7
7
use crate :: types:: { self , arrow:: FinalArrow } ;
8
- use crate :: { encode, BitMachine , WitnessNode } ;
8
+ use crate :: { encode, BitMachine } ;
9
9
use crate :: { Amr , BitIter , BitWriter , Cmr , Error , FirstPassImr , Imr , Value } ;
10
10
11
11
use super :: {
12
- Commit , CommitData , CommitNode , Construct , ConstructNode , Constructible , Converter , Hide ,
13
- Inner , Marker , NoDisconnect , NoWitness , Node , Witness , WitnessData ,
12
+ Commit , CommitData , CommitNode , Construct , ConstructData , ConstructNode , Constructible ,
13
+ Converter , Hide , Inner , Marker , NoDisconnect , NoWitness , Node ,
14
14
} ;
15
15
16
16
use std:: collections:: HashSet ;
@@ -221,15 +221,15 @@ impl<J: Jet> RedeemNode<J> {
221
221
self . convert :: < MaxSharing < Redeem < J > > , _ , _ > ( & mut Unfinalizer ( PhantomData ) )
222
222
}
223
223
224
- /// Convert a [`RedeemNode`] back into a [`WitnessNode `]
224
+ /// Convert a [`RedeemNode`] back into a [`ConstructNode `]
225
225
/// by loosening the finalized types, witness data and disconnected branches.
226
- pub fn to_witness_node ( & self ) -> Arc < WitnessNode < J > > {
227
- struct ToWitness < J > {
226
+ pub fn to_construct_node ( & self ) -> Arc < ConstructNode < J > > {
227
+ struct ToConstruct < J > {
228
228
inference_context : types:: Context ,
229
229
phantom : PhantomData < J > ,
230
230
}
231
231
232
- impl < J : Jet > Converter < Redeem < J > , Witness < J > > for ToWitness < J > {
232
+ impl < J : Jet > Converter < Redeem < J > , Construct < J > > for ToConstruct < J > {
233
233
type Error = ( ) ;
234
234
235
235
fn convert_witness (
@@ -243,31 +243,31 @@ impl<J: Jet> RedeemNode<J> {
243
243
fn convert_disconnect (
244
244
& mut self ,
245
245
_: & PostOrderIterItem < & Node < Redeem < J > > > ,
246
- right : Option < & Arc < Node < Witness < J > > > > ,
246
+ right : Option < & Arc < Node < Construct < J > > > > ,
247
247
_: & Arc < RedeemNode < J > > ,
248
- ) -> Result < Option < Arc < Node < Witness < J > > > > , Self :: Error > {
248
+ ) -> Result < Option < Arc < Node < Construct < J > > > > , Self :: Error > {
249
249
Ok ( right. cloned ( ) )
250
250
}
251
251
252
252
fn convert_data (
253
253
& mut self ,
254
254
_: & PostOrderIterItem < & Node < Redeem < J > > > ,
255
255
inner : Inner <
256
- & Arc < Node < Witness < J > > > ,
256
+ & Arc < Node < Construct < J > > > ,
257
257
J ,
258
- & Option < Arc < WitnessNode < J > > > ,
258
+ & Option < Arc < ConstructNode < J > > > ,
259
259
& Option < Value > ,
260
260
> ,
261
- ) -> Result < WitnessData < J > , Self :: Error > {
261
+ ) -> Result < ConstructData < J > , Self :: Error > {
262
262
let inner = inner
263
263
. map ( |node| node. cached_data ( ) )
264
264
. map_witness ( |maybe_value| maybe_value. clone ( ) ) ;
265
- Ok ( WitnessData :: from_inner ( & self . inference_context , inner)
265
+ Ok ( ConstructData :: from_inner ( & self . inference_context , inner)
266
266
. expect ( "types were already finalized" ) )
267
267
}
268
268
}
269
269
270
- self . convert :: < InternalSharing , _ , _ > ( & mut ToWitness {
270
+ self . convert :: < InternalSharing , _ , _ > ( & mut ToConstruct {
271
271
inference_context : types:: Context :: new ( ) ,
272
272
phantom : PhantomData ,
273
273
} )
@@ -297,7 +297,7 @@ impl<J: Jet> RedeemNode<J> {
297
297
phantom : PhantomData < J > ,
298
298
}
299
299
300
- impl < J : Jet > Converter < Redeem < J > , Witness < J > > for Pruner < J > {
300
+ impl < J : Jet > Converter < Redeem < J > , Construct < J > > for Pruner < J > {
301
301
type Error = std:: convert:: Infallible ;
302
302
303
303
fn convert_witness (
@@ -313,9 +313,9 @@ impl<J: Jet> RedeemNode<J> {
313
313
fn convert_disconnect (
314
314
& mut self ,
315
315
_: & PostOrderIterItem < & RedeemNode < J > > ,
316
- right : Option < & Arc < WitnessNode < J > > > ,
316
+ right : Option < & Arc < ConstructNode < J > > > ,
317
317
_: & Arc < RedeemNode < J > > ,
318
- ) -> Result < Option < Arc < WitnessNode < J > > > , Self :: Error > {
318
+ ) -> Result < Option < Arc < ConstructNode < J > > > , Self :: Error > {
319
319
debug_assert ! (
320
320
right. is_some( ) ,
321
321
"disconnected branch should exist in unpruned redeem program"
@@ -326,8 +326,8 @@ impl<J: Jet> RedeemNode<J> {
326
326
fn prune_case (
327
327
& mut self ,
328
328
data : & PostOrderIterItem < & RedeemNode < J > > ,
329
- _left : & Arc < WitnessNode < J > > ,
330
- _right : & Arc < WitnessNode < J > > ,
329
+ _left : & Arc < ConstructNode < J > > ,
330
+ _right : & Arc < ConstructNode < J > > ,
331
331
) -> Result < Hide , Self :: Error > {
332
332
// The IMR of the pruned program may change,
333
333
// but the Converter trait gives us access to the unpruned node (`data`).
@@ -346,25 +346,30 @@ impl<J: Jet> RedeemNode<J> {
346
346
fn convert_data (
347
347
& mut self ,
348
348
_: & PostOrderIterItem < & RedeemNode < J > > ,
349
- inner : Inner < & Arc < WitnessNode < J > > , J , & Option < Arc < WitnessNode < J > > > , & Option < Value > > ,
350
- ) -> Result < WitnessData < J > , Self :: Error > {
349
+ inner : Inner <
350
+ & Arc < ConstructNode < J > > ,
351
+ J ,
352
+ & Option < Arc < ConstructNode < J > > > ,
353
+ & Option < Value > ,
354
+ > ,
355
+ ) -> Result < ConstructData < J > , Self :: Error > {
351
356
let converted_inner = inner
352
357
. map ( |node| node. cached_data ( ) )
353
358
. map_witness ( Option :: < Value > :: clone) ;
354
- let retyped = WitnessData :: from_inner ( & self . inference_context , converted_inner)
359
+ let retyped = ConstructData :: from_inner ( & self . inference_context , converted_inner)
355
360
. expect ( "pruned types should check out if unpruned types check out" ) ;
356
361
Ok ( retyped)
357
362
}
358
363
}
359
364
360
365
struct Finalizer < J > ( PhantomData < J > ) ;
361
366
362
- impl < J : Jet > Converter < Witness < J > , Redeem < J > > for Finalizer < J > {
367
+ impl < J : Jet > Converter < Construct < J > , Redeem < J > > for Finalizer < J > {
363
368
type Error = std:: convert:: Infallible ;
364
369
365
370
fn convert_witness (
366
371
& mut self ,
367
- data : & PostOrderIterItem < & WitnessNode < J > > ,
372
+ data : & PostOrderIterItem < & ConstructNode < J > > ,
368
373
witness : & Option < Value > ,
369
374
) -> Result < Value , Self :: Error > {
370
375
let pruned_target_ty = data
@@ -383,9 +388,9 @@ impl<J: Jet> RedeemNode<J> {
383
388
384
389
fn convert_disconnect (
385
390
& mut self ,
386
- _: & PostOrderIterItem < & WitnessNode < J > > ,
391
+ _: & PostOrderIterItem < & ConstructNode < J > > ,
387
392
right : Option < & Arc < RedeemNode < J > > > ,
388
- _: & Option < Arc < WitnessNode < J > > > ,
393
+ _: & Option < Arc < ConstructNode < J > > > ,
389
394
) -> Result < Arc < RedeemNode < J > > , Self :: Error > {
390
395
Ok ( right
391
396
. map ( Arc :: clone)
@@ -394,7 +399,7 @@ impl<J: Jet> RedeemNode<J> {
394
399
395
400
fn convert_data (
396
401
& mut self ,
397
- data : & PostOrderIterItem < & WitnessNode < J > > ,
402
+ data : & PostOrderIterItem < & ConstructNode < J > > ,
398
403
inner : Inner < & Arc < RedeemNode < J > > , J , & Arc < RedeemNode < J > > , & Value > ,
399
404
) -> Result < Arc < RedeemData < J > > , Self :: Error > {
400
405
// Finalize target types of witness nodes in advance so we can prune their values.
@@ -457,7 +462,7 @@ impl<J: Jet> RedeemNode<J> {
457
462
fn convert_witness (
458
463
& mut self ,
459
464
data : & PostOrderIterItem < & ConstructNode < J > > ,
460
- _: & NoWitness ,
465
+ _: & Option < Value > ,
461
466
) -> Result < Value , Self :: Error > {
462
467
let arrow = data. node . data . arrow ( ) ;
463
468
let target_ty = arrow. target . finalize ( ) ?;
0 commit comments