union Type [src]
This data structure is used by the Zig language code generation and
therefore must be kept in sync with the compiler implementation.
Fields
type: void
void: void
bool: void
noreturn: void
int: Int
float: Float
pointer: Pointer
array: Array
@"struct": Struct
comptime_float: void
comptime_int: void
undefined: void
null: void
optional: Optional
error_union: ErrorUnion
error_set: ErrorSet
@"enum": Enum
@"union": Union
@"fn": Fn
@"opaque": Opaque
frame: Frame
@"anyframe": AnyFrame
vector: Vector
enum_literal: void
Members
- AnyFrame (struct)
- Array (struct)
- ContainerLayout (enum)
- Declaration (struct)
- Enum (struct)
- EnumField (struct)
- Error (struct)
- ErrorSet (Type)
- ErrorUnion (struct)
- Float (struct)
- Fn (struct)
- Frame (struct)
- Int (struct)
- Opaque (struct)
- Optional (struct)
- Pointer (struct)
- Struct (struct)
- StructField (struct)
- Union (struct)
- UnionField (struct)
- Vector (struct)
Source
pub const Type = union(enum) {
type: void,
void: void,
bool: void,
noreturn: void,
int: Int,
float: Float,
pointer: Pointer,
array: Array,
@"struct": Struct,
comptime_float: void,
comptime_int: void,
undefined: void,
null: void,
optional: Optional,
error_union: ErrorUnion,
error_set: ErrorSet,
@"enum": Enum,
@"union": Union,
@"fn": Fn,
@"opaque": Opaque,
frame: Frame,
@"anyframe": AnyFrame,
vector: Vector,
enum_literal: void,
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Int = struct {
signedness: Signedness,
bits: u16,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Float = struct {
bits: u16,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Pointer = struct {
size: Size,
is_const: bool,
is_volatile: bool,
/// TODO make this u16 instead of comptime_int
alignment: comptime_int,
address_space: AddressSpace,
child: type,
is_allowzero: bool,
/// The type of the sentinel is the element type of the pointer, which is
/// the value of the `child` field in this struct. However there is no way
/// to refer to that type here, so we use `*const anyopaque`.
/// See also: `sentinel`
sentinel_ptr: ?*const anyopaque,
/// Loads the pointer type's sentinel value from `sentinel_ptr`.
/// Returns `null` if the pointer type has no sentinel.
pub inline fn sentinel(comptime ptr: Pointer) ?ptr.child {
const sp: *const ptr.child = @ptrCast(@alignCast(ptr.sentinel_ptr orelse return null));
return sp.*;
}
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Size = enum(u2) {
one,
many,
slice,
c,
};
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Array = struct {
len: comptime_int,
child: type,
/// The type of the sentinel is the element type of the array, which is
/// the value of the `child` field in this struct. However there is no way
/// to refer to that type here, so we use `*const anyopaque`.
/// See also: `sentinel`.
sentinel_ptr: ?*const anyopaque,
/// Loads the array type's sentinel value from `sentinel_ptr`.
/// Returns `null` if the array type has no sentinel.
pub inline fn sentinel(comptime arr: Array) ?arr.child {
const sp: *const arr.child = @ptrCast(@alignCast(arr.sentinel_ptr orelse return null));
return sp.*;
}
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const ContainerLayout = enum(u2) {
auto,
@"extern",
@"packed",
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const StructField = struct {
name: [:0]const u8,
type: type,
/// The type of the default value is the type of this struct field, which
/// is the value of the `type` field in this struct. However there is no
/// way to refer to that type here, so we use `*const anyopaque`.
/// See also: `defaultValue`.
default_value_ptr: ?*const anyopaque,
is_comptime: bool,
alignment: comptime_int,
/// Loads the field's default value from `default_value_ptr`.
/// Returns `null` if the field has no default value.
pub inline fn defaultValue(comptime sf: StructField) ?sf.type {
const dp: *const sf.type = @ptrCast(@alignCast(sf.default_value_ptr orelse return null));
return dp.*;
}
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Struct = struct {
layout: ContainerLayout,
/// Only valid if layout is .@"packed"
backing_integer: ?type = null,
fields: []const StructField,
decls: []const Declaration,
is_tuple: bool,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Optional = struct {
child: type,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const ErrorUnion = struct {
error_set: type,
payload: type,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Error = struct {
name: [:0]const u8,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const ErrorSet = ?[]const Error;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const EnumField = struct {
name: [:0]const u8,
value: comptime_int,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Enum = struct {
tag_type: type,
fields: []const EnumField,
decls: []const Declaration,
is_exhaustive: bool,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const UnionField = struct {
name: [:0]const u8,
type: type,
alignment: comptime_int,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Union = struct {
layout: ContainerLayout,
tag_type: ?type,
fields: []const UnionField,
decls: []const Declaration,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Fn = struct {
calling_convention: CallingConvention,
is_generic: bool,
is_var_args: bool,
/// TODO change the language spec to make this not optional.
return_type: ?type,
params: []const Param,
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Param = struct {
is_generic: bool,
is_noalias: bool,
type: ?type,
};
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Opaque = struct {
decls: []const Declaration,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Frame = struct {
function: *const anyopaque,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const AnyFrame = struct {
child: ?type,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Vector = struct {
len: comptime_int,
child: type,
};
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Declaration = struct {
name: [:0]const u8,
};
}