aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-07-10 20:39:42 +0100
committerGinger Bill <bill@gingerbill.org>2017-07-10 20:39:42 +0100
commitce4b7b8b7d54e889413cf2d43d85f2e4f4a0b007 (patch)
treee0e6335ddb211cdb927e73c7814d2b375124f7fe /src/ir.cpp
parent069a47220e55d0b64732c0eb146802edb6388246 (diff)
Nested record declarations
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 9335a71fd..477ae799e 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3632,10 +3632,13 @@ void ir_pop_target_list(irProcedure *proc) {
void ir_gen_global_type_name(irModule *m, Entity *e, String name) {
+ if (e->type == nullptr) return;
+
irValue *t = ir_value_type_name(m->allocator, name, e->type);
ir_module_add_value(m, e, t);
map_set(&m->members, hash_string(name), t);
+ #if 0
if (is_type_union(e->type)) {
Type *bt = base_type(e->type);
// NOTE(bill): Zeroth entry is null (for `match type` stmts)
@@ -3643,6 +3646,20 @@ void ir_gen_global_type_name(irModule *m, Entity *e, String name) {
ir_mangle_add_sub_type_name(m, bt->Record.variants[j], name);
}
}
+ #endif
+
+ Type *bt = base_type(e->type);
+ if (bt->kind == Type_Record) {
+ Scope *s = bt->Record.scope;
+ if (s != nullptr) {
+ for_array(i, s->elements.entries) {
+ Entity *e = s->elements.entries[i].value;
+ if (e->kind == Entity_TypeName) {
+ ir_mangle_add_sub_type_name(m, e, name);
+ }
+ }
+ }
+ }
}