Fix codegen hidden bugs

This commit is contained in:
Abdelrahman Said
2025-04-16 08:06:05 +01:00
parent 0942643b4e
commit cfa8094260
9 changed files with 26 additions and 32 deletions

View File

@@ -4,5 +4,5 @@
u64 count = list->node_count;
for (u64 i = 0; i < count; ++i) {{
wapp_str8_list_pop_back(list);
wapp_{T}_list_pop_back(list);
}}

View File

@@ -1,23 +1,22 @@
if (!list || !node || !(node->string)) {{
if (!list || !node || !(node->item)) {{
return;
}}
if (index == 0) {{
wapp_str8_list_push_front(list, node);
wapp_{T}_list_push_front(list, node);
return;
}} else if (index == list->node_count) {{
wapp_str8_list_push_back(list, node);
wapp_{T}_list_push_back(list, node);
return;
}}
{T}Node *dst_node = wapp_str8_list_get(list, index);
{T}Node *dst_node = wapp_{T}_list_get(list, index);
if (!dst_node) {{
return;
}}
{T}List node_list = {Tlower}_node_to_list(node);
list->total_size += node_list.total_size;
list->node_count += node_list.node_count;
{T}Node *prev = dst_node->prev;

View File

@@ -12,7 +12,6 @@
}}
--(list->node_count);
list->total_size -= output->string->size;
list->last = output->prev;
output->prev = output->next = NULL;

View File

@@ -12,7 +12,6 @@
}}
--(list->node_count);
list->total_size -= output->string->size;
list->first = output->next;
output->prev = output->next = NULL;

View File

@@ -1,4 +1,4 @@
if (!list || !node || !(node->string)) {{
if (!list || !node || !(node->item)) {{
return;
}}
@@ -9,7 +9,6 @@
return;
}}
list->total_size += node_list.total_size;
list->node_count += node_list.node_count;
{T}Node *last = list->last;

View File

@@ -1,4 +1,4 @@
if (!list || !node || !(node->string)) {{
if (!list || !node || !(node->item)) {{
return;
}}
@@ -9,7 +9,6 @@
return;
}}
list->total_size += node_list.total_size;
list->node_count += node_list.node_count;
{T}Node *first = list->first;

View File

@@ -4,14 +4,14 @@
}}
if (index == 0) {{
output = wapp_str8_list_pop_front(list);
output = wapp_{T}_list_pop_front(list);
goto RETURN_{Tupper}_LIST_REMOVE;
}} else if (index == list->node_count) {{
output = wapp_str8_list_pop_back(list);
output = wapp_{T}_list_pop_back(list);
goto RETURN_{Tupper}_LIST_REMOVE;
}}
output = wapp_str8_list_get(list, index);
output = wapp_{T}_list_get(list, index);
if (!output) {{
goto RETURN_{Tupper}_LIST_REMOVE;
}}
@@ -20,7 +20,6 @@
output->next->prev = output->prev;
--(list->node_count);
list->total_size -= output->string->size;
output->prev = output->next = NULL;

View File

@@ -1,13 +1,11 @@
{T}List output = {{.first = node, .last = node, .total_size = node->string->size, .node_count = 1}};
{T}List output = {{.first = node, .last = node, .total_size = node->item->size, .node_count = 1}};
while (output.first->prev != NULL) {{
output.total_size += output.first->prev->string->size;
output.first = output.first->prev;
++(output.node_count);
}}
while (output.last->next != NULL) {{
output.total_size += output.last->next->string->size;
output.last = output.last->next;
++(output.node_count);
}}