Fix errors due to no loops
This commit is contained in:
@@ -120,12 +120,15 @@ void asm_translate_nodes(buffer_t **asm_buffer, struct PResult nodes,
|
|||||||
const char *src_name)
|
const char *src_name)
|
||||||
{
|
{
|
||||||
// First pass: Setup the ASM label array
|
// First pass: Setup the ASM label array
|
||||||
struct Label labels[nodes.labels * 2];
|
struct Label labels[nodes.labels ? nodes.labels * 2 : 1];
|
||||||
|
if (nodes.labels)
|
||||||
|
{
|
||||||
u64 label_ptr = 0;
|
u64 label_ptr = 0;
|
||||||
for (size_t i = 0; i < nodes.size; ++i)
|
for (size_t i = 0; i < nodes.size; ++i)
|
||||||
if (nodes.nodes[i].type == LIN || nodes.nodes[i].type == LOUT)
|
if (nodes.nodes[i].type == LIN || nodes.nodes[i].type == LOUT)
|
||||||
labels[label_ptr++] =
|
labels[label_ptr++] =
|
||||||
(struct Label){.cur = i, .next = nodes.nodes[i].loop_ref};
|
(struct Label){.cur = i, .next = nodes.nodes[i].loop_ref};
|
||||||
|
}
|
||||||
|
|
||||||
// Second pass: Translating to assembly
|
// Second pass: Translating to assembly
|
||||||
for (size_t i = 0; i < nodes.size; ++i)
|
for (size_t i = 0; i < nodes.size; ++i)
|
||||||
|
|||||||
5
parser.c
5
parser.c
@@ -121,9 +121,11 @@ struct PResult parse_buffer(buffer_t *buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Third pass: setup loop references
|
// Third pass: setup loop references
|
||||||
|
size_t stackptr = 0;
|
||||||
|
if (loops)
|
||||||
|
{
|
||||||
node_t *stack[loops];
|
node_t *stack[loops];
|
||||||
memset(stack, 0, loops);
|
memset(stack, 0, loops);
|
||||||
size_t stackptr = 0;
|
|
||||||
for (size_t i = 0; i < usable; ++i)
|
for (size_t i = 0; i < usable; ++i)
|
||||||
{
|
{
|
||||||
node_t *node = nodes + i;
|
node_t *node = nodes + i;
|
||||||
@@ -143,6 +145,7 @@ struct PResult parse_buffer(buffer_t *buffer)
|
|||||||
stack[stackptr]->loop_ref = i;
|
stack[stackptr]->loop_ref = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (stackptr > 0)
|
if (stackptr > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user