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 › getContainerTypeOf
getContainerTypeOf
Translator.getContainerTypeOf
fn getContainerTypeOf (t : *Translator , ref : ZigNode ) ?ZigNode
File
Code
fn getContainerTypeOf (t : *Translator , ref : ZigNode ) ?ZigNode {
if (ref .castTag (.identifier )) |ident | {
if (t .global_scope .sym_table .get (ident .data )) |value | {
if (value .castTag (.var_decl )) |var_decl | {
return t .getContainer (var_decl .data .type );
}
}
} else if (ref .castTag (.field_access )) |field_access | {
if (t .getContainerTypeOf (field_access .data .lhs )) |ty_node | {
if (ty_node .castTag (.@"struct" ) orelse ty_node .castTag (.@"union" )) |container | {
for (container .data .fields ) |field | {
if (mem .eql (u8 , field .name , field_access .data .field_name )) {
return t .getContainer (field .type );
}
}
} else return ty_node ;
}
}
return null ;
}