* The type of each of a Pascal routine's parameters, with how it is passed * (`const integer`, `var tstrings`), from its signature * (`(const A, B: Integer; var L: TStrings)`); [] for none, null when the * signature can't be read.
(signature: string | undefined)
| 623 | * signature can't be read. |
| 624 | */ |
| 625 | function pascalParameterTypes(signature: string | undefined): string[] | null { |
| 626 | const groups = pascalParameterGroups(signature); |
| 627 | if (!groups) return null; |
| 628 | const types: string[] = []; |
| 629 | for (const group of groups) { |
| 630 | const colon = group.indexOf(':'); |
| 631 | const passed = /^\s*(?:\[[^\]]*\]\s*)*(const|constref|var|out)\b/i.exec(group)?.[1]?.toLowerCase() ?? ''; |
| 632 | const type = colon < 0 ? '' : group.slice(colon + 1).replace(/=[\s\S]*$/, '').replace(/\s+/g, ' ').trim().toLowerCase(); |
| 633 | for (let k = groupNames(group).length; k > 0; k--) types.push(`${passed} ${type}`); |
| 634 | } |
| 635 | return types; |
| 636 | } |
| 637 | |
| 638 | /** The names a parameter group declares (`const A, B: Integer` → A, B). */ |
| 639 | function groupNames(group: string): string[] { |
no test coverage detected