Eliminates all 39 mutable static globals across sema.c (37) and intern_pool.c (2). State is now held in properly-typed structs passed as parameters, mirroring the Zig reference implementation layout. New files matching Zig src/ layout: - compilation.h: CompilationConfig + Compilation (matches Compilation.zig) - zcu.h/zcu.c: ZcuFile, ZcuNamespace, Zcu, zcuInit/zcuDeinit (matches Zcu.zig) - zcu_per_thread.h: forward declarations for PerThread-style functions Key changes: - InternPool gains navs[] (dynamically allocated) + nav_count/nav_cap; Nav functions now take InternPool* (was implicit via globals) - Sema gains Zcu* zcu; semaInit now takes Zcu* instead of InternPool* - All module-level state (files, namespaces, memoized state, config) moved from static globals into Zcu struct - zig0.c creates Compilation + Zcu before semaInit - Test files updated to use zcuInit/zcuDeinit API Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
21 lines
783 B
C
21 lines
783 B
C
// compilation.h — ported from src/Compilation.zig (Config subset we use)
|
|
#ifndef _ZIG0_COMPILATION_H__
|
|
#define _ZIG0_COMPILATION_H__
|
|
#include <stdbool.h>
|
|
|
|
// Matches Compilation.Config (the fields relevant to stage0).
|
|
typedef struct {
|
|
const char* module_root; // was: s_global_module_root
|
|
const char* target_cpu_arch; // was: s_target_cpu_arch_name ("wasm32")
|
|
const char* target_cpu_model; // was: s_target_cpu_model_name ("lime1")
|
|
const char* object_format; // was: s_config_object_format ("wasm")
|
|
const char* link_mode; // was: s_config_link_mode ("static")
|
|
bool is_test; // was: s_config_is_test
|
|
} CompilationConfig;
|
|
|
|
// Matches Compilation struct (minimal subset).
|
|
typedef struct Compilation {
|
|
CompilationConfig config;
|
|
} Compilation;
|
|
#endif
|