Introduce zir.h/zir.c with ZIR instruction types (269 tags, 56 extended opcodes, 8-byte Data union) ported from lib/std/zig/Zir.zig, and astgen.h/astgen.c implementing the empty-container fast path that produces correct ZIR for empty source files. The test infrastructure in astgen_test.zig compares C astGen() output field-by-field against Zig's std.zig.AstGen.generate() using tag-based dispatch, avoiding raw byte comparison since Zig's Data union has no guaranteed in-memory layout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
20 lines
435 B
C
20 lines
435 B
C
#include "zir.h"
|
|
#include <stdlib.h>
|
|
|
|
void zirDeinit(Zir* zir) {
|
|
free(zir->inst_tags);
|
|
free(zir->inst_datas);
|
|
free(zir->extra);
|
|
free(zir->string_bytes);
|
|
zir->inst_tags = NULL;
|
|
zir->inst_datas = NULL;
|
|
zir->extra = NULL;
|
|
zir->string_bytes = NULL;
|
|
zir->inst_len = 0;
|
|
zir->inst_cap = 0;
|
|
zir->extra_len = 0;
|
|
zir->extra_cap = 0;
|
|
zir->string_bytes_len = 0;
|
|
zir->string_bytes_cap = 0;
|
|
}
|