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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | /**
* Dependencies provided to assignment handlers (ADR-109).
*
* Handlers need access to various CodeGenerator capabilities without
* taking a direct dependency on the full CodeGenerator class. This
* interface defines the subset of functionality handlers need.
*/
import * as Parser from "../../../../logic/parser/grammar/CNextParser";
import ICodeGenSymbols from "../../../../types/ICodeGenSymbols";
import TTypeInfo from "../../types/TTypeInfo";
import ITargetCapabilities from "../../types/ITargetCapabilities";
/**
* Dependencies for assignment handlers.
*
* These are provided by CodeGenerator to enable handlers to:
* - Look up type information
* - Access symbol tables
* - Generate expressions
* - Track side effects (needsString, clampOps)
*/
interface IHandlerDeps {
// === Symbol information ===
/** Read-only symbol info (registers, bitmaps, structs, etc.) */
readonly symbols: ICodeGenSymbols;
/** Type registry: variable name -> type info */
readonly typeRegistry: ReadonlyMap<string, TTypeInfo>;
/** Current scope name (for this.* resolution), null if not in scope */
readonly currentScope: string | null;
/** Parameters of current function */
readonly currentParameters: ReadonlyMap<
string,
{ isStruct?: boolean; isArray?: boolean }
>;
/** Target platform capabilities */
readonly targetCapabilities: ITargetCapabilities;
// === Expression generation ===
/**
* Generate C code for an expression.
*/
generateExpression(ctx: Parser.ExpressionContext): string;
/**
* Try to evaluate an expression as a compile-time constant.
* Returns undefined if not a constant.
*/
tryEvaluateConstant(ctx: Parser.ExpressionContext): number | undefined;
/**
* Generate the C target string for an assignment target.
*/
generateAssignmentTarget(ctx: Parser.AssignmentTargetContext): string;
// === Type checking ===
/**
* Check if a type name is a known struct.
*/
isKnownStruct(typeName: string): boolean;
/**
* Check if a name is a known scope.
*/
isKnownScope(name: string): boolean;
/**
* Get member type info for a struct field.
*/
getMemberTypeInfo(structType: string, memberName: string): TTypeInfo | null;
// === Validation ===
/**
* Validate bitmap field literal fits in field width.
*/
validateBitmapFieldLiteral(
expr: Parser.ExpressionContext,
width: number,
fieldName: string,
): void;
/**
* Validate cross-scope visibility for member access.
*/
validateCrossScopeVisibility(scopeName: string, memberName: string): void;
/**
* Check array bounds for compile-time constant indices.
*/
checkArrayBounds(
arrayName: string,
dimensions: readonly number[],
indexExprs: readonly Parser.ExpressionContext[],
line: number,
): void;
/**
* Analyze a member chain target for bit access.
* Returns { isBitAccess: false } if not bit access.
* Returns { isBitAccess: true, baseTarget, bitIndex, baseType } if bit access detected.
*/
analyzeMemberChainForBitAccess(targetCtx: Parser.AssignmentTargetContext): {
isBitAccess: boolean;
baseTarget?: string;
bitIndex?: string;
baseType?: string;
};
// === Float bit indexing ===
/**
* Generate float bit write using shadow variable + memcpy.
* Returns the full statement for writing bits to a float variable.
* Returns null if typeInfo is not a float type.
*/
generateFloatBitWrite(
name: string,
typeInfo: TTypeInfo,
bitIndex: string,
width: string | null,
value: string,
): string | null;
/**
* Convert boolean expression to integer: true -> "1", false -> "0", else "(expr ? 1 : 0)"
*/
foldBooleanToInt(expr: string): string;
// === Side effects ===
/**
* Mark that string.h is needed (for strncpy, memcpy).
*/
markNeedsString(): void;
/**
* Mark that a clamp operation helper is used.
*/
markClampOpUsed(op: string, typeName: string): void;
// === Atomic operations ===
/**
* Generate atomic read-modify-write operation.
*/
generateAtomicRMW(
target: string,
cOp: string,
value: string,
typeInfo: TTypeInfo,
): string;
}
export default IHandlerDeps;
|