feat: add support for null-values

This commit is contained in:
samsonium
2026-10-17 21:56:08 +03:00
parent 244dd33372
commit 82b6cc3346
+10 -6
View File
@@ -281,6 +281,7 @@ int fzl_vm_run(fzl_vm_t *vm)
break;
}
// NOTE: make recursive owning transfer for nested objects!
case FZL_OPCODE_ESCAPE_OBJECT:
{
if (vm->dtop < 1)
@@ -291,7 +292,7 @@ int fzl_vm_run(fzl_vm_t *vm)
return -1;
}
fzl_value_t obj = vm->dstack[--vm->dtop];
if (obj.type != FZL_TYPE_OBJECT)
if (obj.type != FZL_TYPE_OBJECT && obj.type < FZL_TYPE_INT8)
{
snprintf(last_err, sizeof(last_err),
"runtime error - cannot escape non-object type");
@@ -310,13 +311,16 @@ int fzl_vm_run(fzl_vm_t *vm)
}
bool found = false;
for (size_t i = 0; i < current->owned_objects_count; i++)
if (obj.as.u != 0)
{
if (obj.as.obj == current->owned_objects[i])
for (size_t i = 0; i < current->owned_objects_count; i++)
{
found = true;
current->owned_objects[i] = NULL;
break;
if (obj.as.obj == current->owned_objects[i])
{
found = true;
current->owned_objects[i] = NULL;
break;
}
}
}