All files / transpiler/output/codegen/generators TGeneratorEffect.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                                                                                             
/**
 * Side effects returned by generators instead of mutating state.
 *
 * Using a discriminated union enables:
 * - Exhaustive switch handling (TypeScript catches missing cases)
 * - Type-safe payloads per effect type
 * - Central effect processing in the orchestrator
 */
import TTypeInfo from "../types/TTypeInfo";
import TParameterInfo from "../types/TParameterInfo";
import TIncludeHeader from "./TIncludeHeader";
 
type TGeneratorEffect =
  // === Include Effects ===
  | { type: "include"; header: TIncludeHeader }
  | { type: "isr" } // Needs ISR typedef
 
  // === Helper Function Effects ===
  | { type: "helper"; operation: string; cnxType: string } // Overflow clamp helper
  | { type: "safe-div"; operation: "div" | "mod"; cnxType: string } // Safe division helper
 
  // === Type Registration Effects ===
  | { type: "register-type"; name: string; info: TTypeInfo } // Register variable type
  | { type: "register-local"; name: string; isArray: boolean } // Register local variable
  | { type: "register-const-value"; name: string; value: number } // Register compile-time constant
 
  // === Scope Effects (ADR-016) ===
  | { type: "set-scope"; name: string | null } // Enter/exit a scope
 
  // === Function Body Effects ===
  | { type: "enter-function-body" } // Mark entering function body
  | { type: "exit-function-body" } // Mark exiting function body
  | {
      type: "set-parameters";
      params: ReadonlyMap<string, TParameterInfo>;
    } // Set current function parameters
  | { type: "clear-parameters" } // Clear current function parameters
 
  // === Callback Effects ===
  | { type: "register-callback-field"; key: string; typeName: string } // Register callback as struct field type
 
  // === Array Initializer Effects ===
  | { type: "set-array-init-count"; count: number } // Track array element count
  | { type: "set-array-fill-value"; value: string | undefined }; // Track fill-all value
 
export default TGeneratorEffect;