diff options
| author | gingerBill <bill@gingerbill.org> | 2023-07-25 13:31:22 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-07-25 13:31:22 +0100 |
| commit | baea6a1da88444db322f83b8300b5d64d117cfd1 (patch) | |
| tree | 9e0e4b3db70e49d49f688ad3e93ac0aad5ab59b0 /src/tilde_const.cpp | |
| parent | ba48093666e2862e861203b38d3dbc35aa7532ff (diff) | |
Generate anonymous procedure literals
Diffstat (limited to 'src/tilde_const.cpp')
| -rw-r--r-- | src/tilde_const.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/tilde_const.cpp b/src/tilde_const.cpp index 30038cfdf..05b57a97a 100644 --- a/src/tilde_const.cpp +++ b/src/tilde_const.cpp @@ -911,17 +911,24 @@ gb_internal cgValue cg_const_value(cgProcedure *p, Type *type, ExactValue const case ExactValue_Procedure: { Ast *expr = unparen_expr(value.value_procedure); + if (expr->kind == Ast_ProcLit) { + cgProcedure *anon = cg_procedure_generate_anonymous(p->module, expr, p); + TB_Node *ptr = tb_inst_get_symbol_address(p->func, anon->symbol); + GB_ASSERT(are_types_identical(type, anon->type)); + return cg_value(ptr, type); + } + Entity *e = entity_of_node(expr); if (e != nullptr) { - cgValue found = cg_find_procedure_value_from_entity(p->module, e); - GB_ASSERT_MSG(are_types_identical(type, found.type), - "%.*s %s == %s", - LIT(p->name), - type_to_string(type), type_to_string(found.type)); - GB_ASSERT(found.kind == cgValue_Symbol); - return cg_flatten_value(p, found); + TB_Symbol *found = cg_find_symbol_from_entity(p->module, e); + GB_ASSERT_MSG(found != nullptr, "could not find '%.*s'", LIT(e->token.string)); + TB_Node *ptr = tb_inst_get_symbol_address(p->func, found); + GB_ASSERT(type != nullptr); + GB_ASSERT(are_types_identical(type, e->type)); + return cg_value(ptr, type); } - GB_PANIC("TODO(bill): cg_const_value ExactValue_Procedure"); + + GB_PANIC("TODO(bill): cg_const_value ExactValue_Procedure %s", expr_to_string(expr)); } break; } |