All files / transpiler/types TType.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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104                                                                                                                                                                                                               
/**
 * C-Next Type System - Discriminated Union
 *
 * TType represents all possible types in the C-Next type system.
 * Each variant has a `kind` discriminator for type narrowing.
 *
 * Use TTypeUtils for factory functions and type guards.
 */
import TPrimitiveKind from "./TPrimitiveKind";
 
/**
 * Primitive type (built-in types that map to C types)
 */
interface TPrimitiveType {
  readonly kind: "primitive";
  readonly primitive: TPrimitiveKind;
}
 
/**
 * Struct type reference
 */
interface TStructType {
  readonly kind: "struct";
  readonly name: string;
}
 
/**
 * Enum type reference
 */
interface TEnumType {
  readonly kind: "enum";
  readonly name: string;
}
 
/**
 * Bitmap type reference
 * Bitmaps have a fixed bit width (8, 16, 24, 32)
 */
interface TBitmapType {
  readonly kind: "bitmap";
  readonly name: string;
  readonly bitWidth: number;
}
 
/**
 * Array type with element type and dimensions
 * Dimensions can be numbers or strings (for C macro pass-through)
 */
interface TArrayType {
  readonly kind: "array";
  readonly elementType: TType;
  readonly dimensions: ReadonlyArray<number | string>;
}
 
/**
 * String type with capacity
 * C-Next strings are fixed-capacity char arrays
 */
interface TStringType {
  readonly kind: "string";
  readonly capacity: number;
}
 
/**
 * Callback type reference (function pointer type)
 */
interface TCallbackType {
  readonly kind: "callback";
  readonly name: string;
}
 
/**
 * Hardware register type
 */
interface TRegisterType {
  readonly kind: "register";
  readonly name: string;
}
 
/**
 * External type (C++ templates, external classes)
 * Passes through unchanged to generated code
 */
interface TExternalType {
  readonly kind: "external";
  readonly name: string;
}
 
/**
 * Discriminated union of all C-Next types
 */
type TType =
  | TPrimitiveType
  | TStructType
  | TEnumType
  | TBitmapType
  | TArrayType
  | TStringType
  | TCallbackType
  | TRegisterType
  | TExternalType;
 
export default TType;