C / C++ / Objective-C share the C-family initializer & assignment shapes.
(extra?: { special?: string[]; addressOfOnly?: boolean })
| 142 | |
| 143 | /** C / C++ / Objective-C share the C-family initializer & assignment shapes. */ |
| 144 | function cFamilySpec(extra?: { special?: string[]; addressOfOnly?: boolean }): FnRefSpec { |
| 145 | return { |
| 146 | idTypes: new Set(['identifier']), |
| 147 | dispatch: new Map<string, CaptureRule>([ |
| 148 | ['argument_list', { mode: 'args' }], |
| 149 | ['assignment_expression', { mode: 'rhs', field: 'right' }], |
| 150 | ['init_declarator', { mode: 'varinit', field: 'value' }], |
| 151 | ['initializer_list', { mode: 'list' }], |
| 152 | ['initializer_pair', { mode: 'value', field: 'value' }], |
| 153 | ]), |
| 154 | unwrap: new Map([['pointer_expression', 'argument']]), |
| 155 | special: new Set(extra?.special ?? []), |
| 156 | // C has no symbol imports, and callbacks are registered cross-file at repo |
| 157 | // scale (redis: server.c's command table names handlers from t_*.c) — so |
| 158 | // initializer positions bypass the gate and lean on resolution's |
| 159 | // unique-or-drop rule. ONLY 'value'/'list' (struct/array initializers), |
| 160 | // and the flush additionally requires FILE scope: a C file-scope |
| 161 | // initializer is a constant-expression context, so a bare identifier |
| 162 | // there can only be a function address (or enum/macro, which the |
| 163 | // function-kind filter drops) — never a variable. 'rhs'/'varinit' were |
| 164 | // tried and produced false edges (`prev = next`, `*str = field` — data |
| 165 | // assignments matching a unique same-named function elsewhere), so |
| 166 | // assignments stay gated to same-file/import. |
| 167 | ungatedModes: new Set<CaptureMode>(['value', 'list']), |
| 168 | addressOfOnly: extra?.addressOfOnly, |
| 169 | }; |
| 170 | } |
| 171 | |
| 172 | // `this.handleClick` capture (member_expression) emits a `this.`-PREFIXED |
| 173 | // candidate name: resolution scopes it to the enclosing symbol's class |