aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-05-03 13:59:26 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-05-03 13:59:26 -0400
commit51a5bf63a2a9dd73e5b20b0b9aab2f87c6400eb0 (patch)
treecec7e8dec9adb5ba39eb056a43880fe117bd67dd
parente476799ab7d0e26256ac9be25888e963dc0928a0 (diff)
Deprecate function name registering and printing the function's name
-rw-r--r--src/compile.c14
-rw-r--r--src/environment.h1
-rw-r--r--src/stdlib/functiontype.c70
3 files changed, 0 insertions, 85 deletions
diff --git a/src/compile.c b/src/compile.c
index 6dd10a20..0eab15bc 100644
--- a/src/compile.c
+++ b/src/compile.c
@@ -3040,12 +3040,6 @@ CORD compile(env_t *env, ast_t *ast)
DeclareMatch(lambda, ast, Lambda);
CORD name = namespace_name(env, env->namespace, CORD_all("lambda$", String(lambda->id)));
- env->code->function_naming = CORD_all(
- env->code->function_naming,
- "register_function(", name, ", Text(\"", file_base_name(ast->file->filename), ".tm\"), ",
- String(get_line_number(ast->file, ast->start)),
- ", Text(", CORD_quoted(type_to_cord(get_type(env, ast))), "));\n");
-
env_t *body_scope = fresh_scope(env);
body_scope->deferred = NULL;
for (arg_ast_t *arg = lambda->args; arg; arg = arg->next) {
@@ -4303,13 +4297,6 @@ CORD compile_function(env_t *env, CORD name_code, ast_t *ast, CORD *staticdefs)
if (ret_t && ret_t->tag != VoidType)
text = CORD_all(text, "->", type_to_cord(ret_t));
text = CORD_all(text, ")");
-
- if (!is_inline) {
- env->code->function_naming = CORD_all(
- env->code->function_naming,
- "register_function(", name_code, ", Text(\"", file_base_name(ast->file->filename), ".tm\"), ",
- String(get_line_number(ast->file, ast->start)), ", Text(", CORD_quoted(text), "));\n");
- }
return definition;
}
@@ -4493,7 +4480,6 @@ CORD compile_file(env_t *env, ast_t *ast)
"initialized = true;\n",
use_imports,
env->code->variable_initializers,
- env->code->function_naming,
"}\n");
}
diff --git a/src/environment.h b/src/environment.h
index 74de3449..a89935e6 100644
--- a/src/environment.h
+++ b/src/environment.h
@@ -15,7 +15,6 @@ typedef struct {
CORD staticdefs;
CORD lambdas;
CORD variable_initializers;
- CORD function_naming;
} compilation_unit_t;
typedef struct deferral_s {
diff --git a/src/stdlib/functiontype.c b/src/stdlib/functiontype.c
index 3769be2d..b0fff1a7 100644
--- a/src/stdlib/functiontype.c
+++ b/src/stdlib/functiontype.c
@@ -11,79 +11,9 @@
#include "types.h"
#include "util.h"
-typedef struct {
- Text_t filename, name;
- int64_t line_num;
-} func_info_t;
-
-static NamedType_t fields[] = {
- {.name="filename", .type=&Text$info},
- {.name="name", .type=&Text$info},
- {.name="line_num", .type=&Int64$info},
-};
-
-static const TypeInfo_t func_info_type = {.size=sizeof(func_info_t), .align=__alignof__(func_info_t), .metamethods=Struct$metamethods,
- .tag=StructInfo, .StructInfo.name="FuncInfo",
- .StructInfo.num_fields=3, .StructInfo.fields=fields};
-static Table_t function_info = {};
-
-public void register_function(void *fn, Text_t filename, int64_t line_num, Text_t name)
-{
- func_info_t info = {
- .filename=filename,
- .line_num=line_num,
- .name=name,
- };
- Table$set(&function_info, &fn, &info, Table$info(Function$info("???"), &func_info_type));
-}
-
-PUREFUNC static func_info_t *get_function_info(void *fn)
-{
- func_info_t *info = Table$get(function_info, &fn, Table$info(Function$info("???"), &func_info_type));
- if (info) return info;
-
- void *closest_fn = NULL;
- for (int64_t i = 0; i < function_info.entries.length; i++) {
- struct { void *fn; func_info_t info; } *entry = function_info.entries.data + i*function_info.entries.stride;
- if (entry->fn > fn || entry->fn < closest_fn) continue;
- closest_fn = entry->fn;
- info = &entry->info;
- }
- return info;
-}
-
-PUREFUNC public OptionalText_t get_function_name(void *fn)
-{
- func_info_t *info = get_function_info(fn);
- return info ? info->name : NONE_TEXT;
-}
-
-PUREFUNC public OptionalText_t get_function_filename(void *fn)
-{
- func_info_t *info = get_function_info(fn);
- return info ? info->filename : NONE_TEXT;
-}
-
-PUREFUNC public int64_t get_function_line_num(void *fn)
-{
- func_info_t *info = get_function_info(fn);
- return info ? info->line_num : -1;
-}
-
public Text_t Func$as_text(const void *fn, bool colorize, const TypeInfo_t *type)
{
- (void)fn;
Text_t text = Text$from_str(type->FunctionInfo.type_str);
- if (fn) {
- OptionalText_t name = get_function_name(*(void**)fn);
- if (name.length >= 0)
- text = name;
-
- OptionalText_t filename = get_function_filename(*(void**)fn);
- int64_t line_num = get_function_line_num(*(void**)fn);
- if (filename.length >= 0)
- text = Texts(text, Text(" ["), filename, Text(":"), Int64$as_text(&line_num, false, &Int64$info), Text("]"));
- }
if (fn && colorize)
text = Text$concat(Text("\x1b[32;1m"), text, Text("\x1b[m"));
return text;