Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › compiler/ › translate-c/ › Translator.zig › transReturnStmt
transReturnStmt
Translator.transReturnStmt
fn transReturnStmt (t : *Translator , scope : *Scope , return_stmt : Node .ReturnStmt ) TransError !ZigNode
File
Code
fn transReturnStmt (t : *Translator , scope : *Scope , return_stmt : Node .ReturnStmt ) TransError !ZigNode {
switch (return_stmt .operand ) {
.none => return ZigTag .return_void .init (),
.expr => |operand | {
const rhs = try t .transExprCoercing (scope , operand , .used );
const return_qt = scope .findBlockReturnType ();
return ZigTag .@"return" .create (t .arena , try t .toNonBool (rhs , return_qt ));
},
.implicit => |zero | {
if (zero ) return ZigTag .@"return" .create (t .arena , ZigTag .zero_literal .init ());
const return_qt = scope .findBlockReturnType ();
if (return_qt .is (t .comp , .void )) return ZigTag .empty_block .init ();
return ZigTag .@"return" .create (t .arena , ZigTag .undefined_literal .init ());
},
}
}