feature. See also
. The project being documented here (as the example) is the Zig library itself.
Translator.transTypeInit
fn transTypeInit(
t: *Translator,
scope: *Scope,
qt: QualType,
init: Node.Index,
source_loc: TokenIndex,
) TypeError!ZigNode
File
Code
fn transTypeInit(
t: *Translator,
scope: *Scope,
qt: QualType,
init: Node.Index,
source_loc: TokenIndex,
) TypeError!ZigNode {
switch (init.get(t.tree)) {
.string_literal_expr => |literal| {
const elem_ty = try t.transType(scope, qt.childType(t.comp), source_loc);
const string_lit_size = literal.qt.arrayLen(t.comp).?;
const array_size = qt.arrayLen(t.comp).?;
if (array_size == string_lit_size) {
return ZigTag.null_sentinel_array_type.create(t.arena, .{ .len = array_size - 1, .elem_type = elem_ty });
} else {
return ZigTag.array_type.create(t.arena, .{ .len = array_size, .elem_type = elem_ty });
}
},
else => {},
}
return t.transType(scope, qt, source_loc);
}