feat: add "while-not-null" test
This commit is contained in:
+5
-1
@@ -208,7 +208,7 @@ void print_object(fzl_vm_object_t *obj)
|
|||||||
printf("<unknown>");
|
printf("<unknown>");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(">\n");
|
printf(">");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_err_data(fzl_vm_t *vm)
|
void print_err_data(fzl_vm_t *vm)
|
||||||
@@ -435,6 +435,7 @@ int fzl_vm_run(fzl_vm_t *vm)
|
|||||||
fzl_vm_object_t *obj = malloc(sizeof(fzl_vm_object_t));
|
fzl_vm_object_t *obj = malloc(sizeof(fzl_vm_object_t));
|
||||||
obj->values = malloc(values_count * sizeof(fzl_value_t));
|
obj->values = malloc(values_count * sizeof(fzl_value_t));
|
||||||
obj->values_count = values_count;
|
obj->values_count = values_count;
|
||||||
|
memset(obj->values, 0, values_count * sizeof(fzl_value_t));
|
||||||
|
|
||||||
fzl_vm_env_t *current_env = vm->estack[vm->etop - 1];
|
fzl_vm_env_t *current_env = vm->estack[vm->etop - 1];
|
||||||
if (current_env->owned_objects_remainder <=
|
if (current_env->owned_objects_remainder <=
|
||||||
@@ -858,7 +859,10 @@ int fzl_vm_run(fzl_vm_t *vm)
|
|||||||
else if (arg.type == FZL_TYPE_NULL)
|
else if (arg.type == FZL_TYPE_NULL)
|
||||||
printf("<null>\n");
|
printf("<null>\n");
|
||||||
else if (arg.type == FZL_TYPE_OBJECT)
|
else if (arg.type == FZL_TYPE_OBJECT)
|
||||||
|
{
|
||||||
print_object(arg.as.obj);
|
print_object(arg.as.obj);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (fn_id == FZL_BUILTIN_EXIT)
|
else if (fn_id == FZL_BUILTIN_EXIT)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
class Some {
|
||||||
|
Some next;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some l4 = new Some;
|
||||||
|
|
||||||
|
Some l3 = new Some;
|
||||||
|
l3.next = l4;
|
||||||
|
|
||||||
|
Some l2 = new Some;
|
||||||
|
l2.next = l3;
|
||||||
|
|
||||||
|
Some l1 = new Some;
|
||||||
|
l1.next = l2;
|
||||||
|
|
||||||
|
Some root = new Some;
|
||||||
|
root.next = l1;
|
||||||
|
|
||||||
|
Some obj = root;
|
||||||
|
while (obj != null)
|
||||||
|
{
|
||||||
|
obj = obj.next;
|
||||||
|
printline("Now object is:");
|
||||||
|
printline(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
printline(obj);
|
||||||
|
|
||||||
Reference in New Issue
Block a user