Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Public Function

writeAbbrevAdapted

Public Function
std.zig.llvm.bitcode_writer.BitcodeWriter.BlockWriter.writeAbbrevAdapted
pub fn writeAbbrevAdapted(
                    self: *Self,
                    params: anytype,
                    adapter: anytype,
                ) Error!void

Params

  • self: *Self
  • params
  • adapter

Errors

OutOfMemory

File

zig/llvm/bitcode_writer.zig:240
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
                pub fn writeAbbrevAdapted(
                    self: *Self,
                    params: anytype,
                    adapter: anytype,
                ) Error!void {
                    const Abbrev = @TypeOf(params);

                    try self.bitcode.writeBits(comptime abbrevId(Abbrev), abbrev_len);

                    const field_names = @typeInfo(Abbrev).@"struct".field_names;

                    // This abbreviation might only contain literals
                    if (field_names.len == 0) return;

                    comptime var field_index: usize = 0;
                    inline for (Abbrev.ops) |ty| {
                        const param = @field(params, field_names[field_index]);
                        switch (ty) {
                            .literal => continue,
                            .fixed => |len| try self.bitcode.writeBits(adapter.get(param), len),
                            .fixed_runtime => |width_ty| try self.bitcode.writeBits(
                                adapter.get(param),
                                self.bitcode.getTypeWidth(width_ty),
                            ),
                            .vbr => |len| try self.bitcode.writeVbr(adapter.get(param), len),
                            .char6 => try self.bitcode.write6BitChar(adapter.get(param)),
                            .blob => {
                                try self.bitcode.writeVbr(param.len, 6);
                                try self.bitcode.writeBlob(param);
                            },
                            .array_fixed => |len| {
                                try self.bitcode.writeVbr(param.len, 6);
                                for (param) |x| {
                                    try self.bitcode.writeBits(adapter.get(x), len);
                                }
                            },
                            .array_fixed_runtime => |width_ty| {
                                try self.bitcode.writeVbr(param.len, 6);
                                for (param) |x| {
                                    try self.bitcode.writeBits(
                                        adapter.get(x),
                                        self.bitcode.getTypeWidth(width_ty),
                                    );
                                }
                            },
                            .array_vbr => |len| {
                                try self.bitcode.writeVbr(param.len, 6);
                                for (param) |x| {
                                    try self.bitcode.writeVbr(adapter.get(x), len);
                                }
                            },
                            .array_char6 => {
                                try self.bitcode.writeVbr(param.len, 6);
                                for (param) |x| {
                                    try self.bitcode.write6BitChar(adapter.get(x));
                                }
                            },
                        }
                        field_index += 1;
                        if (field_index == field_names.len) break;
                    }
                }