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) {...@@ -786,7 +786,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
786 gen_param_info->src_index = i;786 gen_param_info->src_index = i;
787 gen_param_info->gen_index = SIZE_MAX;787 gen_param_info->gen_index = SIZE_MAX;
788788
789 assert(type_is_complete(type_entry));789 ensure_complete_type(g, type_entry);
790 if (type_has_bits(type_entry)) {790 if (type_has_bits(type_entry)) {
791 TypeTableEntry *gen_type;791 TypeTableEntry *gen_type;
792 if (handle_is_ptr(type_entry)) {792 if (handle_is_ptr(type_entry)) {
...@@ -2911,3 +2911,16 @@ ConstExprValue *create_const_bool(bool value) {...@@ -2911,3 +2911,16 @@ ConstExprValue *create_const_bool(bool value) {
2911 init_const_bool(const_val, value);2911 init_const_bool(const_val, value);
2912 return const_val;2912 return const_val;
2913}2913}
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);...@@ -74,6 +74,8 @@ void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node);
74AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);74AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);
75FnTableEntry *scope_get_fn_if_root(Scope *scope);75FnTableEntry *scope_get_fn_if_root(Scope *scope);
76bool type_requires_comptime(TypeTableEntry *type_entry);76bool type_requires_comptime(TypeTableEntry *type_entry);
77void ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry);
78void complete_enum(CodeGen *g, TypeTableEntry *enum_type);
7779
78ScopeBlock *create_block_scope(AstNode *node, Scope *parent);80ScopeBlock *create_block_scope(AstNode *node, Scope *parent);
79ScopeDefer *create_defer_scope(AstNode *node, Scope *parent);81ScopeDefer *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...@@ -6833,8 +6833,7 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field
6833 IrInstructionFieldPtr *field_ptr_instruction, IrInstruction *container_ptr, TypeTableEntry *container_type)6833 IrInstructionFieldPtr *field_ptr_instruction, IrInstruction *container_ptr, TypeTableEntry *container_type)
6834{6834{
6835 TypeTableEntry *bare_type = container_ref_type(container_type);6835 TypeTableEntry *bare_type = container_ref_type(container_type);
6836 if (!type_is_complete(bare_type))6836 ensure_complete_type(ira->codegen, bare_type);
6837 resolve_container_type(ira->codegen, bare_type);
68386837
6839 if (bare_type->id == TypeTableEntryIdStruct) {6838 if (bare_type->id == TypeTableEntryIdStruct) {
6840 TypeStructField *field = find_struct_type_field(bare_type, field_name);6839 TypeStructField *field = find_struct_type_field(bare_type, field_name);
std/elf.zig+13-11
...@@ -37,7 +37,9 @@ pub const FileType = enum {...@@ -37,7 +37,9 @@ pub const FileType = enum {
37 Core,37 Core,
38};38};
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 {
41 Sparc,43 Sparc,
42 x86,44 x86,
43 Mips,45 Mips,
...@@ -68,7 +70,7 @@ pub const Elf = struct {...@@ -68,7 +70,7 @@ pub const Elf = struct {
68 is_64: bool,70 is_64: bool,
69 is_big_endian: bool,71 is_big_endian: bool,
70 file_type: FileType,72 file_type: FileType,
71 arch: Arch,73 arch: ElfArch,
72 entry_addr: u64,74 entry_addr: u64,
73 program_header_offset: u64,75 program_header_offset: u64,
74 section_header_offset: u64,76 section_header_offset: u64,
...@@ -122,15 +124,15 @@ pub const Elf = struct {...@@ -122,15 +124,15 @@ pub const Elf = struct {
122 };124 };
123125
124 elf.arch = switch (%return elf.in_stream.readInt(elf.is_big_endian, u16)) {126 elf.arch = switch (%return elf.in_stream.readInt(elf.is_big_endian, u16)) {
125 0x02 => Arch.Sparc,127 0x02 => ElfArch.Sparc,
126 0x03 => Arch.x86,128 0x03 => ElfArch.x86,
127 0x08 => Arch.Mips,129 0x08 => ElfArch.Mips,
128 0x14 => Arch.PowerPc,130 0x14 => ElfArch.PowerPc,
129 0x28 => Arch.Arm,131 0x28 => ElfArch.Arm,
130 0x2A => Arch.SuperH,132 0x2A => ElfArch.SuperH,
131 0x32 => Arch.IA_64,133 0x32 => ElfArch.IA_64,
132 0x3E => Arch.x86_64,134 0x3E => ElfArch.x86_64,
133 0xb7 => Arch.AArch64,135 0xb7 => ElfArch.AArch64,
134 else => return error.InvalidFormat,136 else => return error.InvalidFormat,
135 };137 };
136138