All files / transpiler/output/codegen/helpers dimensionEvalOptions.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                                  1705x              
/**
 * Issue #1159: the one place that binds `ArrayDimensionParser` to the live
 * constant/type state.
 *
 * `ArrayDimensionParser` is deliberately pure — it takes its lookups as
 * options so it stays unit-testable without `CodeGenState`. That purity is
 * worth keeping, but it means every caller has to supply the same three
 * lookups, and a caller that supplies fewer silently resolves fewer dimension
 * forms than the others. That is how the `.c` came to fold a const in a
 * local declaration (`uint8_t b[6]`) while emitting the bare identifier in a
 * parameter (`uint8_t buf[SIZE]`) for the same const — a VLA parameter, which
 * CLAUDE.md rules out ("the transpiler resolves consts to their value, no C
 * VLA").
 *
 * Callers use this builder rather than assembling options inline, so a new
 * dimension form becomes resolvable everywhere at once.
 */
 
import CodeGenState from "../../../state/CodeGenState";
import TYPE_WIDTH from "../../../constants/TYPE_WIDTH";
 
/**
 * Build the constant-folding options for an array dimension from current state.
 */
function dimensionEvalOptions() {
  return {
    constValues: CodeGenState.constValues,
    typeWidths: TYPE_WIDTH,
  };
}
 
export default dimensionEvalOptions;