All files / utils/types IConstantEnvironment.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                                                   
import type TConstExpr from "../../types/TConstExpr";
import type TConstResult from "../../types/TConstResult";
import type ISourcePosition from "./ISourcePosition";
 
/**
 * What a name in a constant expression is worth where it is written (#1175).
 *
 * The one thing `ConstantEvaluator` cannot decide by itself: a name means what
 * the binder says it means at its position (ADR-057), and only the pass
 * evaluating knows which declarations are in view. 1.4 Resolve answers while it
 * folds the program's consts and enum values; later passes answer from the
 * settled `Program`. Both answer through one chain resolver, so a name cannot
 * fold to one value in the .h and another in the .c.
 */
interface IConstantEnvironment {
  valueOf(name: Extract<TConstExpr, { kind: "name" }>): TConstResult;
  /**
   * A C-Next type name as C spells it where it is written (`sizeof`, a cast):
   * ADR-057 qualifies a bare name to the scope type it means there (#1863
   * review: `sizeof(P)` inside scope S reached C as `P`, not `S__P`)
   */
  cTypeName(typeName: string, at: ISourcePosition): string;
}
 
export default IConstantEnvironment;