wip: working on generator

- Feat: add break handler
- Feat: add class handler
- Feat: add format string handler
- Feat: add loop handler
This commit is contained in:
samsonium
2026-11-04 20:04:33 +03:00
parent 7fe3fe3ff3
commit b278e8bb74
4 changed files with 192 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#include <compiler/fzl_gen.h>
#include <compiler/internals/gen.h>
#include <stdbool.h>
#include <stdio.h>
// Break keyword
bool gen_break(fzl_gen_t *gen, fzl_node_t *node)
{
if (!gen || !node)
return false;
fzl_gen_ctx_t *ctx = gen->ctx;
while (ctx != NULL)
{
if (ctx && ctx->type == FZL_GEN_CTX_TYPE_LOOP)
break;
ctx = ctx->parent;
}
if (!ctx || ctx->type != FZL_GEN_CTX_TYPE_LOOP)
return false;
for (size_t i = gen->syms_top - 1; i > ctx->level + 1; i--)
gen_op(gen, FZL_OPCODE_RM_ENVTABLE);
gen_op(gen, FZL_OPCODE_JMP);
ctx->loop.breaks[ctx->loop.breaks_count++] = gen->ops_count;
gen_word(gen, 0);
return true;
}