From 1e6df09900ebb0f3f1d2d3deb57e25ee463b50e4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 26 Feb 2024 23:10:19 -0500 Subject: Fix up some type namespace issues --- compile.c | 4 +++- environment.c | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/compile.c b/compile.c index c6e6ddf5..fc5fa539 100644 --- a/compile.c +++ b/compile.c @@ -1041,7 +1041,9 @@ CORD compile_type_info(env_t *env, type_t *t) case ClosureType: { errx(1, "No typeinfo for closures yet"); } - default: errx(1, "No such typeinfo"); + case TypeInfoType: return "&TypeInfo_namespace.type"; + default: + compiler_err(NULL, 0, 0, "I couldn't convert to a type info: %T", t); } } diff --git a/environment.c b/environment.c index 6957f26d..60857c2c 100644 --- a/environment.c +++ b/environment.c @@ -16,8 +16,8 @@ static type_t *namespace_type(const char *name, table_t *ns) { arg_t *fields = NULL; for (int64_t i = Table_length(ns); i >= 1; i--) { - struct {const char *name; binding_t binding; } *entry = Table_entry(ns, i); - fields = new(arg_t, .next=fields, .name=entry->name, .type=entry->binding.type); + struct {const char *name; binding_t *binding; } *entry = Table_entry(ns, i); + fields = new(arg_t, .next=fields, .name=entry->name, .type=entry->binding->type); } return Type(StructType, .name=name, .fields=fields); } @@ -63,7 +63,9 @@ env_t *new_compilation_unit(void) }; for (size_t i = 0; i < sizeof(global_types)/sizeof(global_types[0]); i++) { - Table_str_set(env->globals, global_types[i].name, namespace_type(global_types[i].name, &global_types[i].namespace)); + table_t *ns = new(table_t); + *ns = global_types[i].namespace; + Table_str_set(env->globals, global_types[i].name, new(binding_t, .type=namespace_type(global_types[i].name, ns))); Table_str_set(env->types, global_types[i].name, global_types[i].type); } -- cgit v1.2.3