Skip to documentation
SLOP

tiny.choir.Attribute

Reference tiny.choir Attribute

Defined in ir.attribute.

API (37)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

No direct callersNo direct callsir.attributeAttribute
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/choir/src/core/attribute.zig:5

zig
pub const Attribute = struct {    attr_id: AttrID,    impl: *const anyopaque,    abstract: *const interfaces.AbstractAttribute,    pub const AttrID = enum(u32) {        invalid = 0,        _,    };    pub const first_dynamic_attr_id: u32 = @backingInt(AttrID.invalid) + 1;    pub const DialectAttr = struct {        payload: []const u8,        context: *const anyopaque,    };    pub const IntegerAttr = struct {        value: i64,        width: u8,        is_signed: bool,        context: *const anyopaque,        pub fn getValue(self: *const IntegerAttr) i64 {            return self.value;        }        pub fn getUnsignedValue(self: *const IntegerAttr) u64 {            return @bitCast(self.value);        }    };    pub const FloatAttr = struct {        value: f64,        width: u8,        context: *const anyopaque,        pub fn getValue(self: *const FloatAttr) f64 {            return self.value;        }        pub fn getF32Value(self: *const FloatAttr) f32 {            return @floatCast(self.value);        }    };    pub const BoolAttr = struct {        value: bool,        context: *const anyopaque,        pub fn getValue(self: *const BoolAttr) bool {            return self.value;        }    };    pub const StringAttr = struct {        value: []const u8,        context: *const anyopaque,        pub fn getValue(self: *const StringAttr) []const u8 {            return self.value;        }    };    pub const SymbolRefAttr = struct {        root_reference: []const u8,        nested_references: []const []const u8,        context: *const anyopaque,        pub fn getRootReference(self: *const SymbolRefAttr) []const u8 {            return self.root_reference;        }        pub fn getNestedReferences(self: *const SymbolRefAttr) []const []const u8 {            return self.nested_references;        }        pub fn getLeafReference(self: *const SymbolRefAttr) []const u8 {            if (self.nested_references.len == 0) return self.root_reference;            return self.nested_references[self.nested_references.len - 1];        }        pub fn isFlat(self: *const SymbolRefAttr) bool {            return self.nested_references.len == 0;        }    };    pub const StringListAttr = struct {        values: []const []const u8,        context: *const anyopaque,        pub fn getValues(self: *const StringListAttr) []const []const u8 {            return self.values;        }    };    pub const TypeListAttr = struct {        values: []const Type,        context: *const anyopaque,        pub fn getValues(self: *const TypeListAttr) []const Type {            return self.values;        }    };    pub const ArrayAttr = struct {        values: []const Attribute,        context: *const anyopaque,        pub fn getValues(self: *const ArrayAttr) []const Attribute {            return self.values;        }    };    pub fn attrIdFromInt(id: u32) AttrID {        return @fromBackingInt(@intCast(id));    }    pub fn isa(self: Attribute, comptime attr_id: AttrID) bool {        return self.attr_id == attr_id;    }    pub fn eql(self: Attribute, other: Attribute) bool {        if (self.attr_id != other.attr_id) return false;        if (self.impl == other.impl) return true;        if (self.getInterface(interfaces.AttributeEqualInterface)) |vtable| {            return vtable.eql(self.impl, other.impl);        }        return false;    }    pub fn getInterface(self: Attribute, comptime IFace: type) ?*const IFace.VTable {        if (self.abstract.getInterface(IFace.id)) |iface| {            return @ptrCast(@alignCast(iface));        }        return null;    }    pub fn InterfaceHandle(comptime IFace: type) type {        return struct {            attr: Attribute,            vtable: *const IFace.VTable,            fn returnType(comptime fn_ptr_type: type) type {                const ptr_info = @typeInfo(fn_ptr_type);                const fn_type = switch (ptr_info) {                    .pointer => |p| p.child,                    else => @compileError("expected interface vtable field to be a function pointer"),                };                const fn_info = switch (@typeInfo(fn_type)) {                    .@"fn" => |f| f,                    else => @compileError("expected interface vtable field to be a function pointer"),                };                return fn_info.return_type orelse @compileError("generic interface vtable methods are not supported");            }            fn methodFnPtrType(comptime method: std.meta.FieldEnum(IFace.VTable)) type {                const dummy: IFace.VTable = undefined;                return @TypeOf(@field(dummy, @tagName(method)));            }            pub inline fn call(                self: @This(),                comptime method: std.meta.FieldEnum(IFace.VTable),                args: anytype,            ) returnType(methodFnPtrType(method)) {                const fn_ptr = @field(self.vtable, @tagName(method));                return @call(.auto, fn_ptr, .{self.attr.impl} ++ args);            }        };    }    pub fn interface(self: Attribute, comptime IFace: type) ?InterfaceHandle(IFace) {        const vtable = self.getInterface(IFace) orelse return null;        return .{ .attr = self, .vtable = vtable };    }    pub fn getAbstractAttribute(self: Attribute) *const interfaces.AbstractAttribute {        return self.abstract;    }    pub fn hasStorageType(self: Attribute, comptime T: type) bool {        return storageTypeMatchesName(T, self.abstract.name);    }    pub fn cast(self: Attribute, comptime T: type) ?*const T {        if (!self.hasStorageType(T)) return null;        return @ptrCast(@alignCast(self.impl));    }    pub fn format(self: Attribute, writer: *std.Io.Writer) std.Io.Writer.Error!void {        if (self.getInterface(interfaces.AttributePrintInterface)) |vtable| {            return vtable.print(self.impl, writer);        }        if (self.abstract.name.len > 0) {            try writer.print("#attr<{s}>", .{self.abstract.name});        } else {            try writer.print("#attr<{d}>", .{@backingInt(self.attr_id)});        }    }};

Source: lib/choir/src/root.zig:48

zig
pub const Attribute = ir.Attribute;
Called byCallsNo direct callsAttributeinterfaceprivate sourcelib.choir.src.core.operation.registrationMethodsAttributeInterfaceHandle
Static calls · unresolved targets: 2 · external targets: 0.
Called byCallsNo direct callstest sourcelib.choir.src.core.attribute.test_Attributecast checks comptime storage typetest sourcelib.choir.src.core.attributetest: NamedAttributeList grows spille...test sourcelib.choir.src.core.attributetest: NamedAttributeList keeps dictio...test sourcelib.choir.src.core.attributetest: NamedAttributeList stores small...private sourcelib.choir.src.core.context.attrsgetArrayAttr+8 moreAttributeattrIdFromInt
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersAttributehasStorageTypeAttributecast
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersAttributegetInterfaceAttributeeql
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callersAttributegetInterfaceAttributeformat
Static calls · unresolved targets: 2 · external targets: 0.
Called byCallsNo direct callsAttributeeqlAttributeformatAttributeinterfaceAttributegetInterface
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsAttributecastprivate sourcelib.choir.src.core.attributestorageTypeMatchesNameAttributehasStorageType
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersAttributeInterfaceHandleAttributegetInterfaceAttributeinterface
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

backends.wasm.emission.module_encoding.common.ir.Attribute, backends.wasm.emission.module_encoding.common.ir.attribute.Attribute, ir.Attribute.

Complete caller list for Attribute.attrIdFromInt

13 direct callers.

Audit

Definitions35
Public names175
Members27
Version26.7.0
Revisiondaab053ee433