mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 10:04:50 +00:00
Share Field scalar facts and use one coded-index tag registry for widths and decoding. Preserve reserved constructor tags, generic-instantiation restrictions, heap failure order and selected-field signature admission. Derive native import member kind from the validated MemberForwarded coordinate independently of name lookup, retaining known field or method identity when its display name is unreadable. Validation: 368 focused source, CLI and MCP tests passed; five lost-kind regressions reproduced on the previous commit. Heap-width, coded-width, reserved-tag and selection boundaries are covered. Typecheck and lint passed.
26 lines
863 B
TypeScript
26 lines
863 B
TypeScript
import type { ManagedMetadataLayout } from "./ManagedMetadataLayout.js";
|
|
import { metadataRowCursor, metadataToken } from "./ManagedMetadataHeaps.js";
|
|
|
|
/** Scalar Field facts; consumers own heap admission and field selection. */
|
|
export const readFieldDefinitionRow = (
|
|
bytes: Buffer,
|
|
layout: ManagedMetadataLayout,
|
|
row: number,
|
|
): {
|
|
readonly token: string;
|
|
readonly rowOffset: number;
|
|
readonly flags: number;
|
|
readonly nameIndex: number;
|
|
readonly signatureIndex: number;
|
|
} => {
|
|
// Layout admission bounds the complete row independently of its heap values.
|
|
const cursor = metadataRowCursor(bytes, layout, 4, row);
|
|
return {
|
|
token: metadataToken(4, row),
|
|
rowOffset: cursor.start,
|
|
flags: cursor.readUInt16(),
|
|
nameIndex: cursor.readIndex(layout.stringIndexSize),
|
|
signatureIndex: cursor.readIndex(layout.blobIndexSize),
|
|
};
|
|
};
|