feature. See also
. The project being documented here (as the example) is the Zig library itself.
Translator.transStringLiteral
fn transStringLiteral(
t: *Translator,
scope: *Scope,
expr: Node.Index,
literal: Node.CharLiteral,
) TransError!ZigNode
File
Code
fn transStringLiteral(
t: *Translator,
scope: *Scope,
expr: Node.Index,
literal: Node.CharLiteral,
) TransError!ZigNode {
switch (literal.kind) {
.ascii, .utf8 => return t.transNarrowStringLiteral(expr, literal),
.utf16, .utf32, .wide => {
const name = try std.fmt.allocPrint(t.arena, "{s}_string_{d}", .{ @tagName(literal.kind), t.getMangle() });
const array_type = try t.transTypeInit(scope, literal.qt, expr, literal.literal_tok);
const lit_array = try t.transStringLiteralInitializer(expr, literal, array_type);
const decl = try ZigTag.var_simple.create(t.arena, .{ .name = name, .init = lit_array });
try scope.appendNode(decl);
return ZigTag.identifier.create(t.arena, name);
},
}
}