Fork of daniellemaywood.uk/gleam — Wasm codegen work
64 kB
2294 lines
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2024 The Gleam contributors
3
4//! AST traversal routines, referenced from [`syn::visit`](https://docs.rs/syn/latest/syn/visit/index.html)
5//!
6//! Each method of the [`Visit`] trait can be overridden to customize the
7//! behaviour when visiting the corresponding type of AST node. By default,
8//! every method recursively visits the substructure of the node by using the
9//! right visitor method.
10//!
11//! # Example
12//!
13//! Suppose we would like to collect all function names in a module,
14//! we can do the following:
15//!
16//! ```no_run
17//! use gleam_core::ast::{TypedFunction, visit::{self, Visit}};
18//!
19//! struct FnCollector<'ast> {
20//! functions: Vec<&'ast TypedFunction>
21//! }
22//!
23//! impl<'ast> Visit<'ast> for FnCollector<'ast> {
24//! fn visit_typed_function(&mut self, fun: &'ast TypedFunction) {
25//! self.functions.push(fun);
26//!
27//! // Use the default behaviour to visit any nested functions
28//! visit::visit_typed_function(self, fun);
29//! }
30//! }
31//!
32//! fn print_all_module_functions() {
33//! let module = todo!("module");
34//! let mut fn_collector = FnCollector { functions: vec![] };
35//!
36//! // This will walk the AST and collect all functions
37//! fn_collector.visit_typed_module(module);
38//!
39//! // Print the collected functions
40//! println!("{:#?}", fn_collector.functions);
41//! }
42//! ```
43
44use crate::{
45 analyse::Inferred,
46 ast::{
47 BitArraySize, RecordBeingUpdated, TypeAstConstructorName, TypedBitArraySize,
48 TypedConstantBitArraySegment, TypedDefinitions, TypedImport, TypedTailPattern,
49 TypedTypeAlias, typed::InvalidExpression,
50 },
51 exhaustiveness::CompiledCase,
52 parse::LiteralFloatValue,
53 type_::{
54 FieldMap, ModuleValueConstructor, PatternConstructor, TypedCallArg, ValueConstructor,
55 error::VariableOrigin,
56 },
57};
58use std::sync::Arc;
59
60use ecow::EcoString;
61use num_bigint::BigInt;
62use vec1::Vec1;
63
64use crate::type_::Type;
65
66use super::{
67 AssignName, BinOp, BitArrayOption, CallArg, Pattern, PipelineAssignmentKind, RecordUpdateArg,
68 SrcSpan, Statement, TodoKind, TypeAst, TypedArg, TypedAssert, TypedAssignment, TypedClause,
69 TypedClauseGuard, TypedConstant, TypedCustomType, TypedExpr, TypedExprBitArraySegment,
70 TypedFunction, TypedModule, TypedModuleConstant, TypedPattern, TypedPatternBitArraySegment,
71 TypedPipelineAssignment, TypedStatement, TypedUse, untyped::FunctionLiteralKind,
72};
73
74pub trait Visit<'ast> {
75 fn visit_typed_module(&mut self, module: &'ast TypedModule) {
76 visit_typed_module(self, module);
77 }
78
79 fn visit_typed_function(&mut self, fun: &'ast TypedFunction) {
80 visit_typed_function(self, fun);
81 }
82
83 fn visit_typed_module_constant(&mut self, constant: &'ast TypedModuleConstant) {
84 visit_typed_module_constant(self, constant);
85 }
86
87 fn visit_typed_custom_type(&mut self, custom_type: &'ast TypedCustomType) {
88 visit_typed_custom_type(self, custom_type);
89 }
90
91 fn visit_typed_type_alias(&mut self, type_alias: &'ast TypedTypeAlias) {
92 visit_typed_type_alias(self, type_alias);
93 }
94
95 fn visit_typed_import(&mut self, import: &'ast TypedImport) {
96 visit_typed_import(self, import);
97 }
98
99 fn visit_typed_expr(&mut self, expr: &'ast TypedExpr) {
100 visit_typed_expr(self, expr);
101 }
102
103 fn visit_typed_expr_echo(
104 &mut self,
105 location: &'ast SrcSpan,
106 type_: &'ast Arc<Type>,
107 expression: &'ast Option<Box<TypedExpr>>,
108 message: &'ast Option<Box<TypedExpr>>,
109 ) {
110 visit_typed_expr_echo(self, location, type_, expression, message);
111 }
112
113 fn visit_typed_expr_int(
114 &mut self,
115 location: &'ast SrcSpan,
116 type_: &'ast Arc<Type>,
117 value: &'ast EcoString,
118 ) {
119 visit_typed_expr_int(self, location, type_, value);
120 }
121
122 fn visit_typed_expr_float(
123 &mut self,
124 location: &'ast SrcSpan,
125 type_: &'ast Arc<Type>,
126 value: &'ast EcoString,
127 ) {
128 visit_typed_expr_float(self, location, type_, value);
129 }
130
131 fn visit_typed_expr_string(
132 &mut self,
133 location: &'ast SrcSpan,
134 type_: &'ast Arc<Type>,
135 value: &'ast EcoString,
136 ) {
137 visit_typed_expr_string(self, location, type_, value);
138 }
139
140 fn visit_typed_expr_block(
141 &mut self,
142 location: &'ast SrcSpan,
143 statements: &'ast [TypedStatement],
144 ) {
145 visit_typed_expr_block(self, location, statements);
146 }
147
148 fn visit_typed_expr_pipeline(
149 &mut self,
150 location: &'ast SrcSpan,
151 first_value: &'ast TypedPipelineAssignment,
152 assignments: &'ast [(TypedPipelineAssignment, PipelineAssignmentKind)],
153 finally: &'ast TypedExpr,
154 finally_kind: &'ast PipelineAssignmentKind,
155 ) {
156 visit_typed_expr_pipeline(
157 self,
158 location,
159 first_value,
160 assignments,
161 finally,
162 finally_kind,
163 );
164 }
165
166 fn visit_typed_expr_var(
167 &mut self,
168 location: &'ast SrcSpan,
169 constructor: &'ast ValueConstructor,
170 name: &'ast EcoString,
171 ) {
172 visit_typed_expr_var(self, location, constructor, name);
173 }
174
175 fn visit_typed_expr_fn(
176 &mut self,
177 location: &'ast SrcSpan,
178 type_: &'ast Arc<Type>,
179 kind: &'ast FunctionLiteralKind,
180 arguments: &'ast [TypedArg],
181 body: &'ast Vec1<TypedStatement>,
182 return_annotation: &'ast Option<TypeAst>,
183 ) {
184 visit_typed_expr_fn(
185 self,
186 location,
187 type_,
188 kind,
189 arguments,
190 body,
191 return_annotation,
192 );
193 }
194
195 fn visit_typed_expr_list(
196 &mut self,
197 location: &'ast SrcSpan,
198 type_: &'ast Arc<Type>,
199 elements: &'ast [TypedExpr],
200 tail: &'ast Option<Box<TypedExpr>>,
201 ) {
202 visit_typed_expr_list(self, location, type_, elements, tail);
203 }
204
205 fn visit_typed_expr_call(
206 &mut self,
207 location: &'ast SrcSpan,
208 type_: &'ast Arc<Type>,
209 fun: &'ast TypedExpr,
210 arguments: &'ast [TypedCallArg],
211 open_parenthesis: &'ast Option<u32>,
212 ) {
213 visit_typed_expr_call(self, location, type_, fun, arguments, open_parenthesis);
214 }
215
216 fn visit_typed_expr_bin_op(
217 &mut self,
218 location: &'ast SrcSpan,
219 type_: &'ast Arc<Type>,
220 operator: &'ast BinOp,
221 operator_start: &'ast u32,
222 left: &'ast TypedExpr,
223 right: &'ast TypedExpr,
224 ) {
225 visit_typed_expr_bin_op(self, location, type_, operator, operator_start, left, right);
226 }
227
228 fn visit_typed_expr_case(
229 &mut self,
230 location: &'ast SrcSpan,
231 type_: &'ast Arc<Type>,
232 subjects: &'ast [TypedExpr],
233 clauses: &'ast [TypedClause],
234 compiled_case: &'ast CompiledCase,
235 ) {
236 visit_typed_expr_case(self, location, type_, subjects, clauses, compiled_case);
237 }
238
239 #[allow(clippy::too_many_arguments)]
240 fn visit_typed_expr_record_access(
241 &mut self,
242 location: &'ast SrcSpan,
243 field_start: &'ast u32,
244 type_: &'ast Arc<Type>,
245 label: &'ast EcoString,
246 index: &'ast u64,
247 record: &'ast TypedExpr,
248 documentation: &'ast Option<EcoString>,
249 ) {
250 visit_typed_expr_record_access(
251 self,
252 location,
253 field_start,
254 type_,
255 label,
256 index,
257 record,
258 documentation,
259 );
260 }
261
262 #[allow(clippy::too_many_arguments)]
263 fn visit_typed_expr_module_select(
264 &mut self,
265 location: &'ast SrcSpan,
266 field_start: &'ast u32,
267 type_: &'ast Arc<Type>,
268 label: &'ast EcoString,
269 module_name: &'ast EcoString,
270 module_alias: &'ast EcoString,
271 constructor: &'ast ModuleValueConstructor,
272 ) {
273 visit_typed_expr_module_select(
274 self,
275 location,
276 field_start,
277 type_,
278 label,
279 module_name,
280 module_alias,
281 constructor,
282 );
283 }
284
285 fn visit_typed_expr_tuple(
286 &mut self,
287 location: &'ast SrcSpan,
288 type_: &'ast Arc<Type>,
289 elements: &'ast [TypedExpr],
290 ) {
291 visit_typed_expr_tuple(self, location, type_, elements);
292 }
293
294 fn visit_typed_expr_tuple_index(
295 &mut self,
296 location: &'ast SrcSpan,
297 type_: &'ast Arc<Type>,
298 index: &'ast u64,
299 tuple: &'ast TypedExpr,
300 ) {
301 visit_typed_expr_tuple_index(self, location, type_, index, tuple);
302 }
303
304 fn visit_typed_expr_todo(
305 &mut self,
306 location: &'ast SrcSpan,
307 message: &'ast Option<Box<TypedExpr>>,
308 kind: &'ast TodoKind,
309 type_: &'ast Arc<Type>,
310 ) {
311 visit_typed_expr_todo(self, location, message, kind, type_);
312 }
313
314 fn visit_typed_expr_panic(
315 &mut self,
316 location: &'ast SrcSpan,
317 message: &'ast Option<Box<TypedExpr>>,
318 type_: &'ast Arc<Type>,
319 ) {
320 visit_typed_expr_panic(self, location, message, type_);
321 }
322
323 fn visit_typed_expr_bit_array(
324 &mut self,
325 location: &'ast SrcSpan,
326 type_: &'ast Arc<Type>,
327 segments: &'ast [TypedExprBitArraySegment],
328 ) {
329 visit_typed_expr_bit_array(self, location, type_, segments);
330 }
331
332 #[allow(clippy::too_many_arguments)]
333 fn visit_typed_expr_record_update(
334 &mut self,
335 location: &'ast SrcSpan,
336 spread_start: &'ast u32,
337 type_: &'ast Arc<Type>,
338 updated_record: &'ast TypedExpr,
339 updated_record_assigned_name: &'ast Option<EcoString>,
340 constructor: &'ast TypedExpr,
341 arguments: &'ast [TypedCallArg],
342 ) {
343 visit_typed_expr_record_update(
344 self,
345 location,
346 spread_start,
347 type_,
348 updated_record,
349 updated_record_assigned_name,
350 constructor,
351 arguments,
352 );
353 }
354
355 fn visit_typed_expr_negate_bool(&mut self, location: &'ast SrcSpan, value: &'ast TypedExpr) {
356 visit_typed_expr_negate_bool(self, location, value);
357 }
358
359 fn visit_typed_expr_negate_int(&mut self, location: &'ast SrcSpan, value: &'ast TypedExpr) {
360 visit_typed_expr_negate_int(self, location, value);
361 }
362
363 fn visit_typed_expr_invalid(
364 &mut self,
365 location: &'ast SrcSpan,
366 type_: &'ast Arc<Type>,
367 extra_information: &'ast Option<InvalidExpression>,
368 ) {
369 visit_typed_expr_invalid(self, location, type_, extra_information);
370 }
371
372 fn visit_typed_statement(&mut self, statement: &'ast TypedStatement) {
373 visit_typed_statement(self, statement);
374 }
375
376 fn visit_typed_assignment(&mut self, assignment: &'ast TypedAssignment) {
377 visit_typed_assignment(self, assignment);
378 }
379
380 fn visit_typed_use(&mut self, use_: &'ast TypedUse) {
381 visit_typed_use(self, use_);
382 }
383
384 fn visit_typed_assert(&mut self, assert: &'ast TypedAssert) {
385 visit_typed_assert(self, assert);
386 }
387
388 fn visit_typed_pipeline_assignment(&mut self, assignment: &'ast TypedPipelineAssignment) {
389 visit_typed_pipeline_assignment(self, assignment);
390 }
391
392 fn visit_typed_call_arg(&mut self, arg: &'ast TypedCallArg) {
393 visit_typed_call_arg(self, arg);
394 }
395
396 fn visit_typed_clause(&mut self, clause: &'ast TypedClause) {
397 visit_typed_clause(self, clause);
398 }
399
400 fn visit_typed_clause_guard(&mut self, guard: &'ast TypedClauseGuard) {
401 visit_typed_clause_guard(self, guard);
402 }
403
404 fn visit_typed_clause_guard_bin_op(
405 &mut self,
406 left: &'ast TypedClauseGuard,
407 right: &'ast TypedClauseGuard,
408 operator: &'ast BinOp,
409 operator_start: &'ast u32,
410 location: &'ast SrcSpan,
411 ) {
412 visit_typed_clause_guard_bin_op(self, left, right, operator, operator_start, location);
413 }
414
415 fn visit_typed_clause_guard_var(
416 &mut self,
417 location: &'ast SrcSpan,
418 name: &'ast EcoString,
419 type_: &'ast Arc<Type>,
420 definition_location: &'ast SrcSpan,
421 origin: &'ast VariableOrigin,
422 ) {
423 visit_typed_clause_guard_var(self, location, name, type_, definition_location, origin);
424 }
425
426 fn visit_typed_clause_guard_tuple_index(
427 &mut self,
428 location: &'ast SrcSpan,
429 index: &'ast u64,
430 type_: &'ast Arc<Type>,
431 tuple: &'ast TypedClauseGuard,
432 ) {
433 visit_typed_clause_guard_tuple_index(self, location, index, type_, tuple);
434 }
435
436 fn visit_typed_clause_guard_field_access(
437 &mut self,
438 label_location: &'ast SrcSpan,
439 index: &'ast Option<u64>,
440 label: &'ast EcoString,
441 type_: &'ast Arc<Type>,
442 container: &'ast TypedClauseGuard,
443 ) {
444 visit_typed_clause_guard_field_access(self, label_location, index, label, type_, container);
445 }
446
447 #[allow(clippy::too_many_arguments)]
448 fn visit_typed_clause_guard_module_select(
449 &mut self,
450 location: &'ast SrcSpan,
451 field_start: &'ast u32,
452 definition_location: &'ast SrcSpan,
453 type_: &'ast Arc<Type>,
454 label: &'ast EcoString,
455 module_name: &'ast EcoString,
456 module_alias: &'ast EcoString,
457 literal: &'ast TypedConstant,
458 ) {
459 visit_typed_clause_guard_module_select(
460 self,
461 location,
462 field_start,
463 definition_location,
464 type_,
465 label,
466 module_name,
467 module_alias,
468 literal,
469 );
470 }
471
472 fn visit_typed_expr_bit_array_segment(&mut self, segment: &'ast TypedExprBitArraySegment) {
473 visit_typed_expr_bit_array_segment(self, segment);
474 }
475
476 fn visit_typed_bit_array_option(&mut self, option: &'ast BitArrayOption<TypedExpr>) {
477 visit_typed_bit_array_option(self, option);
478 }
479
480 fn visit_typed_pattern(&mut self, pattern: &'ast TypedPattern) {
481 visit_typed_pattern(self, pattern);
482 }
483
484 fn visit_typed_pattern_int(&mut self, location: &'ast SrcSpan, value: &'ast EcoString) {
485 visit_typed_pattern_int(self, location, value);
486 }
487
488 fn visit_typed_pattern_float(&mut self, location: &'ast SrcSpan, value: &'ast EcoString) {
489 visit_typed_pattern_float(self, location, value);
490 }
491
492 fn visit_typed_pattern_string(&mut self, location: &'ast SrcSpan, value: &'ast EcoString) {
493 visit_typed_pattern_string(self, location, value);
494 }
495
496 fn visit_typed_pattern_variable(
497 &mut self,
498 location: &'ast SrcSpan,
499 name: &'ast EcoString,
500 type_: &'ast Arc<Type>,
501 origin: &'ast VariableOrigin,
502 ) {
503 visit_typed_pattern_variable(self, location, name, type_, origin);
504 }
505
506 fn visit_typed_pattern_bit_array_size(&mut self, size: &'ast TypedBitArraySize) {
507 visit_typed_pattern_bit_array_size(self, size);
508 }
509
510 fn visit_typed_bit_array_size_int(&mut self, location: &'ast SrcSpan, value: &'ast EcoString) {
511 visit_typed_bit_array_size_int(self, location, value);
512 }
513
514 fn visit_typed_bit_array_size_variable(
515 &mut self,
516 location: &'ast SrcSpan,
517 name: &'ast EcoString,
518 constructor: &'ast Option<Box<ValueConstructor>>,
519 type_: &'ast Arc<Type>,
520 ) {
521 visit_typed_bit_array_size_variable(self, location, name, constructor, type_);
522 }
523
524 fn visit_typed_pattern_assign(
525 &mut self,
526 location: &'ast SrcSpan,
527 name: &'ast EcoString,
528 pattern: &'ast TypedPattern,
529 ) {
530 visit_typed_pattern_assign(self, location, name, pattern);
531 }
532
533 fn visit_typed_pattern_discard(
534 &mut self,
535 location: &'ast SrcSpan,
536 name: &'ast EcoString,
537 type_: &'ast Arc<Type>,
538 ) {
539 visit_typed_pattern_discard(self, location, name, type_);
540 }
541
542 fn visit_typed_pattern_list(
543 &mut self,
544 location: &'ast SrcSpan,
545 elements: &'ast Vec<TypedPattern>,
546 tail: &'ast Option<Box<TypedTailPattern>>,
547 type_: &'ast Arc<Type>,
548 ) {
549 visit_typed_pattern_list(self, location, elements, tail, type_);
550 }
551
552 #[allow(clippy::too_many_arguments)]
553 fn visit_typed_pattern_constructor(
554 &mut self,
555 location: &'ast SrcSpan,
556 name_location: &'ast SrcSpan,
557 name: &'ast EcoString,
558 arguments: &'ast Vec<CallArg<TypedPattern>>,
559 module: &'ast Option<(EcoString, SrcSpan)>,
560 constructor: &'ast Inferred<PatternConstructor>,
561 spread: &'ast Option<SrcSpan>,
562 type_: &'ast Arc<Type>,
563 ) {
564 visit_typed_pattern_constructor(
565 self,
566 location,
567 name_location,
568 name,
569 arguments,
570 module,
571 constructor,
572 spread,
573 type_,
574 );
575 }
576
577 fn visit_typed_pattern_call_arg(&mut self, arg: &'ast CallArg<TypedPattern>) {
578 visit_typed_pattern_call_arg(self, arg);
579 }
580
581 fn visit_typed_pattern_tuple(
582 &mut self,
583 location: &'ast SrcSpan,
584 elements: &'ast Vec<TypedPattern>,
585 ) {
586 visit_typed_pattern_tuple(self, location, elements);
587 }
588
589 fn visit_typed_pattern_bit_array(
590 &mut self,
591 location: &'ast SrcSpan,
592 segments: &'ast [TypedPatternBitArraySegment],
593 ) {
594 visit_typed_pattern_bit_array(self, location, segments);
595 }
596
597 fn visit_typed_pattern_bit_array_option(&mut self, option: &'ast BitArrayOption<TypedPattern>) {
598 visit_typed_pattern_bit_array_option(self, option);
599 }
600
601 fn visit_typed_pattern_string_prefix(
602 &mut self,
603 location: &'ast SrcSpan,
604 left_location: &'ast SrcSpan,
605 left_side_assignment: &'ast Option<(EcoString, SrcSpan)>,
606 right_location: &'ast SrcSpan,
607 left_side_string: &'ast EcoString,
608 right_side_assignment: &'ast AssignName,
609 ) {
610 visit_typed_pattern_string_prefix(
611 self,
612 location,
613 left_location,
614 left_side_assignment,
615 right_location,
616 left_side_string,
617 right_side_assignment,
618 );
619 }
620
621 fn visit_typed_pattern_invalid(&mut self, location: &'ast SrcSpan, type_: &'ast Arc<Type>) {
622 visit_typed_pattern_invalid(self, location, type_);
623 }
624
625 fn visit_type_ast(
626 &mut self,
627 node: &'ast TypeAst,
628 // The type inferred for this annotation.
629 // It might not always be possible to infer one in presence of type
630 // errors, so this is optional!
631 inferred_type: Option<Arc<Type>>,
632 ) {
633 visit_type_ast(self, node, inferred_type);
634 }
635
636 fn visit_type_ast_constructor(
637 &mut self,
638 location: &'ast SrcSpan,
639 name: &'ast TypeAstConstructorName,
640 arguments: &'ast [TypeAst],
641 inferred_arguments_types: Option<Vec<Arc<Type>>>,
642 ) {
643 visit_type_ast_constructor(self, location, name, arguments, inferred_arguments_types);
644 }
645
646 fn visit_type_ast_fn(
647 &mut self,
648 location: &'ast SrcSpan,
649 arguments: &'ast [TypeAst],
650 arguments_types: Option<Vec<Arc<Type>>>,
651 return_: &'ast TypeAst,
652 return_type: Option<Arc<Type>>,
653 ) {
654 visit_type_ast_fn(
655 self,
656 location,
657 arguments,
658 arguments_types,
659 return_,
660 return_type,
661 );
662 }
663
664 fn visit_type_ast_var(&mut self, location: &'ast SrcSpan, name: &'ast EcoString) {
665 visit_type_ast_var(self, location, name);
666 }
667
668 fn visit_type_ast_tuple(
669 &mut self,
670 location: &'ast SrcSpan,
671 elements: &'ast [TypeAst],
672 elements_types: Option<&Vec<Arc<Type>>>,
673 ) {
674 visit_type_ast_tuple(self, location, elements, elements_types);
675 }
676
677 fn visit_type_ast_hole(
678 &mut self,
679 location: &'ast SrcSpan,
680 name: &'ast EcoString,
681 type_: Option<Arc<Type>>,
682 ) {
683 visit_type_ast_hole(self, location, name, type_);
684 }
685
686 fn visit_typed_constant(&mut self, constant: &'ast TypedConstant) {
687 visit_typed_constant(self, constant);
688 }
689
690 fn visit_typed_constant_todo(
691 &mut self,
692 location: &'ast SrcSpan,
693 type_: &'ast Arc<Type>,
694 message: &'ast Option<Box<TypedConstant>>,
695 ) {
696 visit_typed_constant_todo(self, location, type_, message);
697 }
698
699 fn visit_typed_constant_int(
700 &mut self,
701 location: &'ast SrcSpan,
702 value: &'ast EcoString,
703 int_value: &'ast BigInt,
704 ) {
705 visit_typed_constant_int(self, location, value, int_value);
706 }
707
708 fn visit_typed_constant_float(
709 &mut self,
710 location: &'ast SrcSpan,
711 value: &'ast EcoString,
712 float_value: &'ast LiteralFloatValue,
713 ) {
714 visit_typed_constant_float(self, location, value, float_value);
715 }
716
717 fn visit_typed_constant_string(&mut self, location: &'ast SrcSpan, value: &'ast EcoString) {
718 visit_typed_constant_string(self, location, value);
719 }
720
721 fn visit_typed_constant_tuple(
722 &mut self,
723 location: &'ast SrcSpan,
724 elements: &'ast Vec<TypedConstant>,
725 type_: &'ast Arc<Type>,
726 ) {
727 visit_typed_constant_tuple(self, location, elements, type_);
728 }
729
730 fn visit_typed_constant_list(
731 &mut self,
732 location: &'ast SrcSpan,
733 elements: &'ast Vec<TypedConstant>,
734 type_: &'ast Arc<Type>,
735 tail: &'ast Option<Box<TypedConstant>>,
736 ) {
737 visit_typed_constant_list(self, location, elements, type_, tail);
738 }
739
740 #[allow(clippy::too_many_arguments)]
741 fn visit_typed_constant_record(
742 &mut self,
743 location: &'ast SrcSpan,
744 module: &'ast Option<(EcoString, SrcSpan)>,
745 name: &'ast EcoString,
746 arguments: &'ast Option<Vec<CallArg<TypedConstant>>>,
747 type_: &'ast Arc<Type>,
748 field_map: &'ast Inferred<FieldMap>,
749 record_constructor: &'ast Option<Box<ValueConstructor>>,
750 ) {
751 visit_typed_constant_record(
752 self,
753 location,
754 module,
755 name,
756 arguments,
757 type_,
758 field_map,
759 record_constructor,
760 );
761 }
762
763 #[allow(clippy::too_many_arguments)]
764 fn visit_typed_constant_record_update(
765 &mut self,
766 location: &'ast SrcSpan,
767 constructor_location: &'ast SrcSpan,
768 module: &'ast Option<(EcoString, SrcSpan)>,
769 name: &'ast EcoString,
770 record: &'ast RecordBeingUpdated<TypedConstant>,
771 arguments: &'ast [RecordUpdateArg<TypedConstant>],
772 type_: &'ast Arc<Type>,
773 field_map: &'ast Inferred<FieldMap>,
774 ) {
775 visit_typed_constant_record_update(
776 self,
777 location,
778 constructor_location,
779 module,
780 name,
781 record,
782 arguments,
783 type_,
784 field_map,
785 );
786 }
787
788 fn visit_typed_constant_bit_array(
789 &mut self,
790 location: &'ast SrcSpan,
791 segments: &'ast [TypedConstantBitArraySegment],
792 ) {
793 visit_typed_constant_bit_array(self, location, segments);
794 }
795
796 fn visit_typed_constant_var(
797 &mut self,
798 location: &'ast SrcSpan,
799 module: &'ast Option<(EcoString, SrcSpan)>,
800 name: &'ast EcoString,
801 constructor: &'ast Option<Box<ValueConstructor>>,
802 type_: &'ast Arc<Type>,
803 ) {
804 visit_typed_constant_var(self, location, module, name, constructor, type_);
805 }
806
807 fn visit_typed_constant_string_concatenation(
808 &mut self,
809 location: &'ast SrcSpan,
810 left: &'ast TypedConstant,
811 right: &'ast TypedConstant,
812 ) {
813 visit_typed_constant_string_concatenation(self, location, left, right);
814 }
815
816 fn visit_typed_constant_invalid(
817 &mut self,
818 location: &'ast SrcSpan,
819 type_: &'ast Arc<Type>,
820 extra_information: &'ast Option<InvalidExpression>,
821 ) {
822 visit_typed_constant_invalid(self, location, type_, extra_information);
823 }
824}
825
826fn visit_typed_constant_invalid<'a, V: Visit<'a> + ?Sized>(
827 _v: &mut V,
828 _location: &'a SrcSpan,
829 _type_: &'a Type,
830 _extra_information: &'a Option<InvalidExpression>,
831) {
832 // No further traversal needed for constant invalid expressions
833}
834
835fn visit_typed_constant_string_concatenation<'a, V: Visit<'a> + ?Sized>(
836 v: &mut V,
837 _location: &'a SrcSpan,
838 left: &'a TypedConstant,
839 right: &'a TypedConstant,
840) {
841 v.visit_typed_constant(left);
842 v.visit_typed_constant(right);
843}
844
845pub fn visit_typed_constant_var<'a, V: Visit<'a> + ?Sized>(
846 _v: &mut V,
847 _location: &'a SrcSpan,
848 _module: &'a Option<(EcoString, SrcSpan)>,
849 _name: &'a EcoString,
850 _constructor: &'a Option<Box<ValueConstructor>>,
851 _type_: &'a Arc<Type>,
852) {
853 // No further traversal needed for constant vars
854}
855
856fn visit_typed_constant_bit_array<'a, V: Visit<'a> + ?Sized>(
857 _v: &mut V,
858 _location: &'a SrcSpan,
859 _segments: &'a [TypedConstantBitArraySegment],
860) {
861 // TODO
862}
863
864#[allow(clippy::too_many_arguments)]
865pub fn visit_typed_constant_record<'a, V: Visit<'a> + ?Sized>(
866 v: &mut V,
867 _location: &'a SrcSpan,
868 _module: &'a Option<(EcoString, SrcSpan)>,
869 _name: &'a EcoString,
870 arguments: &'a Option<Vec<CallArg<TypedConstant>>>,
871 _type_: &'a Arc<Type>,
872 _field_map: &'a Inferred<FieldMap>,
873 _record_constructor: &'a Option<Box<ValueConstructor>>,
874) {
875 for argument in arguments.iter().flatten() {
876 v.visit_typed_constant(&argument.value);
877 }
878}
879
880#[allow(clippy::too_many_arguments)]
881pub fn visit_typed_constant_record_update<'a, V: Visit<'a> + ?Sized>(
882 v: &mut V,
883 _location: &'a SrcSpan,
884 _constructor_location: &'a SrcSpan,
885 _module: &'a Option<(EcoString, SrcSpan)>,
886 _name: &'a EcoString,
887 record: &'a RecordBeingUpdated<TypedConstant>,
888 arguments: &'a [RecordUpdateArg<TypedConstant>],
889 _type_: &'a Arc<Type>,
890 _field_map: &'a Inferred<FieldMap>,
891) {
892 v.visit_typed_constant(&record.base);
893 for argument in arguments {
894 v.visit_typed_constant(&argument.value);
895 }
896}
897
898fn visit_typed_constant_list<'a, V: Visit<'a> + ?Sized>(
899 v: &mut V,
900 _location: &'a SrcSpan,
901 elements: &'a Vec<TypedConstant>,
902 _type_: &'a Arc<Type>,
903 tail: &'a Option<Box<TypedConstant>>,
904) {
905 for element in elements {
906 v.visit_typed_constant(element);
907 }
908 if let Some(tail) = tail {
909 v.visit_typed_constant(tail);
910 }
911}
912
913fn visit_typed_constant_tuple<'a, V: Visit<'a> + ?Sized>(
914 v: &mut V,
915 _location: &'a SrcSpan,
916 elements: &'a Vec<TypedConstant>,
917 _type_: &'a Arc<Type>,
918) {
919 for element in elements {
920 v.visit_typed_constant(element);
921 }
922}
923
924fn visit_typed_constant_string<'a, V: Visit<'a> + ?Sized>(
925 _v: &mut V,
926 _location: &'a SrcSpan,
927 _value: &'a EcoString,
928) {
929 // No further traversal needed for constant strings
930}
931
932fn visit_typed_constant_float<'a, V: Visit<'a> + ?Sized>(
933 _v: &mut V,
934 _location: &'a SrcSpan,
935 _value: &'a EcoString,
936 _float_value: &'a LiteralFloatValue,
937) {
938 // No further traversal needed for constant floats
939}
940
941fn visit_typed_constant_int<'a, V: Visit<'a> + ?Sized>(
942 _v: &mut V,
943 _location: &'a SrcSpan,
944 _value: &'a EcoString,
945 _int_value: &'a BigInt,
946) {
947 // No further traversal needed for constant ints
948}
949
950pub fn visit_typed_constant_todo<'a, V: Visit<'a> + ?Sized>(
951 _v: &mut V,
952 _location: &'a SrcSpan,
953 _type_: &'a Arc<Type>,
954 _message: &'a Option<Box<TypedConstant>>,
955) {
956 // No further traversal needed for constant todos
957}
958
959pub fn visit_typed_module<'a, V>(v: &mut V, module: &'a TypedModule)
960where
961 V: Visit<'a> + ?Sized,
962{
963 let TypedDefinitions {
964 imports,
965 constants,
966 custom_types,
967 type_aliases,
968 functions,
969 } = &module.definitions;
970
971 for import in imports {
972 v.visit_typed_import(import);
973 }
974
975 for constant in constants {
976 v.visit_typed_module_constant(constant);
977 }
978
979 for custom_type in custom_types {
980 v.visit_typed_custom_type(custom_type);
981 }
982
983 for type_alias in type_aliases {
984 v.visit_typed_type_alias(type_alias);
985 }
986
987 for function in functions {
988 v.visit_typed_function(function);
989 }
990}
991
992pub fn visit_typed_function<'a, V>(v: &mut V, fun: &'a TypedFunction)
993where
994 V: Visit<'a> + ?Sized,
995{
996 for argument in fun.arguments.iter() {
997 if let Some(annotation) = &argument.annotation {
998 v.visit_type_ast(annotation, Some(argument.type_.clone()));
999 }
1000 }
1001 if let Some(annotation) = &fun.return_annotation {
1002 v.visit_type_ast(annotation, Some(fun.return_type.clone()));
1003 }
1004
1005 for statement in &fun.body {
1006 v.visit_typed_statement(statement);
1007 }
1008}
1009
1010pub fn visit_type_ast<'a, V>(v: &mut V, node: &'a TypeAst, type_: Option<Arc<Type>>)
1011where
1012 V: Visit<'a> + ?Sized,
1013{
1014 match node {
1015 TypeAst::Constructor(super::TypeAstConstructor {
1016 location,
1017 arguments,
1018 name,
1019 start_parentheses: _,
1020 }) => {
1021 v.visit_type_ast_constructor(
1022 location,
1023 name,
1024 arguments,
1025 type_.and_then(|type_| type_.constructor_types()),
1026 );
1027 }
1028 TypeAst::Fn(super::TypeAstFn {
1029 location,
1030 arguments,
1031 return_,
1032 }) => {
1033 let (arguments_types, return_type) = match type_.and_then(|type_| type_.fn_types()) {
1034 Some((arguments_types, return_type)) => (Some(arguments_types), Some(return_type)),
1035 None => (None, None),
1036 };
1037
1038 v.visit_type_ast_fn(location, arguments, arguments_types, return_, return_type);
1039 }
1040 TypeAst::Var(super::TypeAstVar { location, name }) => {
1041 v.visit_type_ast_var(location, name);
1042 }
1043 TypeAst::Tuple(super::TypeAstTuple { location, elements }) => {
1044 let elements_types = if let Some(Type::Tuple { elements }) = type_.as_deref() {
1045 Some(elements)
1046 } else {
1047 None
1048 };
1049 v.visit_type_ast_tuple(location, elements, elements_types);
1050 }
1051 TypeAst::Hole(super::TypeAstHole { location, name }) => {
1052 v.visit_type_ast_hole(location, name, type_);
1053 }
1054 }
1055}
1056
1057pub fn visit_type_ast_constructor<'a, V>(
1058 v: &mut V,
1059 _location: &'a SrcSpan,
1060 _name: &'a TypeAstConstructorName,
1061 arguments: &'a [TypeAst],
1062 inferred_arguments_types: Option<Vec<Arc<Type>>>,
1063) where
1064 V: Visit<'a> + ?Sized,
1065{
1066 for (i, argument) in arguments.iter().enumerate() {
1067 let argument_type = inferred_arguments_types
1068 .as_ref()
1069 .and_then(|types| types.get(i));
1070 v.visit_type_ast(argument, argument_type.cloned());
1071 }
1072}
1073
1074pub fn visit_type_ast_fn<'a, V>(
1075 v: &mut V,
1076 _location: &'a SrcSpan,
1077 arguments: &'a [TypeAst],
1078 arguments_types: Option<Vec<Arc<Type>>>,
1079 return_: &'a TypeAst,
1080 return_type: Option<Arc<Type>>,
1081) where
1082 V: Visit<'a> + ?Sized,
1083{
1084 for (i, argument) in arguments.iter().enumerate() {
1085 v.visit_type_ast(
1086 argument,
1087 arguments_types
1088 .as_ref()
1089 .and_then(|types| types.get(i))
1090 .cloned(),
1091 );
1092 }
1093 v.visit_type_ast(return_, return_type);
1094}
1095
1096pub fn visit_type_ast_var<'a, V>(_v: &mut V, _location: &'a SrcSpan, _name: &'a EcoString)
1097where
1098 V: Visit<'a> + ?Sized,
1099{
1100 // No further traversal needed for variables
1101}
1102
1103pub fn visit_type_ast_tuple<'a, V>(
1104 v: &mut V,
1105 _location: &'a SrcSpan,
1106 elements: &'a [TypeAst],
1107 elements_types: Option<&Vec<Arc<Type>>>,
1108) where
1109 V: Visit<'a> + ?Sized,
1110{
1111 for (i, element) in elements.iter().enumerate() {
1112 let element_type = elements_types
1113 .as_ref()
1114 .and_then(|types| types.get(i))
1115 .cloned();
1116 v.visit_type_ast(element, element_type);
1117 }
1118}
1119
1120pub fn visit_type_ast_hole<'a, V>(
1121 _v: &mut V,
1122 _location: &'a SrcSpan,
1123 _name: &'a EcoString,
1124 _type_: Option<Arc<Type>>,
1125) where
1126 V: Visit<'a> + ?Sized,
1127{
1128 // No further traversal needed for holes
1129}
1130
1131pub fn visit_typed_module_constant<'a, V>(v: &mut V, constant: &'a TypedModuleConstant)
1132where
1133 V: Visit<'a> + ?Sized,
1134{
1135 if let Some(annotation) = &constant.annotation {
1136 v.visit_type_ast(annotation, Some(constant.type_.clone()));
1137 }
1138 v.visit_typed_constant(&constant.value);
1139}
1140
1141pub fn visit_typed_constant<'a, V: Visit<'a> + ?Sized>(v: &mut V, constant: &'a TypedConstant) {
1142 match constant {
1143 super::Constant::Todo {
1144 location,
1145 type_,
1146 message,
1147 } => v.visit_typed_constant_todo(location, type_, message),
1148 super::Constant::Int {
1149 location,
1150 value,
1151 int_value,
1152 } => v.visit_typed_constant_int(location, value, int_value),
1153 super::Constant::Float {
1154 location,
1155 value,
1156 float_value,
1157 } => v.visit_typed_constant_float(location, value, float_value),
1158 super::Constant::String { location, value } => {
1159 v.visit_typed_constant_string(location, value);
1160 }
1161 super::Constant::Tuple {
1162 location,
1163 elements,
1164 type_,
1165 } => v.visit_typed_constant_tuple(location, elements, type_),
1166 super::Constant::List {
1167 location,
1168 elements,
1169 type_,
1170 tail,
1171 } => v.visit_typed_constant_list(location, elements, type_, tail),
1172 super::Constant::Record {
1173 location,
1174 module,
1175 name,
1176 arguments,
1177 type_,
1178 field_map,
1179 record_constructor,
1180 } => v.visit_typed_constant_record(
1181 location,
1182 module,
1183 name,
1184 arguments,
1185 type_,
1186 field_map,
1187 record_constructor,
1188 ),
1189 super::Constant::RecordUpdate {
1190 location,
1191 constructor_location,
1192 module,
1193 name,
1194 record,
1195 arguments,
1196 type_,
1197 field_map,
1198 } => v.visit_typed_constant_record_update(
1199 location,
1200 constructor_location,
1201 module,
1202 name,
1203 record,
1204 arguments,
1205 type_,
1206 field_map,
1207 ),
1208 super::Constant::BitArray { location, segments } => {
1209 v.visit_typed_constant_bit_array(location, segments);
1210 }
1211 super::Constant::Var {
1212 location,
1213 module,
1214 name,
1215 constructor,
1216 type_,
1217 } => v.visit_typed_constant_var(location, module, name, constructor, type_),
1218 super::Constant::StringConcatenation {
1219 location,
1220 left,
1221 right,
1222 } => v.visit_typed_constant_string_concatenation(location, left, right),
1223 super::Constant::Invalid {
1224 location,
1225 type_,
1226 extra_information,
1227 } => v.visit_typed_constant_invalid(location, type_, extra_information),
1228 }
1229}
1230
1231pub fn visit_typed_custom_type<'a, V>(v: &mut V, custom_type: &'a TypedCustomType)
1232where
1233 V: Visit<'a> + ?Sized,
1234{
1235 for record in &custom_type.constructors {
1236 for argument in &record.arguments {
1237 v.visit_type_ast(&argument.ast, Some(argument.type_.clone()));
1238 }
1239 }
1240}
1241
1242pub fn visit_typed_type_alias<'a, V>(v: &mut V, type_alias: &'a TypedTypeAlias)
1243where
1244 V: Visit<'a> + ?Sized,
1245{
1246 v.visit_type_ast(&type_alias.type_ast, Some(type_alias.type_.clone()));
1247}
1248
1249pub fn visit_typed_import<'a, V>(_v: &mut V, _import: &'a TypedImport)
1250where
1251 V: Visit<'a> + ?Sized,
1252{
1253}
1254
1255pub fn visit_typed_expr<'a, V>(v: &mut V, node: &'a TypedExpr)
1256where
1257 V: Visit<'a> + ?Sized,
1258{
1259 match node {
1260 TypedExpr::Int {
1261 location,
1262 type_,
1263 value,
1264 int_value: _,
1265 } => v.visit_typed_expr_int(location, type_, value),
1266 TypedExpr::Float {
1267 location,
1268 type_,
1269 value,
1270 float_value: _,
1271 } => v.visit_typed_expr_float(location, type_, value),
1272 TypedExpr::String {
1273 location,
1274 type_,
1275 value,
1276 } => v.visit_typed_expr_string(location, type_, value),
1277 TypedExpr::Block {
1278 location,
1279 statements,
1280 } => v.visit_typed_expr_block(location, statements),
1281 TypedExpr::Pipeline {
1282 location,
1283 first_value,
1284 assignments,
1285 finally,
1286 finally_kind,
1287 } => v.visit_typed_expr_pipeline(location, first_value, assignments, finally, finally_kind),
1288 TypedExpr::Var {
1289 location,
1290 constructor,
1291 name,
1292 } => v.visit_typed_expr_var(location, constructor, name),
1293 TypedExpr::Fn {
1294 location,
1295 type_,
1296 kind,
1297 arguments,
1298 body,
1299 return_annotation,
1300 purity: _,
1301 } => v.visit_typed_expr_fn(location, type_, kind, arguments, body, return_annotation),
1302 TypedExpr::List {
1303 location,
1304 type_,
1305 elements,
1306 tail,
1307 } => v.visit_typed_expr_list(location, type_, elements, tail),
1308 TypedExpr::Call {
1309 location,
1310 type_,
1311 fun,
1312 arguments,
1313 open_parenthesis,
1314 } => v.visit_typed_expr_call(location, type_, fun, arguments, open_parenthesis),
1315 TypedExpr::BinOp {
1316 location,
1317 type_,
1318 operator,
1319 operator_start,
1320 left,
1321 right,
1322 } => v.visit_typed_expr_bin_op(location, type_, operator, operator_start, left, right),
1323 TypedExpr::Case {
1324 location,
1325 type_,
1326 subjects,
1327 clauses,
1328 compiled_case,
1329 } => v.visit_typed_expr_case(location, type_, subjects, clauses, compiled_case),
1330 TypedExpr::RecordAccess {
1331 location,
1332 field_start,
1333 type_,
1334 label,
1335 index,
1336 record,
1337 documentation,
1338 } => v.visit_typed_expr_record_access(
1339 location,
1340 field_start,
1341 type_,
1342 label,
1343 index,
1344 record,
1345 documentation,
1346 ),
1347 TypedExpr::ModuleSelect {
1348 location,
1349 field_start,
1350 type_,
1351 label,
1352 module_name,
1353 module_alias,
1354 constructor,
1355 } => v.visit_typed_expr_module_select(
1356 location,
1357 field_start,
1358 type_,
1359 label,
1360 module_name,
1361 module_alias,
1362 constructor,
1363 ),
1364 TypedExpr::Tuple {
1365 location,
1366 type_,
1367 elements,
1368 } => v.visit_typed_expr_tuple(location, type_, elements),
1369 TypedExpr::TupleIndex {
1370 location,
1371 type_,
1372 index,
1373 tuple,
1374 } => v.visit_typed_expr_tuple_index(location, type_, index, tuple),
1375 TypedExpr::Todo {
1376 location,
1377 message,
1378 kind,
1379 type_,
1380 } => v.visit_typed_expr_todo(location, message, kind, type_),
1381 TypedExpr::Panic {
1382 location,
1383 message,
1384 type_,
1385 } => v.visit_typed_expr_panic(location, message, type_),
1386 TypedExpr::BitArray {
1387 location,
1388 type_,
1389 segments,
1390 } => v.visit_typed_expr_bit_array(location, type_, segments),
1391 TypedExpr::RecordUpdate {
1392 location,
1393 spread_start,
1394 type_,
1395 updated_record,
1396 updated_record_assigned_name,
1397 constructor,
1398 arguments,
1399 } => v.visit_typed_expr_record_update(
1400 location,
1401 spread_start,
1402 type_,
1403 updated_record,
1404 updated_record_assigned_name,
1405 constructor,
1406 arguments,
1407 ),
1408 TypedExpr::NegateBool { location, value } => {
1409 v.visit_typed_expr_negate_bool(location, value);
1410 }
1411 TypedExpr::NegateInt { location, value } => v.visit_typed_expr_negate_int(location, value),
1412 TypedExpr::Invalid {
1413 location,
1414 type_,
1415 extra_information,
1416 } => v.visit_typed_expr_invalid(location, type_, extra_information),
1417 TypedExpr::Echo {
1418 location,
1419 expression,
1420 message,
1421 type_,
1422 } => v.visit_typed_expr_echo(location, type_, expression, message),
1423 TypedExpr::PositionalAccess { .. } => {}
1424 }
1425}
1426
1427pub fn visit_typed_expr_int<'a, V>(
1428 _v: &mut V,
1429 _location: &'a SrcSpan,
1430 _type_: &'a Arc<Type>,
1431 _value: &'a EcoString,
1432) where
1433 V: Visit<'a> + ?Sized,
1434{
1435}
1436
1437pub fn visit_typed_expr_float<'a, V>(
1438 _v: &mut V,
1439 _location: &'a SrcSpan,
1440 _type_: &'a Arc<Type>,
1441 _value: &'a EcoString,
1442) where
1443 V: Visit<'a> + ?Sized,
1444{
1445}
1446
1447pub fn visit_typed_expr_string<'a, V>(
1448 _v: &mut V,
1449 _location: &'a SrcSpan,
1450 _type_: &'a Arc<Type>,
1451 _value: &'a EcoString,
1452) where
1453 V: Visit<'a> + ?Sized,
1454{
1455}
1456
1457pub fn visit_typed_expr_block<'a, V>(
1458 v: &mut V,
1459 _location: &'a SrcSpan,
1460 statements: &'a [TypedStatement],
1461) where
1462 V: Visit<'a> + ?Sized,
1463{
1464 for statement in statements {
1465 v.visit_typed_statement(statement);
1466 }
1467}
1468
1469pub fn visit_typed_expr_pipeline<'a, V>(
1470 v: &mut V,
1471 _location: &'a SrcSpan,
1472 first_value: &'a TypedPipelineAssignment,
1473 assignments: &'a [(TypedPipelineAssignment, PipelineAssignmentKind)],
1474 finally: &'a TypedExpr,
1475 _finally_kind: &'a PipelineAssignmentKind,
1476) where
1477 V: Visit<'a> + ?Sized,
1478{
1479 v.visit_typed_pipeline_assignment(first_value);
1480 for (assignment, _kind) in assignments {
1481 v.visit_typed_pipeline_assignment(assignment);
1482 }
1483
1484 v.visit_typed_expr(finally);
1485}
1486
1487pub fn visit_typed_pipeline_assignment<'a, V>(v: &mut V, assignment: &'a TypedPipelineAssignment)
1488where
1489 V: Visit<'a> + ?Sized,
1490{
1491 v.visit_typed_expr(&assignment.value);
1492}
1493
1494pub fn visit_typed_expr_var<'a, V>(
1495 _v: &mut V,
1496 _location: &'a SrcSpan,
1497 _constructor: &'a ValueConstructor,
1498 _name: &'a EcoString,
1499) where
1500 V: Visit<'a> + ?Sized,
1501{
1502 /* TODO */
1503}
1504
1505pub fn visit_typed_expr_fn<'a, V>(
1506 v: &mut V,
1507 _location: &'a SrcSpan,
1508 type_: &'a Arc<Type>,
1509 _kind: &'a FunctionLiteralKind,
1510 arguments: &'a [TypedArg],
1511 body: &'a Vec1<TypedStatement>,
1512 return_annotation: &'a Option<TypeAst>,
1513) where
1514 V: Visit<'a> + ?Sized,
1515{
1516 for argument in arguments {
1517 if let Some(annotation) = &argument.annotation {
1518 v.visit_type_ast(annotation, Some(argument.type_.clone()));
1519 }
1520 }
1521 if let Some(return_) = return_annotation {
1522 v.visit_type_ast(return_, type_.fn_types().map(|(_, return_)| return_));
1523 }
1524
1525 for statement in body {
1526 v.visit_typed_statement(statement);
1527 }
1528}
1529
1530pub fn visit_typed_expr_list<'a, V>(
1531 v: &mut V,
1532 _location: &'a SrcSpan,
1533 _type_: &'a Arc<Type>,
1534 elements: &'a [TypedExpr],
1535 tail: &'a Option<Box<TypedExpr>>,
1536) where
1537 V: Visit<'a> + ?Sized,
1538{
1539 for element in elements {
1540 v.visit_typed_expr(element);
1541 }
1542
1543 if let Some(tail) = tail {
1544 v.visit_typed_expr(tail);
1545 }
1546}
1547
1548pub fn visit_typed_expr_call<'a, V>(
1549 v: &mut V,
1550 _location: &'a SrcSpan,
1551 _type_: &'a Arc<Type>,
1552 fun: &'a TypedExpr,
1553 arguments: &'a [TypedCallArg],
1554 _arguments_start: &'a Option<u32>,
1555) where
1556 V: Visit<'a> + ?Sized,
1557{
1558 v.visit_typed_expr(fun);
1559 for argument in arguments {
1560 v.visit_typed_call_arg(argument);
1561 }
1562}
1563
1564pub fn visit_typed_expr_bin_op<'a, V>(
1565 v: &mut V,
1566 _location: &'a SrcSpan,
1567 _type_: &'a Arc<Type>,
1568 _operator: &'a BinOp,
1569 _operator_start: &'a u32,
1570 left: &'a TypedExpr,
1571 right: &'a TypedExpr,
1572) where
1573 V: Visit<'a> + ?Sized,
1574{
1575 v.visit_typed_expr(left);
1576 v.visit_typed_expr(right);
1577}
1578
1579pub fn visit_typed_expr_case<'a, V>(
1580 v: &mut V,
1581 _location: &'a SrcSpan,
1582 _type_: &'a Arc<Type>,
1583 subjects: &'a [TypedExpr],
1584 clauses: &'a [TypedClause],
1585 _compiled_case: &'a CompiledCase,
1586) where
1587 V: Visit<'a> + ?Sized,
1588{
1589 for subject in subjects {
1590 v.visit_typed_expr(subject);
1591 }
1592
1593 for clause in clauses {
1594 v.visit_typed_clause(clause);
1595 }
1596}
1597
1598#[allow(clippy::too_many_arguments)]
1599pub fn visit_typed_expr_record_access<'a, V>(
1600 v: &mut V,
1601 _location: &'a SrcSpan,
1602 _field_start: &'a u32,
1603 _type_: &'a Arc<Type>,
1604 _label: &'a EcoString,
1605 _index: &'a u64,
1606 record: &'a TypedExpr,
1607 _documentation: &'a Option<EcoString>,
1608) where
1609 V: Visit<'a> + ?Sized,
1610{
1611 v.visit_typed_expr(record);
1612}
1613
1614#[allow(clippy::too_many_arguments)]
1615pub fn visit_typed_expr_module_select<'a, V>(
1616 _v: &mut V,
1617 _location: &'a SrcSpan,
1618 _field_start: &'a u32,
1619 _type_: &'a Arc<Type>,
1620 _label: &'a EcoString,
1621 _module_name: &'a EcoString,
1622 _module_alias: &'a EcoString,
1623 _constructor: &'a ModuleValueConstructor,
1624) where
1625 V: Visit<'a> + ?Sized,
1626{
1627 /* TODO */
1628}
1629
1630pub fn visit_typed_expr_tuple<'a, V>(
1631 v: &mut V,
1632 _location: &'a SrcSpan,
1633 _type_: &'a Arc<Type>,
1634 elements: &'a [TypedExpr],
1635) where
1636 V: Visit<'a> + ?Sized,
1637{
1638 for element in elements {
1639 v.visit_typed_expr(element);
1640 }
1641}
1642
1643pub fn visit_typed_expr_tuple_index<'a, V>(
1644 v: &mut V,
1645 _location: &'a SrcSpan,
1646 _type_: &'a Arc<Type>,
1647 _index: &'a u64,
1648 tuple: &'a TypedExpr,
1649) where
1650 V: Visit<'a> + ?Sized,
1651{
1652 v.visit_typed_expr(tuple);
1653}
1654
1655pub fn visit_typed_expr_todo<'a, V>(
1656 v: &mut V,
1657 _location: &'a SrcSpan,
1658 message: &'a Option<Box<TypedExpr>>,
1659 _kind: &'a TodoKind,
1660 _type_: &'a Arc<Type>,
1661) where
1662 V: Visit<'a> + ?Sized,
1663{
1664 if let Some(message) = message {
1665 v.visit_typed_expr(message);
1666 }
1667}
1668
1669pub fn visit_typed_expr_echo<'a, V>(
1670 v: &mut V,
1671 _location: &'a SrcSpan,
1672 _type_: &'a Arc<Type>,
1673 expression: &'a Option<Box<TypedExpr>>,
1674 message: &'a Option<Box<TypedExpr>>,
1675) where
1676 V: Visit<'a> + ?Sized,
1677{
1678 if let Some(expression) = expression {
1679 v.visit_typed_expr(expression);
1680 }
1681 if let Some(message) = message {
1682 v.visit_typed_expr(message);
1683 }
1684}
1685
1686pub fn visit_typed_expr_panic<'a, V>(
1687 v: &mut V,
1688 _location: &'a SrcSpan,
1689 message: &'a Option<Box<TypedExpr>>,
1690 _type_: &'a Arc<Type>,
1691) where
1692 V: Visit<'a> + ?Sized,
1693{
1694 if let Some(message) = message {
1695 v.visit_typed_expr(message);
1696 }
1697}
1698
1699pub fn visit_typed_expr_bit_array<'a, V>(
1700 v: &mut V,
1701 _location: &'a SrcSpan,
1702 _type_: &'a Arc<Type>,
1703 segments: &'a [TypedExprBitArraySegment],
1704) where
1705 V: Visit<'a> + ?Sized,
1706{
1707 for segment in segments {
1708 v.visit_typed_expr_bit_array_segment(segment);
1709 }
1710}
1711
1712#[allow(clippy::too_many_arguments)]
1713pub fn visit_typed_expr_record_update<'a, V>(
1714 v: &mut V,
1715 _location: &'a SrcSpan,
1716 _spread_start: &'a u32,
1717 _type_: &'a Arc<Type>,
1718 updated_record: &'a TypedExpr,
1719 _updated_record_assigned_name: &'a Option<EcoString>,
1720 constructor: &'a TypedExpr,
1721 arguments: &'a [TypedCallArg],
1722) where
1723 V: Visit<'a> + ?Sized,
1724{
1725 v.visit_typed_expr(constructor);
1726 v.visit_typed_expr(updated_record);
1727 for argument in arguments {
1728 v.visit_typed_call_arg(argument);
1729 }
1730}
1731
1732pub fn visit_typed_expr_negate_bool<'a, V>(v: &mut V, _location: &'a SrcSpan, value: &'a TypedExpr)
1733where
1734 V: Visit<'a> + ?Sized,
1735{
1736 v.visit_typed_expr(value);
1737}
1738
1739pub fn visit_typed_expr_negate_int<'a, V>(v: &mut V, _location: &'a SrcSpan, value: &'a TypedExpr)
1740where
1741 V: Visit<'a> + ?Sized,
1742{
1743 v.visit_typed_expr(value);
1744}
1745
1746pub fn visit_typed_statement<'a, V>(v: &mut V, statement: &'a TypedStatement)
1747where
1748 V: Visit<'a> + ?Sized,
1749{
1750 match statement {
1751 Statement::Expression(expression) => v.visit_typed_expr(expression),
1752 Statement::Assignment(assignment) => v.visit_typed_assignment(assignment),
1753 Statement::Use(use_) => v.visit_typed_use(use_),
1754 Statement::Assert(assert) => v.visit_typed_assert(assert),
1755 }
1756}
1757
1758pub fn visit_typed_assignment<'a, V>(v: &mut V, assignment: &'a TypedAssignment)
1759where
1760 V: Visit<'a> + ?Sized,
1761{
1762 if let Some(annotation) = &assignment.annotation {
1763 v.visit_type_ast(annotation, Some(assignment.type_()));
1764 }
1765 v.visit_typed_expr(&assignment.value);
1766 v.visit_typed_pattern(&assignment.pattern);
1767}
1768
1769pub fn visit_typed_use<'a, V>(v: &mut V, use_: &'a TypedUse)
1770where
1771 V: Visit<'a> + ?Sized,
1772{
1773 v.visit_typed_expr(&use_.call);
1774 // TODO: We should also visit the typed patterns!!
1775}
1776
1777pub fn visit_typed_assert<'a, V>(v: &mut V, assert: &'a TypedAssert)
1778where
1779 V: Visit<'a> + ?Sized,
1780{
1781 v.visit_typed_expr(&assert.value);
1782 if let Some(message) = &assert.message {
1783 v.visit_typed_expr(message);
1784 }
1785}
1786
1787pub fn visit_typed_call_arg<'a, V>(v: &mut V, arg: &'a TypedCallArg)
1788where
1789 V: Visit<'a> + ?Sized,
1790{
1791 v.visit_typed_expr(&arg.value);
1792}
1793
1794pub fn visit_typed_clause<'a, V>(v: &mut V, clause: &'a TypedClause)
1795where
1796 V: Visit<'a> + ?Sized,
1797{
1798 for pattern in clause.pattern.iter() {
1799 v.visit_typed_pattern(pattern);
1800 }
1801 for patterns in clause.alternative_patterns.iter() {
1802 for pattern in patterns {
1803 v.visit_typed_pattern(pattern);
1804 }
1805 }
1806 if let Some(guard) = &clause.guard {
1807 v.visit_typed_clause_guard(guard);
1808 }
1809 v.visit_typed_expr(&clause.then);
1810}
1811
1812pub fn visit_typed_clause_guard<'a, V>(v: &mut V, guard: &'a TypedClauseGuard)
1813where
1814 V: Visit<'a> + ?Sized,
1815{
1816 match guard {
1817 super::ClauseGuard::BinaryOperator {
1818 left,
1819 right,
1820 location,
1821 operator,
1822 operator_start,
1823 } => v.visit_typed_clause_guard_bin_op(left, right, operator, operator_start, location),
1824 super::ClauseGuard::Block { location: _, value } => v.visit_typed_clause_guard(value),
1825 super::ClauseGuard::Not {
1826 location: _,
1827 expression,
1828 } => v.visit_typed_clause_guard(expression),
1829 super::ClauseGuard::Var {
1830 location,
1831 type_,
1832 name,
1833 definition_location,
1834 origin,
1835 } => v.visit_typed_clause_guard_var(location, name, type_, definition_location, origin),
1836 super::ClauseGuard::TupleIndex {
1837 location,
1838 index,
1839 type_,
1840 tuple,
1841 } => v.visit_typed_clause_guard_tuple_index(location, index, type_, tuple),
1842 super::ClauseGuard::FieldAccess {
1843 label_location,
1844 index,
1845 label,
1846 type_,
1847 container,
1848 } => {
1849 v.visit_typed_clause_guard_field_access(label_location, index, label, type_, container);
1850 }
1851 super::ClauseGuard::ModuleSelect {
1852 location,
1853 field_start,
1854 definition_location,
1855 type_,
1856 label,
1857 module_name,
1858 module_alias,
1859 literal,
1860 } => v.visit_typed_clause_guard_module_select(
1861 location,
1862 field_start,
1863 definition_location,
1864 type_,
1865 label,
1866 module_name,
1867 module_alias,
1868 literal,
1869 ),
1870 super::ClauseGuard::Constant(constant) => v.visit_typed_constant(constant),
1871 super::ClauseGuard::Invalid { .. } => (),
1872 }
1873}
1874
1875pub fn visit_typed_clause_guard_bin_op<'a, V>(
1876 v: &mut V,
1877 left: &'a TypedClauseGuard,
1878 right: &'a TypedClauseGuard,
1879 _operator: &'a BinOp,
1880 _operator_start: &'a u32,
1881 _location: &'a SrcSpan,
1882) where
1883 V: Visit<'a> + ?Sized,
1884{
1885 v.visit_typed_clause_guard(left);
1886 v.visit_typed_clause_guard(right);
1887}
1888
1889pub fn visit_typed_clause_guard_var<'a, V>(
1890 _v: &mut V,
1891 _location: &'a SrcSpan,
1892 _name: &'a EcoString,
1893 _type_: &'a Arc<Type>,
1894 _definition_location: &'a SrcSpan,
1895 _origin: &'a VariableOrigin,
1896) where
1897 V: Visit<'a> + ?Sized,
1898{
1899}
1900
1901pub fn visit_typed_clause_guard_tuple_index<'a, V>(
1902 v: &mut V,
1903 _location: &'a SrcSpan,
1904 _index: &'a u64,
1905 _type_: &'a Arc<Type>,
1906 tuple: &'a TypedClauseGuard,
1907) where
1908 V: Visit<'a> + ?Sized,
1909{
1910 v.visit_typed_clause_guard(tuple);
1911}
1912
1913pub fn visit_typed_clause_guard_field_access<'a, V>(
1914 v: &mut V,
1915 _label_location: &'a SrcSpan,
1916 _index: &'a Option<u64>,
1917 _label: &'a EcoString,
1918 _type_: &'a Arc<Type>,
1919 container: &'a TypedClauseGuard,
1920) where
1921 V: Visit<'a> + ?Sized,
1922{
1923 v.visit_typed_clause_guard(container);
1924}
1925
1926#[allow(clippy::too_many_arguments)]
1927pub fn visit_typed_clause_guard_module_select<'a, V>(
1928 _v: &mut V,
1929 _location: &'a SrcSpan,
1930 _field_start: &'a u32,
1931 _definition_location: &'a SrcSpan,
1932 _type_: &'a Arc<Type>,
1933 _label: &'a EcoString,
1934 _module_name: &'a EcoString,
1935 _module_alias: &'a EcoString,
1936 _literal: &'a TypedConstant,
1937) where
1938 V: Visit<'a> + ?Sized,
1939{
1940}
1941
1942pub fn visit_typed_expr_bit_array_segment<'a, V>(v: &mut V, segment: &'a TypedExprBitArraySegment)
1943where
1944 V: Visit<'a> + ?Sized,
1945{
1946 v.visit_typed_expr(&segment.value);
1947 for option in &segment.options {
1948 v.visit_typed_bit_array_option(option);
1949 }
1950}
1951
1952pub fn visit_typed_bit_array_option<'a, V>(v: &mut V, option: &'a BitArrayOption<TypedExpr>)
1953where
1954 V: Visit<'a> + ?Sized,
1955{
1956 match option {
1957 BitArrayOption::Bytes { location: _ } => { /* TODO */ }
1958 BitArrayOption::Int { location: _ } => { /* TODO */ }
1959 BitArrayOption::Float { location: _ } => { /* TODO */ }
1960 BitArrayOption::Bits { location: _ } => { /* TODO */ }
1961 BitArrayOption::Utf8 { location: _ } => { /* TODO */ }
1962 BitArrayOption::Utf16 { location: _ } => { /* TODO */ }
1963 BitArrayOption::Utf32 { location: _ } => { /* TODO */ }
1964 BitArrayOption::Utf8Codepoint { location: _ } => { /* TODO */ }
1965 BitArrayOption::Utf16Codepoint { location: _ } => { /* TODO */ }
1966 BitArrayOption::Utf32Codepoint { location: _ } => { /* TODO */ }
1967 BitArrayOption::Signed { location: _ } => { /* TODO */ }
1968 BitArrayOption::Unsigned { location: _ } => { /* TODO */ }
1969 BitArrayOption::Big { location: _ } => { /* TODO */ }
1970 BitArrayOption::Little { location: _ } => { /* TODO */ }
1971 BitArrayOption::Native { location: _ } => { /* TODO */ }
1972 BitArrayOption::Size {
1973 location: _,
1974 value,
1975 short_form: _,
1976 } => {
1977 v.visit_typed_expr(value);
1978 }
1979 BitArrayOption::Unit {
1980 location: _,
1981 value: _,
1982 } => { /* TODO */ }
1983 }
1984}
1985
1986pub fn visit_typed_pattern<'a, V>(v: &mut V, pattern: &'a TypedPattern)
1987where
1988 V: Visit<'a> + ?Sized,
1989{
1990 match pattern {
1991 Pattern::Int {
1992 location,
1993 value,
1994 int_value: _,
1995 } => v.visit_typed_pattern_int(location, value),
1996 Pattern::Float {
1997 location,
1998 value,
1999 float_value: _,
2000 } => v.visit_typed_pattern_float(location, value),
2001 Pattern::String { location, value } => v.visit_typed_pattern_string(location, value),
2002 Pattern::Variable {
2003 location,
2004 name,
2005 type_,
2006 origin,
2007 } => v.visit_typed_pattern_variable(location, name, type_, origin),
2008 Pattern::BitArraySize(size) => v.visit_typed_pattern_bit_array_size(size),
2009 Pattern::Assign {
2010 location,
2011 name,
2012 pattern,
2013 } => v.visit_typed_pattern_assign(location, name, pattern),
2014 Pattern::Discard {
2015 location,
2016 name,
2017 type_,
2018 } => v.visit_typed_pattern_discard(location, name, type_),
2019 Pattern::List {
2020 location,
2021 elements,
2022 tail,
2023 type_,
2024 } => v.visit_typed_pattern_list(location, elements, tail, type_),
2025 Pattern::Constructor {
2026 location,
2027 name_location,
2028 name,
2029 arguments,
2030 module,
2031 constructor,
2032 spread,
2033 type_,
2034 } => v.visit_typed_pattern_constructor(
2035 location,
2036 name_location,
2037 name,
2038 arguments,
2039 module,
2040 constructor,
2041 spread,
2042 type_,
2043 ),
2044 Pattern::Tuple { location, elements } => v.visit_typed_pattern_tuple(location, elements),
2045 Pattern::BitArray { location, segments } => {
2046 v.visit_typed_pattern_bit_array(location, segments);
2047 }
2048 Pattern::StringPrefix {
2049 location,
2050 left_location,
2051 left_side_assignment,
2052 right_location,
2053 left_side_string,
2054 right_side_assignment,
2055 } => v.visit_typed_pattern_string_prefix(
2056 location,
2057 left_location,
2058 left_side_assignment,
2059 right_location,
2060 left_side_string,
2061 right_side_assignment,
2062 ),
2063 Pattern::Invalid { location, type_ } => v.visit_typed_pattern_invalid(location, type_),
2064 }
2065}
2066
2067fn visit_typed_pattern_int<'a, V>(_v: &mut V, _location: &'a SrcSpan, _value: &'a EcoString)
2068where
2069 V: Visit<'a> + ?Sized,
2070{
2071}
2072
2073pub fn visit_typed_pattern_float<'a, V>(_v: &mut V, _location: &'a SrcSpan, _value: &'a EcoString)
2074where
2075 V: Visit<'a> + ?Sized,
2076{
2077}
2078
2079pub fn visit_typed_pattern_string<'a, V>(_v: &mut V, _location: &'a SrcSpan, _value: &'a EcoString)
2080where
2081 V: Visit<'a> + ?Sized,
2082{
2083}
2084
2085pub fn visit_typed_pattern_variable<'a, V>(
2086 _v: &mut V,
2087 _location: &'a SrcSpan,
2088 _name: &'a EcoString,
2089 _type_: &'a Arc<Type>,
2090 _origin: &'a VariableOrigin,
2091) where
2092 V: Visit<'a> + ?Sized,
2093{
2094}
2095
2096pub fn visit_typed_pattern_bit_array_size<'a, V>(v: &mut V, size: &'a TypedBitArraySize)
2097where
2098 V: Visit<'a> + ?Sized,
2099{
2100 match size {
2101 BitArraySize::Int {
2102 location,
2103 value,
2104 int_value: _,
2105 } => v.visit_typed_bit_array_size_int(location, value),
2106 BitArraySize::Variable {
2107 location,
2108 name,
2109 constructor,
2110 type_,
2111 } => v.visit_typed_bit_array_size_variable(location, name, constructor, type_),
2112 BitArraySize::BinaryOperator { left, right, .. } => {
2113 v.visit_typed_pattern_bit_array_size(left);
2114 v.visit_typed_pattern_bit_array_size(right);
2115 }
2116 BitArraySize::Block { inner, .. } => v.visit_typed_pattern_bit_array_size(inner),
2117 }
2118}
2119
2120pub fn visit_typed_bit_array_size_int<'a, V>(
2121 _v: &mut V,
2122 _location: &'a SrcSpan,
2123 _value: &'a EcoString,
2124) where
2125 V: Visit<'a> + ?Sized,
2126{
2127}
2128
2129pub fn visit_typed_bit_array_size_variable<'a, V>(
2130 _v: &mut V,
2131 _location: &'a SrcSpan,
2132 _name: &'a EcoString,
2133 _constructor: &'a Option<Box<ValueConstructor>>,
2134 _type_: &'a Arc<Type>,
2135) where
2136 V: Visit<'a> + ?Sized,
2137{
2138}
2139
2140pub fn visit_typed_pattern_assign<'a, V>(
2141 v: &mut V,
2142 _location: &'a SrcSpan,
2143 _name: &'a EcoString,
2144 pattern: &'a TypedPattern,
2145) where
2146 V: Visit<'a> + ?Sized,
2147{
2148 v.visit_typed_pattern(pattern);
2149}
2150
2151pub fn visit_typed_pattern_discard<'a, V>(
2152 _v: &mut V,
2153 _location: &'a SrcSpan,
2154 _name: &'a EcoString,
2155 _type_: &'a Arc<Type>,
2156) where
2157 V: Visit<'a> + ?Sized,
2158{
2159}
2160
2161pub fn visit_typed_pattern_list<'a, V>(
2162 v: &mut V,
2163 _location: &'a SrcSpan,
2164 elements: &'a Vec<TypedPattern>,
2165 tail: &'a Option<Box<TypedTailPattern>>,
2166 _type_: &'a Arc<Type>,
2167) where
2168 V: Visit<'a> + ?Sized,
2169{
2170 for element in elements {
2171 v.visit_typed_pattern(element);
2172 }
2173 if let Some(tail) = tail {
2174 v.visit_typed_pattern(&tail.pattern);
2175 }
2176}
2177
2178#[allow(clippy::too_many_arguments)]
2179pub fn visit_typed_pattern_constructor<'a, V>(
2180 v: &mut V,
2181 _location: &'a SrcSpan,
2182 _name_location: &'a SrcSpan,
2183 _name: &'a EcoString,
2184 arguments: &'a Vec<CallArg<TypedPattern>>,
2185 _module: &'a Option<(EcoString, SrcSpan)>,
2186 _constructor: &'a Inferred<PatternConstructor>,
2187 _spread: &'a Option<SrcSpan>,
2188 _type_: &'a Arc<Type>,
2189) where
2190 V: Visit<'a> + ?Sized,
2191{
2192 for argument in arguments {
2193 v.visit_typed_pattern_call_arg(argument);
2194 }
2195}
2196
2197pub fn visit_typed_pattern_call_arg<'a, V>(v: &mut V, argument: &'a CallArg<TypedPattern>)
2198where
2199 V: Visit<'a> + ?Sized,
2200{
2201 v.visit_typed_pattern(&argument.value);
2202}
2203
2204pub fn visit_typed_pattern_tuple<'a, V>(
2205 v: &mut V,
2206 _location: &'a SrcSpan,
2207 elements: &'a Vec<TypedPattern>,
2208) where
2209 V: Visit<'a> + ?Sized,
2210{
2211 for element in elements {
2212 v.visit_typed_pattern(element);
2213 }
2214}
2215
2216pub fn visit_typed_pattern_bit_array<'a, V>(
2217 v: &mut V,
2218 _location: &'a SrcSpan,
2219 segments: &'a [TypedPatternBitArraySegment],
2220) where
2221 V: Visit<'a> + ?Sized,
2222{
2223 for segment in segments {
2224 v.visit_typed_pattern(&segment.value);
2225 for option in segment.options.iter() {
2226 v.visit_typed_pattern_bit_array_option(option);
2227 }
2228 }
2229}
2230
2231pub fn visit_typed_pattern_bit_array_option<'a, V>(
2232 v: &mut V,
2233 option: &'a BitArrayOption<TypedPattern>,
2234) where
2235 V: Visit<'a> + ?Sized,
2236{
2237 match option {
2238 BitArrayOption::Bytes { location: _ } => { /* TODO */ }
2239 BitArrayOption::Int { location: _ } => { /* TODO */ }
2240 BitArrayOption::Float { location: _ } => { /* TODO */ }
2241 BitArrayOption::Bits { location: _ } => { /* TODO */ }
2242 BitArrayOption::Utf8 { location: _ } => { /* TODO */ }
2243 BitArrayOption::Utf16 { location: _ } => { /* TODO */ }
2244 BitArrayOption::Utf32 { location: _ } => { /* TODO */ }
2245 BitArrayOption::Utf8Codepoint { location: _ } => { /* TODO */ }
2246 BitArrayOption::Utf16Codepoint { location: _ } => { /* TODO */ }
2247 BitArrayOption::Utf32Codepoint { location: _ } => { /* TODO */ }
2248 BitArrayOption::Signed { location: _ } => { /* TODO */ }
2249 BitArrayOption::Unsigned { location: _ } => { /* TODO */ }
2250 BitArrayOption::Big { location: _ } => { /* TODO */ }
2251 BitArrayOption::Little { location: _ } => { /* TODO */ }
2252 BitArrayOption::Native { location: _ } => { /* TODO */ }
2253 BitArrayOption::Size {
2254 location: _,
2255 value,
2256 short_form: _,
2257 } => {
2258 v.visit_typed_pattern(value);
2259 }
2260 BitArrayOption::Unit {
2261 location: _,
2262 value: _,
2263 } => { /* TODO */ }
2264 }
2265}
2266
2267pub fn visit_typed_pattern_string_prefix<'a, V>(
2268 _v: &mut V,
2269 _location: &'a SrcSpan,
2270 _left_location: &'a SrcSpan,
2271 _left_side_assignment: &'a Option<(EcoString, SrcSpan)>,
2272 _right_location: &'a SrcSpan,
2273 _left_side_string: &'a EcoString,
2274 _right_side_assignment: &'a AssignName,
2275) where
2276 V: Visit<'a> + ?Sized,
2277{
2278}
2279
2280pub fn visit_typed_pattern_invalid<'a, V>(_v: &mut V, _location: &'a SrcSpan, _type_: &'a Arc<Type>)
2281where
2282 V: Visit<'a> + ?Sized,
2283{
2284}
2285
2286pub fn visit_typed_expr_invalid<'a, V>(
2287 _v: &mut V,
2288 _location: &'a SrcSpan,
2289 _type_: &'a Arc<Type>,
2290 _extra_information: &'a Option<InvalidExpression>,
2291) where
2292 V: Visit<'a> + ?Sized,
2293{
2294}