You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve recreation of records in simulation context. (#10091)
- When re-creating a record from its member variables in simulation code (to send to a function), we were using the Modelica record constructor function created for it automatically. This requires considering which members are marked as protected and are considered non-modifiable. While this can be done it requires more analysis at codegen time to figure out.
Instead, always recreate a record using all its members (for this specific purpose of sending to a function). This is cleaner and also more error proof because it leaves no chance for overlooking any member being protected but getting modified by some other mechanism.
- A new record utility function, `<rec_name>_wrap_from_vars` is now added for each record. This simple function will **assign**
the members of a record from the function parameters. The function expects all members of the record as input.
**Note that the function does not do any deep copy** of the record members from the function parameters. It just assigns them.
This might not be the ideal thing to do but it is necessary right now due to the fact that a record can have an array member variable whose size is dictated by another record member variable. This means a give instance of a record might not be exactly compatible with the declaration due to array size differences, i.e., not copyable to a default allocated record.
The solution to this issue is probably in the NF (if it can be done). The NF should mark these size modified records as new pseudo-types so CodeGen can differentiate them.
Fixes#10084.
0 commit comments