aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-10-13 12:51:47 +0100
committergingerBill <bill@gingerbill.org>2019-10-13 12:51:47 +0100
commit03053a18ce78e567cf1ee596c4975e69790d3def (patch)
tree292780418a07b921b2a9344abab264da38396302 /src/ir.cpp
parent2a6d9e8927ad1eb1e5f3a79fc9ed068a02cbfdfc (diff)
Fix IR generation bug for nested foreign procedure declaration
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 017a12025..0bf706f67 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -8265,24 +8265,27 @@ void ir_build_constant_value_decl(irProcedure *proc, AstValueDecl *vd) {
name = e->Procedure.link_name;
}
+ HashKey key = hash_string(name);
+ irValue **prev_value = map_get(&proc->module->members, key);
+ if (prev_value != nullptr) {
+ // NOTE(bill): Don't do mutliple declarations in the IR
+ return;
+ }
+
+
irValue *value = ir_value_procedure(proc->module, e, e->type, pl->type, pl->body, name);
value->Proc.tags = pl->tags;
value->Proc.inlining = pl->inlining;
- ir_module_add_value(proc->module, e, value);
- ir_build_proc(value, proc);
-
if (value->Proc.is_foreign || value->Proc.is_export) {
- HashKey key = hash_string(name);
- irValue **prev_value = map_get(&proc->module->members, key);
- if (prev_value == nullptr) {
- // NOTE(bill): Don't do mutliple declarations in the IR
- map_set(&proc->module->members, key, value);
- }
+ map_set(&proc->module->members, key, value);
} else {
array_add(&proc->children, &value->Proc);
}
+
+ ir_module_add_value(proc->module, e, value);
+ ir_build_proc(value, proc);
}
}
}