mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 15:33:56 +08:00
refactor(managed): share member signature type decoding (#17306)
This commit is contained in:
@@ -1023,6 +1023,12 @@ const decodeSignature = (
|
||||
scope = "signature",
|
||||
displayTypeName?: SignatureDisplayTypeName,
|
||||
): DecodedSignature => {
|
||||
const readType = (offset: number, position: SignaturePosition) =>
|
||||
readTypeSignature(blob, offset, position, {
|
||||
operands,
|
||||
displayTypeName,
|
||||
...(layout === undefined ? {} : { layout }),
|
||||
});
|
||||
let kind: DecodedSignature["kind"] = "unknown";
|
||||
try {
|
||||
if (blob.length === 0)
|
||||
@@ -1032,11 +1038,7 @@ const decodeSignature = (
|
||||
// method header either, so it is malformed below.
|
||||
if (first === 0x06) {
|
||||
kind = "field";
|
||||
const fieldType = readTypeSignature(blob, 1, "field", {
|
||||
operands,
|
||||
displayTypeName,
|
||||
...(layout === undefined ? {} : { layout }),
|
||||
});
|
||||
const fieldType = readType(1, "field");
|
||||
return {
|
||||
kind: "field",
|
||||
parse_status: fieldType.next === blob.length ? "decoded" : "partial",
|
||||
@@ -1052,11 +1054,7 @@ const decodeSignature = (
|
||||
}
|
||||
const header = readMethodSignatureHeader(blob, 0, "member");
|
||||
kind = "method";
|
||||
const returnType = readTypeSignature(blob, header.next, "return", {
|
||||
operands,
|
||||
displayTypeName,
|
||||
...(layout === undefined ? {} : { layout }),
|
||||
});
|
||||
const returnType = readType(header.next, "return");
|
||||
let offset = returnType.next;
|
||||
const parameters: string[] = [];
|
||||
let sentinelSeen = false;
|
||||
@@ -1072,11 +1070,7 @@ const decodeSignature = (
|
||||
if (blob[offset] === undefined || blob[offset] === 0x41)
|
||||
malformedSignature("VARARG signature has adjacent sentinels", offset);
|
||||
}
|
||||
const parameter = readTypeSignature(blob, offset, "parameter", {
|
||||
operands,
|
||||
displayTypeName,
|
||||
...(layout === undefined ? {} : { layout }),
|
||||
});
|
||||
const parameter = readType(offset, "parameter");
|
||||
parameters.push(parameter.value);
|
||||
offset = parameter.next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user