All files / TRANSPILE/3-Render/codegen/types TPlannedScopeVariable.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52                                                                                                       
/**
 * How an ADR-016 scope member that declares a VARIABLE is emitted.
 *
 * Every scope variable is emitted at file scope under a scope-qualified C name,
 * with visibility deciding linkage. The three arms are the three shapes that
 * takes, and which one applies is decided from the declaration alone -- so the
 * choice is made once, here, and the renderer does not re-derive it.
 *
 * ## The `skipped` arm is why this is a union rather than a nullable record
 *
 * Issue #282 inlines a PRIVATE CONST SCALAR at its use sites instead of
 * emitting it, and Issue #500 exempts arrays because an array cannot be
 * inlined. A skipped member must render NOTHING -- not even its type --
 * because rendering a type registers an include: a file whose only `u32` is a
 * skipped private const would otherwise gain `#include <stdint.h>` for a
 * declaration that never appears. Stating the skip as an arm with no renders
 * on it makes that structural instead of a rule to remember.
 */
type TPlannedScopeVariable =
  /** Issue #282/#500: a private const scalar, inlined at its uses. */
  | { readonly kind: "skipped" }
  /** Issue #375: `Type name(arg, arg);` -- C++ constructor syntax. */
  | {
      readonly kind: "constructor";
      readonly fullName: string;
      readonly isPrivate: boolean;
      /** Argument identifiers, already resolved to their scope-qualified names. */
      readonly args: readonly string[];
      readonly renderType: () => string;
    }
  /** Everything else. */
  | {
      readonly kind: "regular";
      readonly fullName: string;
      readonly isPrivate: boolean;
      readonly isConst: boolean;
      readonly isArray: boolean;
      /** ADR-030 provenance is recorded at the DECLARATION's position. */
      readonly declarationLine: number | undefined;
      /** Rendered `atomic`/`volatile` prefixes; at most one is non-empty. */
      readonly atomic: string;
      readonly volatile: string;
      readonly renderType: () => string;
      readonly renderArrayTypeDimensions: () => string;
      /** Null when the declaration carries no C-style trailing dimensions. */
      readonly renderCStyleDimensions: (() => string) | null;
      readonly renderStringCapacityDimension: () => string;
      readonly renderInitializer: () => string;
    };
 
export default TPlannedScopeVariable;