feat: add object escaping on assing to variable in outer env
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "common/fzl_types.h"
|
||||
#include <common/fzl_value.h>
|
||||
#include <stdio.h>
|
||||
#include <vm/fzl_vm.h>
|
||||
@@ -136,7 +137,8 @@ int op_load_local(fzl_vm_t *vm)
|
||||
|
||||
if (depth >= vm->etop)
|
||||
{
|
||||
snprintf(last_err, sizeof(last_err), "runtime error - local depth out of range");
|
||||
snprintf(last_err, sizeof(last_err),
|
||||
"runtime error - local depth out of range");
|
||||
print_err_data(vm);
|
||||
return -1;
|
||||
}
|
||||
@@ -144,7 +146,8 @@ int op_load_local(fzl_vm_t *vm)
|
||||
fzl_vm_env_t *env = vm->estack[vm->etop - 1 - depth];
|
||||
if (env->size <= slot)
|
||||
{
|
||||
snprintf(last_err, sizeof(last_err), "runtime error - local slot out of range");
|
||||
snprintf(last_err, sizeof(last_err),
|
||||
"runtime error - local slot out of range");
|
||||
print_err_data(vm);
|
||||
return -1;
|
||||
}
|
||||
@@ -170,7 +173,8 @@ int op_store_local(fzl_vm_t *vm)
|
||||
|
||||
if (depth >= vm->etop)
|
||||
{
|
||||
snprintf(last_err, sizeof(last_err), "runtime error - local depth out of range");
|
||||
snprintf(last_err, sizeof(last_err),
|
||||
"runtime error - local depth out of range");
|
||||
print_err_data(vm);
|
||||
return -1;
|
||||
}
|
||||
@@ -178,11 +182,21 @@ int op_store_local(fzl_vm_t *vm)
|
||||
fzl_vm_env_t *env = vm->estack[vm->etop - 1 - depth];
|
||||
if (env->size <= slot)
|
||||
{
|
||||
snprintf(last_err, sizeof(last_err), "runtime error - local slot out of range");
|
||||
snprintf(last_err, sizeof(last_err),
|
||||
"runtime error - local slot out of range");
|
||||
print_err_data(vm);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (value.type == FZL_TYPE_OBJECT && depth != 0)
|
||||
{
|
||||
for (size_t i = 0; i < depth; i++)
|
||||
{
|
||||
escape_recursive(vm->estack[vm->etop - i], vm->estack[vm->etop - 1 - i],
|
||||
value.as.obj);
|
||||
}
|
||||
}
|
||||
|
||||
env->table[slot].value = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user