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 | 18x 1x 17x 17x 17x 70x 70x 70x 17x 17x 15x | /**
* Bitmap Comment Utilities
*
* Shared utility for generating bitmap field layout comments.
* Issue #707: Extracted from BitmapGenerator.ts and ScopeGenerator.ts
* to reduce code duplication.
*/
/**
* Bitmap field information
*/
interface IBitmapFieldInfo {
offset: number;
width: number;
}
/**
* Generate comment lines describing bitmap field layout.
*
* @param fields - Map of field names to their offset/width info
* @returns Array of comment lines (without leading spaces), or empty array if no fields
*
* @example
* // Output format:
* // /* Fields:
* // * Running: bit 0 (1 bit)
* // * Mode: bits 2-4 (3 bits)
* // * /
*/
function generateBitmapFieldComments(
fields: ReadonlyMap<string, IBitmapFieldInfo>,
): string[] {
// Return empty array for empty field maps
if (fields.size === 0) {
return [];
}
const lines: string[] = [];
lines.push("/* Fields:");
for (const [fieldName, info] of fields.entries()) {
const endBit = info.offset + info.width - 1;
const bitRange =
info.width === 1 ? `bit ${info.offset}` : `bits ${info.offset}-${endBit}`;
lines.push(
` * ${fieldName}: ${bitRange} (${info.width} bit${info.width > 1 ? "s" : ""})`,
);
}
lines.push(" */");
return lines;
}
/**
* Bitmap Comment Utilities
*/
class BitmapCommentUtils {
static readonly generateBitmapFieldComments = generateBitmapFieldComments;
}
export default BitmapCommentUtils;
|