DoxigAlpha

addBundleAsNotes

Function parameters

Parameters

#
wip:*Wip

Type definitions in this namespace

Types

#
ErrorMessageList
There will be a MessageIndex for each len at start.
SourceLocation
Trailing:
ErrorMessage
Trailing:

Functions in this namespace

Functions

#
nullTerminatedString
Given an index into `string_bytes` returns the null-terminated string found there.

Special encoding when there are no errors.

Values

#
empty
Special encoding when there are no errors.

Source

Implementation

#
pub fn addBundleAsNotes(wip: *Wip, other: ErrorBundle) Allocator.Error!void {
    const gpa = wip.gpa;

    try wip.string_bytes.ensureUnusedCapacity(gpa, other.string_bytes.len);
    try wip.extra.ensureUnusedCapacity(gpa, other.extra.len);

    const other_list = other.getMessages();

    // The ensureUnusedCapacity call above guarantees this.
    const notes_start = wip.reserveNotes(@intCast(other_list.len)) catch unreachable;
    for (notes_start.., other_list) |note, message| {
        // This line can cause `wip.extra.items` to be resized.
        const note_index = @intFromEnum(wip.addOtherMessage(other, message) catch unreachable);
        wip.extra.items[note] = note_index;
    }
}