1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! A visitor implementation for finding state variables in an abstract syntax
//! tree (AST). The `StateFinder` struct is designed to traverse the AST and
//! identify state variables that are referenced within derivative function calls
//! (`der`). It collects these state variable names into a `HashSet` for later
//! processing.
//!
//! # Fields
//! - `states`: A `HashSet` containing the names of the state variables found
//! during the traversal.
//!
//! # Visitor Implementation
//! - The `exit_expression` method is invoked when exiting an expression node
//! during the AST traversal. It performs the following actions:
//! - Checks if the expression is a function call with the identifier `der`.
//! - If the first argument of the `der` function is a component reference,
//! the state variable name is extracted and added to the `states` set.
//! - **Note:** The AST is NOT modified - `der()` calls remain as function calls
//! to maintain Base Modelica compliance.
//!
//! This visitor is useful for identifying which variables are states (appear in
//! der() calls) without transforming the AST representation.
use IndexSet;
use crateir;
use crateBUILTIN_DER;
use crateMutVisitor;