diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-08-03 21:21:56 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-08-03 21:21:56 +0100 |
| commit | 49d337c83039715fd3100f6ec8a88dff80c08c4b (patch) | |
| tree | f129486fb80a44dc106a277a576438d0ce344d8c /src/ir_print.cpp | |
| parent | 294092979e89faa67dc77d2261e9ddafc18b0d0d (diff) | |
v0.6.2; Use Ada_Case for typesv0.6.2
Diffstat (limited to 'src/ir_print.cpp')
| -rw-r--r-- | src/ir_print.cpp | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp index c7dc9e2d0..70afb29e5 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -293,7 +293,7 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t) { case Type_Union: { if (t->Union.variants.count == 0) { - ir_write_string(f, "%%..opaque"); + ir_print_encoded_local(f, str_lit("..opaque")); } else { // NOTE(bill): The zero size array is used to fix the alignment used in a structure as // LLVM takes the first element's alignment as the entire alignment (like C) @@ -1723,10 +1723,41 @@ void ir_print_proc(irFileBuffer *f, irModule *m, irProcedure *proc) { void ir_print_type_name(irFileBuffer *f, irModule *m, irValue *v) { GB_ASSERT(v->kind == irValue_TypeName); - Type *bt = base_type(ir_type(v)); + Type *t = base_type(v->TypeName.type); ir_print_encoded_local(f, v->TypeName.name); ir_write_string(f, str_lit(" = type ")); - ir_print_type(f, m, base_type(v->TypeName.type)); + + + switch (t->kind) { + case Type_Union: + if (t->Union.variants.count == 0) { + ir_write_string(f, str_lit("{}")); + } else { + ir_print_type(f, m, t); + } + break; + case Type_Struct: + if (t->Struct.fields.count == 0) { + if (t->Struct.is_packed) { + ir_write_byte(f, '<'); + } + ir_write_byte(f, '{'); + if (t->Struct.custom_align > 0) { + ir_fprintf(f, "[0 x <%lld x i8>]", t->Struct.custom_align); + } + ir_write_byte(f, '}'); + if (t->Struct.is_packed) { + ir_write_byte(f, '>'); + } + } else { + ir_print_type(f, m, t); + } + break; + default: + ir_print_type(f, m, t); + break; + } + ir_write_byte(f, '\n'); } |