import "map.hff"; import "all.hff"; struct StringKeyTraits { fn hash(s *const u8) u32 { return fnv1a_s(FNV1A_INI, s); } fn eq(a *const u8, b *const u8) bool { return streq(a, b); } } struct Env { parent *Env, alloc *Allocator, decls Map<*const u8, *DeclList, StringKeyTraits>, } extern fn mkenv(parent *Env, alloc *Allocator) *Env { let env *Env = xmalloc(sizeof Env); *env = { parent, alloc }; return env; } extern fn envput(env *Env, decl *const Decl) *Decl { let l **DeclList = env.decls->get_slot(decl.name); let n *DeclList = env.alloc->alloc(sizeof *DeclList); n.link = *l; n.decl = *decl; *l = n; return &n.decl; }