Local struct initialization in Sys41VM (ain v1)

Sys41VM doesn't have the SH_LOCALCREATE instruction, so struct pages
must be allocated when function_call() initializes local variables.
This commit is contained in:
kichikuou
2024-05-29 13:14:48 +09:00
parent 10169951c0
commit b85b426872
+3
View File
@@ -347,6 +347,9 @@ static int _function_call(int fno, int return_address)
// initialize local variables
for (int i = f->nr_args; i < f->nr_vars; i++) {
heap[slot].page->values[i] = variable_initval(f->vars[i].type.data);
if (ain->version <= 1 && f->vars[i].type.data == AIN_STRUCT) {
create_struct(f->vars[i].type.struc, &heap[slot].page->values[i]);
}
}
// jump to function start
instr_ptr = ain->functions[fno].address;