本文整理汇总了C++中VirtualMachine::runApplication方法的典型用法代码示例。如果您正苦于以下问题:C++ VirtualMachine::runApplication方法的具体用法?C++ VirtualMachine::runApplication怎么用?C++ VirtualMachine::runApplication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine::runApplication方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeInstr
void CommandLine::executeInstr() {
if (!strcmp(argv[0], "load")) {
#if defined(__APPLE__)
char* buf = (char*)alloca(sizeof(argv[1]) + 7);
sprintf(buf, "%s.dylib", argv[1]);
#else
char* buf = (char*)alloca(sizeof(argv[1]) + 4);
sprintf(buf, "%s.so", argv[1]);
#endif
void* handle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
if (handle == 0) {
fprintf(stderr, "\t Unable to load %s\n", argv[1]);
printf("\t error = %s\n", dlerror());
return;
}
boot_t func = (boot_t)(intptr_t)dlsym(handle, "initialiseVirtualMachine");
if (func == 0) {
fprintf(stderr, "\t Unable to find %s boot method\n", argv[1]);
dlclose(handle);
return;
}
func();
create_vm_t vmlet = (create_vm_t)(intptr_t)dlsym(handle, "createVirtualMachine");
vmlets[argv[1]] = vmlet;
} else {
create_vm_t func = vmlets[argv[0]];
mvm::Object* CU = compilers[argv[0]];
if (!func) {
fprintf(stderr, "\t Unknown vm %s\n", argv[0]);
} else {
#if 0
thread_arg_t* thread_arg = (thread_arg_t*)malloc(sizeof (thread_arg_t));
thread_arg->argc = argc;
thread_arg->argv = argv;
thread_arg->func = func;
int tid = 0;
Thread::start(&tid, (int (*)(void *))startApp, thread_arg);
#else
VirtualMachine* VM = func(CU);
VM->runApplication(argc, argv);
#endif
}
}
}
示例2: startApp
extern "C" int startApp(thread_arg_t* arg) {
int argc = arg->argc;
char** argv = arg->argv;
create_vm_t func = arg->func;
free(arg);
#ifndef MULTIPLE_GC
Collector::inject_my_thread(&argc);
VirtualMachine* VM = func();
VM->runApplication(argc, argv);
Collector::remove_my_thread();
Collector::collect();
#else
Collector* GC = Collector::allocate();
GC->inject_my_thread(&argc);
func(argc, argv);
GC->remove_my_thread();
GC->collect();
#endif
return 0;
}