Fork of daniellemaywood.uk/gleam — Wasm codegen work
48 kB
1756 lines
1//! AST traversal routines, referenced from [`syn::visit`](https://docs.rs/syn/latest/syn/visit/index.html)
2//!
3//! Each method of the [`Visit`] trait can be overriden to customize the
4//! behaviour when visiting the corresponding type of AST node. By default,
5//! every method recursively visits the substructure of the node by using the
6//! right visitor method.
7//!
8//! # Example
9//!
10//! Suppose we would like to collect all function names in a module,
11//! we can do the following:
12//!
13//! ```no_run
14//! use gleam_core::ast::{TypedFunction, visit::{self, Visit}};
15//!
16//! struct FnCollector<'ast> {
17//! functions: Vec<&'ast TypedFunction>
18//! }
19//!
20//! impl<'ast> Visit<'ast> for FnCollector<'ast> {
21//! fn visit_typed_function(&mut self, fun: &'ast TypedFunction) {
22//! self.functions.push(fun);
23//!
24//! // Use the default behaviour to visit any nested functions
25//! visit::visit_typed_function(self, fun);
26//! }
27//! }
28//!
29//! fn print_all_module_functions() {
30//! let module = todo!("module");
31//! let mut fn_collector = FnCollector { functions: vec![] };
32//!
33//! // This will walk the AST and collect all functions
34//! fn_collector.visit_typed_module(module);
35//!
36//! // Print the collected functions
37//! println!("{:#?}", fn_collector.functions);
38//! }
39//! ```
40
41use crate::{
42 analyse::Inferred,
43 exhaustiveness::CompiledCase,
44 type_::{
45 ModuleValueConstructor, PatternConstructor, TypedCallArg, ValueConstructor,
46 error::VariableOrigin,
47 },
48};
49use std::sync::Arc;
50
51use ecow::EcoString;
52use vec1::Vec1;
53
54use crate::type_::Type;
55
56use super::{
57 AssignName, BinOp, BitArrayOption, CallArg, Definition, Pattern, PipelineAssignmentKind,
58 SrcSpan, Statement, TodoKind, TypeAst, TypedArg, TypedAssert, TypedAssignment, TypedClause,
59 TypedClauseGuard, TypedConstant, TypedCustomType, TypedDefinition, TypedExpr,
60 TypedExprBitArraySegment, TypedFunction, TypedModule, TypedModuleConstant, TypedPattern,
61 TypedPatternBitArraySegment, TypedPipelineAssignment, TypedStatement, TypedUse,
62 untyped::FunctionLiteralKind,
63};
64
65pub trait Visit<'ast> {
66 fn visit_typed_module(&mut self, module: &'ast TypedModule) {
67 visit_typed_module(self, module);
68 }
69
70 fn visit_typed_definition(&mut self, def: &'ast TypedDefinition) {
71 visit_typed_definition(self, def);
72 }
73
74 fn visit_typed_function(&mut self, fun: &'ast TypedFunction) {
75 visit_typed_function(self, fun);
76 }
77
78 fn visit_typed_module_constant(&mut self, constant: &'ast TypedModuleConstant) {
79 visit_typed_module_constant(self, constant);
80 }
81
82 fn visit_typed_custom_type(&mut self, custom_type: &'ast TypedCustomType) {
83 visit_typed_custom_type(self, custom_type);
84 }
85
86 fn visit_typed_expr(&mut self, expr: &'ast TypedExpr) {
87 visit_typed_expr(self, expr);
88 }
89
90 fn visit_typed_expr_echo(
91 &mut self,
92 location: &'ast SrcSpan,
93 type_: &'ast Arc<Type>,
94 expression: &'ast Option<Box<TypedExpr>>,
95 message: &'ast Option<Box<TypedExpr>>,
96 ) {
97 visit_typed_expr_echo(self, location, type_, expression, message);
98 }
99
100 fn visit_typed_expr_int(
101 &mut self,
102 location: &'ast SrcSpan,
103 type_: &'ast Arc<Type>,
104 value: &'ast EcoString,
105 ) {
106 visit_typed_expr_int(self, location, type_, value);
107 }
108
109 fn visit_typed_expr_float(
110 &mut self,
111 location: &'ast SrcSpan,
112 type_: &'ast Arc<Type>,
113 value: &'ast EcoString,
114 ) {
115 visit_typed_expr_float(self, location, type_, value);
116 }
117
118 fn visit_typed_expr_string(
119 &mut self,
120 location: &'ast SrcSpan,
121 type_: &'ast Arc<Type>,
122 value: &'ast EcoString,
123 ) {
124 visit_typed_expr_string(self, location, type_, value);
125 }
126
127 fn visit_typed_expr_block(
128 &mut self,
129 location: &'ast SrcSpan,
130 statements: &'ast [TypedStatement],
131 ) {
132 visit_typed_expr_block(self, location, statements);
133 }
134
135 fn visit_typed_expr_pipeline(
136 &mut self,
137 location: &'ast SrcSpan,
138 first_value: &'ast TypedPipelineAssignment,
139 assignments: &'ast [(TypedPipelineAssignment, PipelineAssignmentKind)],
140 finally: &'ast TypedExpr,
141 finally_kind: &'ast PipelineAssignmentKind,
142 ) {
143 visit_typed_expr_pipeline(
144 self,
145 location,
146 first_value,
147 assignments,
148 finally,
149 finally_kind,
150 );
151 }
152
153 fn visit_typed_expr_var(
154 &mut self,
155 location: &'ast SrcSpan,
156 constructor: &'ast ValueConstructor,
157 name: &'ast EcoString,
158 ) {
159 visit_typed_expr_var(self, location, constructor, name);
160 }
161
162 fn visit_typed_expr_fn(
163 &mut self,
164 location: &'ast SrcSpan,
165 type_: &'ast Arc<Type>,
166 kind: &'ast FunctionLiteralKind,
167 args: &'ast [TypedArg],
168 body: &'ast Vec1<TypedStatement>,
169 return_annotation: &'ast Option<TypeAst>,
170 ) {
171 visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation);
172 }
173
174 fn visit_typed_expr_list(
175 &mut self,
176 location: &'ast SrcSpan,
177 type_: &'ast Arc<Type>,
178 elements: &'ast [TypedExpr],
179 tail: &'ast Option<Box<TypedExpr>>,
180 ) {
181 visit_typed_expr_list(self, location, type_, elements, tail);
182 }
183
184 fn visit_typed_expr_call(
185 &mut self,
186 location: &'ast SrcSpan,
187 type_: &'ast Arc<Type>,
188 fun: &'ast TypedExpr,
189 args: &'ast [TypedCallArg],
190 ) {
191 visit_typed_expr_call(self, location, type_, fun, args);
192 }
193
194 fn visit_typed_expr_bin_op(
195 &mut self,
196 location: &'ast SrcSpan,
197 type_: &'ast Arc<Type>,
198 name: &'ast BinOp,
199 name_location: &'ast SrcSpan,
200 left: &'ast TypedExpr,
201 right: &'ast TypedExpr,
202 ) {
203 visit_typed_expr_bin_op(self, location, type_, name, name_location, left, right);
204 }
205
206 fn visit_typed_expr_case(
207 &mut self,
208 location: &'ast SrcSpan,
209 type_: &'ast Arc<Type>,
210 subjects: &'ast [TypedExpr],
211 clauses: &'ast [TypedClause],
212 compiled_case: &'ast CompiledCase,
213 ) {
214 visit_typed_expr_case(self, location, type_, subjects, clauses, compiled_case);
215 }
216
217 fn visit_typed_expr_record_access(
218 &mut self,
219 location: &'ast SrcSpan,
220 field_start: &'ast u32,
221 type_: &'ast Arc<Type>,
222 label: &'ast EcoString,
223 index: &'ast u64,
224 record: &'ast TypedExpr,
225 ) {
226 visit_typed_expr_record_access(self, location, field_start, type_, label, index, record);
227 }
228
229 #[allow(clippy::too_many_arguments)]
230 fn visit_typed_expr_module_select(
231 &mut self,
232 location: &'ast SrcSpan,
233 field_start: &'ast u32,
234 type_: &'ast Arc<Type>,
235 label: &'ast EcoString,
236 module_name: &'ast EcoString,
237 module_alias: &'ast EcoString,
238 constructor: &'ast ModuleValueConstructor,
239 ) {
240 visit_typed_expr_module_select(
241 self,
242 location,
243 field_start,
244 type_,
245 label,
246 module_name,
247 module_alias,
248 constructor,
249 );
250 }
251
252 fn visit_typed_expr_tuple(
253 &mut self,
254 location: &'ast SrcSpan,
255 type_: &'ast Arc<Type>,
256 elements: &'ast [TypedExpr],
257 ) {
258 visit_typed_expr_tuple(self, location, type_, elements);
259 }
260
261 fn visit_typed_expr_tuple_index(
262 &mut self,
263 location: &'ast SrcSpan,
264 type_: &'ast Arc<Type>,
265 index: &'ast u64,
266 tuple: &'ast TypedExpr,
267 ) {
268 visit_typed_expr_tuple_index(self, location, type_, index, tuple);
269 }
270
271 fn visit_typed_expr_todo(
272 &mut self,
273 location: &'ast SrcSpan,
274 message: &'ast Option<Box<TypedExpr>>,
275 kind: &'ast TodoKind,
276 type_: &'ast Arc<Type>,
277 ) {
278 visit_typed_expr_todo(self, location, message, kind, type_);
279 }
280
281 fn visit_typed_expr_panic(
282 &mut self,
283 location: &'ast SrcSpan,
284 message: &'ast Option<Box<TypedExpr>>,
285 type_: &'ast Arc<Type>,
286 ) {
287 visit_typed_expr_panic(self, location, message, type_);
288 }
289
290 fn visit_typed_expr_bit_array(
291 &mut self,
292 location: &'ast SrcSpan,
293 type_: &'ast Arc<Type>,
294 segments: &'ast [TypedExprBitArraySegment],
295 ) {
296 visit_typed_expr_bit_array(self, location, type_, segments);
297 }
298
299 fn visit_typed_expr_record_update(
300 &mut self,
301 location: &'ast SrcSpan,
302 type_: &'ast Arc<Type>,
303 record: &'ast Option<Box<TypedAssignment>>,
304 constructor: &'ast TypedExpr,
305 args: &'ast [TypedCallArg],
306 ) {
307 visit_typed_expr_record_update(self, location, type_, record, constructor, args);
308 }
309
310 fn visit_typed_expr_negate_bool(&mut self, location: &'ast SrcSpan, value: &'ast TypedExpr) {
311 visit_typed_expr_negate_bool(self, location, value);
312 }
313
314 fn visit_typed_expr_negate_int(&mut self, location: &'ast SrcSpan, value: &'ast TypedExpr) {
315 visit_typed_expr_negate_int(self, location, value)
316 }
317
318 fn visit_typed_expr_invalid(&mut self, location: &'ast SrcSpan, type_: &'ast Arc<Type>) {
319 visit_typed_expr_invalid(self, location, type_);
320 }
321
322 fn visit_typed_statement(&mut self, stmt: &'ast TypedStatement) {
323 visit_typed_statement(self, stmt);
324 }
325
326 fn visit_typed_assignment(&mut self, assignment: &'ast TypedAssignment) {
327 visit_typed_assignment(self, assignment);
328 }
329
330 fn visit_typed_use(&mut self, use_: &'ast TypedUse) {
331 visit_typed_use(self, use_);
332 }
333
334 fn visit_typed_assert(&mut self, assert: &'ast TypedAssert) {
335 visit_typed_assert(self, assert);
336 }
337
338 fn visit_typed_pipeline_assignment(&mut self, assignment: &'ast TypedPipelineAssignment) {
339 visit_typed_pipeline_assignment(self, assignment);
340 }
341
342 fn visit_typed_call_arg(&mut self, arg: &'ast TypedCallArg) {
343 visit_typed_call_arg(self, arg);
344 }
345
346 fn visit_typed_clause(&mut self, clause: &'ast TypedClause) {
347 visit_typed_clause(self, clause);
348 }
349
350 fn visit_typed_clause_guard(&mut self, guard: &'ast TypedClauseGuard) {
351 visit_typed_clause_guard(self, guard);
352 }
353
354 fn visit_typed_clause_guard_var(
355 &mut self,
356 location: &'ast SrcSpan,
357 name: &'ast EcoString,
358 type_: &'ast Arc<Type>,
359 definition_location: &'ast SrcSpan,
360 ) {
361 visit_typed_clause_guard_var(self, location, name, type_, definition_location);
362 }
363
364 fn visit_typed_clause_guard_tuple_index(
365 &mut self,
366 location: &'ast SrcSpan,
367 index: &'ast u64,
368 type_: &'ast Arc<Type>,
369 tuple: &'ast TypedClauseGuard,
370 ) {
371 visit_typed_clause_guard_tuple_index(self, location, index, type_, tuple)
372 }
373
374 fn visit_typed_clause_guard_field_access(
375 &mut self,
376 location: &'ast SrcSpan,
377 index: &'ast Option<u64>,
378 label: &'ast EcoString,
379 type_: &'ast Arc<Type>,
380 container: &'ast TypedClauseGuard,
381 ) {
382 visit_typed_clause_guard_field_access(self, location, index, label, type_, container)
383 }
384
385 fn visit_typed_clause_guard_module_select(
386 &mut self,
387 location: &'ast SrcSpan,
388 type_: &'ast Arc<Type>,
389 label: &'ast EcoString,
390 module_name: &'ast EcoString,
391 module_alias: &'ast EcoString,
392 literal: &'ast TypedConstant,
393 ) {
394 visit_typed_clause_guard_module_select(
395 self,
396 location,
397 type_,
398 label,
399 module_name,
400 module_alias,
401 literal,
402 )
403 }
404
405 fn visit_typed_expr_bit_array_segment(&mut self, segment: &'ast TypedExprBitArraySegment) {
406 visit_typed_expr_bit_array_segment(self, segment);
407 }
408
409 fn visit_typed_bit_array_option(&mut self, option: &'ast BitArrayOption<TypedExpr>) {
410 visit_typed_bit_array_option(self, option);
411 }
412
413 fn visit_typed_pattern(&mut self, pattern: &'ast TypedPattern) {
414 visit_typed_pattern(self, pattern);
415 }
416
417 fn visit_typed_pattern_int(&mut self, location: &'ast SrcSpan, value: &'ast EcoString) {
418 visit_typed_pattern_int(self, location, value);
419 }
420
421 fn visit_typed_pattern_float(&mut self, location: &'ast SrcSpan, value: &'ast EcoString) {
422 visit_typed_pattern_float(self, location, value);
423 }
424
425 fn visit_typed_pattern_string(&mut self, location: &'ast SrcSpan, value: &'ast EcoString) {
426 visit_typed_pattern_string(self, location, value);
427 }
428
429 fn visit_typed_pattern_variable(
430 &mut self,
431 location: &'ast SrcSpan,
432 name: &'ast EcoString,
433 type_: &'ast Arc<Type>,
434 origin: &'ast VariableOrigin,
435 ) {
436 visit_typed_pattern_variable(self, location, name, type_, origin);
437 }
438
439 fn visit_typed_pattern_var_usage(
440 &mut self,
441 location: &'ast SrcSpan,
442 name: &'ast EcoString,
443 constructor: &'ast Option<ValueConstructor>,
444 type_: &'ast Arc<Type>,
445 ) {
446 visit_typed_pattern_var_usage(self, location, name, constructor, type_);
447 }
448
449 fn visit_typed_pattern_assign(
450 &mut self,
451 location: &'ast SrcSpan,
452 name: &'ast EcoString,
453 pattern: &'ast TypedPattern,
454 ) {
455 visit_typed_pattern_assign(self, location, name, pattern);
456 }
457
458 fn visit_typed_pattern_discard(
459 &mut self,
460 location: &'ast SrcSpan,
461 name: &'ast EcoString,
462 type_: &'ast Arc<Type>,
463 ) {
464 visit_typed_pattern_discard(self, location, name, type_)
465 }
466
467 fn visit_typed_pattern_list(
468 &mut self,
469 location: &'ast SrcSpan,
470 elements: &'ast Vec<TypedPattern>,
471 tail: &'ast Option<Box<TypedPattern>>,
472 type_: &'ast Arc<Type>,
473 ) {
474 visit_typed_pattern_list(self, location, elements, tail, type_);
475 }
476
477 #[allow(clippy::too_many_arguments)]
478 fn visit_typed_pattern_constructor(
479 &mut self,
480 location: &'ast SrcSpan,
481 name_location: &'ast SrcSpan,
482 name: &'ast EcoString,
483 arguments: &'ast Vec<CallArg<TypedPattern>>,
484 module: &'ast Option<(EcoString, SrcSpan)>,
485 constructor: &'ast Inferred<PatternConstructor>,
486 spread: &'ast Option<SrcSpan>,
487 type_: &'ast Arc<Type>,
488 ) {
489 visit_typed_pattern_constructor(
490 self,
491 location,
492 name_location,
493 name,
494 arguments,
495 module,
496 constructor,
497 spread,
498 type_,
499 );
500 }
501
502 fn visit_typed_pattern_call_arg(&mut self, arg: &'ast CallArg<TypedPattern>) {
503 visit_typed_pattern_call_arg(self, arg);
504 }
505
506 fn visit_typed_pattern_tuple(
507 &mut self,
508 location: &'ast SrcSpan,
509 elements: &'ast Vec<TypedPattern>,
510 ) {
511 visit_typed_pattern_tuple(self, location, elements);
512 }
513
514 fn visit_typed_pattern_bit_array(
515 &mut self,
516 location: &'ast SrcSpan,
517 segments: &'ast Vec<TypedPatternBitArraySegment>,
518 ) {
519 visit_typed_pattern_bit_array(self, location, segments);
520 }
521
522 fn visit_typed_pattern_bit_array_option(&mut self, option: &'ast BitArrayOption<TypedPattern>) {
523 visit_typed_pattern_bit_array_option(self, option);
524 }
525
526 fn visit_typed_pattern_string_prefix(
527 &mut self,
528 location: &'ast SrcSpan,
529 left_location: &'ast SrcSpan,
530 left_side_assignment: &'ast Option<(EcoString, SrcSpan)>,
531 right_location: &'ast SrcSpan,
532 left_side_string: &'ast EcoString,
533 right_side_assignment: &'ast AssignName,
534 ) {
535 visit_typed_pattern_string_prefix(
536 self,
537 location,
538 left_location,
539 left_side_assignment,
540 right_location,
541 left_side_string,
542 right_side_assignment,
543 );
544 }
545
546 fn visit_typed_pattern_invalid(&mut self, location: &'ast SrcSpan, type_: &'ast Arc<Type>) {
547 visit_typed_pattern_invalid(self, location, type_);
548 }
549
550 fn visit_type_ast(&mut self, node: &'ast TypeAst) {
551 visit_type_ast(self, node);
552 }
553
554 fn visit_type_ast_constructor(
555 &mut self,
556 location: &'ast SrcSpan,
557 name_location: &'ast SrcSpan,
558 module: &'ast Option<(EcoString, SrcSpan)>,
559 name: &'ast EcoString,
560 arguments: &'ast Vec<TypeAst>,
561 ) {
562 visit_type_ast_constructor(self, location, name_location, module, name, arguments);
563 }
564
565 fn visit_type_ast_fn(
566 &mut self,
567 location: &'ast SrcSpan,
568 arguments: &'ast Vec<TypeAst>,
569 return_: &'ast TypeAst,
570 ) {
571 visit_type_ast_fn(self, location, arguments, return_);
572 }
573
574 fn visit_type_ast_var(&mut self, location: &'ast SrcSpan, name: &'ast EcoString) {
575 visit_type_ast_var(self, location, name);
576 }
577
578 fn visit_type_ast_tuple(&mut self, location: &'ast SrcSpan, elements: &'ast Vec<TypeAst>) {
579 visit_type_ast_tuple(self, location, elements);
580 }
581
582 fn visit_type_ast_hole(&mut self, location: &'ast SrcSpan, name: &'ast EcoString) {
583 visit_type_ast_hole(self, location, name);
584 }
585}
586
587pub fn visit_typed_module<'a, V>(v: &mut V, module: &'a TypedModule)
588where
589 V: Visit<'a> + ?Sized,
590{
591 for definition in &module.definitions {
592 v.visit_typed_definition(definition);
593 }
594}
595
596pub fn visit_typed_definition<'a, V>(v: &mut V, def: &'a TypedDefinition)
597where
598 V: Visit<'a> + ?Sized,
599{
600 match def {
601 Definition::Function(fun) => v.visit_typed_function(fun),
602 Definition::TypeAlias(_typealias) => { /* TODO */ }
603 Definition::CustomType(custom_type) => v.visit_typed_custom_type(custom_type),
604 Definition::Import(_import) => { /* TODO */ }
605 Definition::ModuleConstant(constant) => v.visit_typed_module_constant(constant),
606 }
607}
608pub fn visit_typed_function<'a, V>(v: &mut V, fun: &'a TypedFunction)
609where
610 V: Visit<'a> + ?Sized,
611{
612 for stmt in &fun.body {
613 v.visit_typed_statement(stmt);
614 }
615}
616
617pub fn visit_type_ast<'a, V>(v: &mut V, node: &'a TypeAst)
618where
619 V: Visit<'a> + ?Sized,
620{
621 match node {
622 TypeAst::Constructor(super::TypeAstConstructor {
623 location,
624 name_location,
625 arguments,
626 module,
627 name,
628 }) => {
629 v.visit_type_ast_constructor(location, name_location, module, name, arguments);
630 }
631 TypeAst::Fn(super::TypeAstFn {
632 location,
633 arguments,
634 return_,
635 }) => {
636 v.visit_type_ast_fn(location, arguments, return_);
637 }
638 TypeAst::Var(super::TypeAstVar { location, name }) => {
639 v.visit_type_ast_var(location, name);
640 }
641 TypeAst::Tuple(super::TypeAstTuple { location, elements }) => {
642 v.visit_type_ast_tuple(location, elements);
643 }
644 TypeAst::Hole(super::TypeAstHole { location, name }) => {
645 v.visit_type_ast_hole(location, name);
646 }
647 }
648}
649
650pub fn visit_type_ast_constructor<'a, V>(
651 v: &mut V,
652 _location: &'a SrcSpan,
653 _name_location: &'a SrcSpan,
654 _module: &'a Option<(EcoString, SrcSpan)>,
655 _name: &'a EcoString,
656 arguments: &'a Vec<TypeAst>,
657) where
658 V: Visit<'a> + ?Sized,
659{
660 for argument in arguments {
661 v.visit_type_ast(argument);
662 }
663}
664
665pub fn visit_type_ast_fn<'a, V>(
666 v: &mut V,
667 _location: &'a SrcSpan,
668 arguments: &'a Vec<TypeAst>,
669 return_: &'a TypeAst,
670) where
671 V: Visit<'a> + ?Sized,
672{
673 for argument in arguments {
674 v.visit_type_ast(argument);
675 }
676 v.visit_type_ast(return_);
677}
678
679pub fn visit_type_ast_var<'a, V>(_v: &mut V, _location: &'a SrcSpan, _name: &'a EcoString)
680where
681 V: Visit<'a> + ?Sized,
682{
683 // No further traversal needed for variables
684}
685
686pub fn visit_type_ast_tuple<'a, V>(v: &mut V, _location: &'a SrcSpan, elements: &'a Vec<TypeAst>)
687where
688 V: Visit<'a> + ?Sized,
689{
690 for element in elements {
691 v.visit_type_ast(element);
692 }
693}
694
695pub fn visit_type_ast_hole<'a, V>(_v: &mut V, _location: &'a SrcSpan, _name: &'a EcoString)
696where
697 V: Visit<'a> + ?Sized,
698{
699 // No further traversal needed for holes
700}
701
702pub fn visit_typed_module_constant<'a, V>(_v: &mut V, _constant: &'a TypedModuleConstant)
703where
704 V: Visit<'a> + ?Sized,
705{
706}
707
708pub fn visit_typed_custom_type<'a, V>(v: &mut V, custom_type: &'a TypedCustomType)
709where
710 V: Visit<'a> + ?Sized,
711{
712 for record in &custom_type.constructors {
713 for argument in &record.arguments {
714 v.visit_type_ast(&argument.ast);
715 }
716 }
717}
718
719pub fn visit_typed_expr<'a, V>(v: &mut V, node: &'a TypedExpr)
720where
721 V: Visit<'a> + ?Sized,
722{
723 match node {
724 TypedExpr::Int {
725 location,
726 type_,
727 value,
728 int_value: _,
729 } => v.visit_typed_expr_int(location, type_, value),
730 TypedExpr::Float {
731 location,
732 type_,
733 value,
734 } => v.visit_typed_expr_float(location, type_, value),
735 TypedExpr::String {
736 location,
737 type_,
738 value,
739 } => v.visit_typed_expr_string(location, type_, value),
740 TypedExpr::Block {
741 location,
742 statements,
743 } => v.visit_typed_expr_block(location, statements),
744 TypedExpr::Pipeline {
745 location,
746 first_value,
747 assignments,
748 finally,
749 finally_kind,
750 } => v.visit_typed_expr_pipeline(location, first_value, assignments, finally, finally_kind),
751 TypedExpr::Var {
752 location,
753 constructor,
754 name,
755 } => v.visit_typed_expr_var(location, constructor, name),
756 TypedExpr::Fn {
757 location,
758 type_,
759 kind,
760 args,
761 body,
762 return_annotation,
763 purity: _,
764 } => v.visit_typed_expr_fn(location, type_, kind, args, body, return_annotation),
765 TypedExpr::List {
766 location,
767 type_,
768 elements,
769 tail,
770 } => v.visit_typed_expr_list(location, type_, elements, tail),
771 TypedExpr::Call {
772 location,
773 type_,
774 fun,
775 args,
776 } => v.visit_typed_expr_call(location, type_, fun, args),
777 TypedExpr::BinOp {
778 location,
779 type_,
780 name,
781 name_location,
782 left,
783 right,
784 } => v.visit_typed_expr_bin_op(location, type_, name, name_location, left, right),
785 TypedExpr::Case {
786 location,
787 type_,
788 subjects,
789 clauses,
790 compiled_case,
791 } => v.visit_typed_expr_case(location, type_, subjects, clauses, compiled_case),
792 TypedExpr::RecordAccess {
793 location,
794 field_start,
795 type_,
796 label,
797 index,
798 record,
799 } => v.visit_typed_expr_record_access(location, field_start, type_, label, index, record),
800 TypedExpr::ModuleSelect {
801 location,
802 field_start,
803 type_,
804 label,
805 module_name,
806 module_alias,
807 constructor,
808 } => v.visit_typed_expr_module_select(
809 location,
810 field_start,
811 type_,
812 label,
813 module_name,
814 module_alias,
815 constructor,
816 ),
817 TypedExpr::Tuple {
818 location,
819 type_,
820 elements,
821 } => v.visit_typed_expr_tuple(location, type_, elements),
822 TypedExpr::TupleIndex {
823 location,
824 type_,
825 index,
826 tuple,
827 } => v.visit_typed_expr_tuple_index(location, type_, index, tuple),
828 TypedExpr::Todo {
829 location,
830 message,
831 kind,
832 type_,
833 } => v.visit_typed_expr_todo(location, message, kind, type_),
834 TypedExpr::Panic {
835 location,
836 message,
837 type_,
838 } => v.visit_typed_expr_panic(location, message, type_),
839 TypedExpr::BitArray {
840 location,
841 type_,
842 segments,
843 } => v.visit_typed_expr_bit_array(location, type_, segments),
844 TypedExpr::RecordUpdate {
845 location,
846 type_,
847 record_assignment,
848 constructor,
849 args,
850 } => {
851 v.visit_typed_expr_record_update(location, type_, record_assignment, constructor, args)
852 }
853 TypedExpr::NegateBool { location, value } => {
854 v.visit_typed_expr_negate_bool(location, value)
855 }
856 TypedExpr::NegateInt { location, value } => v.visit_typed_expr_negate_int(location, value),
857 TypedExpr::Invalid { location, type_ } => v.visit_typed_expr_invalid(location, type_),
858 TypedExpr::Echo {
859 location,
860 expression,
861 message,
862 type_,
863 } => v.visit_typed_expr_echo(location, type_, expression, message),
864 }
865}
866
867pub fn visit_typed_expr_int<'a, V>(
868 _v: &mut V,
869 _location: &'a SrcSpan,
870 _type_: &'a Arc<Type>,
871 _value: &'a EcoString,
872) where
873 V: Visit<'a> + ?Sized,
874{
875}
876
877pub fn visit_typed_expr_float<'a, V>(
878 _v: &mut V,
879 _location: &'a SrcSpan,
880 _type_: &'a Arc<Type>,
881 _value: &'a EcoString,
882) where
883 V: Visit<'a> + ?Sized,
884{
885}
886
887pub fn visit_typed_expr_string<'a, V>(
888 _v: &mut V,
889 _location: &'a SrcSpan,
890 _type_: &'a Arc<Type>,
891 _value: &'a EcoString,
892) where
893 V: Visit<'a> + ?Sized,
894{
895}
896
897pub fn visit_typed_expr_block<'a, V>(
898 v: &mut V,
899 _location: &'a SrcSpan,
900 statements: &'a [TypedStatement],
901) where
902 V: Visit<'a> + ?Sized,
903{
904 for stmt in statements {
905 v.visit_typed_statement(stmt);
906 }
907}
908
909pub fn visit_typed_expr_pipeline<'a, V>(
910 v: &mut V,
911 _location: &'a SrcSpan,
912 first_value: &'a TypedPipelineAssignment,
913 assignments: &'a [(TypedPipelineAssignment, PipelineAssignmentKind)],
914 finally: &'a TypedExpr,
915 _finally_kind: &'a PipelineAssignmentKind,
916) where
917 V: Visit<'a> + ?Sized,
918{
919 v.visit_typed_pipeline_assignment(first_value);
920 for (assignment, _kind) in assignments {
921 v.visit_typed_pipeline_assignment(assignment);
922 }
923
924 v.visit_typed_expr(finally);
925}
926
927pub fn visit_typed_pipeline_assignment<'a, V>(v: &mut V, assignment: &'a TypedPipelineAssignment)
928where
929 V: Visit<'a> + ?Sized,
930{
931 v.visit_typed_expr(&assignment.value);
932}
933
934pub fn visit_typed_expr_var<'a, V>(
935 _v: &mut V,
936 _location: &'a SrcSpan,
937 _constructor: &'a ValueConstructor,
938 _name: &'a EcoString,
939) where
940 V: Visit<'a> + ?Sized,
941{
942 /* TODO */
943}
944
945pub fn visit_typed_expr_fn<'a, V>(
946 v: &mut V,
947 _location: &'a SrcSpan,
948 _type_: &'a Arc<Type>,
949 _kind: &'a FunctionLiteralKind,
950 _args: &'a [TypedArg],
951 body: &'a Vec1<TypedStatement>,
952 _return_annotation: &'a Option<TypeAst>,
953) where
954 V: Visit<'a> + ?Sized,
955{
956 for stmt in body {
957 v.visit_typed_statement(stmt);
958 }
959}
960
961pub fn visit_typed_expr_list<'a, V>(
962 v: &mut V,
963 _location: &'a SrcSpan,
964 _type_: &'a Arc<Type>,
965 elements: &'a [TypedExpr],
966 tail: &'a Option<Box<TypedExpr>>,
967) where
968 V: Visit<'a> + ?Sized,
969{
970 for element in elements {
971 v.visit_typed_expr(element);
972 }
973
974 if let Some(tail) = tail {
975 v.visit_typed_expr(tail);
976 }
977}
978
979pub fn visit_typed_expr_call<'a, V>(
980 v: &mut V,
981 _location: &'a SrcSpan,
982 _type_: &'a Arc<Type>,
983 fun: &'a TypedExpr,
984 args: &'a [TypedCallArg],
985) where
986 V: Visit<'a> + ?Sized,
987{
988 v.visit_typed_expr(fun);
989 for arg in args {
990 v.visit_typed_call_arg(arg);
991 }
992}
993
994pub fn visit_typed_expr_bin_op<'a, V>(
995 v: &mut V,
996 _location: &'a SrcSpan,
997 _type_: &'a Arc<Type>,
998 _name: &'a BinOp,
999 _name_location: &'a SrcSpan,
1000 left: &'a TypedExpr,
1001 right: &'a TypedExpr,
1002) where
1003 V: Visit<'a> + ?Sized,
1004{
1005 v.visit_typed_expr(left);
1006 v.visit_typed_expr(right);
1007}
1008
1009pub fn visit_typed_expr_case<'a, V>(
1010 v: &mut V,
1011 _location: &'a SrcSpan,
1012 _type_: &'a Arc<Type>,
1013 subjects: &'a [TypedExpr],
1014 clauses: &'a [TypedClause],
1015 _compiled_case: &'a CompiledCase,
1016) where
1017 V: Visit<'a> + ?Sized,
1018{
1019 for subject in subjects {
1020 v.visit_typed_expr(subject);
1021 }
1022
1023 for clause in clauses {
1024 v.visit_typed_clause(clause);
1025 }
1026}
1027
1028pub fn visit_typed_expr_record_access<'a, V>(
1029 v: &mut V,
1030 _location: &'a SrcSpan,
1031 _field_start: &'a u32,
1032 _type_: &'a Arc<Type>,
1033 _label: &'a EcoString,
1034 _index: &'a u64,
1035 record: &'a TypedExpr,
1036) where
1037 V: Visit<'a> + ?Sized,
1038{
1039 v.visit_typed_expr(record);
1040}
1041
1042#[allow(clippy::too_many_arguments)]
1043pub fn visit_typed_expr_module_select<'a, V>(
1044 _v: &mut V,
1045 _location: &'a SrcSpan,
1046 _field_start: &'a u32,
1047 _type_: &'a Arc<Type>,
1048 _label: &'a EcoString,
1049 _module_name: &'a EcoString,
1050 _module_alias: &'a EcoString,
1051 _constructor: &'a ModuleValueConstructor,
1052) where
1053 V: Visit<'a> + ?Sized,
1054{
1055 /* TODO */
1056}
1057
1058pub fn visit_typed_expr_tuple<'a, V>(
1059 v: &mut V,
1060 _location: &'a SrcSpan,
1061 _type_: &'a Arc<Type>,
1062 elements: &'a [TypedExpr],
1063) where
1064 V: Visit<'a> + ?Sized,
1065{
1066 for element in elements {
1067 v.visit_typed_expr(element);
1068 }
1069}
1070
1071pub fn visit_typed_expr_tuple_index<'a, V>(
1072 v: &mut V,
1073 _location: &'a SrcSpan,
1074 _type_: &'a Arc<Type>,
1075 _index: &'a u64,
1076 tuple: &'a TypedExpr,
1077) where
1078 V: Visit<'a> + ?Sized,
1079{
1080 v.visit_typed_expr(tuple);
1081}
1082
1083pub fn visit_typed_expr_todo<'a, V>(
1084 v: &mut V,
1085 _location: &'a SrcSpan,
1086 message: &'a Option<Box<TypedExpr>>,
1087 _kind: &'a TodoKind,
1088 _type_: &'a Arc<Type>,
1089) where
1090 V: Visit<'a> + ?Sized,
1091{
1092 if let Some(message) = message {
1093 v.visit_typed_expr(message);
1094 }
1095}
1096
1097pub fn visit_typed_expr_echo<'a, V>(
1098 v: &mut V,
1099 _location: &'a SrcSpan,
1100 _type_: &'a Arc<Type>,
1101 expression: &'a Option<Box<TypedExpr>>,
1102 message: &'a Option<Box<TypedExpr>>,
1103) where
1104 V: Visit<'a> + ?Sized,
1105{
1106 if let Some(expression) = expression {
1107 v.visit_typed_expr(expression)
1108 }
1109 if let Some(message) = message {
1110 v.visit_typed_expr(message)
1111 }
1112}
1113
1114pub fn visit_typed_expr_panic<'a, V>(
1115 v: &mut V,
1116 _location: &'a SrcSpan,
1117 message: &'a Option<Box<TypedExpr>>,
1118 _type: &'a Arc<Type>,
1119) where
1120 V: Visit<'a> + ?Sized,
1121{
1122 if let Some(message) = message {
1123 v.visit_typed_expr(message);
1124 }
1125}
1126
1127pub fn visit_typed_expr_bit_array<'a, V>(
1128 v: &mut V,
1129 _location: &'a SrcSpan,
1130 _type_: &'a Arc<Type>,
1131 segments: &'a [TypedExprBitArraySegment],
1132) where
1133 V: Visit<'a> + ?Sized,
1134{
1135 for segment in segments {
1136 v.visit_typed_expr_bit_array_segment(segment);
1137 }
1138}
1139
1140pub fn visit_typed_expr_record_update<'a, V>(
1141 v: &mut V,
1142 _location: &'a SrcSpan,
1143 _type: &'a Arc<Type>,
1144 record: &'a Option<Box<TypedAssignment>>,
1145 constructor: &'a TypedExpr,
1146 args: &'a [TypedCallArg],
1147) where
1148 V: Visit<'a> + ?Sized,
1149{
1150 v.visit_typed_expr(constructor);
1151 if let Some(record) = record {
1152 v.visit_typed_assignment(record);
1153 }
1154 for arg in args {
1155 v.visit_typed_call_arg(arg);
1156 }
1157}
1158
1159pub fn visit_typed_expr_negate_bool<'a, V>(v: &mut V, _location: &'a SrcSpan, value: &'a TypedExpr)
1160where
1161 V: Visit<'a> + ?Sized,
1162{
1163 v.visit_typed_expr(value);
1164}
1165
1166pub fn visit_typed_expr_negate_int<'a, V>(v: &mut V, _location: &'a SrcSpan, value: &'a TypedExpr)
1167where
1168 V: Visit<'a> + ?Sized,
1169{
1170 v.visit_typed_expr(value);
1171}
1172
1173pub fn visit_typed_statement<'a, V>(v: &mut V, stmt: &'a TypedStatement)
1174where
1175 V: Visit<'a> + ?Sized,
1176{
1177 match stmt {
1178 Statement::Expression(expr) => v.visit_typed_expr(expr),
1179 Statement::Assignment(assignment) => v.visit_typed_assignment(assignment),
1180 Statement::Use(use_) => v.visit_typed_use(use_),
1181 Statement::Assert(assert) => v.visit_typed_assert(assert),
1182 }
1183}
1184
1185pub fn visit_typed_assignment<'a, V>(v: &mut V, assignment: &'a TypedAssignment)
1186where
1187 V: Visit<'a> + ?Sized,
1188{
1189 v.visit_typed_expr(&assignment.value);
1190 v.visit_typed_pattern(&assignment.pattern);
1191}
1192
1193pub fn visit_typed_use<'a, V>(v: &mut V, use_: &'a TypedUse)
1194where
1195 V: Visit<'a> + ?Sized,
1196{
1197 v.visit_typed_expr(&use_.call);
1198 // TODO: We should also visit the typed patterns!!
1199}
1200
1201pub fn visit_typed_assert<'a, V>(v: &mut V, assert: &'a TypedAssert)
1202where
1203 V: Visit<'a> + ?Sized,
1204{
1205 v.visit_typed_expr(&assert.value);
1206 if let Some(message) = &assert.message {
1207 v.visit_typed_expr(message);
1208 }
1209}
1210
1211pub fn visit_typed_call_arg<'a, V>(v: &mut V, arg: &'a TypedCallArg)
1212where
1213 V: Visit<'a> + ?Sized,
1214{
1215 v.visit_typed_expr(&arg.value);
1216}
1217
1218pub fn visit_typed_clause<'a, V>(v: &mut V, clause: &'a TypedClause)
1219where
1220 V: Visit<'a> + ?Sized,
1221{
1222 for pattern in clause.pattern.iter() {
1223 v.visit_typed_pattern(pattern);
1224 }
1225 for patterns in clause.alternative_patterns.iter() {
1226 for pattern in patterns {
1227 v.visit_typed_pattern(pattern);
1228 }
1229 }
1230 if let Some(guard) = &clause.guard {
1231 v.visit_typed_clause_guard(guard);
1232 }
1233 v.visit_typed_expr(&clause.then);
1234}
1235
1236pub fn visit_typed_clause_guard<'a, V>(v: &mut V, guard: &'a TypedClauseGuard)
1237where
1238 V: Visit<'a> + ?Sized,
1239{
1240 match guard {
1241 super::ClauseGuard::Equals {
1242 location: _,
1243 left,
1244 right,
1245 }
1246 | super::ClauseGuard::NotEquals {
1247 location: _,
1248 left,
1249 right,
1250 }
1251 | super::ClauseGuard::GtInt {
1252 location: _,
1253 left,
1254 right,
1255 }
1256 | super::ClauseGuard::GtEqInt {
1257 location: _,
1258 left,
1259 right,
1260 }
1261 | super::ClauseGuard::LtInt {
1262 location: _,
1263 left,
1264 right,
1265 }
1266 | super::ClauseGuard::LtEqInt {
1267 location: _,
1268 left,
1269 right,
1270 }
1271 | super::ClauseGuard::GtFloat {
1272 location: _,
1273 left,
1274 right,
1275 }
1276 | super::ClauseGuard::GtEqFloat {
1277 location: _,
1278 left,
1279 right,
1280 }
1281 | super::ClauseGuard::LtFloat {
1282 location: _,
1283 left,
1284 right,
1285 }
1286 | super::ClauseGuard::LtEqFloat {
1287 location: _,
1288 left,
1289 right,
1290 }
1291 | super::ClauseGuard::AddInt {
1292 location: _,
1293 left,
1294 right,
1295 }
1296 | super::ClauseGuard::AddFloat {
1297 location: _,
1298 left,
1299 right,
1300 }
1301 | super::ClauseGuard::SubInt {
1302 location: _,
1303 left,
1304 right,
1305 }
1306 | super::ClauseGuard::SubFloat {
1307 location: _,
1308 left,
1309 right,
1310 }
1311 | super::ClauseGuard::MultInt {
1312 location: _,
1313 left,
1314 right,
1315 }
1316 | super::ClauseGuard::MultFloat {
1317 location: _,
1318 left,
1319 right,
1320 }
1321 | super::ClauseGuard::DivInt {
1322 location: _,
1323 left,
1324 right,
1325 }
1326 | super::ClauseGuard::DivFloat {
1327 location: _,
1328 left,
1329 right,
1330 }
1331 | super::ClauseGuard::RemainderInt {
1332 location: _,
1333 left,
1334 right,
1335 }
1336 | super::ClauseGuard::Or {
1337 location: _,
1338 left,
1339 right,
1340 }
1341 | super::ClauseGuard::And {
1342 location: _,
1343 left,
1344 right,
1345 } => {
1346 v.visit_typed_clause_guard(left);
1347 v.visit_typed_clause_guard(right);
1348 }
1349 super::ClauseGuard::Not {
1350 location: _,
1351 expression,
1352 } => v.visit_typed_clause_guard(expression),
1353 super::ClauseGuard::Var {
1354 location,
1355 type_,
1356 name,
1357 definition_location,
1358 } => v.visit_typed_clause_guard_var(location, name, type_, definition_location),
1359 super::ClauseGuard::TupleIndex {
1360 location,
1361 index,
1362 type_,
1363 tuple,
1364 } => v.visit_typed_clause_guard_tuple_index(location, index, type_, tuple),
1365 super::ClauseGuard::FieldAccess {
1366 location,
1367 index,
1368 label,
1369 type_,
1370 container,
1371 } => v.visit_typed_clause_guard_field_access(location, index, label, type_, container),
1372 super::ClauseGuard::ModuleSelect {
1373 location,
1374 type_,
1375 label,
1376 module_name,
1377 module_alias,
1378 literal,
1379 } => v.visit_typed_clause_guard_module_select(
1380 location,
1381 type_,
1382 label,
1383 module_name,
1384 module_alias,
1385 literal,
1386 ),
1387 super::ClauseGuard::Constant(_constant) => {}
1388 }
1389}
1390
1391pub fn visit_typed_clause_guard_var<'a, V>(
1392 _v: &mut V,
1393 _location: &'a SrcSpan,
1394 _name: &'a EcoString,
1395 _type_: &'a Arc<Type>,
1396 _definition_location: &'a SrcSpan,
1397) where
1398 V: Visit<'a> + ?Sized,
1399{
1400}
1401
1402pub fn visit_typed_clause_guard_tuple_index<'a, V>(
1403 v: &mut V,
1404 _location: &'a SrcSpan,
1405 _index: &'a u64,
1406 _type_: &'a Arc<Type>,
1407 tuple: &'a TypedClauseGuard,
1408) where
1409 V: Visit<'a> + ?Sized,
1410{
1411 v.visit_typed_clause_guard(tuple);
1412}
1413
1414pub fn visit_typed_clause_guard_field_access<'a, V>(
1415 v: &mut V,
1416 _location: &'a SrcSpan,
1417 _index: &'a Option<u64>,
1418 _label: &'a EcoString,
1419 _type_: &'a Arc<Type>,
1420 container: &'a TypedClauseGuard,
1421) where
1422 V: Visit<'a> + ?Sized,
1423{
1424 v.visit_typed_clause_guard(container);
1425}
1426
1427pub fn visit_typed_clause_guard_module_select<'a, V>(
1428 _v: &mut V,
1429 _location: &'a SrcSpan,
1430 _type_: &'a Arc<Type>,
1431 _label: &'a EcoString,
1432 _module_name: &'a EcoString,
1433 _module_alias: &'a EcoString,
1434 _literal: &'a TypedConstant,
1435) where
1436 V: Visit<'a> + ?Sized,
1437{
1438}
1439
1440pub fn visit_typed_expr_bit_array_segment<'a, V>(v: &mut V, segment: &'a TypedExprBitArraySegment)
1441where
1442 V: Visit<'a> + ?Sized,
1443{
1444 v.visit_typed_expr(&segment.value);
1445 for option in &segment.options {
1446 v.visit_typed_bit_array_option(option);
1447 }
1448}
1449
1450pub fn visit_typed_bit_array_option<'a, V>(v: &mut V, option: &'a BitArrayOption<TypedExpr>)
1451where
1452 V: Visit<'a> + ?Sized,
1453{
1454 match option {
1455 BitArrayOption::Bytes { location: _ } => { /* TODO */ }
1456 BitArrayOption::Int { location: _ } => { /* TODO */ }
1457 BitArrayOption::Float { location: _ } => { /* TODO */ }
1458 BitArrayOption::Bits { location: _ } => { /* TODO */ }
1459 BitArrayOption::Utf8 { location: _ } => { /* TODO */ }
1460 BitArrayOption::Utf16 { location: _ } => { /* TODO */ }
1461 BitArrayOption::Utf32 { location: _ } => { /* TODO */ }
1462 BitArrayOption::Utf8Codepoint { location: _ } => { /* TODO */ }
1463 BitArrayOption::Utf16Codepoint { location: _ } => { /* TODO */ }
1464 BitArrayOption::Utf32Codepoint { location: _ } => { /* TODO */ }
1465 BitArrayOption::Signed { location: _ } => { /* TODO */ }
1466 BitArrayOption::Unsigned { location: _ } => { /* TODO */ }
1467 BitArrayOption::Big { location: _ } => { /* TODO */ }
1468 BitArrayOption::Little { location: _ } => { /* TODO */ }
1469 BitArrayOption::Native { location: _ } => { /* TODO */ }
1470 BitArrayOption::Size {
1471 location: _,
1472 value,
1473 short_form: _,
1474 } => {
1475 v.visit_typed_expr(value);
1476 }
1477 BitArrayOption::Unit {
1478 location: _,
1479 value: _,
1480 } => { /* TODO */ }
1481 }
1482}
1483
1484pub fn visit_typed_pattern<'a, V>(v: &mut V, pattern: &'a TypedPattern)
1485where
1486 V: Visit<'a> + ?Sized,
1487{
1488 match pattern {
1489 Pattern::Int {
1490 location,
1491 value,
1492 int_value: _,
1493 } => v.visit_typed_pattern_int(location, value),
1494 Pattern::Float { location, value } => v.visit_typed_pattern_float(location, value),
1495 Pattern::String { location, value } => v.visit_typed_pattern_string(location, value),
1496 Pattern::Variable {
1497 location,
1498 name,
1499 type_,
1500 origin,
1501 } => v.visit_typed_pattern_variable(location, name, type_, origin),
1502 Pattern::VarUsage {
1503 location,
1504 name,
1505 constructor,
1506 type_,
1507 } => v.visit_typed_pattern_var_usage(location, name, constructor, type_),
1508 Pattern::Assign {
1509 location,
1510 name,
1511 pattern,
1512 } => v.visit_typed_pattern_assign(location, name, pattern),
1513 Pattern::Discard {
1514 location,
1515 name,
1516 type_,
1517 } => v.visit_typed_pattern_discard(location, name, type_),
1518 Pattern::List {
1519 location,
1520 elements,
1521 tail,
1522 type_,
1523 } => v.visit_typed_pattern_list(location, elements, tail, type_),
1524 Pattern::Constructor {
1525 location,
1526 name_location,
1527 name,
1528 arguments,
1529 module,
1530 constructor,
1531 spread,
1532 type_,
1533 } => v.visit_typed_pattern_constructor(
1534 location,
1535 name_location,
1536 name,
1537 arguments,
1538 module,
1539 constructor,
1540 spread,
1541 type_,
1542 ),
1543 Pattern::Tuple { location, elements } => v.visit_typed_pattern_tuple(location, elements),
1544 Pattern::BitArray { location, segments } => {
1545 v.visit_typed_pattern_bit_array(location, segments)
1546 }
1547 Pattern::StringPrefix {
1548 location,
1549 left_location,
1550 left_side_assignment,
1551 right_location,
1552 left_side_string,
1553 right_side_assignment,
1554 } => v.visit_typed_pattern_string_prefix(
1555 location,
1556 left_location,
1557 left_side_assignment,
1558 right_location,
1559 left_side_string,
1560 right_side_assignment,
1561 ),
1562 Pattern::Invalid { location, type_ } => v.visit_typed_pattern_invalid(location, type_),
1563 }
1564}
1565
1566fn visit_typed_pattern_int<'a, V>(_v: &mut V, _location: &'a SrcSpan, _value: &'a EcoString)
1567where
1568 V: Visit<'a> + ?Sized,
1569{
1570}
1571
1572pub fn visit_typed_pattern_float<'a, V>(_v: &mut V, _location: &'a SrcSpan, _value: &'a EcoString)
1573where
1574 V: Visit<'a> + ?Sized,
1575{
1576}
1577
1578pub fn visit_typed_pattern_string<'a, V>(_v: &mut V, _location: &'a SrcSpan, _value: &'a EcoString)
1579where
1580 V: Visit<'a> + ?Sized,
1581{
1582}
1583
1584pub fn visit_typed_pattern_variable<'a, V>(
1585 _v: &mut V,
1586 _location: &'a SrcSpan,
1587 _name: &'a EcoString,
1588 _type: &'a Arc<Type>,
1589 _origin: &'a VariableOrigin,
1590) where
1591 V: Visit<'a> + ?Sized,
1592{
1593}
1594
1595pub fn visit_typed_pattern_var_usage<'a, V>(
1596 _v: &mut V,
1597 _location: &'a SrcSpan,
1598 _name: &'a EcoString,
1599 _constructor: &'a Option<ValueConstructor>,
1600 _type: &'a Arc<Type>,
1601) where
1602 V: Visit<'a> + ?Sized,
1603{
1604}
1605
1606pub fn visit_typed_pattern_assign<'a, V>(
1607 v: &mut V,
1608 _location: &'a SrcSpan,
1609 _name: &'a EcoString,
1610 pattern: &'a TypedPattern,
1611) where
1612 V: Visit<'a> + ?Sized,
1613{
1614 v.visit_typed_pattern(pattern);
1615}
1616
1617pub fn visit_typed_pattern_discard<'a, V>(
1618 _v: &mut V,
1619 _location: &'a SrcSpan,
1620 _name: &'a EcoString,
1621 _type: &'a Arc<Type>,
1622) where
1623 V: Visit<'a> + ?Sized,
1624{
1625}
1626
1627pub fn visit_typed_pattern_list<'a, V>(
1628 v: &mut V,
1629 _location: &'a SrcSpan,
1630 elements: &'a Vec<TypedPattern>,
1631 tail: &'a Option<Box<TypedPattern>>,
1632 _type: &'a Arc<Type>,
1633) where
1634 V: Visit<'a> + ?Sized,
1635{
1636 for element in elements {
1637 v.visit_typed_pattern(element);
1638 }
1639 if let Some(tail) = tail {
1640 v.visit_typed_pattern(tail);
1641 }
1642}
1643
1644#[allow(clippy::too_many_arguments)]
1645pub fn visit_typed_pattern_constructor<'a, V>(
1646 v: &mut V,
1647 _location: &'a SrcSpan,
1648 _name_location: &'a SrcSpan,
1649 _name: &'a EcoString,
1650 arguments: &'a Vec<CallArg<TypedPattern>>,
1651 _module: &'a Option<(EcoString, SrcSpan)>,
1652 _constructor: &'a Inferred<PatternConstructor>,
1653 _spread: &'a Option<SrcSpan>,
1654 _type: &'a Arc<Type>,
1655) where
1656 V: Visit<'a> + ?Sized,
1657{
1658 for argument in arguments {
1659 v.visit_typed_pattern_call_arg(argument);
1660 }
1661}
1662
1663pub fn visit_typed_pattern_call_arg<'a, V>(v: &mut V, argument: &'a CallArg<TypedPattern>)
1664where
1665 V: Visit<'a> + ?Sized,
1666{
1667 v.visit_typed_pattern(&argument.value)
1668}
1669
1670pub fn visit_typed_pattern_tuple<'a, V>(
1671 v: &mut V,
1672 _location: &'a SrcSpan,
1673 elements: &'a Vec<TypedPattern>,
1674) where
1675 V: Visit<'a> + ?Sized,
1676{
1677 for element in elements {
1678 v.visit_typed_pattern(element);
1679 }
1680}
1681
1682pub fn visit_typed_pattern_bit_array<'a, V>(
1683 v: &mut V,
1684 _location: &'a SrcSpan,
1685 segments: &'a Vec<TypedPatternBitArraySegment>,
1686) where
1687 V: Visit<'a> + ?Sized,
1688{
1689 for segment in segments {
1690 v.visit_typed_pattern(&segment.value);
1691 for option in segment.options.iter() {
1692 v.visit_typed_pattern_bit_array_option(option);
1693 }
1694 }
1695}
1696
1697pub fn visit_typed_pattern_bit_array_option<'a, V>(
1698 v: &mut V,
1699 option: &'a BitArrayOption<TypedPattern>,
1700) where
1701 V: Visit<'a> + ?Sized,
1702{
1703 match option {
1704 BitArrayOption::Bytes { location: _ } => { /* TODO */ }
1705 BitArrayOption::Int { location: _ } => { /* TODO */ }
1706 BitArrayOption::Float { location: _ } => { /* TODO */ }
1707 BitArrayOption::Bits { location: _ } => { /* TODO */ }
1708 BitArrayOption::Utf8 { location: _ } => { /* TODO */ }
1709 BitArrayOption::Utf16 { location: _ } => { /* TODO */ }
1710 BitArrayOption::Utf32 { location: _ } => { /* TODO */ }
1711 BitArrayOption::Utf8Codepoint { location: _ } => { /* TODO */ }
1712 BitArrayOption::Utf16Codepoint { location: _ } => { /* TODO */ }
1713 BitArrayOption::Utf32Codepoint { location: _ } => { /* TODO */ }
1714 BitArrayOption::Signed { location: _ } => { /* TODO */ }
1715 BitArrayOption::Unsigned { location: _ } => { /* TODO */ }
1716 BitArrayOption::Big { location: _ } => { /* TODO */ }
1717 BitArrayOption::Little { location: _ } => { /* TODO */ }
1718 BitArrayOption::Native { location: _ } => { /* TODO */ }
1719 BitArrayOption::Size {
1720 location: _,
1721 value,
1722 short_form: _,
1723 } => {
1724 v.visit_typed_pattern(value);
1725 }
1726 BitArrayOption::Unit {
1727 location: _,
1728 value: _,
1729 } => { /* TODO */ }
1730 }
1731}
1732
1733pub fn visit_typed_pattern_string_prefix<'a, V>(
1734 _v: &mut V,
1735 _location: &'a SrcSpan,
1736 _left_location: &'a SrcSpan,
1737 _left_side_assignment: &'a Option<(EcoString, SrcSpan)>,
1738 _right_location: &'a SrcSpan,
1739 _left_side_string: &'a EcoString,
1740 _right_side_assignment: &'a AssignName,
1741) where
1742 V: Visit<'a> + ?Sized,
1743{
1744}
1745
1746pub fn visit_typed_pattern_invalid<'a, V>(_v: &mut V, _location: &'a SrcSpan, _type_: &'a Arc<Type>)
1747where
1748 V: Visit<'a> + ?Sized,
1749{
1750}
1751
1752pub fn visit_typed_expr_invalid<'a, V>(_v: &mut V, _location: &'a SrcSpan, _type_: &'a Arc<Type>)
1753where
1754 V: Visit<'a> + ?Sized,
1755{
1756}