aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-04-13 15:48:56 +0100
committergingerBill <bill@gingerbill.org>2020-04-13 15:48:56 +0100
commitf229084baa383ebd81c5d04db1ede5dc71017904 (patch)
treeb2f5f4ace82547fd96e1e6bf3279dd300272c928 /src/ir.cpp
parentf09b6a4c90805a562b2252430f844e85d06f1ee1 (diff)
Basic polymorphic named procedure parameters for procedures and records
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index e8ab09ea5..a5d532b97 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -1984,7 +1984,11 @@ irDebugEncoding ir_debug_encoding_for_basic(BasicKind kind) {
// case Basic_f16:
case Basic_f32:
case Basic_f64:
- return irDebugBasicEncoding_float;
+ case Basic_f32le:
+ case Basic_f64le:
+ case Basic_f32be:
+ case Basic_f64be:
+ return irDebugBasicEncoding_float;
// case Basic_complex32:
case Basic_complex64:
@@ -7104,6 +7108,29 @@ irValue *ir_build_expr_internal(irProcedure *proc, Ast *expr) {
return ir_emit_conv(proc, v, tv.type);
}
+ if (tv.value.kind == ExactValue_Procedure) {
+ Ast *expr = tv.value.value_procedure;
+ if (expr->kind == Ast_ProcLit) {
+ return ir_gen_anonymous_proc_lit(proc->module, str_lit("_proclit"), expr);
+ }
+ Entity *e = entity_from_expr(expr);
+ e = strip_entity_wrapping(e);
+ GB_ASSERT(e != nullptr);
+ auto *found = map_get(&proc->module->values, hash_entity(e));
+ if (found) {
+ auto v = *found;
+ // NOTE(bill): This is because pointers are already pointers in LLVM
+ if (is_type_proc(ir_type(v))) {
+ return v;
+ }
+ return ir_emit_load(proc, v);
+ } else if (e != nullptr && e->kind == Entity_Variable) {
+ return ir_addr_load(proc, ir_build_addr(proc, expr));
+ }
+
+ GB_PANIC("Error in: %.*s(%td:%td) %s\n", LIT(proc->name), e->token.pos.line, e->token.pos.column);
+ }
+
return ir_add_module_constant(proc->module, tv.type, tv.value);
}
@@ -7139,6 +7166,8 @@ irValue *ir_build_expr_internal(irProcedure *proc, Ast *expr) {
case_ast_node(i, Ident, expr);
Entity *e = entity_of_ident(expr);
+ e = strip_entity_wrapping(e);
+
GB_ASSERT_MSG(e != nullptr, "%s", expr_to_string(expr));
if (e->kind == Entity_Builtin) {
Token token = ast_token(expr);