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