enumstd.zig.Zir.Inst.Declaration.Name[src]

Fields

@"comptime" = std.math.maxInt(u32)
@"usingnamespace" = std.math.maxInt(u32) - 1
unnamed_test = std.math.maxInt(u32) - 2
_

Other values are NullTerminatedString values, i.e. index into string_bytes. If the byte referenced is 0, the decl is a named test, and the actual name begins at the following byte.

Functions

FunctionisNamedTest[src]

pub fn isNamedTest(name: Name, zir: Zir) bool

Parameters

name: Name
zir: Zir

Source Code

Source code
pub fn isNamedTest(name: Name, zir: Zir) bool {
    return switch (name) {
        .@"comptime", .@"usingnamespace", .unnamed_test => false,
        _ => zir.string_bytes[@intFromEnum(name)] == 0,
    };
}

FunctiontoString[src]

pub fn toString(name: Name, zir: Zir) ?NullTerminatedString

Parameters

name: Name
zir: Zir

Source Code

Source code
pub fn toString(name: Name, zir: Zir) ?NullTerminatedString {
    switch (name) {
        .@"comptime", .@"usingnamespace", .unnamed_test => return null,
        _ => {},
    }
    const idx: u32 = @intFromEnum(name);
    if (zir.string_bytes[idx] == 0) {
        // Named test
        return @enumFromInt(idx + 1);
    }
    return @enumFromInt(idx);
}

Source Code

Source code
pub const Name = enum(u32) {
    @"comptime" = std.math.maxInt(u32),
    @"usingnamespace" = std.math.maxInt(u32) - 1,
    unnamed_test = std.math.maxInt(u32) - 2,
    /// Other values are `NullTerminatedString` values, i.e. index into
    /// `string_bytes`. If the byte referenced is 0, the decl is a named
    /// test, and the actual name begins at the following byte.
    _,

    pub fn isNamedTest(name: Name, zir: Zir) bool {
        return switch (name) {
            .@"comptime", .@"usingnamespace", .unnamed_test => false,
            _ => zir.string_bytes[@intFromEnum(name)] == 0,
        };
    }
    pub fn toString(name: Name, zir: Zir) ?NullTerminatedString {
        switch (name) {
            .@"comptime", .@"usingnamespace", .unnamed_test => return null,
            _ => {},
        }
        const idx: u32 = @intFromEnum(name);
        if (zir.string_bytes[idx] == 0) {
            // Named test
            return @enumFromInt(idx + 1);
        }
        return @enumFromInt(idx);
    }
}