@@ -227,6 +227,9 @@ pub const Node = extern union {
227
227
/// [1]type{val} ** count
228
228
array_filler ,
229
229
230
+ /// @import("std").zig.c_translation.EmulateBitfieldStruct(S)
231
+ helpers_emulate_bitfield_struct ,
232
+
230
233
pub const last_no_payload_tag = Tag .@"break" ;
231
234
pub const no_payload_count = @intFromEnum (last_no_payload_tag ) + 1 ;
232
235
@@ -376,6 +379,7 @@ pub const Node = extern union {
376
379
.shuffle = > Payload .Shuffle ,
377
380
.builtin_extern = > Payload .Extern ,
378
381
.macro_arithmetic = > Payload .MacroArithmetic ,
382
+ .helpers_emulate_bitfield_struct = > Payload .EmulateBitfieldStruct ,
379
383
};
380
384
}
381
385
@@ -698,6 +702,15 @@ pub const Payload = struct {
698
702
},
699
703
};
700
704
705
+ pub const EmulateBitfieldStruct = struct {
706
+ base : Payload ,
707
+ data : struct {
708
+ record : Node ,
709
+ backings : Node ,
710
+ cfg : Node ,
711
+ },
712
+ };
713
+
701
714
pub const StringSlice = struct {
702
715
base : Payload ,
703
716
data : struct {
@@ -917,6 +930,11 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
917
930
const import_node = try renderStdImport (c , &.{ "zig" , "c_translation" , "shuffleVectorIndex" });
918
931
return renderCall (c , import_node , &.{ payload .lhs , payload .rhs });
919
932
},
933
+ .helpers_emulate_bitfield_struct = > {
934
+ const payload = node .castTag (.helpers_emulate_bitfield_struct ).? .data ;
935
+ const import_node = try renderStdImport (c , &.{ "zig" , "c_translation" , "EmulateBitfieldStruct" });
936
+ return renderCall (c , import_node , &.{ payload .record , payload .backings , payload .cfg });
937
+ },
920
938
.vector = > {
921
939
const payload = node .castTag (.vector ).? .data ;
922
940
return renderBuiltinCall (c , "@Vector" , &.{ payload .lhs , payload .rhs });
@@ -2042,25 +2060,34 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
2042
2060
}
2043
2061
_ = try c .addToken (.r_brace , "}" );
2044
2062
2045
- if (payload .len < 3 ) {
2046
- return c .addNode (.{
2047
- .tag = .struct_init_dot_two_comma ,
2063
+ switch (payload .len ) {
2064
+ 0 = > return c .addNode (.{
2065
+ .tag = .struct_init_dot_two , // the inits[0], inits[1] are both 0
2048
2066
.main_token = l_brace ,
2049
2067
.data = .{
2050
2068
.lhs = inits [0 ],
2051
2069
.rhs = inits [1 ],
2052
2070
},
2053
- });
2054
- } else {
2055
- const span = try c .listToSpan (inits );
2056
- return c .addNode (.{
2057
- .tag = .struct_init_dot_comma ,
2071
+ }),
2072
+ 1 , 2 = > return c .addNode (.{
2073
+ .tag = .struct_init_dot_two_comma ,
2058
2074
.main_token = l_brace ,
2059
2075
.data = .{
2060
- .lhs = span . start ,
2061
- .rhs = span . end ,
2076
+ .lhs = inits [ 0 ] ,
2077
+ .rhs = inits [ 1 ] ,
2062
2078
},
2063
- });
2079
+ }),
2080
+ else = > {
2081
+ const span = try c .listToSpan (inits );
2082
+ return c .addNode (.{
2083
+ .tag = .struct_init_dot_comma ,
2084
+ .main_token = l_brace ,
2085
+ .data = .{
2086
+ .lhs = span .start ,
2087
+ .rhs = span .end ,
2088
+ },
2089
+ });
2090
+ },
2064
2091
}
2065
2092
},
2066
2093
.container_init = > {
@@ -2387,6 +2414,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
2387
2414
.helpers_promoteIntLiteral ,
2388
2415
.helpers_shuffle_vector_index ,
2389
2416
.helpers_flexible_array_type ,
2417
+ .helpers_emulate_bitfield_struct ,
2390
2418
.std_mem_zeroinit ,
2391
2419
.integer_literal ,
2392
2420
.float_literal ,
0 commit comments