feature. See also
. The project being documented here (as the example) is the Zig library itself.
Translator.transDecl
fn transDecl(t: *Translator, scope: *Scope, decl: Node.Index) !void
File
Code
fn transDecl(t: *Translator, scope: *Scope, decl: Node.Index) !void {
switch (decl.get(t.tree)) {
.typedef => |typedef_decl| {
if (typedef_decl.implicit) return;
try t.transTypeDef(scope, decl);
},
.struct_decl, .union_decl => |record_decl| {
try t.transRecordDecl(scope, record_decl.container_qt);
},
.struct_forward_decl, .union_forward_decl => |record_decl| {
if (record_decl.definition) |some| {
return t.transDecl(scope, some);
}
try t.transRecordDecl(scope, record_decl.container_qt);
},
.enum_decl => |enum_decl| {
try t.transEnumDecl(scope, enum_decl.container_qt);
},
.enum_forward_decl => |enum_decl| {
if (enum_decl.definition) |some| {
return t.transDecl(scope, some);
}
try t.transEnumDecl(scope, enum_decl.container_qt);
},
.enum_field,
.record_field,
=> return,
.function => |function| {
if (function.definition) |definition| {
return t.transFnDecl(scope, definition.get(t.tree).function);
}
try t.transFnDecl(scope, function);
},
.variable => |variable| {
if (variable.definition != null) return;
try t.transVarDecl(scope, variable, decl);
},
.static_assert => |static_assert| {
try t.transStaticAssert(&t.global_scope.base, static_assert);
},
.global_asm => |global_asm| {
try t.transGlobalAsm(&t.global_scope.base, global_asm);
},
.empty_decl => {},
else => unreachable,
}
}