Changed TypeInfo layout.
This commit is contained in:
248
src/codegen.cpp
248
src/codegen.cpp
@@ -6349,143 +6349,143 @@ static void define_builtin_compile_vars(CodeGen *g) {
|
||||
{
|
||||
// TODO: Add method info where methods are supported.
|
||||
buf_appendf(contents,
|
||||
"pub const IntInfo = struct {\n"
|
||||
" is_signed: bool,\n"
|
||||
" bits: u8,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const FloatInfo = struct {\n"
|
||||
" bits: u8,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const PointerInfo = struct {\n"
|
||||
" is_const: bool,\n"
|
||||
" is_volatile: bool,\n"
|
||||
" alignment: u32,\n"
|
||||
" child: &TypeInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const ArrayInfo = struct {\n"
|
||||
" len: usize,\n"
|
||||
" child: &TypeInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const ContainerLayout = enum {\n"
|
||||
" Auto,\n"
|
||||
" Extern,\n"
|
||||
" Packed,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const StructFieldInfo = struct {\n"
|
||||
" name: []const u8,\n"
|
||||
" offset: usize,\n"
|
||||
" type_info: TypeInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const StructInfo = struct {\n"
|
||||
" layout: ContainerLayout,\n"
|
||||
" fields: []StructFieldInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const NullableInfo = struct {\n"
|
||||
" child: &TypeInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const ErrorUnionInfo = struct {\n"
|
||||
" error_set: ErrorSetInfo,\n"
|
||||
" payload: &TypeInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const ErrorInfo = struct {\n"
|
||||
" name: []const u8,\n"
|
||||
" value: usize,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const ErrorSetInfo = struct {\n"
|
||||
" errors: []ErrorInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const EnumFieldInfo = struct {\n"
|
||||
" name: []const u8,\n"
|
||||
" value: usize,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const EnumInfo = struct {\n"
|
||||
" layout: ContainerLayout,\n"
|
||||
" tag_type: IntInfo,\n"
|
||||
" fields: []EnumFieldInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const UnionFieldInfo = struct {\n"
|
||||
" name: []const u8,\n"
|
||||
" enum_field: EnumFieldInfo,\n"
|
||||
" type_info: TypeInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const UnionInfo = struct {\n"
|
||||
" layout: ContainerLayout,\n"
|
||||
" tag_type: ?EnumInfo,\n"
|
||||
" fields: []UnionFieldInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const CallingConvention = enum {\n"
|
||||
" Unspecified,\n"
|
||||
" C,\n"
|
||||
" Cold,\n"
|
||||
" Naked,\n"
|
||||
" Stdcall,\n"
|
||||
" Async,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const FnArgInfo = struct {\n"
|
||||
" is_comptime: bool,\n"
|
||||
" name: []const u8,\n"
|
||||
" type_info: TypeInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const FnInfo = struct {\n"
|
||||
" calling_convention: CallingConvention,\n"
|
||||
" is_generic: bool,\n"
|
||||
" is_varargs: bool,\n"
|
||||
" return_type: &TypeInfo,\n"
|
||||
" args: []FnArgInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const BoundFnInfo = struct {\n"
|
||||
" bound_type: &TypeInfo,\n"
|
||||
" fn_info: FnInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const PromiseInfo = struct {\n"
|
||||
" child: ?&TypeInfo,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"pub const TypeInfo = union(TypeId) {\n"
|
||||
" Type: void,\n"
|
||||
" Void: void,\n"
|
||||
" Bool: void,\n"
|
||||
" NoReturn: void,\n"
|
||||
" Int: IntInfo,\n"
|
||||
" Float: FloatInfo,\n"
|
||||
" Pointer: PointerInfo,\n"
|
||||
" Array: ArrayInfo,\n"
|
||||
" Struct: StructInfo,\n"
|
||||
" Int: Int,\n"
|
||||
" Float: Float,\n"
|
||||
" Pointer: Pointer,\n"
|
||||
" Array: Array,\n"
|
||||
" Struct: Struct,\n"
|
||||
" FloatLiteral: void,\n"
|
||||
" IntLiteral: void,\n"
|
||||
" UndefinedLiteral: void,\n"
|
||||
" NullLiteral: void,\n"
|
||||
" Nullable: NullableInfo,\n"
|
||||
" ErrorUnion: ErrorUnionInfo,\n"
|
||||
" ErrorSet: ErrorSetInfo,\n"
|
||||
" Enum: EnumInfo,\n"
|
||||
" Union: UnionInfo,\n"
|
||||
" Fn: FnInfo,\n"
|
||||
" Nullable: Nullable,\n"
|
||||
" ErrorUnion: ErrorUnion,\n"
|
||||
" ErrorSet: ErrorSet,\n"
|
||||
" Enum: Enum,\n"
|
||||
" Union: Union,\n"
|
||||
" Fn: Fn,\n"
|
||||
" Namespace: void,\n"
|
||||
" Block: void,\n"
|
||||
" BoundFn: BoundFnInfo,\n"
|
||||
" BoundFn: BoundFn,\n"
|
||||
" ArgTuple: void,\n"
|
||||
" Opaque: void,\n"
|
||||
" Promise: PromiseInfo,\n"
|
||||
" Promise: Promise,\n"
|
||||
"\n\n"
|
||||
" pub const Int = struct {\n"
|
||||
" is_signed: bool,\n"
|
||||
" bits: u8,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Float = struct {\n"
|
||||
" bits: u8,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Pointer = struct {\n"
|
||||
" is_const: bool,\n"
|
||||
" is_volatile: bool,\n"
|
||||
" alignment: u32,\n"
|
||||
" child: &TypeInfo,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Array = struct {\n"
|
||||
" len: usize,\n"
|
||||
" child: &TypeInfo,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const ContainerLayout = enum {\n"
|
||||
" Auto,\n"
|
||||
" Extern,\n"
|
||||
" Packed,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const StructField = struct {\n"
|
||||
" name: []const u8,\n"
|
||||
" offset: usize,\n"
|
||||
" type_info: TypeInfo,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Struct = struct {\n"
|
||||
" layout: ContainerLayout,\n"
|
||||
" fields: []StructField,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Nullable = struct {\n"
|
||||
" child: &TypeInfo,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const ErrorUnion = struct {\n"
|
||||
" error_set: ErrorSet,\n"
|
||||
" payload: &TypeInfo,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Error = struct {\n"
|
||||
" name: []const u8,\n"
|
||||
" value: usize,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const ErrorSet = struct {\n"
|
||||
" errors: []Error,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const EnumField = struct {\n"
|
||||
" name: []const u8,\n"
|
||||
" value: usize,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Enum = struct {\n"
|
||||
" layout: ContainerLayout,\n"
|
||||
" tag_type: Int,\n"
|
||||
" fields: []EnumField,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const UnionField = struct {\n"
|
||||
" name: []const u8,\n"
|
||||
" enum_field: EnumField,\n"
|
||||
" type_info: TypeInfo,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Union = struct {\n"
|
||||
" layout: ContainerLayout,\n"
|
||||
" tag_type: ?Enum,\n"
|
||||
" fields: []UnionField,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const CallingConvention = enum {\n"
|
||||
" Unspecified,\n"
|
||||
" C,\n"
|
||||
" Cold,\n"
|
||||
" Naked,\n"
|
||||
" Stdcall,\n"
|
||||
" Async,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const FnArg = struct {\n"
|
||||
" is_comptime: bool,\n"
|
||||
" name: []const u8,\n"
|
||||
" type_info: TypeInfo,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Fn = struct {\n"
|
||||
" calling_convention: CallingConvention,\n"
|
||||
" is_generic: bool,\n"
|
||||
" is_varargs: bool,\n"
|
||||
" return_type: &TypeInfo,\n"
|
||||
" args: []FnArg,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const BoundFn = struct {\n"
|
||||
" bound_type: &TypeInfo,\n"
|
||||
" fn_info: Fn,\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
" pub const Promise = struct {\n"
|
||||
" child: ?&TypeInfo,\n"
|
||||
" };\n"
|
||||
"};\n\n");
|
||||
assert(ContainerLayoutAuto == 0);
|
||||
assert(ContainerLayoutExtern == 1);
|
||||
|
||||
Reference in New Issue
Block a user