* The macro of `name` in effect at `offset`: its last `#define` before it, * unless an `#undef` came between.
(macros: readonly CppMacro[], undefs: ReadonlyArray<{ name: string; at: number }>, name: string, offset: number)
| 359 | * unless an `#undef` came between. |
| 360 | */ |
| 361 | function liveMacro(macros: readonly CppMacro[], undefs: ReadonlyArray<{ name: string; at: number }>, name: string, offset: number): CppMacro | null { |
| 362 | let found: CppMacro | null = null; |
| 363 | for (const m of macros) if (m.name === name && m.at < offset && (!found || m.at > found.at)) found = m; |
| 364 | if (!found) return null; |
| 365 | return undefs.some((u) => u.name === name && u.at > found!.at && u.at < offset) ? null : found; |
| 366 | } |
| 367 | |
| 368 | /** A macro's expansion for the arguments `args` (as written), or null when they don't fit its parameters. */ |
| 369 | function expandCppMacro(macro: CppMacro, args: string[]): string | null { |