diff options
| author | gingerBill <bill@gingerbill.org> | 2020-10-29 09:58:08 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-10-29 09:58:08 +0000 |
| commit | 08fae7360afd8eda54a5aaaaa7a7fb502c57c6e8 (patch) | |
| tree | 4a4ae70f943e2d50c4511aaf3737961b7dbdad8a /src/ir.cpp | |
| parent | 4629754f7ced5df477eb017872ef65539db64a27 (diff) | |
Fix ir printing for nested procedure literals indirectly through identifiers
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 58f6b1799..2b3bd35df 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -1623,6 +1623,7 @@ irDefer ir_add_defer_proc(irProcedure *proc, isize scope_index, irValue *deferre return d; } +irValue *ir_add_module_constant(irModule *m, Type *type, ExactValue value); irValue *ir_check_compound_lit_constant(irModule *m, Ast *expr) { expr = unparen_expr(expr); @@ -1644,6 +1645,14 @@ irValue *ir_check_compound_lit_constant(irModule *m, Ast *expr) { if (expr->kind == Ast_ProcLit) { return ir_gen_anonymous_proc_lit(m, str_lit("_proclit"), expr); } + + if (expr->kind == Ast_Ident || expr->kind == Ast_SelectorExpr) { + TypeAndValue tav = type_and_value_of_expr(expr); + if (tav.mode == Addressing_Constant) { + return ir_add_module_constant(m, tav.type, tav.value); + } + } + return nullptr; } |