summaryrefslogtreecommitdiff
path: root/src/codegen/codegen_utils.c
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-22 22:40:43 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-22 22:40:43 +0000
commited4bbfd8cf4a72fdf4a5d6cba94d537cab340356 (patch)
tree80f520cb36f25a210537b477007b0ac5a24e4b8e /src/codegen/codegen_utils.c
parent3d1840e8690bef6e58a208d9ca33857a59a2e852 (diff)
Removing some duplicates and dissecting codegen/parser.
Diffstat (limited to 'src/codegen/codegen_utils.c')
-rw-r--r--src/codegen/codegen_utils.c20
1 files changed, 20 insertions, 0 deletions
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<T>" -> "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)
{