I am trying to migrate some modules to DML 1.4 and I face some problems during bank content iteration. Specifically, I originally have the snippet below:
select reg in ($signals.unmapped_registers) where (reg.signal_number == signal) {
// some statements here
} else {
log "unimplemented", 1: "Power/Board: Signal %d is unimplemented", signal;
return;
}
However, unmapped_registers is not valid in DML 1.4, thus leading to an unknown identifier compiler error.
How am I supposed to iterate over all the unmapped registers of a specific bank in DML 1.4 and select the one I want based on some specific criteria (i.e. the signal_number parameter)?
I've already tried swapping the select statement with foreach without success.
I've also tried to iterate over all bank registers that instantiate a specific template, but still without success.
You need to
foreach
over a template that hassignal_number
as type member.When you iterate using
foreach
, the iteration variable is a run-time template reference, which means that not all declarations of the template can be accessed: Only parameters with a declared explicit type belong to the template type (together with all method declarations annotated withshared
, and mostsession
andsaved
declarations). So in your case, your problem is likely thatsignal_number
does not have a declared type.If you add a parameter type like this:
then you can implement your loop like this: