mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-03 20:38:13 +03:00
Merge pull request #18 from kichikuou/GlobalLoad
system.GlobalLoad() should not call destructors
This commit is contained in:
+1
-1
@@ -90,7 +90,7 @@ static inline void stack_push_value(union vm_value v)
|
||||
union vm_value stack_pop(void);
|
||||
|
||||
union vm_value global_get(int varno);
|
||||
void global_set(int varno, union vm_value val);
|
||||
void global_set(int varno, union vm_value val, bool call_dtors);
|
||||
struct page *local_page(void);
|
||||
|
||||
int vm_string_ref(struct string *s);
|
||||
|
||||
+3
-1
@@ -347,7 +347,9 @@ int load_globals(const char *keyname, const char *filename, const char *group_na
|
||||
goto cleanup;
|
||||
}
|
||||
current_global = i;
|
||||
global_set(i, json_to_vm_value(ain->globals[i].type.data, ain->globals[i].type.struc, ain->globals[i].type.rank, value));
|
||||
|
||||
bool call_dtors = false; // Destructors for old objects are not called.
|
||||
global_set(i, json_to_vm_value(ain->globals[i].type.data, ain->globals[i].type.struc, ain->globals[i].type.rank, value), call_dtors);
|
||||
if (n)
|
||||
(*n)++;
|
||||
}
|
||||
|
||||
@@ -134,14 +134,17 @@ union vm_value global_get(int varno)
|
||||
return heap[0].page->values[varno];
|
||||
}
|
||||
|
||||
void global_set(int varno, union vm_value val)
|
||||
void global_set(int varno, union vm_value val, bool call_dtors)
|
||||
{
|
||||
switch (ain->globals[varno].type.data) {
|
||||
case AIN_STRING:
|
||||
case AIN_STRUCT:
|
||||
case AIN_ARRAY_TYPE:
|
||||
if (heap[0].page->values[varno].i > 0) {
|
||||
heap_unref(heap[0].page->values[varno].i);
|
||||
if (call_dtors)
|
||||
heap_unref(heap[0].page->values[varno].i);
|
||||
else
|
||||
exit_unref(heap[0].page->values[varno].i);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user