zig/test
mlugg 548a087faf
compiler: split Decl into Nav and Cau
The type `Zcu.Decl` in the compiler is problematic: over time it has
gained many responsibilities. Every source declaration, container type,
generic instantiation, and `@extern` has a `Decl`. The functions of
these `Decl`s are in some cases entirely disjoint.

After careful analysis, I determined that the two main responsibilities
of `Decl` are as follows:
* A `Decl` acts as the "subject" of semantic analysis at comptime. A
  single unit of analysis is either a runtime function body, or a
  `Decl`. It registers incremental dependencies, tracks analysis errors,
  etc.
* A `Decl` acts as a "global variable": a pointer to it is consistent,
  and it may be lowered to a specific symbol by the codegen backend.

This commit eliminates `Decl` and introduces new types to model these
responsibilities: `Cau` (Comptime Analysis Unit) and `Nav` (Named
Addressable Value).

Every source declaration, and every container type requiring resolution
(so *not* including `opaque`), has a `Cau`. For a source declaration,
this `Cau` performs the resolution of its value. (When #131 is
implemented, it is unsolved whether type and value resolution will share
a `Cau` or have two distinct `Cau`s.) For a type, this `Cau` is the
context in which type resolution occurs.

Every non-`comptime` source declaration, every generic instantiation,
and every distinct `extern` has a `Nav`. These are sent to codegen/link:
the backends by definition do not care about `Cau`s.

This commit has some minor technically-breaking changes surrounding
`usingnamespace`. I don't think they'll impact anyone, since the changes
are fixes around semantics which were previously inconsistent (the
behavior changed depending on hashmap iteration order!).

Aside from that, this changeset has no significant user-facing changes.
Instead, it is an internal refactor which makes it easier to correctly
model the responsibilities of different objects, particularly regarding
incremental compilation. The performance impact should be negligible,
but I will take measurements before merging this work into `master`.

Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
2024-08-11 07:29:41 +01:00
..
behavior compiler: split Decl into Nav and Cau 2024-08-11 07:29:41 +01:00
c_abi std.Target: Rework isPPC()/isPPC64() functions. 2024-08-01 20:58:05 +02:00
c_import c_import: extract behavior tests that use @cImport 2024-02-20 18:44:43 +01:00
cases compiler: split Decl into Nav and Cau 2024-08-11 07:29:41 +01:00
incremental incr-test: running an update 2024-07-20 01:06:29 -07:00
link elf: simplify output section tracking for symbols 2024-07-30 10:00:50 +02:00
src compiler: rework type resolution, fully resolve all types 2024-07-04 21:01:42 +01:00
standalone std.debug.Dwarf: fix loading external debuginfo in the ".debuglink" case. 2024-08-08 07:15:00 +02:00
assemble_and_link.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
behavior.zig astgen: fix result info for catch switch_block_err_union 2024-05-11 12:06:13 +03:00
c_import.zig c_import: extract behavior tests that use @cImport 2024-02-20 18:44:43 +01:00
cases.zig remove test/cbe.zig 2024-03-28 15:24:01 +02:00
compare_output.zig std: make options a struct instance instead of a namespace 2024-02-01 15:22:36 +02:00
compile_errors.zig tokenizer: tabs and carriage returns spec conformance 2024-07-31 16:57:42 -07:00
gen_h.zig all: zig fmt and rename "@XToY" to "@YFromX" 2023-06-19 12:34:42 -07:00
llvm_targets.zig std.Target: Remove sparcel architecture tag. 2024-07-30 06:30:25 +02:00
nvptx.zig zig build system: change target, compilation, and module APIs 2024-01-01 17:51:18 -07:00
run_translated_c.zig remove hard tabs from source code 2024-07-31 16:57:42 -07:00
stack_traces.zig test/stack_traces.zig: add err union switch case 2024-01-18 15:10:32 +11:00
tests.zig build.zig: fix -Dskip-non-native 2024-08-01 13:47:29 -07:00
translate_c.zig Merge pull request #20885 from ziglang/simplify-tokenizer 2024-07-31 19:52:34 -07:00