All files / TRANSPILE/3-Render/codegen/types IPlannedCast.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                                                                               
/**
 * A cast expression, reduced to what rendering it needs (#1445 box 3).
 *
 * `targetType` and `operandCode` are already rendered, in that order; see
 * `CastExprGenerator` for why they are values rather than thunks.
 */
interface IPlannedCast {
  /** The target type as it will appear in C, e.g. `uint8_t`. */
  readonly targetType: string;
 
  /**
   * The target type's C-NEXT source text, e.g. `u8`.
   *
   * ADR-024's clamp rule and `TYPE_LIMITS` both key on this spelling, not on
   * the C one -- `TYPE_MAX` is indexed by `u8`, never by `uint8_t`.
   */
  readonly targetTypeName: string;
 
  /** The operand, already rendered. */
  readonly operandCode: string;
 
  /**
   * The operand's essential type, or null when it cannot be resolved.
   *
   * Only a float source can require clamping, so null simply means "not a
   * float" to `CastRequirement` and the cast renders plainly.
   */
  readonly operandType: string | null;
 
  /**
   * #1668: how ADR-024's float-to-integer saturation is written, or null when
   * the cast does not saturate. `"helper"` when the operand has a side effect
   * -- a call, or a volatile or atomic read -- so it is evaluated once;
   * `"inline"` for a pure operand, the bounded ternary.
   */
  readonly clampForm: "inline" | "helper" | null;
}
 
export default IPlannedCast;