growable_array args(this);
int i;
- for(i = 1; i < argc; i++)
+ for(i = 1; i < argc; i++){
args.add(allot_alien(F,(cell)argv[i]));
+ }
args.trim();
userenv[ARGS_ENV] = args.elements.value();
void factorvm::start_standalone_factor(int argc, vm_char **argv)
{
- //printf("thread id is %d\n",GetCurrentThreadId());fflush(stdout);
register_vm(GetCurrentThreadId(),this);
vm_parameters p;
default_parameters(&p);
VM_C_API void start_standalone_factor(int argc, vm_char **argv);
VM_C_API void *start_standalone_factor_in_new_thread(int argc, vm_char **argv);
-
}
FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
{
- //printf("exception handler %d\n",GetCurrentThreadId());fflush(stdout);
factorvm *myvm = lookup_vm(GetCurrentThreadId());
PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord;
CONTEXT *c = (CONTEXT*)pe->ContextRecord;
return EXCEPTION_CONTINUE_EXECUTION;
}
+bool handler_added = 0;
+
void factorvm::c_to_factor_toplevel(cell quot)
{
- if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
- fatal_error("AddVectoredExceptionHandler failed", 0);
+ if(!handler_added){
+ if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
+ fatal_error("AddVectoredExceptionHandler failed", 0);
+ handler_added = 1;
+ }
c_to_factor(quot,this);
- RemoveVectoredExceptionHandler((void *)exception_handler);
+ RemoveVectoredExceptionHandler((void *)exception_handler);
}
void factorvm::open_console()