summaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-26 02:55:51 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-26 02:55:51 +0000
commite310dbff40e60e878032d59fd7c550398ee34e5d (patch)
tree5ef84fbfaf461e9253e75522a7c8798344358183 /src/codegen
parent2022012d6514578bd53a91b3048d08cf8686e233 (diff)
Fixed duplicate logic and stability issues
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/codegen_main.c32
-rw-r--r--src/codegen/codegen_stmt.c14
2 files changed, 17 insertions, 29 deletions
diff --git a/src/codegen/codegen_main.c b/src/codegen/codegen_main.c
index 61269ef..6e66bcb 100644
--- a/src/codegen/codegen_main.c
+++ b/src/codegen/codegen_main.c
@@ -458,15 +458,15 @@ void codegen_node(ParserContext *ctx, ASTNode *node, FILE *out)
if (ctx->parsed_globals_list)
{
- StructRef *s = ctx->parsed_globals_list;
- while (s)
+ StructRef *struct_ref = ctx->parsed_globals_list;
+ while (struct_ref)
{
ASTNode *copy = xmalloc(sizeof(ASTNode));
- *copy = *s->node;
+ *copy = *struct_ref->node;
copy->next = merged_globals;
merged_globals = copy;
- s = s->next;
+ struct_ref = struct_ref->next;
}
}
@@ -477,11 +477,11 @@ void codegen_node(ParserContext *ctx, ASTNode *node, FILE *out)
if (ctx->instantiated_funcs)
{
- ASTNode *s = ctx->instantiated_funcs;
- while (s)
+ ASTNode *fn_node = ctx->instantiated_funcs;
+ while (fn_node)
{
ASTNode *copy = xmalloc(sizeof(ASTNode));
- *copy = *s;
+ *copy = *fn_node;
copy->next = NULL;
if (!merged_funcs)
{
@@ -493,17 +493,17 @@ void codegen_node(ParserContext *ctx, ASTNode *node, FILE *out)
merged_funcs_tail->next = copy;
merged_funcs_tail = copy;
}
- s = s->next;
+ fn_node = fn_node->next;
}
}
if (ctx->parsed_funcs_list)
{
- StructRef *s = ctx->parsed_funcs_list;
- while (s)
+ StructRef *fn_ref = ctx->parsed_funcs_list;
+ while (fn_ref)
{
ASTNode *copy = xmalloc(sizeof(ASTNode));
- *copy = *s->node;
+ *copy = *fn_ref->node;
copy->next = NULL;
if (!merged_funcs)
{
@@ -515,17 +515,17 @@ void codegen_node(ParserContext *ctx, ASTNode *node, FILE *out)
merged_funcs_tail->next = copy;
merged_funcs_tail = copy;
}
- s = s->next;
+ fn_ref = fn_ref->next;
}
}
if (ctx->parsed_impls_list)
{
- StructRef *s = ctx->parsed_impls_list;
- while (s)
+ StructRef *impl_ref = ctx->parsed_impls_list;
+ while (impl_ref)
{
ASTNode *copy = xmalloc(sizeof(ASTNode));
- *copy = *s->node;
+ *copy = *impl_ref->node;
copy->next = NULL;
if (!merged_funcs)
{
@@ -537,7 +537,7 @@ void codegen_node(ParserContext *ctx, ASTNode *node, FILE *out)
merged_funcs_tail->next = copy;
merged_funcs_tail = copy;
}
- s = s->next;
+ impl_ref = impl_ref->next;
}
}
diff --git a/src/codegen/codegen_stmt.c b/src/codegen/codegen_stmt.c
index cba55b4..43e5bb5 100644
--- a/src/codegen/codegen_stmt.c
+++ b/src/codegen/codegen_stmt.c
@@ -70,21 +70,9 @@ static void emit_single_pattern_cond(const char *pat, int id, int is_ptr, FILE *
fprintf(out, "strcmp(_m_%d, %s) == 0", id, pat);
}
}
- else if (pat[0] == '\'')
- {
- // Char literal pattern
- if (is_ptr)
- {
- fprintf(out, "*_m_%d == %s", id, pat);
- }
- else
- {
- fprintf(out, "_m_%d == %s", id, pat);
- }
- }
else
{
- // Numeric or simple pattern
+ // Numeric, Char literal (removed duplicate branch), or simple pattern
if (is_ptr)
{
fprintf(out, "*_m_%d == %s", id, pat);