v0.27.0
What's Changed
A batch of translator and parser correctness fixes. Several of these previously produced C that would not compile, or aborted translation outright.
WHEN handling
- A
WHENcondition that folds to a boolean constant (WHEN (0==1),WHEN (1==1)) was emitted as the C99-invalid tokenfalse/true, so the generatedif ((false)) // conditional WHEN executionfailed to compile. It is now a plain0/1(#323, issue #317). - A compile-time-constant
WHENno longer raisesRuntimeErrorand aborts the parse/translate. "Turning off" a component while keeping its position, orientation, andMCDISPLAYfor setup purposes is a legitimate thing to want, so this is now a guidance warning that names the alternatives (remove/comment the component, or gate it on an instrument parameter).Expr.is_constantalso learned to recognise folded booleans, andAssembler.component(when=…, split=…)now coerces and validates those kwargs the same wayInstance.WHEN/Instance.SPLITdo — previously a string was stored verbatim, which brokeparameter_usedand the{when:p}translation format (#327, issue #318).
Component definitions
DEFINE COMPONENT b INHERIT acombined with a section-levelSECTION INHERIT a(orSECTION INHERIT a EXTEND %{ … %}, or a bareSECTION %{ … %}) duplicated the inherited block instead of overriding it, and the duplicated declarations broke the C compile. Each redefined section now replaces the inherited copy, matching upstream McCode's "all redefined blocks override". The upstreamStatisticalChopper_Monitor.comp— the only component that exercises every one of these forms — now compiles (#325, issue #321).- A NeXus-output component with a string
SETTINGparameter that has no default emittedmccomp_param_nexus(nxhandle, …, "filename", , _instrument_var._parameters.filename, …)— an empty C literal — and failed to compile. The missing default is now written as"NONE"(#322, issue #319). - A
%include "some_file.h" // commentdirective inside a C block was rejected because the directive regexes only tolerated whitespace to end of line. A trailing//line comment or/* … */block comment is now allowed: a file include splices the file in place and keeps the comment on the following line; a library include is lifted out as before and the comment stays where the directive was (#324, issue #320).
Component cache
- The on-disk component IR cache — a
{name}.comp.jsonsidecar written next to every parsed.comp— was only invalidated by the.compfile's mtime, so a parser or schema fix (such as theINHERITfix above) would not reach a user with a warm~/.cache/mccodeantlrafter upgrading. Sidecars are now named{name}.comp.<build>.json, where<build>binds them to the mccode-antlr version and an internal cache-format number; a sidecar from a different build is ignored and pruned rather than trusted.mccode-antlr cache ir-list/ir-clean/ir-buildunderstand the new scheme, andir-clean --staletreats a foreign-build sidecar as stale (#326).
Other Changes
- 319 nexus component string parameters need a default even if there if none was defined by @g5t in #322
- [Fix] emit booleans to C as literal integers by @g5t in #323
- [Fix] include regex does not forbid trailing comments by @g5t in #324
- [Fix] INHERIT component section logic by @g5t in #325
- Salt the component IR cache with the mccode-antlr build by @g5t in #326
- Warn (don't abort) on a compile-time-constant WHEN by @g5t in #327
Full Changelog: v0.26.0...v0.27.0