extern structstd.zig.Zoir.CompileError[src]

Fields

msg: NullTerminatedString
token: Ast.TokenIndex
node_or_offset: u32

If token == invalid_token, this is an Ast.Node.Index. Otherwise, this is a byte offset into token.

first_note: u32

Ignored if note_count == 0.

note_count: u32

Values

Constantinvalid_token[src]

Source Code

Source code
pub const invalid_token: Ast.TokenIndex = std.math.maxInt(Ast.TokenIndex)

Functions

FunctiongetNotes[src]

pub fn getNotes(err: CompileError, zoir: Zoir) []const Note

Parameters

zoir: Zoir

Source Code

Source code
pub fn getNotes(err: CompileError, zoir: Zoir) []const Note {
    return zoir.error_notes[err.first_note..][0..err.note_count];
}

Source Code

Source code
pub const CompileError = extern struct {
    msg: NullTerminatedString,
    token: Ast.TokenIndex,
    /// If `token == invalid_token`, this is an `Ast.Node.Index`.
    /// Otherwise, this is a byte offset into `token`.
    node_or_offset: u32,

    /// Ignored if `note_count == 0`.
    first_note: u32,
    note_count: u32,

    pub fn getNotes(err: CompileError, zoir: Zoir) []const Note {
        return zoir.error_notes[err.first_note..][0..err.note_count];
    }

    pub const Note = extern struct {
        msg: NullTerminatedString,
        token: Ast.TokenIndex,
        /// If `token == invalid_token`, this is an `Ast.Node.Index`.
        /// Otherwise, this is a byte offset into `token`.
        node_or_offset: u32,
    };

    pub const invalid_token: Ast.TokenIndex = std.math.maxInt(Ast.TokenIndex);

    comptime {
        assert(std.meta.hasUniqueRepresentation(CompileError));
        assert(std.meta.hasUniqueRepresentation(Note));
    }
}