[ffigen] BindingsIndex refactor (#283)

Unify and simplify how Types are cached and cycles are broken in the type graph.

- All types that need to be cached (those that have a declaration cursor) are cached in `BindingsIndex._declaredTypes`
- All calls to convert a `CXType` to an ffigen `Type` now go through `getCodeGenType`
- All calls to the related sub-parsers (`parseCompoundDeclaration`, `parseEnumDeclaration`, `parseTypedefDeclaration`) also go through `getCodeGenType`
- Those sub-parsers (mostly) don't know about `BindingsIndex`, and don't know about caching or cycle breaking. That's all handled in one place in `getCodeGenType`
- Cycles are broken by dividing type conversion into 2 stages (the only conversion this matters for is compound types):
    - First the `Type` is created, with as many fields filled in as possible, without a recursive call to `getCodeGenType` (everything except the list of members)
    - Next, `getCodeGenType` inserts the type into the cache
    - Finally, the members are filled in. Recursive calls to `getCodeGenType` are allowed here, as they will hit the cache, breaking any cycles.
10 files changed
tree: d5df94c01b2933a8ef2c306106f6b8891ff3f136
  1. pkgs/