mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 21:38:33 +00:00
workaround for Arch being a primitive type
This commit is contained in:
parent
a71fbe49cb
commit
82101198f1
@ -786,7 +786,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
|
||||
gen_param_info->src_index = i;
|
||||
gen_param_info->gen_index = SIZE_MAX;
|
||||
|
||||
assert(type_is_complete(type_entry));
|
||||
ensure_complete_type(g, type_entry);
|
||||
if (type_has_bits(type_entry)) {
|
||||
TypeTableEntry *gen_type;
|
||||
if (handle_is_ptr(type_entry)) {
|
||||
@ -2911,3 +2911,16 @@ ConstExprValue *create_const_bool(bool value) {
|
||||
init_const_bool(const_val, value);
|
||||
return const_val;
|
||||
}
|
||||
|
||||
void ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry) {
|
||||
if (type_entry->id == TypeTableEntryIdStruct) {
|
||||
if (!type_entry->data.structure.complete)
|
||||
resolve_struct_type(g, type_entry);
|
||||
} else if (type_entry->id == TypeTableEntryIdEnum) {
|
||||
if (!type_entry->data.enumeration.complete)
|
||||
resolve_enum_type(g, type_entry);
|
||||
} else if (type_entry->id == TypeTableEntryIdUnion) {
|
||||
if (!type_entry->data.unionation.complete)
|
||||
resolve_union_type(g, type_entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,6 +74,8 @@ void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node);
|
||||
AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);
|
||||
FnTableEntry *scope_get_fn_if_root(Scope *scope);
|
||||
bool type_requires_comptime(TypeTableEntry *type_entry);
|
||||
void ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry);
|
||||
void complete_enum(CodeGen *g, TypeTableEntry *enum_type);
|
||||
|
||||
ScopeBlock *create_block_scope(AstNode *node, Scope *parent);
|
||||
ScopeDefer *create_defer_scope(AstNode *node, Scope *parent);
|
||||
|
||||
@ -6833,8 +6833,7 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field
|
||||
IrInstructionFieldPtr *field_ptr_instruction, IrInstruction *container_ptr, TypeTableEntry *container_type)
|
||||
{
|
||||
TypeTableEntry *bare_type = container_ref_type(container_type);
|
||||
if (!type_is_complete(bare_type))
|
||||
resolve_container_type(ira->codegen, bare_type);
|
||||
ensure_complete_type(ira->codegen, bare_type);
|
||||
|
||||
if (bare_type->id == TypeTableEntryIdStruct) {
|
||||
TypeStructField *field = find_struct_type_field(bare_type, field_name);
|
||||
|
||||
24
std/elf.zig
24
std/elf.zig
@ -37,7 +37,9 @@ pub const FileType = enum {
|
||||
Core,
|
||||
};
|
||||
|
||||
pub const Arch = enum {
|
||||
// TODO rename this to Arch when the builtin Arch enum is namespaced
|
||||
// or make debug info work for builtin enums
|
||||
pub const ElfArch = enum {
|
||||
Sparc,
|
||||
x86,
|
||||
Mips,
|
||||
@ -68,7 +70,7 @@ pub const Elf = struct {
|
||||
is_64: bool,
|
||||
is_big_endian: bool,
|
||||
file_type: FileType,
|
||||
arch: Arch,
|
||||
arch: ElfArch,
|
||||
entry_addr: u64,
|
||||
program_header_offset: u64,
|
||||
section_header_offset: u64,
|
||||
@ -122,15 +124,15 @@ pub const Elf = struct {
|
||||
};
|
||||
|
||||
elf.arch = switch (%return elf.in_stream.readInt(elf.is_big_endian, u16)) {
|
||||
0x02 => Arch.Sparc,
|
||||
0x03 => Arch.x86,
|
||||
0x08 => Arch.Mips,
|
||||
0x14 => Arch.PowerPc,
|
||||
0x28 => Arch.Arm,
|
||||
0x2A => Arch.SuperH,
|
||||
0x32 => Arch.IA_64,
|
||||
0x3E => Arch.x86_64,
|
||||
0xb7 => Arch.AArch64,
|
||||
0x02 => ElfArch.Sparc,
|
||||
0x03 => ElfArch.x86,
|
||||
0x08 => ElfArch.Mips,
|
||||
0x14 => ElfArch.PowerPc,
|
||||
0x28 => ElfArch.Arm,
|
||||
0x2A => ElfArch.SuperH,
|
||||
0x32 => ElfArch.IA_64,
|
||||
0x3E => ElfArch.x86_64,
|
||||
0xb7 => ElfArch.AArch64,
|
||||
else => return error.InvalidFormat,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user