Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

gleam / compiler-core / src / ast / visit.rs
64 kB 2297 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.clone()); 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( 1523 return_, 1524 type_.fn_types().map(|(_, return_)| return_.clone()), 1525 ); 1526 } 1527 1528 for statement in body { 1529 v.visit_typed_statement(statement); 1530 } 1531} 1532 1533pub fn visit_typed_expr_list<'a, V>( 1534 v: &mut V, 1535 _location: &'a SrcSpan, 1536 _type_: &'a Arc<Type>, 1537 elements: &'a [TypedExpr], 1538 tail: &'a Option<Box<TypedExpr>>, 1539) where 1540 V: Visit<'a> + ?Sized, 1541{ 1542 for element in elements { 1543 v.visit_typed_expr(element); 1544 } 1545 1546 if let Some(tail) = tail { 1547 v.visit_typed_expr(tail); 1548 } 1549} 1550 1551pub fn visit_typed_expr_call<'a, V>( 1552 v: &mut V, 1553 _location: &'a SrcSpan, 1554 _type_: &'a Arc<Type>, 1555 fun: &'a TypedExpr, 1556 arguments: &'a [TypedCallArg], 1557 _arguments_start: &'a Option<u32>, 1558) where 1559 V: Visit<'a> + ?Sized, 1560{ 1561 v.visit_typed_expr(fun); 1562 for argument in arguments { 1563 v.visit_typed_call_arg(argument); 1564 } 1565} 1566 1567pub fn visit_typed_expr_bin_op<'a, V>( 1568 v: &mut V, 1569 _location: &'a SrcSpan, 1570 _type_: &'a Arc<Type>, 1571 _operator: &'a BinOp, 1572 _operator_start: &'a u32, 1573 left: &'a TypedExpr, 1574 right: &'a TypedExpr, 1575) where 1576 V: Visit<'a> + ?Sized, 1577{ 1578 v.visit_typed_expr(left); 1579 v.visit_typed_expr(right); 1580} 1581 1582pub fn visit_typed_expr_case<'a, V>( 1583 v: &mut V, 1584 _location: &'a SrcSpan, 1585 _type_: &'a Arc<Type>, 1586 subjects: &'a [TypedExpr], 1587 clauses: &'a [TypedClause], 1588 _compiled_case: &'a CompiledCase, 1589) where 1590 V: Visit<'a> + ?Sized, 1591{ 1592 for subject in subjects { 1593 v.visit_typed_expr(subject); 1594 } 1595 1596 for clause in clauses { 1597 v.visit_typed_clause(clause); 1598 } 1599} 1600 1601#[allow(clippy::too_many_arguments)] 1602pub fn visit_typed_expr_record_access<'a, V>( 1603 v: &mut V, 1604 _location: &'a SrcSpan, 1605 _field_start: &'a u32, 1606 _type_: &'a Arc<Type>, 1607 _label: &'a EcoString, 1608 _index: &'a u64, 1609 record: &'a TypedExpr, 1610 _documentation: &'a Option<EcoString>, 1611) where 1612 V: Visit<'a> + ?Sized, 1613{ 1614 v.visit_typed_expr(record); 1615} 1616 1617#[allow(clippy::too_many_arguments)] 1618pub fn visit_typed_expr_module_select<'a, V>( 1619 _v: &mut V, 1620 _location: &'a SrcSpan, 1621 _field_start: &'a u32, 1622 _type_: &'a Arc<Type>, 1623 _label: &'a EcoString, 1624 _module_name: &'a EcoString, 1625 _module_alias: &'a EcoString, 1626 _constructor: &'a ModuleValueConstructor, 1627) where 1628 V: Visit<'a> + ?Sized, 1629{ 1630 /* TODO */ 1631} 1632 1633pub fn visit_typed_expr_tuple<'a, V>( 1634 v: &mut V, 1635 _location: &'a SrcSpan, 1636 _type_: &'a Arc<Type>, 1637 elements: &'a [TypedExpr], 1638) where 1639 V: Visit<'a> + ?Sized, 1640{ 1641 for element in elements { 1642 v.visit_typed_expr(element); 1643 } 1644} 1645 1646pub fn visit_typed_expr_tuple_index<'a, V>( 1647 v: &mut V, 1648 _location: &'a SrcSpan, 1649 _type_: &'a Arc<Type>, 1650 _index: &'a u64, 1651 tuple: &'a TypedExpr, 1652) where 1653 V: Visit<'a> + ?Sized, 1654{ 1655 v.visit_typed_expr(tuple); 1656} 1657 1658pub fn visit_typed_expr_todo<'a, V>( 1659 v: &mut V, 1660 _location: &'a SrcSpan, 1661 message: &'a Option<Box<TypedExpr>>, 1662 _kind: &'a TodoKind, 1663 _type_: &'a Arc<Type>, 1664) where 1665 V: Visit<'a> + ?Sized, 1666{ 1667 if let Some(message) = message { 1668 v.visit_typed_expr(message); 1669 } 1670} 1671 1672pub fn visit_typed_expr_echo<'a, V>( 1673 v: &mut V, 1674 _location: &'a SrcSpan, 1675 _type_: &'a Arc<Type>, 1676 expression: &'a Option<Box<TypedExpr>>, 1677 message: &'a Option<Box<TypedExpr>>, 1678) where 1679 V: Visit<'a> + ?Sized, 1680{ 1681 if let Some(expression) = expression { 1682 v.visit_typed_expr(expression) 1683 } 1684 if let Some(message) = message { 1685 v.visit_typed_expr(message) 1686 } 1687} 1688 1689pub fn visit_typed_expr_panic<'a, V>( 1690 v: &mut V, 1691 _location: &'a SrcSpan, 1692 message: &'a Option<Box<TypedExpr>>, 1693 _type_: &'a Arc<Type>, 1694) where 1695 V: Visit<'a> + ?Sized, 1696{ 1697 if let Some(message) = message { 1698 v.visit_typed_expr(message); 1699 } 1700} 1701 1702pub fn visit_typed_expr_bit_array<'a, V>( 1703 v: &mut V, 1704 _location: &'a SrcSpan, 1705 _type_: &'a Arc<Type>, 1706 segments: &'a [TypedExprBitArraySegment], 1707) where 1708 V: Visit<'a> + ?Sized, 1709{ 1710 for segment in segments { 1711 v.visit_typed_expr_bit_array_segment(segment); 1712 } 1713} 1714 1715#[allow(clippy::too_many_arguments)] 1716pub fn visit_typed_expr_record_update<'a, V>( 1717 v: &mut V, 1718 _location: &'a SrcSpan, 1719 _spread_start: &'a u32, 1720 _type_: &'a Arc<Type>, 1721 updated_record: &'a TypedExpr, 1722 _updated_record_assigned_name: &'a Option<EcoString>, 1723 constructor: &'a TypedExpr, 1724 arguments: &'a [TypedCallArg], 1725) where 1726 V: Visit<'a> + ?Sized, 1727{ 1728 v.visit_typed_expr(constructor); 1729 v.visit_typed_expr(updated_record); 1730 for argument in arguments { 1731 v.visit_typed_call_arg(argument); 1732 } 1733} 1734 1735pub fn visit_typed_expr_negate_bool<'a, V>(v: &mut V, _location: &'a SrcSpan, value: &'a TypedExpr) 1736where 1737 V: Visit<'a> + ?Sized, 1738{ 1739 v.visit_typed_expr(value); 1740} 1741 1742pub fn visit_typed_expr_negate_int<'a, V>(v: &mut V, _location: &'a SrcSpan, value: &'a TypedExpr) 1743where 1744 V: Visit<'a> + ?Sized, 1745{ 1746 v.visit_typed_expr(value); 1747} 1748 1749pub fn visit_typed_statement<'a, V>(v: &mut V, statement: &'a TypedStatement) 1750where 1751 V: Visit<'a> + ?Sized, 1752{ 1753 match statement { 1754 Statement::Expression(expression) => v.visit_typed_expr(expression), 1755 Statement::Assignment(assignment) => v.visit_typed_assignment(assignment), 1756 Statement::Use(use_) => v.visit_typed_use(use_), 1757 Statement::Assert(assert) => v.visit_typed_assert(assert), 1758 } 1759} 1760 1761pub fn visit_typed_assignment<'a, V>(v: &mut V, assignment: &'a TypedAssignment) 1762where 1763 V: Visit<'a> + ?Sized, 1764{ 1765 if let Some(annotation) = &assignment.annotation { 1766 v.visit_type_ast(annotation, Some(assignment.type_())); 1767 } 1768 v.visit_typed_expr(&assignment.value); 1769 v.visit_typed_pattern(&assignment.pattern); 1770} 1771 1772pub fn visit_typed_use<'a, V>(v: &mut V, use_: &'a TypedUse) 1773where 1774 V: Visit<'a> + ?Sized, 1775{ 1776 v.visit_typed_expr(&use_.call); 1777 // TODO: We should also visit the typed patterns!! 1778} 1779 1780pub fn visit_typed_assert<'a, V>(v: &mut V, assert: &'a TypedAssert) 1781where 1782 V: Visit<'a> + ?Sized, 1783{ 1784 v.visit_typed_expr(&assert.value); 1785 if let Some(message) = &assert.message { 1786 v.visit_typed_expr(message); 1787 } 1788} 1789 1790pub fn visit_typed_call_arg<'a, V>(v: &mut V, arg: &'a TypedCallArg) 1791where 1792 V: Visit<'a> + ?Sized, 1793{ 1794 v.visit_typed_expr(&arg.value); 1795} 1796 1797pub fn visit_typed_clause<'a, V>(v: &mut V, clause: &'a TypedClause) 1798where 1799 V: Visit<'a> + ?Sized, 1800{ 1801 for pattern in clause.pattern.iter() { 1802 v.visit_typed_pattern(pattern); 1803 } 1804 for patterns in clause.alternative_patterns.iter() { 1805 for pattern in patterns { 1806 v.visit_typed_pattern(pattern); 1807 } 1808 } 1809 if let Some(guard) = &clause.guard { 1810 v.visit_typed_clause_guard(guard); 1811 } 1812 v.visit_typed_expr(&clause.then); 1813} 1814 1815pub fn visit_typed_clause_guard<'a, V>(v: &mut V, guard: &'a TypedClauseGuard) 1816where 1817 V: Visit<'a> + ?Sized, 1818{ 1819 match guard { 1820 super::ClauseGuard::BinaryOperator { 1821 left, 1822 right, 1823 location, 1824 operator, 1825 operator_start, 1826 } => v.visit_typed_clause_guard_bin_op(left, right, operator, operator_start, location), 1827 super::ClauseGuard::Block { location: _, value } => v.visit_typed_clause_guard(value), 1828 super::ClauseGuard::Not { 1829 location: _, 1830 expression, 1831 } => v.visit_typed_clause_guard(expression), 1832 super::ClauseGuard::Var { 1833 location, 1834 type_, 1835 name, 1836 definition_location, 1837 origin, 1838 } => v.visit_typed_clause_guard_var(location, name, type_, definition_location, origin), 1839 super::ClauseGuard::TupleIndex { 1840 location, 1841 index, 1842 type_, 1843 tuple, 1844 } => v.visit_typed_clause_guard_tuple_index(location, index, type_, tuple), 1845 super::ClauseGuard::FieldAccess { 1846 label_location, 1847 index, 1848 label, 1849 type_, 1850 container, 1851 } => { 1852 v.visit_typed_clause_guard_field_access(label_location, index, label, type_, container) 1853 } 1854 super::ClauseGuard::ModuleSelect { 1855 location, 1856 field_start, 1857 definition_location, 1858 type_, 1859 label, 1860 module_name, 1861 module_alias, 1862 literal, 1863 } => v.visit_typed_clause_guard_module_select( 1864 location, 1865 field_start, 1866 definition_location, 1867 type_, 1868 label, 1869 module_name, 1870 module_alias, 1871 literal, 1872 ), 1873 super::ClauseGuard::Constant(constant) => v.visit_typed_constant(constant), 1874 super::ClauseGuard::Invalid { .. } => (), 1875 } 1876} 1877 1878pub fn visit_typed_clause_guard_bin_op<'a, V>( 1879 v: &mut V, 1880 left: &'a TypedClauseGuard, 1881 right: &'a TypedClauseGuard, 1882 _operator: &'a BinOp, 1883 _operator_start: &'a u32, 1884 _location: &'a SrcSpan, 1885) where 1886 V: Visit<'a> + ?Sized, 1887{ 1888 v.visit_typed_clause_guard(left); 1889 v.visit_typed_clause_guard(right); 1890} 1891 1892pub fn visit_typed_clause_guard_var<'a, V>( 1893 _v: &mut V, 1894 _location: &'a SrcSpan, 1895 _name: &'a EcoString, 1896 _type_: &'a Arc<Type>, 1897 _definition_location: &'a SrcSpan, 1898 _origin: &'a VariableOrigin, 1899) where 1900 V: Visit<'a> + ?Sized, 1901{ 1902} 1903 1904pub fn visit_typed_clause_guard_tuple_index<'a, V>( 1905 v: &mut V, 1906 _location: &'a SrcSpan, 1907 _index: &'a u64, 1908 _type_: &'a Arc<Type>, 1909 tuple: &'a TypedClauseGuard, 1910) where 1911 V: Visit<'a> + ?Sized, 1912{ 1913 v.visit_typed_clause_guard(tuple); 1914} 1915 1916pub fn visit_typed_clause_guard_field_access<'a, V>( 1917 v: &mut V, 1918 _label_location: &'a SrcSpan, 1919 _index: &'a Option<u64>, 1920 _label: &'a EcoString, 1921 _type_: &'a Arc<Type>, 1922 container: &'a TypedClauseGuard, 1923) where 1924 V: Visit<'a> + ?Sized, 1925{ 1926 v.visit_typed_clause_guard(container); 1927} 1928 1929#[allow(clippy::too_many_arguments)] 1930pub fn visit_typed_clause_guard_module_select<'a, V>( 1931 _v: &mut V, 1932 _location: &'a SrcSpan, 1933 _field_start: &'a u32, 1934 _definition_location: &'a SrcSpan, 1935 _type_: &'a Arc<Type>, 1936 _label: &'a EcoString, 1937 _module_name: &'a EcoString, 1938 _module_alias: &'a EcoString, 1939 _literal: &'a TypedConstant, 1940) where 1941 V: Visit<'a> + ?Sized, 1942{ 1943} 1944 1945pub fn visit_typed_expr_bit_array_segment<'a, V>(v: &mut V, segment: &'a TypedExprBitArraySegment) 1946where 1947 V: Visit<'a> + ?Sized, 1948{ 1949 v.visit_typed_expr(&segment.value); 1950 for option in &segment.options { 1951 v.visit_typed_bit_array_option(option); 1952 } 1953} 1954 1955pub fn visit_typed_bit_array_option<'a, V>(v: &mut V, option: &'a BitArrayOption<TypedExpr>) 1956where 1957 V: Visit<'a> + ?Sized, 1958{ 1959 match option { 1960 BitArrayOption::Bytes { location: _ } => { /* TODO */ } 1961 BitArrayOption::Int { location: _ } => { /* TODO */ } 1962 BitArrayOption::Float { location: _ } => { /* TODO */ } 1963 BitArrayOption::Bits { location: _ } => { /* TODO */ } 1964 BitArrayOption::Utf8 { location: _ } => { /* TODO */ } 1965 BitArrayOption::Utf16 { location: _ } => { /* TODO */ } 1966 BitArrayOption::Utf32 { location: _ } => { /* TODO */ } 1967 BitArrayOption::Utf8Codepoint { location: _ } => { /* TODO */ } 1968 BitArrayOption::Utf16Codepoint { location: _ } => { /* TODO */ } 1969 BitArrayOption::Utf32Codepoint { location: _ } => { /* TODO */ } 1970 BitArrayOption::Signed { location: _ } => { /* TODO */ } 1971 BitArrayOption::Unsigned { location: _ } => { /* TODO */ } 1972 BitArrayOption::Big { location: _ } => { /* TODO */ } 1973 BitArrayOption::Little { location: _ } => { /* TODO */ } 1974 BitArrayOption::Native { location: _ } => { /* TODO */ } 1975 BitArrayOption::Size { 1976 location: _, 1977 value, 1978 short_form: _, 1979 } => { 1980 v.visit_typed_expr(value); 1981 } 1982 BitArrayOption::Unit { 1983 location: _, 1984 value: _, 1985 } => { /* TODO */ } 1986 } 1987} 1988 1989pub fn visit_typed_pattern<'a, V>(v: &mut V, pattern: &'a TypedPattern) 1990where 1991 V: Visit<'a> + ?Sized, 1992{ 1993 match pattern { 1994 Pattern::Int { 1995 location, 1996 value, 1997 int_value: _, 1998 } => v.visit_typed_pattern_int(location, value), 1999 Pattern::Float { 2000 location, 2001 value, 2002 float_value: _, 2003 } => v.visit_typed_pattern_float(location, value), 2004 Pattern::String { location, value } => v.visit_typed_pattern_string(location, value), 2005 Pattern::Variable { 2006 location, 2007 name, 2008 type_, 2009 origin, 2010 } => v.visit_typed_pattern_variable(location, name, type_, origin), 2011 Pattern::BitArraySize(size) => v.visit_typed_pattern_bit_array_size(size), 2012 Pattern::Assign { 2013 location, 2014 name, 2015 pattern, 2016 } => v.visit_typed_pattern_assign(location, name, pattern), 2017 Pattern::Discard { 2018 location, 2019 name, 2020 type_, 2021 } => v.visit_typed_pattern_discard(location, name, type_), 2022 Pattern::List { 2023 location, 2024 elements, 2025 tail, 2026 type_, 2027 } => v.visit_typed_pattern_list(location, elements, tail, type_), 2028 Pattern::Constructor { 2029 location, 2030 name_location, 2031 name, 2032 arguments, 2033 module, 2034 constructor, 2035 spread, 2036 type_, 2037 } => v.visit_typed_pattern_constructor( 2038 location, 2039 name_location, 2040 name, 2041 arguments, 2042 module, 2043 constructor, 2044 spread, 2045 type_, 2046 ), 2047 Pattern::Tuple { location, elements } => v.visit_typed_pattern_tuple(location, elements), 2048 Pattern::BitArray { location, segments } => { 2049 v.visit_typed_pattern_bit_array(location, segments) 2050 } 2051 Pattern::StringPrefix { 2052 location, 2053 left_location, 2054 left_side_assignment, 2055 right_location, 2056 left_side_string, 2057 right_side_assignment, 2058 } => v.visit_typed_pattern_string_prefix( 2059 location, 2060 left_location, 2061 left_side_assignment, 2062 right_location, 2063 left_side_string, 2064 right_side_assignment, 2065 ), 2066 Pattern::Invalid { location, type_ } => v.visit_typed_pattern_invalid(location, type_), 2067 } 2068} 2069 2070fn visit_typed_pattern_int<'a, V>(_v: &mut V, _location: &'a SrcSpan, _value: &'a EcoString) 2071where 2072 V: Visit<'a> + ?Sized, 2073{ 2074} 2075 2076pub fn visit_typed_pattern_float<'a, V>(_v: &mut V, _location: &'a SrcSpan, _value: &'a EcoString) 2077where 2078 V: Visit<'a> + ?Sized, 2079{ 2080} 2081 2082pub fn visit_typed_pattern_string<'a, V>(_v: &mut V, _location: &'a SrcSpan, _value: &'a EcoString) 2083where 2084 V: Visit<'a> + ?Sized, 2085{ 2086} 2087 2088pub fn visit_typed_pattern_variable<'a, V>( 2089 _v: &mut V, 2090 _location: &'a SrcSpan, 2091 _name: &'a EcoString, 2092 _type_: &'a Arc<Type>, 2093 _origin: &'a VariableOrigin, 2094) where 2095 V: Visit<'a> + ?Sized, 2096{ 2097} 2098 2099pub fn visit_typed_pattern_bit_array_size<'a, V>(v: &mut V, size: &'a TypedBitArraySize) 2100where 2101 V: Visit<'a> + ?Sized, 2102{ 2103 match size { 2104 BitArraySize::Int { 2105 location, 2106 value, 2107 int_value: _, 2108 } => v.visit_typed_bit_array_size_int(location, value), 2109 BitArraySize::Variable { 2110 location, 2111 name, 2112 constructor, 2113 type_, 2114 } => v.visit_typed_bit_array_size_variable(location, name, constructor, type_), 2115 BitArraySize::BinaryOperator { left, right, .. } => { 2116 v.visit_typed_pattern_bit_array_size(left); 2117 v.visit_typed_pattern_bit_array_size(right); 2118 } 2119 BitArraySize::Block { inner, .. } => v.visit_typed_pattern_bit_array_size(inner), 2120 } 2121} 2122 2123pub fn visit_typed_bit_array_size_int<'a, V>( 2124 _v: &mut V, 2125 _location: &'a SrcSpan, 2126 _value: &'a EcoString, 2127) where 2128 V: Visit<'a> + ?Sized, 2129{ 2130} 2131 2132pub fn visit_typed_bit_array_size_variable<'a, V>( 2133 _v: &mut V, 2134 _location: &'a SrcSpan, 2135 _name: &'a EcoString, 2136 _constructor: &'a Option<Box<ValueConstructor>>, 2137 _type_: &'a Arc<Type>, 2138) where 2139 V: Visit<'a> + ?Sized, 2140{ 2141} 2142 2143pub fn visit_typed_pattern_assign<'a, V>( 2144 v: &mut V, 2145 _location: &'a SrcSpan, 2146 _name: &'a EcoString, 2147 pattern: &'a TypedPattern, 2148) where 2149 V: Visit<'a> + ?Sized, 2150{ 2151 v.visit_typed_pattern(pattern); 2152} 2153 2154pub fn visit_typed_pattern_discard<'a, V>( 2155 _v: &mut V, 2156 _location: &'a SrcSpan, 2157 _name: &'a EcoString, 2158 _type_: &'a Arc<Type>, 2159) where 2160 V: Visit<'a> + ?Sized, 2161{ 2162} 2163 2164pub fn visit_typed_pattern_list<'a, V>( 2165 v: &mut V, 2166 _location: &'a SrcSpan, 2167 elements: &'a Vec<TypedPattern>, 2168 tail: &'a Option<Box<TypedTailPattern>>, 2169 _type_: &'a Arc<Type>, 2170) where 2171 V: Visit<'a> + ?Sized, 2172{ 2173 for element in elements { 2174 v.visit_typed_pattern(element); 2175 } 2176 if let Some(tail) = tail { 2177 v.visit_typed_pattern(&tail.pattern); 2178 } 2179} 2180 2181#[allow(clippy::too_many_arguments)] 2182pub fn visit_typed_pattern_constructor<'a, V>( 2183 v: &mut V, 2184 _location: &'a SrcSpan, 2185 _name_location: &'a SrcSpan, 2186 _name: &'a EcoString, 2187 arguments: &'a Vec<CallArg<TypedPattern>>, 2188 _module: &'a Option<(EcoString, SrcSpan)>, 2189 _constructor: &'a Inferred<PatternConstructor>, 2190 _spread: &'a Option<SrcSpan>, 2191 _type_: &'a Arc<Type>, 2192) where 2193 V: Visit<'a> + ?Sized, 2194{ 2195 for argument in arguments { 2196 v.visit_typed_pattern_call_arg(argument); 2197 } 2198} 2199 2200pub fn visit_typed_pattern_call_arg<'a, V>(v: &mut V, argument: &'a CallArg<TypedPattern>) 2201where 2202 V: Visit<'a> + ?Sized, 2203{ 2204 v.visit_typed_pattern(&argument.value) 2205} 2206 2207pub fn visit_typed_pattern_tuple<'a, V>( 2208 v: &mut V, 2209 _location: &'a SrcSpan, 2210 elements: &'a Vec<TypedPattern>, 2211) where 2212 V: Visit<'a> + ?Sized, 2213{ 2214 for element in elements { 2215 v.visit_typed_pattern(element); 2216 } 2217} 2218 2219pub fn visit_typed_pattern_bit_array<'a, V>( 2220 v: &mut V, 2221 _location: &'a SrcSpan, 2222 segments: &'a [TypedPatternBitArraySegment], 2223) where 2224 V: Visit<'a> + ?Sized, 2225{ 2226 for segment in segments { 2227 v.visit_typed_pattern(&segment.value); 2228 for option in segment.options.iter() { 2229 v.visit_typed_pattern_bit_array_option(option); 2230 } 2231 } 2232} 2233 2234pub fn visit_typed_pattern_bit_array_option<'a, V>( 2235 v: &mut V, 2236 option: &'a BitArrayOption<TypedPattern>, 2237) where 2238 V: Visit<'a> + ?Sized, 2239{ 2240 match option { 2241 BitArrayOption::Bytes { location: _ } => { /* TODO */ } 2242 BitArrayOption::Int { location: _ } => { /* TODO */ } 2243 BitArrayOption::Float { location: _ } => { /* TODO */ } 2244 BitArrayOption::Bits { location: _ } => { /* TODO */ } 2245 BitArrayOption::Utf8 { location: _ } => { /* TODO */ } 2246 BitArrayOption::Utf16 { location: _ } => { /* TODO */ } 2247 BitArrayOption::Utf32 { location: _ } => { /* TODO */ } 2248 BitArrayOption::Utf8Codepoint { location: _ } => { /* TODO */ } 2249 BitArrayOption::Utf16Codepoint { location: _ } => { /* TODO */ } 2250 BitArrayOption::Utf32Codepoint { location: _ } => { /* TODO */ } 2251 BitArrayOption::Signed { location: _ } => { /* TODO */ } 2252 BitArrayOption::Unsigned { location: _ } => { /* TODO */ } 2253 BitArrayOption::Big { location: _ } => { /* TODO */ } 2254 BitArrayOption::Little { location: _ } => { /* TODO */ } 2255 BitArrayOption::Native { location: _ } => { /* TODO */ } 2256 BitArrayOption::Size { 2257 location: _, 2258 value, 2259 short_form: _, 2260 } => { 2261 v.visit_typed_pattern(value); 2262 } 2263 BitArrayOption::Unit { 2264 location: _, 2265 value: _, 2266 } => { /* TODO */ } 2267 } 2268} 2269 2270pub fn visit_typed_pattern_string_prefix<'a, V>( 2271 _v: &mut V, 2272 _location: &'a SrcSpan, 2273 _left_location: &'a SrcSpan, 2274 _left_side_assignment: &'a Option<(EcoString, SrcSpan)>, 2275 _right_location: &'a SrcSpan, 2276 _left_side_string: &'a EcoString, 2277 _right_side_assignment: &'a AssignName, 2278) where 2279 V: Visit<'a> + ?Sized, 2280{ 2281} 2282 2283pub fn visit_typed_pattern_invalid<'a, V>(_v: &mut V, _location: &'a SrcSpan, _type_: &'a Arc<Type>) 2284where 2285 V: Visit<'a> + ?Sized, 2286{ 2287} 2288 2289pub fn visit_typed_expr_invalid<'a, V>( 2290 _v: &mut V, 2291 _location: &'a SrcSpan, 2292 _type_: &'a Arc<Type>, 2293 _extra_information: &'a Option<InvalidExpression>, 2294) where 2295 V: Visit<'a> + ?Sized, 2296{ 2297}