All files / TRANSPILE/3-Render/codegen/types IPlannedFunction.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 53 54 55 56 57 58 59 60 61 62                                                                                                                           
import type IPlannedFunctionParameter from "./IPlannedFunctionParameter";
 
/**
 * A C-Next function declaration, decided.
 *
 * #1445 box 3: `FunctionGenerator`'s job is a SEQUENCE, not an inspection --
 * enter the context, render the body, update auto-const, render the signature,
 * leave the context -- and Issue #268 is why that order is load-bearing: the
 * body has to run first so the parameter list can see which parameters it
 * modified. Everything the generator read off the node it handed straight to
 * the orchestrator.
 *
 * So the values come over as values, and the two steps whose TIMING the
 * generator owns come over as thunks. A thunk here is not a node in disguise:
 * the generator cannot look inside one, which is the point -- it can only
 * decide when to run it.
 */
interface IPlannedFunction {
  readonly name: string;
 
  /** The rendered C return type. */
  readonly returnType: string;
 
  /**
   * The return type as WRITTEN.
   *
   * Distinct from `returnType`: the context records this one, because typing
   * a `return` expression is a C-Next question (#477) and the C spelling has
   * already lost the distinctions it needs.
   */
  readonly returnTypeText: string;
 
  /** ADR-016: `main(u8 args[][])` or `main(string args[])`. */
  readonly isMainWithArgs: boolean;
 
  /**
   * The first parameter's name, which the main-with-args form records as the
   * name its body refers to `argv` by.
   */
  readonly firstParameterName: string | undefined;
 
  /** The parameters the context registers, or null when there are none. */
  readonly parameters: readonly IPlannedFunctionParameter[] | null;
 
  /**
   * Render the body. Runs INSIDE the context, and before the signature --
   * Issue #268.
   */
  readonly renderBody: () => string;
 
  /**
   * Render the parameter list, or null when the function declares none (which
   * renders as `void`).
   *
   * Runs after `updateFunctionParamsAutoConst`, so it can see which
   * parameters the body modified.
   */
  readonly renderParameterList: (() => string) | null;
}
 
export default IPlannedFunction;