diff --git a/include/vm.h b/include/vm.h index df0afb3..faf1df1 100644 --- a/include/vm.h +++ b/include/vm.h @@ -97,7 +97,7 @@ int vm_string_ref(struct string *s); int vm_copy_page(struct page *page); union vm_value vm_copy(union vm_value v, enum ain_data_type type); -void vm_execute_ain(struct ain *program); +int vm_execute_ain(struct ain *program); void vm_call(int fno, int struct_page); int vm_time(void); diff --git a/src/system4.c b/src/system4.c index cfb5274..20b47e7 100644 --- a/src/system4.c +++ b/src/system4.c @@ -352,6 +352,5 @@ int main(int argc, char *argv[]) dbg_init(); #endif - vm_execute_ain(ain); - sys_exit(0); + sys_exit(vm_execute_ain(ain)); } diff --git a/src/vm.c b/src/vm.c index f2794af..3a459a1 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1581,7 +1581,7 @@ static void vm_execute(void) } } -void vm_execute_ain(struct ain *program) +int vm_execute_ain(struct ain *program) { // initialize VM state stack_size = INITIAL_STACK_SIZE; @@ -1631,6 +1631,7 @@ void vm_execute_ain(struct ain *program) } vm_call(ain->main, -1); + return stack_pop().i; } void vm_stack_trace(void)