authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-18 20:09:34-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-18 20:09:34-05:00
log82101198f1ff2438f5db61d3a85eee3e0e1b95db
tree74e197e1000e88677b40629cc0f6ec40223f1923
parenta71fbe49cbbf068e00300533d5f3874efadb8c18

workaround for Arch being a primitive type


4 files changed, 30 insertions(+), 14 deletions(-)

src/analyze.cpp+14-1
......@@ -786,7 +786,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
786786 gen_param_info->src_index = i;
787787 gen_param_info->gen_index = SIZE_MAX;
788788
789 assert(type_is_complete(type_entry));
789 ensure_complete_type(g, type_entry);
790790 if (type_has_bits(type_entry)) {
791791 TypeTableEntry *gen_type;
792792 if (handle_is_ptr(type_entry)) {
......@@ -2911,3 +2911,16 @@ ConstExprValue *create_const_bool(bool value) {
29112911 init_const_bool(const_val, value);
29122912 return const_val;
29132913}
2914
2915void ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry) {
2916 if (type_entry->id == TypeTableEntryIdStruct) {
2917 if (!type_entry->data.structure.complete)
2918 resolve_struct_type(g, type_entry);
2919 } else if (type_entry->id == TypeTableEntryIdEnum) {
2920 if (!type_entry->data.enumeration.complete)
2921 resolve_enum_type(g, type_entry);
2922 } else if (type_entry->id == TypeTableEntryIdUnion) {
2923 if (!type_entry->data.unionation.complete)
2924 resolve_union_type(g, type_entry);
2925 }
2926}
src/analyze.hpp+2
......@@ -74,6 +74,8 @@ void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node);
7474AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);
7575FnTableEntry *scope_get_fn_if_root(Scope *scope);
7676bool type_requires_comptime(TypeTableEntry *type_entry);
77void ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry);
78void complete_enum(CodeGen *g, TypeTableEntry *enum_type);
7779
7880ScopeBlock *create_block_scope(AstNode *node, Scope *parent);
7981ScopeDefer *create_defer_scope(AstNode *node, Scope *parent);
src/ir.cpp+1-2
......@@ -6833,8 +6833,7 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field
68336833 IrInstructionFieldPtr *field_ptr_instruction, IrInstruction *container_ptr, TypeTableEntry *container_type)
68346834{
68356835 TypeTableEntry *bare_type = container_ref_type(container_type);
6836 if (!type_is_complete(bare_type))
6837 resolve_container_type(ira->codegen, bare_type);
6836 ensure_complete_type(ira->codegen, bare_type);
68386837
68396838 if (bare_type->id == TypeTableEntryIdStruct) {
68406839 TypeStructField *field = find_struct_type_field(bare_type, field_name);
std/elf.zig+13-11
......@@ -37,7 +37,9 @@ pub const FileType = enum {
3737 Core,
3838};
3939
40pub const Arch = enum {
40// TODO rename this to Arch when the builtin Arch enum is namespaced
41// or make debug info work for builtin enums
42pub const ElfArch = enum {
4143 Sparc,
4244 x86,
4345 Mips,
......@@ -68,7 +70,7 @@ pub const Elf = struct {
6870 is_64: bool,
6971 is_big_endian: bool,
7072 file_type: FileType,
71 arch: Arch,
73 arch: ElfArch,
7274 entry_addr: u64,
7375 program_header_offset: u64,
7476 section_header_offset: u64,
......@@ -122,15 +124,15 @@ pub const Elf = struct {
122124 };
123125
124126 elf.arch = switch (%return elf.in_stream.readInt(elf.is_big_endian, u16)) {
125 0x02 => Arch.Sparc,
126 0x03 => Arch.x86,
127 0x08 => Arch.Mips,
128 0x14 => Arch.PowerPc,
129 0x28 => Arch.Arm,
130 0x2A => Arch.SuperH,
131 0x32 => Arch.IA_64,
132 0x3E => Arch.x86_64,
133 0xb7 => Arch.AArch64,
127 0x02 => ElfArch.Sparc,
128 0x03 => ElfArch.x86,
129 0x08 => ElfArch.Mips,
130 0x14 => ElfArch.PowerPc,
131 0x28 => ElfArch.Arm,
132 0x2A => ElfArch.SuperH,
133 0x32 => ElfArch.IA_64,
134 0x3E => ElfArch.x86_64,
135 0xb7 => ElfArch.AArch64,
134136 else => return error.InvalidFormat,
135137 };
136138