From ed50bd1b655ff028bdd650edecdcdd6675f1dee0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 17 Aug 2016 20:11:04 -0700 Subject: progress toward stack trace printing --- src/codegen.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index e840e42c06..3b954da4f6 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -4576,6 +4576,33 @@ static void define_builtin_types(CodeGen *g) { g->builtin_types.entry_environ_enum = entry; } + { + TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum); + entry->deep_const = true; + entry->zero_bits = true; // only allowed at compile time + buf_init_from_str(&entry->name, "@ObjectFormat"); + uint32_t field_count = target_oformat_count(); + entry->data.enumeration.field_count = field_count; + entry->data.enumeration.fields = allocate(field_count); + for (uint32_t i = 0; i < field_count; i += 1) { + TypeEnumField *type_enum_field = &entry->data.enumeration.fields[i]; + ZigLLVM_ObjectFormatType oformat = get_target_oformat(i); + type_enum_field->name = buf_create_from_str(get_target_oformat_name(oformat)); + type_enum_field->value = i; + type_enum_field->type_entry = g->builtin_types.entry_void; + + if (oformat == g->zig_target.oformat) { + g->target_oformat_index = i; + } + } + entry->data.enumeration.complete = true; + + TypeTableEntry *tag_type_entry = get_smallest_unsigned_int_type(g, field_count); + entry->data.enumeration.tag_type = tag_type_entry; + + g->builtin_types.entry_oformat_enum = entry; + } + { TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum); entry->deep_const = true; -- cgit v1.2.3