From ed4bbfd8cf4a72fdf4a5d6cba94d537cab340356 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Thu, 22 Jan 2026 22:40:43 +0000 Subject: Removing some duplicates and dissecting codegen/parser. --- src/codegen/codegen_utils.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/codegen/codegen_utils.c') diff --git a/src/codegen/codegen_utils.c b/src/codegen/codegen_utils.c index e490789..fe580bf 100644 --- a/src/codegen/codegen_utils.c +++ b/src/codegen/codegen_utils.c @@ -20,6 +20,26 @@ int loop_defer_boundary[MAX_LOOP_DEPTH]; int loop_depth = 0; int func_defer_boundary = 0; +// Strip template suffix from a type name (for example, "MyStruct" -> "MyStruct") +// Returns newly allocated string, caller must free. +char *strip_template_suffix(const char *name) +{ + if (!name) + { + return NULL; + } + char *lt = strchr(name, '<'); + if (lt) + { + int len = lt - name; + char *buf = xmalloc(len + 1); + strncpy(buf, name, len); + buf[len] = 0; + return buf; + } + return xstrdup(name); +} + // Helper to emit variable declarations with array types. void emit_var_decl_type(ParserContext *ctx, FILE *out, const char *type_str, const char *var_name) { -- cgit v1.2.3