aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-06-11 16:11:54 +0100
committergingerBill <bill@gingerbill.org>2020-06-11 16:11:54 +0100
commit01d12770fac3138f3d406a6fd1660018fd0f7e27 (patch)
treefcfb8ea84e2a04af3d498bc8e2a05f073fc18cdd /src/ir.cpp
parent82b559c32b7afd9d8dd265f6541ba0f8e81345f4 (diff)
Fix compound literals for constant procedure fields
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 5a24c8c3d..fb1a20f6d 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -1615,10 +1615,10 @@ irDefer ir_add_defer_proc(irProcedure *proc, isize scope_index, irValue *deferre
}
-void ir_check_compound_lit_constant(irModule *m, Ast *expr) {
+irValue *ir_check_compound_lit_constant(irModule *m, Ast *expr) {
expr = unparen_expr(expr);
if (expr == nullptr) {
- return;
+ return nullptr;
}
if (expr->kind == Ast_CompoundLit) {
ast_node(cl, CompoundLit, expr);
@@ -1633,8 +1633,9 @@ void ir_check_compound_lit_constant(irModule *m, Ast *expr) {
}
}
if (expr->kind == Ast_ProcLit) {
- ir_gen_anonymous_proc_lit(m, str_lit("_proclit"), expr);
+ return ir_gen_anonymous_proc_lit(m, str_lit("_proclit"), expr);
}
+ return nullptr;
}
irValue *ir_add_module_constant(irModule *m, Type *type, ExactValue value) {
@@ -1674,7 +1675,11 @@ irValue *ir_add_module_constant(irModule *m, Type *type, ExactValue value) {
}
if (value.kind == ExactValue_Compound) {
- ir_check_compound_lit_constant(m, value.value_compound);
+ // NOTE(bill): Removed for numerous reasons
+ irValue *lit = ir_check_compound_lit_constant(m, value.value_compound);
+ if (lit != nullptr) {
+ return lit;
+ }
}
return ir_value_constant(type, value);
@@ -6530,6 +6535,11 @@ void ir_pop_target_list(irProcedure *proc) {
irValue *ir_gen_anonymous_proc_lit(irModule *m, String prefix_name, Ast *expr, irProcedure *proc) {
+ auto *found = map_get(&m->anonymous_proc_lits, hash_pointer(expr));
+ if (found != nullptr) {
+ return *found;
+ }
+
ast_node(pl, ProcLit, expr);
// NOTE(bill): Generate a new name