Files
zig/CLAUDE.md
Motiejus Jakštys 202733edbc astgen: implement ZIR generation for basic expressions and declarations
Mechanical translation of AstGen.zig into C. Implements:
- Container members: comptime, simple_var_decl, test_decl, fn_decl
- Expressions: number_literal, string_literal, identifier (with
  primitive types, integer types, and decl_val/decl_ref resolution),
  field_access (field_val/field_ptr), address_of, builtin_call
  (@import), array_type, array_init (with inferred [_] length),
  array_cat (++), ptr_type
- Statement types: assign with _ = expr discard pattern
- Test infrastructure: testDecl, addFunc, fullBodyExpr,
  blockExprStmts, emitDbgNode/emitDbgStmt, rvalueDiscard
- Support: GenZir sub-block instruction tracking, result location
  propagation (RL_NONE/RL_REF/RL_DISCARD), string dedup, import
  tracking, namespace decl table, lastToken, firstToken

1/5 corpus files pass (test_all.zig). Remaining 4 skip gracefully
via has_compile_errors when encountering unimplemented features.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 21:32:37 +00:00

1.1 KiB

  • when porting features from upstream Zig, it should be a mechanical copy. Don't invent. Most of what you are doing is invented, but needs to be re-done in C. Keep the structure in place, name functions and types the same way (or within reason equivalently if there are namespacing constraints). It should be easy to reference one from the other; and, if there are semantic differences, they must be because Zig or C does not support certain features (like errdefer).
  • See README.md for useful information about this project, incl. how to test this.
  • Never ever remove zig-cache, nether local nor global.
  • Zig code is in ~/code/zig, don't look at /nix/...
  • when translating functions from Zig to C (mechanically, remember?), add them in the same order as in the original Zig file.
  • debug printfs: add printfs only when debugging a specific issue; when done debugging, remove them (or comment them if you may find them useful later). I prefer committing code only when zig build returns no output.
  • remember: mechanical copy when porting existing stuff, no new creativity.