PLC-lang / rusty

Structured Text Parser and LLVM Frontend
GNU Lesser General Public License v3.0
223 stars 53 forks source link

feat: Aliased Hardware Access Variables #1265

Closed volsa closed 2 months ago

volsa commented 4 months ago

Adds support to create new hardware variables by declaring a global variable with the address For example :

VAR_GLOBAL
  heatSwitch AT %IX1.2.3.4 : BOOL;
END_VAR

will create a variable __PI_1_2_3_4 : BOOL and map the heatSwitch variable to it. A runtime can then point the __PI_1_2_3_4 to a real hardware value. This PR still does not allow declaring hardware addresses with no associated variables. Assigning variables inside POUs is also not possible.

mhasel commented 2 months ago

This commit looks good. We should think about adding a validation to verify the PI variables are only accessed in their intended read/write directions, but doing so in a different story/commit is fine with me.