pub trait VisitMut<T = ()> {
Show 31 methods
// Provided methods
fn visit_mut_module(&mut self, module: &mut Module) -> ControlFlow<T> { ... }
fn visit_mut_export(&mut self, export: &mut Export) -> ControlFlow<T> { ... }
fn visit_mut_procedure(
&mut self,
procedure: &mut Procedure,
) -> ControlFlow<T> { ... }
fn visit_mut_constant(&mut self, constant: &mut Constant) -> ControlFlow<T> { ... }
fn visit_mut_constant_expr(
&mut self,
expr: &mut ConstantExpr,
) -> ControlFlow<T> { ... }
fn visit_mut_constant_ref(
&mut self,
path: &mut Span<Arc<Path>>,
) -> ControlFlow<T> { ... }
fn visit_mut_type_decl(&mut self, ty: &mut TypeDecl) -> ControlFlow<T> { ... }
fn visit_mut_type_alias(&mut self, ty: &mut TypeAlias) -> ControlFlow<T> { ... }
fn visit_mut_type_expr(&mut self, ty: &mut TypeExpr) -> ControlFlow<T> { ... }
fn visit_mut_type_ref(
&mut self,
path: &mut Span<Arc<Path>>,
) -> ControlFlow<T> { ... }
fn visit_mut_enum(&mut self, ty: &mut EnumType) -> ControlFlow<T> { ... }
fn visit_mut_enum_variant(
&mut self,
variant: &mut Variant,
) -> ControlFlow<T> { ... }
fn visit_mut_alias(&mut self, alias: &mut Alias) -> ControlFlow<T> { ... }
fn visit_mut_block(&mut self, block: &mut Block) -> ControlFlow<T> { ... }
fn visit_mut_op(&mut self, op: &mut Op) -> ControlFlow<T> { ... }
fn visit_mut_inst(&mut self, inst: &mut Span<Instruction>) -> ControlFlow<T> { ... }
fn visit_mut_system_event(
&mut self,
sys_event: Span<&mut SystemEventNode>,
) -> ControlFlow<T> { ... }
fn visit_mut_debug_options(
&mut self,
options: Span<&mut DebugOptions>,
) -> ControlFlow<T> { ... }
fn visit_mut_exec(
&mut self,
target: &mut InvocationTarget,
) -> ControlFlow<T> { ... }
fn visit_mut_call(
&mut self,
target: &mut InvocationTarget,
) -> ControlFlow<T> { ... }
fn visit_mut_syscall(
&mut self,
target: &mut InvocationTarget,
) -> ControlFlow<T> { ... }
fn visit_mut_procref(
&mut self,
target: &mut InvocationTarget,
) -> ControlFlow<T> { ... }
fn visit_mut_invoke_target(
&mut self,
target: &mut InvocationTarget,
) -> ControlFlow<T> { ... }
fn visit_mut_alias_target(
&mut self,
target: &mut AliasTarget,
) -> ControlFlow<T> { ... }
fn visit_mut_immediate_u8(
&mut self,
imm: &mut Immediate<u8>,
) -> ControlFlow<T> { ... }
fn visit_mut_immediate_u16(
&mut self,
imm: &mut Immediate<u16>,
) -> ControlFlow<T> { ... }
fn visit_mut_immediate_u32(
&mut self,
imm: &mut Immediate<u32>,
) -> ControlFlow<T> { ... }
fn visit_mut_immediate_felt(
&mut self,
imm: &mut Immediate<Felt>,
) -> ControlFlow<T> { ... }
fn visit_mut_immediate_word_value(
&mut self,
imm: &mut Immediate<WordValue>,
) -> ControlFlow<T> { ... }
fn visit_mut_immediate_push_value(
&mut self,
imm: &mut Immediate<PushValue>,
) -> ControlFlow<T> { ... }
fn visit_mut_immediate_error_message(
&mut self,
code: &mut ErrorMsg,
) -> ControlFlow<T> { ... }
}Expand description
Represents a mutable AST visitor, whose “early return” type is T (by default ()).
Mutable visitors are primarily used to perform rewrites of the AST, either for desugaring purposes, optimization purposes, or to iteratively flesh out details in the AST as more information is discovered during compilation (such as the absolute path to a procedure that is imported from another module).
Unless explicitly overridden, all methods of this trait will perform a default depth-first
traversal of the AST. When a node is overridden, you must ensure that the corresponding free
function in this module is called at an appropriate point if you wish to visit all of the
children of that node. For example, if visiting procedures, you must call
visit::visit_mut_procedure either before you do your analysis for that procedure, or after,
corresponding to whether you are rewriting top-down, or bottom-up. If you do not do this, none
of the children of the Procedure node will be visited. This is perfectly valid! Sometimes you
only need to rewrite specific nodes that cannot appear further down the tree, in which case you
do not need to visit any of the children. It is just important to be aware that this is one of
the elements placed in the hands of the visitor implementation.
The methods of this trait all return core::ops::ControlFlow, which can be used to break out
of the traversal early via ControlFlow::Break. The T type parameter of this trait controls
what the value associated with an early return will be. In most cases, the default of () is
all you need - but in some cases it can be useful to return an error or other value, that
indicates why the traversal ended early.