aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-06-03 17:55:13 +0100
committergingerBill <bill@gingerbill.org>2018-06-03 17:55:13 +0100
commit3f4b6b22dce11b538baf61705c1787e6e013af04 (patch)
tree411cef70befdad492ad8737295e463ebca7d43a5 /src/ir.cpp
parente0549df03e20a57a2d01583c2129c8a76246f542 (diff)
Change our IR name mangling rules
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index b62c39888..4843f7453 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -6147,7 +6147,7 @@ irValue *ir_build_cond(irProcedure *proc, AstNode *cond, irBlock *true_block, ir
return v;
}
-void ir_build_poly_proc(irProcedure *proc, AstNodeProcLit *pd, Entity *e) {
+void ir_build_nested_proc(irProcedure *proc, AstNodeProcLit *pd, Entity *e) {
GB_ASSERT(pd->body != nullptr);
if (ir_min_dep_entity(proc->module, e) == false) {
@@ -6165,8 +6165,13 @@ void ir_build_poly_proc(irProcedure *proc, AstNodeProcLit *pd, Entity *e) {
isize name_len = proc->name.len + 1 + pd_name.len + 1 + 10 + 1;
u8 *name_text = gb_alloc_array(proc->module->allocator, u8, name_len);
- i32 guid = cast(i32)proc->children.count;
- name_len = gb_snprintf(cast(char *)name_text, name_len, "%.*s.%.*s-%d", LIT(proc->name), LIT(pd_name), guid);
+
+ if (is_type_polymorphic(e->type)) {
+ i32 guid = cast(i32)proc->children.count;
+ name_len = gb_snprintf(cast(char *)name_text, name_len, "%.*s.%.*s-%d", LIT(proc->name), LIT(pd_name), guid);
+ } else {
+ name_len = gb_snprintf(cast(char *)name_text, name_len, "%.*s.%.*s", LIT(proc->name), LIT(pd_name));
+ }
String name = make_string(name_text, name_len-1);
@@ -6221,8 +6226,12 @@ void ir_build_constant_value_decl(irProcedure *proc, AstNodeValueDecl *vd) {
irModule *m = proc->module;
isize name_len = proc->name.len + 1 + ts_name.len + 1 + 10 + 1;
u8 *name_text = gb_alloc_array(m->allocator, u8, name_len);
- i32 guid = cast(i32)m->members.entries.count;
- name_len = gb_snprintf(cast(char *)name_text, name_len, "%.*s.%.*s-%d", LIT(proc->name), LIT(ts_name), guid);
+ if (is_type_polymorphic(e->type)) {
+ i32 guid = cast(i32)m->members.entries.count;
+ name_len = gb_snprintf(cast(char *)name_text, name_len, "%.*s.%.*s-%d", LIT(proc->name), LIT(ts_name), guid);
+ } else {
+ name_len = gb_snprintf(cast(char *)name_text, name_len, "%.*s.%.*s", LIT(proc->name), LIT(ts_name));
+ }
String name = make_string(name_text, name_len-1);
irValue *value = ir_value_type_name(m->allocator, name, e->type);
@@ -6242,10 +6251,10 @@ void ir_build_constant_value_decl(irProcedure *proc, AstNodeValueDecl *vd) {
continue;
}
DeclInfo *d = decl_info_of_entity(e);
- ir_build_poly_proc(proc, &d->proc_lit->ProcLit, e);
+ ir_build_nested_proc(proc, &d->proc_lit->ProcLit, e);
}
} else {
- ir_build_poly_proc(proc, pl, e);
+ ir_build_nested_proc(proc, pl, e);
}
} else {