feat: add support for null-values
This commit is contained in:
+10
-6
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user