# frontend: incremental compilation progress · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/84c2ebd6c6b16752d8d030d5904d0a525283cbf5)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 84c2ebd6c6b16752d8d030d5904d0a525283cbf5

Requested commit: 84c2ebd6c6b16752d8d030d5904d0a525283cbf5

Commit: 84c2ebd6c6b16752d8d030d5904d0a525283cbf5

Tree: 442234d4a737c6fbcf4f165ac18fa2a31cef9ac1

Author: mlugg

Committer: Jacob Young

## Message

```
frontend: incremental compilation progress

Another big commit, sorry! This commit makes all fixes necessary for
incremental updates of the compiler itself (specifically, adding a
breakpoint to `zirCompileLog`) to succeed, at least on the frontend.

The biggest change here is a reform to how types are handled. It works
like this:
* When a type is first created in `zirStructDecl` etc, its namespace is
  scanned. If the type requires resolution, an `interned` dependency is
  declared for the containing `AnalUnit`.
* `zirThis` also declared an `interned` dependency for its `AnalUnit` on
  the namespace's owner type.
* If the type's namespace changes, the surrounding source declaration
  changes hash, so `zirStructDecl` etc will be hit again. We check
  whether the namespace has been scanned this generation, and re-scan it
  if not.
* Namespace lookups also check whether the namespace in question
  requires a re-scan based on the generation. This is because there's no
  guarantee that the `zirStructDecl` is re-analyzed before the namespace
  lookup is re-analyzed.
* If a type's structure (essentially its fields) change, then the type's
  `Cau` is considered outdated. When the type is re-analyzed due to
  being outdated, or the `zirStructDecl` is re-analyzed by being
  transitively outdated, or a corresponding `zirThis` is re-analyzed by
  being transitively outdated, the struct type is recreated at a new
  `InternPool` index. The namespace's owner is updated (but not
  re-scanned, since that is handled by the mechanisms above), and the
  old type, while remaining a valid `Index`, is removed from the map
  metadata so it will never be found by lookups. `zirStructDecl` and
  `zirThis` store an `interned` dependency on the *new* type.

```

## Parents

- [65cbdefe4d923efd8fd2cfb555cc02a52c5635fc](https://git.cafe/gitcafe/zig/commit/65cbdefe4d923efd8fd2cfb555cc02a52c5635fc?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/84c2ebd6c6b16752d8d030d5904d0a525283cbf5?format=markdown)
