McStasMcXtrace / mccode-antlr

McCode grammar implemented with ANTLR4
1 stars 0 forks source link

[Fix] issue 48, [Fix] commandline mccode utils #53

Closed g5t closed 5 months ago

g5t commented 5 months ago

As part of issue #48 a code generator change was noted https://github.com/McStasMcXtrace/McCode/commit/e56bb8dbff1b6d6532bc30ad30eb3777d049caad that modified the behavior of naming component-defined USERVARS.

It's not clear what the behavior was prior to that commit, but after every component USERVARS entry is added to the particle struct with the 1-based index of the component instance appended.

For example, the component Monochromator_curved defines two USERVARS ncol and nrow which are used to keep-track of the interacting monochromator-array tile for each scattered neutron. In the test instrument Test_focus.instr there is one Monochromator_curved component instance in the fifth position, so the generated C code has a particle struct containing ncol_5 and nrow_5.

Prior to this PR mccode_antlr mistakenly treated all component USERVAR parameters as-named in the single namespace; and would produce a struct with ncol and nrow. This would then break the component TRACE code which attempts to set the two values by name, e.g. particle_setvar_void(_particle, "ncol_5", &col);.

This PR changes the mccode_antlr behavior to match the McCode-3 code generator, fixing #48