@@ -131,3 +131,73 @@ impl<J: Jet> ExecTracker<J> for NoTracker {
131131 }
132132 }
133133}
134+
135+ /// Tracker that just outputs all its activity to stderr.
136+ #[ derive( Clone , Debug , Default ) ]
137+ pub struct StderrTracker {
138+ exec_count : usize ,
139+ inner : SetTracker ,
140+ }
141+
142+ impl StderrTracker {
143+ /// Constructs a new empty [`StderrTracker`], ready for use.
144+ pub fn new ( ) -> Self {
145+ Self :: default ( )
146+ }
147+ }
148+
149+ impl < J : Jet > ExecTracker < J > for StderrTracker {
150+ fn visit_node ( & mut self , node : & RedeemNode < J > , input : super :: FrameIter , output : NodeOutput ) {
151+ let input_val = Value :: from_padded_bits ( & mut input. clone ( ) , & node. arrow ( ) . source )
152+ . expect ( "input from bit machine will always be well-formed" ) ;
153+ eprintln ! (
154+ "[{:4}] exec {:10} {}" ,
155+ self . exec_count,
156+ node. inner( ) ,
157+ node. arrow( )
158+ ) ;
159+ eprintln ! ( " input {input_val}" ) ;
160+ match output. clone ( ) {
161+ NodeOutput :: NonTerminal => { /* don't bother describing non-terminal output */ }
162+ NodeOutput :: JetFailed => eprintln ! ( " JET FAILED" ) ,
163+ NodeOutput :: Success ( mut output) => {
164+ let output_val = Value :: from_padded_bits ( & mut output, & node. arrow ( ) . target )
165+ . expect ( "input from bit machine will always be well-formed" ) ;
166+ eprintln ! ( " output {output_val}" ) ;
167+ }
168+ }
169+
170+ if let crate :: node:: Inner :: AssertL ( _, cmr) = node. inner ( ) {
171+ // SimplicityHL, when compiling in "debug mode", tags nodes by inserting
172+ // synthetic AssertL nodes where the "cmr" is actually a key into a lookup
173+ // table of debug information. An implementation of ExecTracker within
174+ // the compiler itself might do a lookup here to output more useful
175+ // information to the user.
176+ eprintln ! ( " [debug] assertL CMR {cmr}" ) ;
177+ }
178+
179+ ExecTracker :: < J > :: visit_node ( & mut self . inner , node, input, output) ;
180+ self . exec_count += 1 ;
181+ eprintln ! ( ) ;
182+ }
183+ }
184+
185+ impl < J : Jet > PruneTracker < J > for StderrTracker {
186+ fn contains_left ( & self , ihr : Ihr ) -> bool {
187+ if PruneTracker :: < J > :: contains_left ( & self . inner , ihr) {
188+ true
189+ } else {
190+ eprintln ! ( "Pruning unexecuted left child of IHR {ihr}" ) ;
191+ false
192+ }
193+ }
194+
195+ fn contains_right ( & self , ihr : Ihr ) -> bool {
196+ if PruneTracker :: < J > :: contains_right ( & self . inner , ihr) {
197+ true
198+ } else {
199+ eprintln ! ( "Pruning unexecuted right child of IHR {ihr}" ) ;
200+ false
201+ }
202+ }
203+ }
0 commit comments