# self-hosted: implement Decl lookup · gitcafe/zig

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

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

Visibility: public

Requested revision: 7e58c56ca72099f6e71752289be7165947bfaa04

Requested commit: 7e58c56ca72099f6e71752289be7165947bfaa04

Commit: 7e58c56ca72099f6e71752289be7165947bfaa04

Tree: d4b5def4b5fd17caba14e88f5bdc3673449e8fdd

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
self-hosted: implement Decl lookup

 * Take advantage of coercing anonymous struct literals to struct types.
 * Reworks Module to favor Zig source as the primary use case.
   Breaks ZIR compilation, which will have to be restored in a future commit.
 * Decl uses src_index rather then src, pointing to an AST Decl node
   index, or ZIR Module Decl index, rather than a byte offset.
 * ZIR instructions have an `analyzed_inst` field instead of Module
   having a hash table.
 * Module.Fn loses the `fn_type` field since it is redundant with
   its `owner_decl` `TypedValue` type.
 * Implement Type and Value copying. A ZIR Const instruction's TypedValue
   is copied to the Decl arena during analysis, which allows freeing the
   ZIR text instructions post-analysis.
 * Don't flush the ELF file if there are compilation errors.
 * Function return types allow arbitrarily complex expressions.
 * AST->ZIR for function calls and return statements.

```

## Parents

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

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