Skip to content

v0.27.0

Choose a tag to compare

@g5t g5t released this 28 Aug 15:19
· 15 commits to main since this release
21f197f

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 WHEN condition that folds to a boolean constant (WHEN (0==1), WHEN (1==1)) was emitted as the C99-invalid token false / true, so the generated if ((false)) // conditional WHEN execution failed to compile. It is now a plain 0 / 1 (#323, issue #317).
  • A compile-time-constant WHEN no longer raises RuntimeError and aborts the parse/translate. "Turning off" a component while keeping its position, orientation, and MCDISPLAY for 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_constant also learned to recognise folded booleans, and Assembler.component(when=…, split=…) now coerces and validates those kwargs the same way Instance.WHEN / Instance.SPLIT do — previously a string was stored verbatim, which broke parameter_used and the {when:p} translation format (#327, issue #318).

Component definitions

  • DEFINE COMPONENT b INHERIT a combined with a section-level SECTION INHERIT a (or SECTION INHERIT a EXTEND %{ … %}, or a bare SECTION %{ … %}) 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 upstream StatisticalChopper_Monitor.comp — the only component that exercises every one of these forms — now compiles (#325, issue #321).
  • A NeXus-output component with a string SETTING parameter that has no default emitted mccomp_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" // comment directive 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.json sidecar written next to every parsed .comp — was only invalidated by the .comp file's mtime, so a parser or schema fix (such as the INHERIT fix above) would not reach a user with a warm ~/.cache/mccodeantlr after 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-build understand the new scheme, and ir-clean --stale treats 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