pub struct TreeLoop {
pub inputargs: Vec<InputArg>,
pub ops: Vec<Op>,
pub snapshots: Vec<Snapshot>,
}Expand description
A completed trace ready for optimization and compilation.
Fields§
§inputargs: Vec<InputArg>Input arguments to the trace (loop header variables).
ops: Vec<Op>The recorded operations, in execution order.
snapshots: Vec<Snapshot>opencoder.py parity: per-guard snapshots captured during tracing.
Indexed by the guard op’s rd_resume_position.
Implementations§
Source§impl TreeLoop
impl TreeLoop
Sourcepub fn new(inputargs: Vec<InputArg>, ops: Vec<Op>) -> Self
pub fn new(inputargs: Vec<InputArg>, ops: Vec<Op>) -> Self
Create a new trace from input arguments and operations.
Sourcepub fn with_snapshots(
inputargs: Vec<InputArg>,
ops: Vec<Op>,
snapshots: Vec<Snapshot>,
) -> Self
pub fn with_snapshots( inputargs: Vec<InputArg>, ops: Vec<Op>, snapshots: Vec<Snapshot>, ) -> Self
Create a new trace with snapshots.
Sourcepub fn num_inputargs(&self) -> usize
pub fn num_inputargs(&self) -> usize
Number of input arguments.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether this trace ends with FINISH.
Sourcepub fn get_op(&self, opref: OpRef) -> Option<&Op>
pub fn get_op(&self, opref: OpRef) -> Option<&Op>
Get a reference to the operation at the given OpRef index.
Sourcepub fn iter_guards(&self) -> impl Iterator<Item = &Op>
pub fn iter_guards(&self) -> impl Iterator<Item = &Op>
Iterate over all guard operations.
Sourcepub fn num_guards(&self) -> usize
pub fn num_guards(&self) -> usize
Number of guard operations.
Sourcepub fn get_final_op(&self) -> Option<&Op>
pub fn get_final_op(&self) -> Option<&Op>
Get the final operation (Jump or Finish).
Sourcepub fn find_label(&self) -> Option<usize>
pub fn find_label(&self) -> Option<usize>
Get the Label position (if this is a peeled loop).
Sourcepub fn split_at_label(&self) -> (&[Op], &[Op])
pub fn split_at_label(&self) -> (&[Op], &[Op])
Split at Label: returns (preamble_ops, body_ops). If no Label, returns (all_ops, empty).
Sourcepub fn inputarg_types(&self) -> Vec<Type>
pub fn inputarg_types(&self) -> Vec<Type>
Get the input arg types.
Sourcepub fn get_iter(&self) -> TraceIterator<'_>
pub fn get_iter(&self) -> TraceIterator<'_>
Create a trace iterator for this trace.
Sourcepub fn check_consistency(&self) -> bool
pub fn check_consistency(&self) -> bool
history.py: check_consistency() Verify that the trace structure is valid.
Sourcepub fn free_vars(&self) -> Vec<OpRef>
pub fn free_vars(&self) -> Vec<OpRef>
Get all OpRefs used as arguments but not defined by any op. These are the “free variables” — inputs from outside the trace.
Sourcepub fn count_by_category(&self) -> (usize, usize, usize, usize)
pub fn count_by_category(&self) -> (usize, usize, usize, usize)
Count operations by opcode category.
Sourcepub fn cut_trace_from(
&self,
start: TracePosition,
original_boxes: &[OpRef],
original_box_types: &[Type],
) -> TreeLoop
pub fn cut_trace_from( &self, start: TracePosition, original_boxes: &[OpRef], original_box_types: &[Type], ) -> TreeLoop
opencoder.py CutTrace parity — create a new trace by cutting at the
given position. original_boxes become the new inputargs; any OpRef
referenced after the cut but defined before it (and not in
original_boxes) is re-emitted as a prefix operation (transitive
closure of dependencies).