feat: implement environment table for vm

This commit is contained in:
samsonium
2026-10-12 17:20:41 +03:00
parent 2c76277a68
commit e7573743aa
5 changed files with 164 additions and 18 deletions
+11 -17
View File
@@ -29,8 +29,13 @@ fzl_vm_t *fzl_mkvm(const char *filepath)
vm->ops = NULL;
vm->ops_count = 0;
vm->ip = 0;
vm->dtop = 0;
vm->ctop = 0;
vm->etop = 0;
memset(vm->dstack, 0, sizeof(vm->dstack));
vm->dtop = 0;
memset(vm->cstack, 0, sizeof(vm->cstack));
memset(vm->estack, 0, sizeof(vm->estack));
FILE *fd = fopen(filepath, "rb");
if (!fd)
@@ -117,6 +122,11 @@ int fzl_vm_run(fzl_vm_t *vm)
switch (opcode)
{
case FZL_OPCODE_MK_ENVTABLE:
case FZL_OPCODE_STORE:
case FZL_OPCODE_WRITE:
break;
case FZL_OPCODE_CALL_BUILTIN:
{
uint64_t fn_id = vm->ops[++vm->ip];
@@ -127,24 +137,8 @@ int fzl_vm_run(fzl_vm_t *vm)
printf("%s\n", arg.as.s.value);
else if (arg.type == FZL_TYPE_CHAR)
printf("%c\n", arg.as.c);
else if (arg.type == FZL_TYPE_INT8)
printf("%d\n", arg.as.i8);
else if (arg.type == FZL_TYPE_INT16)
printf("%d\n", arg.as.i16);
else if (arg.type == FZL_TYPE_INT32)
printf("%d\n", arg.as.i32);
else if (arg.type == FZL_TYPE_INT64)
printf("%ld\n", arg.as.i64);
else if (arg.type == FZL_TYPE_INT)
printf("%ld\n", arg.as.i);
else if (arg.type == FZL_TYPE_UINT8)
printf("%u\n", arg.as.u8);
else if (arg.type == FZL_TYPE_UINT16)
printf("%u\n", arg.as.u16);
else if (arg.type == FZL_TYPE_UINT32)
printf("%u\n", arg.as.u32);
else if (arg.type == FZL_TYPE_UINT64)
printf("%lu\n", arg.as.u64);
else if (arg.type == FZL_TYPE_UINT)
printf("%lu\n", arg.as.u);
else if (arg.type == FZL_TYPE_BOOL)