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